@qonto/embed-sdk 0.17.0 → 0.18.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.
@@ -1,5 +1,6 @@
1
- import type { BeneficiaryDataObject, NewBeneficiary } from './beneficiaries.types';
1
+ import type { BeneficiaryDataObject, EditableBeneficiaryProperties, NewBeneficiary } from './beneficiaries.types';
2
2
  import type { PaginationResponseDataObject, PaginationSettings } from '@common/api-pagination/api-pagination.types';
3
+ import type { MfaMethod } from '@common/operation-settings/operation-settings.types';
3
4
  interface GetBeneficiariesParams {
4
5
  accessToken: string;
5
6
  stagingToken?: string;
@@ -20,6 +21,13 @@ interface UntrustBeneficiariesParams {
20
21
  accessToken: string;
21
22
  stagingToken?: string;
22
23
  }
24
+ interface UpdateBeneficiaryParams {
25
+ beneficiaryParamsBeingEdited: EditableBeneficiaryProperties;
26
+ accessToken: string;
27
+ stagingToken?: string;
28
+ idempotencyKey?: string;
29
+ mfaPreference?: MfaMethod;
30
+ }
23
31
  interface GetBeneficiariesApiResponse {
24
32
  beneficiaries: BeneficiaryDataObject[];
25
33
  meta: PaginationResponseDataObject;
@@ -29,5 +37,6 @@ export declare function getBeneficiary({ accessToken, stagingToken, beneficiaryI
29
37
  export declare function addBeneficiary({ beneficiary, accessToken, stagingToken, }: AddBeneficiaryParams): Promise<any>;
30
38
  export declare function trustBeneficiaries(): Promise<void>;
31
39
  export declare function untrustBeneficiaries({ beneficiaryIds, accessToken, stagingToken, }: UntrustBeneficiariesParams): Promise<BeneficiaryDataObject[]>;
40
+ export declare function updateBeneficiary({ beneficiaryParamsBeingEdited, accessToken, stagingToken, idempotencyKey, mfaPreference, }: UpdateBeneficiaryParams): Promise<BeneficiaryDataObject>;
32
41
  export {};
33
42
  //# sourceMappingURL=beneficiaries.api.d.ts.map
@@ -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,cAAc,EACf,MAAM,uBAAuB,CAAC;AAI/B,OAAO,KAAK,EACV,4BAA4B,EAC5B,kBAAkB,EACnB,MAAM,6CAA6C,CAAC;AAKrD,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;AAID,UAAU,2BAA2B;IACnC,aAAa,EAAE,qBAAqB,EAAE,CAAC;IACvC,IAAI,EAAE,4BAA4B,CAAC;CACpC;AAED,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"}
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;AAIrD,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,EAAE,MAAM,CAAC;IACpB,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,wBAAsB,iBAAiB,CAAC,EACtC,4BAA4B,EAC5B,WAAW,EACX,YAAY,EACZ,cAAc,EACd,aAAa,GACd,EAAE,uBAAuB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAyB1D"}
@@ -1,4 +1,4 @@
1
- import type { Beneficiary, GetBeneficiariesResponse, NewBeneficiary } from './beneficiaries.types';
1
+ import type { Beneficiary, EditableBeneficiaryProperties, GetBeneficiariesResponse, NewBeneficiary } from './beneficiaries.types';
2
2
  import type { PaginationSettings } from '@common/api-pagination/api-pagination.types';
3
3
  import { type OperationSettings } from '@validation/operation-settings-validation';
4
4
  /**
@@ -78,6 +78,28 @@ export declare function addBeneficiary({ beneficiary, accessToken, stagingToken,
78
78
  accessToken?: string;
79
79
  stagingToken?: string;
80
80
  }): Promise<Beneficiary>;
81
+ /**
82
+ * Update any of the editable properites of a beneficiary in the current user's
83
+ * account by ID.
84
+ * @param updateBeneficiaryParams - An object containing:
85
+ * - `beneficiarySettings`: An object that contains a mandatory beneficiary ID
86
+ * and any of the editable properties of a beneficiary, which are `name`,
87
+ * `email` and `activityTag`.
88
+ * - `operationSettings`: An object with operation-level settings such as
89
+ * `accessToken`, `stagingToken`, `mfaPreference`, and other optional
90
+ * parameters. See {@link BeneficiaryParams}.
91
+ * @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.
100
+ * @throws \{EmbedApiError\} If the API request fails or returns an error.
101
+ */
102
+ export declare function updateBeneficiary({ beneficiarySettings, operationSettings, }: BeneficiaryParams<EditableBeneficiaryProperties>): Promise<Beneficiary>;
81
103
  /**
82
104
  * Trusts a list of beneficiaries in the current user's account.
83
105
  *
@@ -1 +1 @@
1
- {"version":3,"file":"beneficiaries.d.ts","sourceRoot":"","sources":["../../src/beneficiaries/beneficiaries.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,wBAAwB,EACxB,cAAc,EACf,MAAM,uBAAuB,CAAC;AAc/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAGtF,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,2CAA2C,CAAC;AAEnD;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC;;;;OAIG;IACH,mBAAmB,EAAE,CAAC,CAAC;IACvB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,gBAAgB,CAAC,sBAAsB,CAAC,EAAE;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAqBpC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,cAAc,CAAC,EACnC,aAAa,EACb,WAAW,EACX,YAAY,GACb,EAAE;IACD,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,WAAW,CAAC,CASvB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,cAAc,CAAC,EACnC,WAAW,EACX,WAAW,EACX,YAAY,GACb,EAAE;IACD,WAAW,EAAE,cAAc,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,WAAW,CAAC,CASvB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,mBAAmB,EACnB,iBAAiB,GAClB,EAAE,iBAAiB,CAAC;IACnB,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B,CAAC,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAsB1B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,oBAAoB,CAAC,EACzC,cAAc,EACd,WAAW,EACX,YAAY,GACb,EAAE;IACD,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CASzB"}
1
+ {"version":3,"file":"beneficiaries.d.ts","sourceRoot":"","sources":["../../src/beneficiaries/beneficiaries.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,6BAA6B,EAC7B,wBAAwB,EACxB,cAAc,EACf,MAAM,uBAAuB,CAAC;AAgB/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAGtF,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,2CAA2C,CAAC;AAEnD;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC;;;;OAIG;IACH,mBAAmB,EAAE,CAAC,CAAC;IACvB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,gBAAgB,CAAC,sBAAsB,CAAC,EAAE;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAqBpC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,cAAc,CAAC,EACnC,aAAa,EACb,WAAW,EACX,YAAY,GACb,EAAE;IACD,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,WAAW,CAAC,CASvB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,cAAc,CAAC,EACnC,WAAW,EACX,WAAW,EACX,YAAY,GACb,EAAE;IACD,WAAW,EAAE,cAAc,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,WAAW,CAAC,CASvB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,mBAAmB,EACnB,iBAAiB,GAClB,EAAE,iBAAiB,CAAC,6BAA6B,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAezE;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"}
@@ -27,6 +27,9 @@ export type NewBeneficiary = Pick<Beneficiary, 'name' | 'iban'> & {
27
27
  bic?: string;
28
28
  activityTag?: (typeof ACTIVITY_TAGS)[keyof typeof ACTIVITY_TAGS];
29
29
  };
30
+ export type EditableBeneficiaryProperties = {
31
+ id: string;
32
+ } & Partial<Pick<Beneficiary, 'name' | 'email' | 'activityTag'>>;
30
33
  export interface BeneficiaryDataObject {
31
34
  id: string;
32
35
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"beneficiaries.types.d.ts","sourceRoot":"","sources":["../../src/beneficiaries/beneficiaries.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAEnF;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,KAAK,CAAC;IAChB,MAAM,EAAE,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,OAAO,oBAAoB,CAAC,CAAC;IACzE,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG;IAChE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;CAClE,CAAC;AAEF,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;IACjE,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,KAAK,CAAC;IAChB,MAAM,EAAE,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,OAAO,oBAAoB,CAAC,CAAC;IACzE,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,wBAAwB,GAAG,IAAI,CAAC,qBAAqB,EAAE,MAAM,CAAC,GAAG;IAC3E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;CAClE,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,aAAa,EAAE,WAAW,EAAE,CAAC;IAC7B;;OAEG;IACH,IAAI,CAAC,EAAE,eAAe,CAAC;CACxB"}
1
+ {"version":3,"file":"beneficiaries.types.d.ts","sourceRoot":"","sources":["../../src/beneficiaries/beneficiaries.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAEnF;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,KAAK,CAAC;IAChB,MAAM,EAAE,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,OAAO,oBAAoB,CAAC,CAAC;IACzE,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG;IAChE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;CAClE,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAClE,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,GAAG,aAAa,CAAC,CACpD,CAAC;AAEF,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;IACjE,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,KAAK,CAAC;IAChB,MAAM,EAAE,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,OAAO,oBAAoB,CAAC,CAAC;IACzE,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,wBAAwB,GAAG,IAAI,CAAC,qBAAqB,EAAE,MAAM,CAAC,GAAG;IAC3E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;CAClE,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,aAAa,EAAE,WAAW,EAAE,CAAC;IAC7B;;OAEG;IACH,IAAI,CAAC,EAAE,eAAe,CAAC;CACxB"}
@@ -1,5 +1,6 @@
1
- import type { NewBeneficiary } from '@beneficiaries/beneficiaries.types';
1
+ import type { EditableBeneficiaryProperties, NewBeneficiary } from '@beneficiaries/beneficiaries.types';
2
2
  export declare function validateGetBeneficiaryParams(beneficiaryId: string): string;
3
3
  export declare function validateAddBeneficiaryParams(beneficiary: NewBeneficiary): NewBeneficiary;
4
+ export declare function validateUpdateBeneficiaryParams(beneficiaryBeingEdited: EditableBeneficiaryProperties): EditableBeneficiaryProperties;
4
5
  export declare function validateTrustBeneficiariesParams(beneficiaryIds: string[]): string[];
5
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,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAMzE,wBAAgB,4BAA4B,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAU1E;AAED,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,cAAc,GAC1B,cAAc,CAyBhB;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,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 +1 @@
1
- {"version":3,"file":"cards.d.ts","sourceRoot":"","sources":["../../src/cards/cards.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,IAAI,EAET,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACxB,MAAM,eAAe,CAAC;AAYvB,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,2CAA2C,CAAC;AAInD;;;;;;GAMG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B;;;OAGG;IACH,YAAY,EAAE,CAAC,CAAC;IAChB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,QAAQ,CAAC,EAC7B,YAAY,EACZ,WAAW,EACX,YAAY,GACb,EAAE;IACD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAelB;AAED;;;;;;;;GAQG;AACH,wBAAsB,OAAO,CAAC,EAC5B,MAAM,EACN,WAAW,EACX,YAAY,GACb,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,IAAI,CAAC,CAYhB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmFG;AACH,wBAAsB,SAAS,CAC7B,UAAU,EAAE,UAAU,CAAC,iBAAiB,CAAC,GACxC,OAAO,CAAC,IAAI,CAAC,CA8Bf;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,UAAU,CAC9B,UAAU,EAAE,UAAU,CAAC,kBAAkB,CAAC,GACzC,OAAO,CAAC,IAAI,CAAC,CA8Bf;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,WAAW,CAC/B,UAAU,EAAE,UAAU,CAAC,mBAAmB,CAAC,GAC1C,OAAO,CAAC,uBAAuB,CAAC,CAoClC"}
1
+ {"version":3,"file":"cards.d.ts","sourceRoot":"","sources":["../../src/cards/cards.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,IAAI,EAET,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACxB,MAAM,eAAe,CAAC;AAYvB,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,2CAA2C,CAAC;AAInD;;;;;;GAMG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B;;;OAGG;IACH,YAAY,EAAE,CAAC,CAAC;IAChB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,QAAQ,CAAC,EAC7B,YAAY,EACZ,WAAW,EACX,YAAY,GACb,EAAE;IACD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAelB;AAED;;;;;;;;GAQG;AACH,wBAAsB,OAAO,CAAC,EAC5B,MAAM,EACN,WAAW,EACX,YAAY,GACb,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,IAAI,CAAC,CAYhB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmFG;AACH,wBAAsB,SAAS,CAC7B,UAAU,EAAE,UAAU,CAAC,iBAAiB,CAAC,GACxC,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,UAAU,CAC9B,UAAU,EAAE,UAAU,CAAC,kBAAkB,CAAC,GACzC,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,WAAW,CAC/B,UAAU,EAAE,UAAU,CAAC,mBAAmB,CAAC,GAC1C,OAAO,CAAC,uBAAuB,CAAC,CAsClC"}
@@ -22,7 +22,7 @@ export declare class OperationSettingsManager {
22
22
  * Gets the UI parent element ID
23
23
  * @returns The current UI parent element ID or null if not set
24
24
  */
25
- getUIParentElementId(): string | null;
25
+ getUIParentElementId(): string | undefined;
26
26
  /**
27
27
  * Gets the MFA preference
28
28
  * @returns The current MFA preference or null if not set
@@ -1 +1 @@
1
- {"version":3,"file":"operation-settings.d.ts","sourceRoot":"","sources":["../../../src/common/operation-settings/operation-settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qDAAqD,CAAC;AAGrF;;GAEG;AACH,qBAAa,wBAAwB;IACnC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA2B;IAClD,OAAO,CAAC,iBAAiB,CAAuB;IAChD,OAAO,CAAC,aAAa,CAAkC;IACvD,OAAO,CAAC,SAAS,CAAkB;IAEnC,OAAO;IAIP;;OAEG;WACW,WAAW,IAAI,wBAAwB;IAOrD;;;OAGG;IACI,WAAW,CAAC,QAAQ,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,IAAI;IAY9D;;;OAGG;IACI,oBAAoB,IAAI,MAAM,GAAG,IAAI;IAI5C;;;OAGG;IACI,gBAAgB,IAAI,SAAS;IAIpC;;;OAGG;IACI,YAAY,IAAI,OAAO;IAG9B;;OAEG;IACI,aAAa,IAAI,IAAI;CAI7B;AAGD,eAAO,MAAM,wBAAwB,0BAAyC,CAAC"}
1
+ {"version":3,"file":"operation-settings.d.ts","sourceRoot":"","sources":["../../../src/common/operation-settings/operation-settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qDAAqD,CAAC;AAGrF;;GAEG;AACH,qBAAa,wBAAwB;IACnC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA2B;IAClD,OAAO,CAAC,iBAAiB,CAAqB;IAC9C,OAAO,CAAC,aAAa,CAAkC;IACvD,OAAO,CAAC,SAAS,CAAkB;IAEnC,OAAO;IAIP;;OAEG;WACW,WAAW,IAAI,wBAAwB;IAOrD;;;OAGG;IACI,WAAW,CAAC,QAAQ,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,IAAI;IAY9D;;;OAGG;IACI,oBAAoB,IAAI,MAAM,GAAG,SAAS;IAIjD;;;OAGG;IACI,gBAAgB,IAAI,SAAS;IAIpC;;;OAGG;IACI,YAAY,IAAI,OAAO;IAG9B;;OAEG;IACI,aAAa,IAAI,IAAI;CAI7B;AAGD,eAAO,MAAM,wBAAwB,0BAAyC,CAAC"}
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).QontoEmbed={})}(this,(function(e){"use strict";class t{constructor(){this.accessToken=null,this.stagingToken=null}static getInstance(){return t.instance||(t.instance=new t),t.instance}setAccessToken(e){this.accessToken=e}getAccessToken(){return this.accessToken}hasAccessToken(){return null!==this.accessToken&&""!==this.accessToken}clearAccessToken(){this.accessToken=null}setStagingToken(e){this.stagingToken=e}getStagingToken(){return this.stagingToken}hasStagingToken(){return null!==this.stagingToken&&""!==this.stagingToken}clearStagingToken(){this.stagingToken=null}}const n=t.getInstance();class i extends Error{constructor(){super(),this.stack=""}toString(){return`${this.name}: ${this.message}`}}class a extends i{constructor(){super(),this.name="AuthenticationError",this.message="Authentication failed due to missing or invalid access token.\nEnsure you have called the initialize function with a valid access token."}}function r(){if(!n.hasAccessToken())throw new a;return n.getAccessToken()}class s extends i{constructor(e){super(),this.name="InvalidParametersError",this.invalidParameters=Array.isArray(e)?e:[e],this.message=`Invalid parameters were passed to the function:\n${this.invalidParameters.map((e=>e)).join("\n")}`}}const o={READY:"qonto.ready"},c={CARD_SEE:"card.see",CARD_SEE_DETAILS:"card.see-details",CARD_ORDER:"card.order",CARD_UNLOCK:"card.unlock",CARD_SHOW_PIN:"card.show.pin",CARD_SET_PIN:"card.set.pin",TRANSFER_SINGLE_CREATE:"transfer.single.create",BENEFICIARIES_TRUST:"beneficiary.trust"},d={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},m={MASTER:"master",SANDBOX:"sandbox",QA:"qa"},l={EN:"en",FR:"fr",DE:"de",ES:"es",IT:"it",PT:"pt"},u={PASSKEY:"passkey",SMS_OTP:"sms-otp",PAIRED_DEVICE:"paired-device",MOCK:"mock"};var f=Object.freeze({__proto__:null,ACTIONS:c,ACTIVITY_TAGS:{ATM:"atm",FALLBACK:"fallback",FEES:"fees",FINANCE:"finance",FOOD_AND_GROCERY:"food_and_grocery",GAS_STATION:"gas_station",HARDWARE_AND_EQUIPMENT:"hardware_and_equipment",HOTEL_AND_LODGING:"hotel_and_lodging",INSURANCE:"insurance",IT_AND_ELECTRONICS:"it_and_electronics",LEGAL_AND_ACCOUNTING:"legal_and_accounting",LOGISTICS:"logistics",MANUFACTURING:"manufacturing",MARKETING:"marketing",OFFICE_RENTAL:"office_rental",OFFICE_SUPPLY:"office_supply",ONLINE_SERVICE:"online_service",OTHER_EXPENSE:"other_expense",OTHER_INCOME:"other_income",OTHER_SERVICE:"other_service",PENDING:"pending",REFUND:"refund",RESTAURANT_AND_BAR:"restaurant_and_bar",SALES:"sales",SALARY:"salary",SUBSCRIPTION:"subscription",TAX:"tax",TRANSPORT:"transport",TREASURY_AND_INTERCO:"treasury_and_interco",UTILITY:"utility",VOUCHER:"voucher"},BENEFICIARY_STATUSES:{PENDING:"pending",VALIDATED:"validated",DECLINED:"declined"},BRANCHES:m,ENVIRONMENTS:d,IFRAME_EVENTS:o,LOCALES:l,MFA_METHODS:u,TRANSFER_DECLINE_REASONS:{BENEFICIARY_BIC_INVALID:"beneficiary_bic_invalid",BENEFICIARY_IBAN_INVALID:"beneficiary_iban_invalid",BENEFICIARY_STATUS:"beneficiary_status",BENEFICIARY_NETWORK_RULES_ERROR:"beneficiary_network_rules_error",ORGANISATION_COMPLIANCE_REASONS:"organisation_compliance_reasons",DEBIT_ACCOUNT_INSUFFICIENT_FUNDS:"debit_account_insufficient_funds",QONTO_PROCESSING_FAILED:"qonto_processing_failed"},TRANSFER_STATUSES:{PENDING:"pending",PROCESSING:"processing",CANCELED:"canceled",DECLINED:"declined",SETTLED:"settled"}});class g{constructor(){this.uiParentElementId=null,this.mfaPreference=u.PASSKEY,this.debugMode=!1}static getInstance(){return g.instance||(g.instance=new g),g.instance}setSettings(e){e.uiParentElementId&&(this.uiParentElementId=e.uiParentElementId),e.mfaPreference&&(this.mfaPreference=e.mfaPreference),e.debugMode&&(this.debugMode=e.debugMode)}getUIParentElementId(){return this.uiParentElementId}getMFAPreference(){return this.mfaPreference}getDebugMode(){return this.debugMode}clearSettings(){this.uiParentElementId=null,this.mfaPreference=u.PASSKEY}}const p=g.getInstance(),h="https://embed.qonto.com",_="https://embed-js{branch}.staging.qonto.co",y="https://embed.dev.qonto.co",T={[d.PRODUCTION]:{IFRAME_BASE_URL:h,IFRAME_URL:`${h}/connect`,THIRD_PARTY_API_URL:"https://thirdparty.qonto.com"},[d.STAGING]:{IFRAME_BASE_URL:_,IFRAME_URL:`${_}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"},[d.LOCAL]:{IFRAME_BASE_URL:y,IFRAME_URL:`${y}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"}};class I{constructor(){this.environment=d.PRODUCTION,this.branch=m.SANDBOX;const e=process.env.QONTO_EMBED_ENVIRONMENT,t=process.env.QONTO_EMBED_BRANCH;this.environment=Object.values(d).includes(e)?e:d.PRODUCTION,this.branch=Object.values(m).includes(t)?t:m.SANDBOX}static getInstance(){return I.instance||(I.instance=new I),I.instance}setEnvironment(e){this.environment=e}getEnvironment(){return this.environment}isProductionEnvironment(){return this.environment===d.PRODUCTION}setBranch(e){this.branch=e}getBranch(){return this.branch}clear(){this.environment=d.PRODUCTION,this.branch=m.MASTER}getEnvironmentUrls(){if(this.environment===d.PRODUCTION)return T.production;{const e=T[this.environment];return Object.entries(e).reduce(((e,[t,n])=>({...e,[t]:n.replace("{branch}",`-${this.branch}`)})),{})}}}const E=I.getInstance();function b(e){const t=e?.uiParentElementId||p.getUIParentElementId();if(!t)throw new s("operationSettings parameter must have a uiParentElementId for the called function.\nYou can pass it either to the initialize function or in a per function basis.");const n=e?.mfaPreference||p.getMFAPreference();if(n){const e=(i=Object.values(u),E.isProductionEnvironment()?i.filter((e=>e!==u.MOCK)):i);if(!e.includes(n))throw new s(`operationSettings.mfaPreference must be one of ${e.join(", ")}`);if(E.isProductionEnvironment()&&n===u.MOCK)throw new s("operationSettings.mfaPreference cannot be set to mock in production environment.")}var i;const a=e?.debugMode||p.getDebugMode();if(void 0!==a&&"boolean"!=typeof a)throw new s("operationSettings.debugMode must be a boolean.");return{...e,uiParentElementId:t,mfaPreference:n,debugMode:a,...e}}const w=Object.values(l);function A(e){if(!function(e){return w.includes(e)}(e))throw new s(`Unsupported locale: ${e}. The locale must be one of: ${w.join(", ")}.`);return e}function k(e){if(!e?.accessToken)throw new s("Access token is required when calling initialize()");return e?.operationSettings&&b(e.operationSettings),function(e){if(e.environment){if(!["production","staging","local"].includes(e.environment))throw new s('If provided, environment must be either "production" or "staging"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.environment.PRODUCTION" or "constants.environment.STAGING"');if(e.branch&&!["master","sandbox","qa"].includes(e.branch))throw new s('If provided, branch must be either "master", "sandbox" or "qa"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.branch.MASTER" or "constants.environment.SANDBOX" and so on')}}(e),e.locale&&A(e.locale),e}class R{constructor(){this.currentLocale="en"}static getInstance(){return R.instance||(R.instance=new R),R.instance}setLocale(e){this.currentLocale=e}getLocale(){return this.currentLocale}setDefaultLocale(){this.currentLocale="en"}}const L=R.getInstance();const S={initialize:function(e){const{accessToken:t,stagingToken:i,operationSettings:a,environment:r,branch:s,locale:o}=k(e);n.setAccessToken(t),i&&n.setStagingToken(i),o&&L.setLocale(o),a&&p.setSettings(a),r&&(E.setEnvironment(r),s&&E.setBranch(s))},logout:function(){n.clearAccessToken(),n.clearStagingToken(),L.setDefaultLocale()},constants:f},{initialize:v,logout:P,constants:D}=S;class O extends i{constructor(e){super();const t=Array.isArray(e)?e.join("\n"):e;this.name="EmbedApiError",this.message=`The call to the Embed API failed with the following errors:\n${t}`}}function N({accessToken:e,stagingToken:t,idempotencyKey:i,mfaPreference:a}){const r=new Headers;r.append("Authorization",`Bearer ${e}`);const s=t||n.getStagingToken();s&&r.append("X-Qonto-Staging-Token",s),i&&r.append("X-Qonto-Idempotency-Key",i);const o=a||p.getMFAPreference();return o&&r.append("X-Qonto-2fa-Preference",o),r.append("Content-Type","application/json"),r.append("Accept-Language",L.getLocale()),r}var U;!function(e){e.PENDING="pending",e.ONHOLD="onhold",e.ORDER_CANCELED="order_canceled",e.LIVE="live",e.PAUSED="paused",e.STOLEN="stolen",e.LOST="lost",e.PIN_BLOCKED="pin_blocked",e.DELETED="deleted",e.PRE_EXPIRED="pre_expired",e.EXPIRED="expired",e.DISCARDED="discarded",e.SHIPPED_LOST="shipped_lost",e.ABUSIVE="abusive"}(U||(U={}));const C={TRANSPORT:"transport",RESTAURANT_AND_BAR:"restaurant_and_bar",FOOD_AND_GROCERY:"food_and_grocery",IT_AND_ELECTRONICS:"it_and_electronics",UTILITY:"utility",TAX:"tax",LEGAL_AND_ACCOUNTING:"legal_and_accounting",ATM:"atm",OFFICE_SUPPLY:"office_supply",HARDWARE_AND_EQUIPMENT:"hardware_and_equipment",FINANCE:"finance"};var M,$;function B(e,t){const n=t.filter((t=>t.requiredIfPresent?!e[t.name]&&e[t.requiredIfPresent]:void 0===e[t.name])).map((e=>e.name));if(n.length>0)throw new s(n.map((e=>`Missing required parameter: ${e}`)))}function F(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"string"!=typeof e)).map((([e])=>`${e} must be a string`))}function j(e){return Object.entries(e).filter((([,e])=>void 0!==e&&!1!==e&&!0!==e)).map((([e])=>`${e} must be a boolean`))}function Y(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"number"!=typeof e)).map((([e])=>`${e} must be a number`))}!function(e){e.VIRTUAL="virtual"}(M||(M={})),function(e){e.METAL="metal",e.PLUS="plus",e.STANDARD="standard"}($||($={}));const G=[{name:"organizationId"},{name:"membershipId"},{name:"bankAccountId"},{name:"monthlyLimit"},{name:"cardLevel"}],q=[...G,{name:"atmDailyLimit",requiredIfPresent:"hasAtmDailyLimit"},{name:"hasAtmDailyLimit",requiredIfPresent:"hasAtmOption"},{name:"atmMonthlyLimit",requiredIfPresent:"hasAtmOption"},{name:"shipToBusiness"},{name:"cardLevel"}];function x(e){if(!e)throw new s("cardSettings parameter is required for the called function");return"virtual"===e.cardLevel?function(e){return B(e,G),function(e){const{membershipId:t,organizationId:n,bankAccountId:i,hasDailyLimit:a,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:m,categories:l,cardLevel:u}=e,f=function(e){return"virtual"!==e?['cardLevel must be "virtual"']:[]}(u),g=F({membershipId:t,organizationId:n,bankAccountId:i}),p=j({hasDailyLimit:a,hasTransactionLimit:r}),h=Y({monthlyLimit:o,dailyLimit:c,transactionLimit:d}),_=H(m),y=z(l),T=[...f,...g,...p,...h,..._,...y];if(T.length>0)throw new s(T)}(e),e}(e):function(e){B(e,q),function(e){const{membershipId:t,organizationId:n,bankAccountId:i,hasDailyLimit:a,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:m,categories:l,cardLevel:u,hasNfcOption:f,hasForeignPaymentOption:g,hasOnlinePaymentOption:p,shipToBusiness:h,hasAtmOption:_,hasAtmDailyLimit:y,atmDailyLimit:T,atmMonthlyLimit:I,address:E,cardDesign:b,typeOfPrint:w}=e,A=function(e){return Object.values($).includes(e)?[]:['cardLevel must be one of "standard", "plus", "metal"']}(u),k=function(e){const t=null!=e&&"string"!=typeof e,n=!["print","embossed",void 0,null].includes(e);return t||n?['typeOfPrint must be one of "print", "embossed" or null']:[]}(w),R=F({membershipId:t,organizationId:n,bankAccountId:i}),L=j({hasDailyLimit:a,hasTransactionLimit:r,hasAtmOption:_,hasNfcOption:f,hasForeignPaymentOption:g,hasOnlinePaymentOption:p,hasAtmDailyLimit:y,shipToBusiness:h}),S=Y({monthlyLimit:o,dailyLimit:c,transactionLimit:d,atmDailyLimit:T,atmMonthlyLimit:I}),v=H(m),P=z(l),D=function(e){return["undefined","string"].includes(typeof e)?[]:["cardDesign must be a string"]}(b),O=function(e,t){if(t)return[];return!e||e.contactName&&e.firstLine&&e.zipCode&&e.city&&e.country?[]:["address must contain at least contactName, firstLine, zipCode, city and country properties"]}(E,h),N=[...A,...R,...L,...S,...v,...P,...k,...D,...O];if(N.length>0)throw new s(N)}(e)}(e)}function H(e){const t=!Array.isArray(e)||!e.every((e=>Number.isInteger(e)&&e>0&&e<8));return void 0!==e&&t?["activeDays must be an array of integers between 1 and 7"]:[]}function z(e){const t=!Array.isArray(e)||e.some((e=>"string"!=typeof e));return void 0!==e&&t?["categories must be an array of strings"]:[]}class K extends i{constructor(e){super(),this.name="EmbedOperationError",this.message=e}}const V=[];for(let e=0;e<256;++e)V.push((e+256).toString(16).slice(1));let X;const Q=new Uint8Array(16);var W={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function J(e,t,n){if(W.randomUUID&&!e)return W.randomUUID();const i=(e=e||{}).random??e.rng?.()??function(){if(!X){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");X=crypto.getRandomValues.bind(crypto)}return X(Q)}();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e,t=0){return(V[e[t+0]]+V[e[t+1]]+V[e[t+2]]+V[e[t+3]]+"-"+V[e[t+4]]+V[e[t+5]]+"-"+V[e[t+6]]+V[e[t+7]]+"-"+V[e[t+8]]+V[e[t+9]]+"-"+V[e[t+10]]+V[e[t+11]]+V[e[t+12]]+V[e[t+13]]+V[e[t+14]]+V[e[t+15]]).toLowerCase()}(i)}class Z{constructor(e){this.options=e,this.iframe=null,this.parentElement=null,this.messageListeners=new Map,this.defaultTimeout=3e4;const t=new URL(e.iframeUrl);this.targetOrigin=`${t.protocol}//${t.host}`}async initialize(){if(this.iframe)return this;if(this.parentElement=document.getElementById(this.options.parentElementId),!this.parentElement)throw new K(`Could not install the authentication UI because the parent element with id ${this.options.parentElementId} was not found.\nPlease make sure to pass a valid parentElementId when calling the method.`);return new Promise(((e,t)=>{this.iframe=document.createElement("iframe"),this.iframe.src=this.options.iframeUrl,this.iframe.style.width="100%",this.iframe.style.height="100%",this.iframe.style.border="none";const n=this.options.timeout||this.defaultTimeout,i=setTimeout((()=>{window.removeEventListener("message",a),t(new K(`Could not install the authentication UI because the timeout of ${n}ms was reached.\nPlease make sure the application can reach the Internet.`))}),n),a=t=>{t.data.eventId===o.READY&&(clearTimeout(i),window.removeEventListener("message",a),e(this))};window.addEventListener("message",a),this.parentElement?.appendChild(this.iframe)}))}postMessage(e){if(!this.iframe||!this.iframe.contentWindow)return Promise.reject(new K("Attempted to perform an Embed operation without having the authentication UI initialized."));const t=function({actionId:e,actionData:t}){const n=p.getMFAPreference();return{actionId:e,actionData:{...t,scaPreference:t.scaPreference||n,idempotencyKey:t.idempotencyKey||J()}}}(e);return new Promise(((e,n)=>{const i=a=>{if(a.data?.actionId===t.actionId){if("error"===a.data.status)return this.removeMessageListener(t.actionId,i),n(new K(`An error occurred when performing the action ${t.actionId}.\n${JSON.stringify(a.data.payload)}`));this.removeMessageListener(t.actionId,i),e(a.data.payload)}};this.addMessageListener(t.actionId,i),this.iframe?.contentWindow?.postMessage(t,this.targetOrigin)}))}addMessageListener(e,t){this.messageListeners.has(e)||this.messageListeners.set(e,[]);this.messageListeners.get(e).push(t),window.addEventListener("message",t)}removeMessageListener(e,t){const n=this.messageListeners.get(e);if(n){const e=n.indexOf(t);-1!==e&&(n.splice(e,1),window.removeEventListener("message",t))}}destroy(){this.messageListeners.forEach((e=>{e.forEach((e=>{window.removeEventListener("message",e)}))})),this.messageListeners.clear(),this.iframe&&this.parentElement&&(this.parentElement.removeChild(this.iframe),this.iframe=null)}}function ee({accessToken:e,stagingToken:t,locale:n,debugMode:i}){const a=i||!1,r=n||L.getLocale(),s=E.getEnvironmentUrls().IFRAME_URL,o=t?`;staging_token=${encodeURIComponent(t)}`:"";return`${s}?debug=${a}&lang=${encodeURIComponent(r)}#access_token=${encodeURIComponent(e)}${o}`}function te({parentElementId:e,iframeUrl:t}){return new Z({parentElementId:e,iframeUrl:t}).initialize()}function ne(e){return"virtual"===e.cardLevel?function(e){const t=ae(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:J(),body:{card:{payment_monthly_limit:e.monthlyLimit,payment_daily_limit:e.dailyLimit,payment_daily_limit_option:e.hasDailyLimit,payment_transaction_limit:e.transactionLimit,payment_transaction_limit_option:e.hasTransactionLimit,active_days:e.activeDays||[],holder_id:e.membershipId,organization_id:e.organizationId,bank_account_id:e.bankAccountId,categories:t,card_level:e.cardLevel}}}}}(e):function(e){const t=ae(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:J(),body:{card:{payment_monthly_limit:e.monthlyLimit,payment_daily_limit:e.dailyLimit,payment_daily_limit_option:e.hasDailyLimit,payment_transaction_limit:e.transactionLimit,payment_transaction_limit_option:e.hasTransactionLimit,active_days:e.activeDays||[],holder_id:e.membershipId,organization_id:e.organizationId,bank_account_id:e.bankAccountId,categories:t,card_level:e.cardLevel,card_design:e.cardDesign,..."plus"===e.cardLevel&&{type_of_print:e.typeOfPrint},ship_to_business_address:e.shipToBusiness,atm_option:e.hasAtmOption,nfc_option:e.hasNfcOption,foreign_option:e.hasForeignPaymentOption,online_option:e.hasOnlinePaymentOption,atm_daily_limit:e.atmDailyLimit,atm_monthly_limit:e.atmMonthlyLimit,...!e.shipToBusiness&&{address:{contact_name:e.address?.contactName,first_line:e.address?.firstLine,second_line:e.address?.secondLine,third_line:e.address?.thirdLine,zipcode:e.address?.zipCode,city:e.address?.city,country:e.address?.country}}}}}}}(e)}function ie(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 ae(e){const t=Object.values(C);return(e||[]).filter((e=>t.includes(e)))}const re={getCards:async function({membershipId:e,accessToken:t,stagingToken:n}){try{const i=t||r();if(e&&"string"!=typeof e)throw new s("membershipId must be a string");const a=await async function({membershipId:e,accessToken:t,stagingToken:n}){const i={method:"GET",headers:N({accessToken:t,stagingToken:n})},a=E.getEnvironmentUrls().THIRD_PARTY_API_URL,r=e?`${a}/v2/cards?holder_ids[]=${e}`:`${a}/v2/cards`,s=await fetch(r,i),o=await s.json();if(o.errors)throw new O(o.errors.map((e=>`${e.code}: ${e.detail}`)));return o.cards}({membershipId:e,accessToken:i,stagingToken:n});return a.map((e=>ie(e)))}catch(e){return Promise.reject(e)}},getCard:async function({cardId:e,accessToken:t,stagingToken:n}){try{const i=t||r();if(e&&"string"!=typeof e)throw new s("cardId must be a string");const a=await async function({cardId:e,accessToken:t,stagingToken:n}){const i={method:"GET",headers:N({accessToken:t,stagingToken:n})},a=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}/v2/cards?ids[]=${e}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.cards[0]}({cardId:e,accessToken:i,stagingToken:n});return ie(a)}catch(e){return Promise.reject(e)}},orderCard:async function(e){try{const t=r(),{uiParentElementId:i,debugMode:a}=b(e.operationSettings);x(e.cardSettings);const s=ee({accessToken:t,stagingToken:n.getStagingToken()||void 0,debugMode:a}),o=await te({iframeUrl:s,parentElementId:i}),c=ne(e.cardSettings),d=await o.postMessage(c);return o.destroy(),ie(d)}catch(e){return Promise.reject(e)}},unlockCard:async function(e){try{const t=r(),{uiParentElementId:i,debugMode:a}=b(e.operationSettings);!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId is required for the called function");const t=F({cardId:e.cardId});if(t.length>0)throw new s(t)}(e.cardSettings);const o=ee({accessToken:t,stagingToken:n.getStagingToken()||void 0,debugMode:a}),d=await te({iframeUrl:o,parentElementId:i}),m=function(e){return{actionId:c.CARD_UNLOCK,actionData:{body:{cardId:e.cardSettings.cardId}}}}(e),l=await d.postMessage(m);return d.destroy(),ie(l)}catch(e){return Promise.reject(e)}},displayCard:async function(e){try{const{uiParentElementId:t,accessToken:n,stagingToken:i,debugMode:a,mfaPreference:o}=b(e.operationSettings),c=n||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 t=F({cardId:e.cardId});if(t.length>0)throw new s(t);let n={};void 0!==e.allowPinReveal&&(n={allowPinReveal:e.allowPinReveal}),void 0!==e.allowBlocking&&(n={...n,allowBlocking:e.allowBlocking});const i=j(n);if(i.length>0)throw new s(i)}(e.cardSettings);const d=await async function(e){const{accessToken:t,stagingToken:n,mfaPreference:i}=e,a={method:"GET",headers:N({accessToken:t,stagingToken:n,mfaPreference:i})},r=E.getEnvironmentUrls().THIRD_PARTY_API_URL,s=await fetch(`${r}/v2/cards/${e.cardId}/data_view`,a),o=await s.json();if(o.errors)throw new O(o.errors.map((e=>`${e.code}: ${e.detail}`)));return o.iframe_url}({...e.cardSettings,accessToken:c,stagingToken:i,mfaPreference:o}),{allowPinReveal:m,allowBlocking:l}=e.cardSettings,u=function(e,t){const n=new URL(e);return"boolean"==typeof t.allowPinReveal&&n.searchParams.set("canSeePin",t.allowPinReveal.toString()),"boolean"==typeof t.allowBlocking&&n.searchParams.set("canBlock",t.allowBlocking.toString()),!0===t.debugMode&&n.searchParams.set("debug",t.debugMode.toString()),n.toString()}(d,{allowPinReveal:m,allowBlocking:l,debugMode:a}),f=await te({iframeUrl:u,parentElementId:t});return{destroyEmbedUI:()=>{f.destroy()}}}catch(e){return Promise.reject(e)}}},se=re;function oe({endpointUrl:e,paginationSettings:t}){const n=new URL(e);return t?.page&&n.searchParams.set("page",t.page.toString()),t?.itemsPerPage&&n.searchParams.set("per_page",t.itemsPerPage.toString()),n}function ce(e){if(e)return{totalItems:e?.total_count,totalPages:e?.total_pages,currentPage:e?.current_page,itemsPerPage:e?.per_page,previousPage:e?.prev_page||null,nextPage:e?.next_page||null}}function de(e){return{id:e.id,name:e.name,email:e.email,activityTag:e.activity_tag,iban:e.iban,bic:e.bic,currency:e.currency,status:e.status,trusted:e.trusted,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at)}}function me(e){return{name:e.name,...e.email&&{email:e.email},...e.activityTag&&{activity_tag:e.activityTag},iban:e.iban,...e.bic&&{bic:e.bic}}}const le="/v2/sepa/beneficiaries";async function ue({accessToken:e,stagingToken:t,beneficiaryId:n}){const i={method:"GET",headers:N({accessToken:e,stagingToken:t})},a=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${le}/${n}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.beneficiary}const fe=[{name:"name"},{name:"iban"}];const ge={getBeneficiaries:async function(e){const t=e?.accessToken||r(),n=await async function({paginationSettings:e,accessToken:t,stagingToken:n}){const i={method:"GET",headers:N({accessToken:t,stagingToken:n})},a=oe({endpointUrl:new URL(E.getEnvironmentUrls().THIRD_PARTY_API_URL+le),paginationSettings:e}),r=await fetch(a,i),s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return{beneficiaries:s.beneficiaries,meta:s.meta}}({accessToken:t,stagingToken:e?.stagingToken,paginationSettings:e?.paginationSettings}),i=n.beneficiaries.map((e=>de(e))),a=ce(n.meta);return{beneficiaries:i,...a?{meta:a}:{}}},getBeneficiary:async function({beneficiaryId:e,accessToken:t,stagingToken:n}){const i=t||r();return function(e){if(!e)throw new s("beneficiaryId parameter is required for the called function");if(e&&"string"!=typeof e)throw new s("beneficiaryId must be a string")}(e),de(await ue({beneficiaryId:e,accessToken:i,stagingToken:n}))},addBeneficiary:async function({beneficiary:e,accessToken:t,stagingToken:n}){const i=t||r();!function(e){if(!e)throw new s("beneficiary parameter is required for the called function");if("object"!=typeof e)throw new s("beneficiary must be an object");B(e,fe);const t=F({name:e.name,iban:e.iban,email:e.email,activityTag:e.activityTag,bic:e.bic});if(t.length>0)throw new s(t)}(e);return de(await async function({beneficiary:e,accessToken:t,stagingToken:n}){const i={method:"POST",headers:N({accessToken:t,stagingToken:n,idempotencyKey:J()}),body:JSON.stringify({beneficiary:me(e)})},a=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${le}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.beneficiary}({beneficiary:e,accessToken:i,stagingToken:n}))},untrustBeneficiaries:async function({beneficiaryIds:e,accessToken:t,stagingToken:n}){const i=t||r();!function(e){if(!e)throw new s("beneficiaryIds parameter is required for the called function");if(!Array.isArray(e)||!e.every((e=>"string"==typeof e)))throw new s("beneficiaryIds must be an array of strings")}(e);return(await async function({beneficiaryIds:e,accessToken:t,stagingToken:n}){const i={method:"PATCH",headers:N({accessToken:t,stagingToken:n}),body:JSON.stringify({ids:e})},a=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${le}/untrust`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.beneficiaries}({beneficiaryIds:e,accessToken:i,stagingToken:n})).map(de)}};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 he(e){const t=e.beneficiaryId||e.beneficiary?.id;return{bank_account_id:e.bankAccountId,beneficiary_id:t,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachments?{attachments:e.attachments}:{}}}const _e="/v2/sepa/transfers";const ye=[{name:"bankAccountId"},{name:"reference"},{name:"amount"}];async function Te({sepaTransferSettings:e,operationSettings:t}){if(e.beneficiary)return e.beneficiary;return de(await ue({beneficiaryId:e.beneficiaryId,accessToken:t?.accessToken,stagingToken:t?.stagingToken}))}const Ie="browser",Ee="server";class be extends Error{constructor(e){switch(super(),this.name="InvalidRuntimeError",e){case Ie:this.message="This code is running in a browser environment, but it is expected to run in a server environment.";break;case Ee:this.message="This code is running in a server environment, but it is expected to run in a browser environment.";break;default:this.message="This code is not expected to run in this environment. Check if the function was server-only or browser-only."}}}const we={getSepaTransfers:async function(e={}){const t=e?.accessToken||r(),n=await async function({accessToken:e,stagingToken:t,paginationSettings:n}){const i={method:"GET",headers:N({accessToken:e,stagingToken:t})},a=oe({endpointUrl:new URL(E.getEnvironmentUrls().THIRD_PARTY_API_URL+_e),paginationSettings:n}),r=await fetch(a,i);if(!r.ok)throw new O("Failed to fetch SEPA transfers");const s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return{transfers:s.transfers,meta:s.meta}}({accessToken:t,stagingToken:e?.stagingToken,paginationSettings:e?.paginationSettings}),i=n.transfers.map((e=>pe(e))),a=ce(n.meta);return{transfers:i,...a?{meta:a}:{}}},getSepaTransfer:async function({sepaTransferId:e,accessToken:t,stagingToken:n}){const i=t||r();!function(e){if(!e)throw new s("sepaTransferId parameter is required for the called function");if(e&&"string"!=typeof e)throw new s("sepaTransferId must be a string")}(e);return pe(await async function({accessToken:e,stagingToken:t,sepaTransferId:n}){const i={method:"GET",headers:N({accessToken:e,stagingToken:t})},a=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${_e}/${n}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new O(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.external_transfer}({sepaTransferId:e,accessToken:i,stagingToken:n}))},createSepaTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const i=t?.accessToken||r(),a=t?.stagingToken||n.getStagingToken(),o=t?.idempotencyKey||J();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(B(e,ye),!e.beneficiaryId&&!e.beneficiary)throw new s("Either beneficiaryId or beneficiary must be provided");const t=[...F({beneficiaryId:e.beneficiaryId,bankAccountId:e.bankAccountId,note:e.note,reference:e.reference}),...Y({amount:e.amount})].flat();if(t.length>0)throw new s(t);if(e.amount>3e4&&(!e.attachments||0===e.attachments.length))throw new s("Attachments are required for transfers over €30,000")}(e);const m={...e,beneficiary:await Te({sepaTransferSettings:e,operationSettings:{accessToken:i,stagingToken:a||void 0}})};if(m.beneficiary.trusted)d=await async function({transfer:e,accessToken:t,stagingToken:n,idempotencyKey:i}){const a=he(e),r={method:"POST",headers:N({accessToken:t,stagingToken:n,idempotencyKey:i}),body:JSON.stringify({transfer:a})},s=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${_e}`,o=await fetch(s,r),c=await o.json();if(c.errors)throw new O(c.errors.map((e=>`${e.code}: ${e.detail}`)));return c.transfer}({transfer:m,accessToken:i,stagingToken:a||void 0,idempotencyKey:o});else{if("undefined"==typeof window||"undefined"==typeof document)throw new be(Ie);const{uiParentElementId:e,debugMode:n}=b(t);let r;try{const t=ee({accessToken:i,stagingToken:a||void 0,debugMode:n});r=await te({iframeUrl:t,parentElementId:e});const s=he(m);d=await r.postMessage({actionId:c.TRANSFER_SINGLE_CREATE,actionData:{body:{transfer:{...s}},idempotencyKey:o}})}finally{r?.destroy()}}return pe(d)}};e.beneficiaries=ge,e.cards=se,e.constants=D,e.initialize=v,e.logout=P,e.sepaTransfers=we}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).QontoEmbed={})}(this,(function(e){"use strict";class t{constructor(){this.accessToken=null,this.stagingToken=null}static getInstance(){return t.instance||(t.instance=new t),t.instance}setAccessToken(e){this.accessToken=e}getAccessToken(){return this.accessToken}hasAccessToken(){return null!==this.accessToken&&""!==this.accessToken}clearAccessToken(){this.accessToken=null}setStagingToken(e){this.stagingToken=e}getStagingToken(){return this.stagingToken}hasStagingToken(){return null!==this.stagingToken&&""!==this.stagingToken}clearStagingToken(){this.stagingToken=null}}const n=t.getInstance();class i extends Error{constructor(){super(),this.stack=""}toString(){return`${this.name}: ${this.message}`}}class a extends i{constructor(){super(),this.name="AuthenticationError",this.message="Authentication failed due to missing or invalid access token.\nEnsure you have called the initialize function with a valid access token."}}function r(){if(!n.hasAccessToken())throw new a;return n.getAccessToken()}class s extends i{constructor(e){super(),this.name="InvalidParametersError",this.invalidParameters=Array.isArray(e)?e:[e],this.message=`Invalid parameters were passed to the function:\n${this.invalidParameters.map((e=>e)).join("\n")}`}}const o={READY:"qonto.ready"},c={CARD_SEE:"card.see",CARD_SEE_DETAILS:"card.see-details",CARD_ORDER:"card.order",CARD_UNLOCK:"card.unlock",CARD_SHOW_PIN:"card.show.pin",CARD_SET_PIN:"card.set.pin",TRANSFER_SINGLE_CREATE:"transfer.single.create",BENEFICIARIES_TRUST:"beneficiary.trust"},d={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},m={MASTER:"master",SANDBOX:"sandbox",QA:"qa"},l={EN:"en",FR:"fr",DE:"de",ES:"es",IT:"it",PT:"pt"},u={PASSKEY:"passkey",SMS_OTP:"sms-otp",PAIRED_DEVICE:"paired-device",MOCK:"mock"};var f=Object.freeze({__proto__:null,ACTIONS:c,ACTIVITY_TAGS:{ATM:"atm",FALLBACK:"fallback",FEES:"fees",FINANCE:"finance",FOOD_AND_GROCERY:"food_and_grocery",GAS_STATION:"gas_station",HARDWARE_AND_EQUIPMENT:"hardware_and_equipment",HOTEL_AND_LODGING:"hotel_and_lodging",INSURANCE:"insurance",IT_AND_ELECTRONICS:"it_and_electronics",LEGAL_AND_ACCOUNTING:"legal_and_accounting",LOGISTICS:"logistics",MANUFACTURING:"manufacturing",MARKETING:"marketing",OFFICE_RENTAL:"office_rental",OFFICE_SUPPLY:"office_supply",ONLINE_SERVICE:"online_service",OTHER_EXPENSE:"other_expense",OTHER_INCOME:"other_income",OTHER_SERVICE:"other_service",PENDING:"pending",REFUND:"refund",RESTAURANT_AND_BAR:"restaurant_and_bar",SALES:"sales",SALARY:"salary",SUBSCRIPTION:"subscription",TAX:"tax",TRANSPORT:"transport",TREASURY_AND_INTERCO:"treasury_and_interco",UTILITY:"utility",VOUCHER:"voucher"},BENEFICIARY_STATUSES:{PENDING:"pending",VALIDATED:"validated",DECLINED:"declined"},BRANCHES:m,ENVIRONMENTS:d,IFRAME_EVENTS:o,LOCALES:l,MFA_METHODS:u,TRANSFER_DECLINE_REASONS:{BENEFICIARY_BIC_INVALID:"beneficiary_bic_invalid",BENEFICIARY_IBAN_INVALID:"beneficiary_iban_invalid",BENEFICIARY_STATUS:"beneficiary_status",BENEFICIARY_NETWORK_RULES_ERROR:"beneficiary_network_rules_error",ORGANISATION_COMPLIANCE_REASONS:"organisation_compliance_reasons",DEBIT_ACCOUNT_INSUFFICIENT_FUNDS:"debit_account_insufficient_funds",QONTO_PROCESSING_FAILED:"qonto_processing_failed"},TRANSFER_STATUSES:{PENDING:"pending",PROCESSING:"processing",CANCELED:"canceled",DECLINED:"declined",SETTLED:"settled"}});class g{constructor(){this.mfaPreference=u.PASSKEY,this.debugMode=!1}static getInstance(){return g.instance||(g.instance=new g),g.instance}setSettings(e){e.uiParentElementId&&(this.uiParentElementId=e.uiParentElementId),e.mfaPreference&&(this.mfaPreference=e.mfaPreference),e.debugMode&&(this.debugMode=e.debugMode)}getUIParentElementId(){return this.uiParentElementId}getMFAPreference(){return this.mfaPreference}getDebugMode(){return this.debugMode}clearSettings(){this.uiParentElementId=void 0,this.mfaPreference=u.PASSKEY}}const p=g.getInstance(),h="https://embed.qonto.com",_="https://embed-js{branch}.staging.qonto.co",y="https://embed.dev.qonto.co",T={[d.PRODUCTION]:{IFRAME_BASE_URL:h,IFRAME_URL:`${h}/connect`,THIRD_PARTY_API_URL:"https://thirdparty.qonto.com"},[d.STAGING]:{IFRAME_BASE_URL:_,IFRAME_URL:`${_}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"},[d.LOCAL]:{IFRAME_BASE_URL:y,IFRAME_URL:`${y}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"}};class I{constructor(){this.environment=d.PRODUCTION,this.branch=m.SANDBOX;const e=process.env.QONTO_EMBED_ENVIRONMENT,t=process.env.QONTO_EMBED_BRANCH;this.environment=Object.values(d).includes(e)?e:d.PRODUCTION,this.branch=Object.values(m).includes(t)?t:m.SANDBOX}static getInstance(){return I.instance||(I.instance=new I),I.instance}setEnvironment(e){this.environment=e}getEnvironment(){return this.environment}isProductionEnvironment(){return this.environment===d.PRODUCTION}setBranch(e){this.branch=e}getBranch(){return this.branch}clear(){this.environment=d.PRODUCTION,this.branch=m.MASTER}getEnvironmentUrls(){if(this.environment===d.PRODUCTION)return T.production;{const e=T[this.environment];return Object.entries(e).reduce(((e,[t,n])=>({...e,[t]:n.replace("{branch}",`-${this.branch}`)})),{})}}}const E=I.getInstance(),b={requiresUI:!1};function w(e,{requiresUI:t}=b){const n=e?.uiParentElementId||p.getUIParentElementId();if(t&&!n)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(u),E.isProductionEnvironment()?a.filter((e=>e!==u.MOCK)):a);if(!e.includes(i))throw new s(`operationSettings.mfaPreference must be one of ${e.join(", ")}`);if(E.isProductionEnvironment()&&i===u.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.");return{...e,uiParentElementId:n,mfaPreference:i,debugMode:r,...e}}const A=Object.values(l);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)throw new s("Access token is required when calling initialize()");return e?.operationSettings&&w(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 L{constructor(){this.currentLocale="en"}static getInstance(){return L.instance||(L.instance=new L),L.instance}setLocale(e){this.currentLocale=e}getLocale(){return this.currentLocale}setDefaultLocale(){this.currentLocale="en"}}const S=L.getInstance();const v={initialize:function(e){const{accessToken:t,stagingToken:i,operationSettings:a,environment:r,branch:s,locale:o}=R(e);n.setAccessToken(t),i&&n.setStagingToken(i),o&&S.setLocale(o),a&&p.setSettings(a),r&&(E.setEnvironment(r),s&&E.setBranch(s))},logout:function(){n.clearAccessToken(),n.clearStagingToken(),S.setDefaultLocale()},constants:f},{initialize:P,logout:D,constants:O}=v;class N extends i{constructor(e){super();const t=Array.isArray(e)?e.join("\n"):e;this.name="EmbedApiError",this.message=`The call to the Embed API failed with the following errors:\n${t}`}}function U({accessToken:e,stagingToken:t,idempotencyKey:i,mfaPreference:a}){const r=new Headers;r.append("Authorization",`Bearer ${e}`);const s=t||n.getStagingToken();s&&r.append("X-Qonto-Staging-Token",s),i&&r.append("X-Qonto-Idempotency-Key",i);const o=a||p.getMFAPreference();return o&&r.append("X-Qonto-2fa-Preference",o),r.append("Content-Type","application/json"),r.append("Accept-Language",S.getLocale()),r}var C;!function(e){e.PENDING="pending",e.ONHOLD="onhold",e.ORDER_CANCELED="order_canceled",e.LIVE="live",e.PAUSED="paused",e.STOLEN="stolen",e.LOST="lost",e.PIN_BLOCKED="pin_blocked",e.DELETED="deleted",e.PRE_EXPIRED="pre_expired",e.EXPIRED="expired",e.DISCARDED="discarded",e.SHIPPED_LOST="shipped_lost",e.ABUSIVE="abusive"}(C||(C={}));const M={TRANSPORT:"transport",RESTAURANT_AND_BAR:"restaurant_and_bar",FOOD_AND_GROCERY:"food_and_grocery",IT_AND_ELECTRONICS:"it_and_electronics",UTILITY:"utility",TAX:"tax",LEGAL_AND_ACCOUNTING:"legal_and_accounting",ATM:"atm",OFFICE_SUPPLY:"office_supply",HARDWARE_AND_EQUIPMENT:"hardware_and_equipment",FINANCE:"finance"};var $,B;function F(e,t){const n=t.filter((t=>t.requiredIfPresent?!e[t.name]&&e[t.requiredIfPresent]:void 0===e[t.name])).map((e=>e.name));if(n.length>0)throw new s(n.map((e=>`Missing required parameter: ${e}`)))}function j(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"string"!=typeof e)).map((([e])=>`${e} must be a string`))}function q(e){return Object.entries(e).filter((([,e])=>void 0!==e&&!1!==e&&!0!==e)).map((([e])=>`${e} must be a boolean`))}function Y(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"number"!=typeof e)).map((([e])=>`${e} must be a number`))}!function(e){e.VIRTUAL="virtual"}($||($={})),function(e){e.METAL="metal",e.PLUS="plus",e.STANDARD="standard"}(B||(B={}));const G=[{name:"organizationId"},{name:"membershipId"},{name:"bankAccountId"},{name:"monthlyLimit"},{name:"cardLevel"}],x=[...G,{name:"atmDailyLimit",requiredIfPresent:"hasAtmDailyLimit"},{name:"hasAtmDailyLimit",requiredIfPresent:"hasAtmOption"},{name:"atmMonthlyLimit",requiredIfPresent:"hasAtmOption"},{name:"shipToBusiness"},{name:"cardLevel"}];function H(e){if(!e)throw new s("cardSettings parameter is required for the called function");return"virtual"===e.cardLevel?function(e){return F(e,G),function(e){const{membershipId:t,organizationId:n,bankAccountId:i,hasDailyLimit:a,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:m,categories:l,cardLevel:u}=e,f=function(e){return"virtual"!==e?['cardLevel must be "virtual"']:[]}(u),g=j({membershipId:t,organizationId:n,bankAccountId:i}),p=q({hasDailyLimit:a,hasTransactionLimit:r}),h=Y({monthlyLimit:o,dailyLimit:c,transactionLimit:d}),_=z(m),y=K(l),T=[...f,...g,...p,...h,..._,...y];if(T.length>0)throw new s(T)}(e),e}(e):function(e){F(e,x),function(e){const{membershipId:t,organizationId:n,bankAccountId:i,hasDailyLimit:a,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:m,categories:l,cardLevel:u,hasNfcOption:f,hasForeignPaymentOption:g,hasOnlinePaymentOption:p,shipToBusiness:h,hasAtmOption:_,hasAtmDailyLimit:y,atmDailyLimit:T,atmMonthlyLimit:I,address:E,cardDesign:b,typeOfPrint:w}=e,A=function(e){return Object.values(B).includes(e)?[]:['cardLevel must be one of "standard", "plus", "metal"']}(u),k=function(e){const t=null!=e&&"string"!=typeof e,n=!["print","embossed",void 0,null].includes(e);return t||n?['typeOfPrint must be one of "print", "embossed" or null']:[]}(w),R=j({membershipId:t,organizationId:n,bankAccountId:i}),L=q({hasDailyLimit:a,hasTransactionLimit:r,hasAtmOption:_,hasNfcOption:f,hasForeignPaymentOption:g,hasOnlinePaymentOption:p,hasAtmDailyLimit:y,shipToBusiness:h}),S=Y({monthlyLimit:o,dailyLimit:c,transactionLimit:d,atmDailyLimit:T,atmMonthlyLimit:I}),v=z(m),P=K(l),D=function(e){return["undefined","string"].includes(typeof e)?[]:["cardDesign must be a string"]}(b),O=function(e,t){if(t)return[];return!e||e.contactName&&e.firstLine&&e.zipCode&&e.city&&e.country?[]:["address must contain at least contactName, firstLine, zipCode, city and country properties"]}(E,h),N=[...A,...R,...L,...S,...v,...P,...k,...D,...O];if(N.length>0)throw new s(N)}(e)}(e)}function z(e){const t=!Array.isArray(e)||!e.every((e=>Number.isInteger(e)&&e>0&&e<8));return void 0!==e&&t?["activeDays must be an array of integers between 1 and 7"]:[]}function K(e){const t=!Array.isArray(e)||e.some((e=>"string"!=typeof e));return void 0!==e&&t?["categories must be an array of strings"]:[]}class V extends i{constructor(e){super(),this.name="EmbedOperationError",this.message=e}}const X=[];for(let e=0;e<256;++e)X.push((e+256).toString(16).slice(1));let Q;const W=new Uint8Array(16);var J={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Z(e,t,n){if(J.randomUUID&&!e)return J.randomUUID();const i=(e=e||{}).random??e.rng?.()??function(){if(!Q){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Q=crypto.getRandomValues.bind(crypto)}return Q(W)}();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e,t=0){return(X[e[t+0]]+X[e[t+1]]+X[e[t+2]]+X[e[t+3]]+"-"+X[e[t+4]]+X[e[t+5]]+"-"+X[e[t+6]]+X[e[t+7]]+"-"+X[e[t+8]]+X[e[t+9]]+"-"+X[e[t+10]]+X[e[t+11]]+X[e[t+12]]+X[e[t+13]]+X[e[t+14]]+X[e[t+15]]).toLowerCase()}(i)}class ee{constructor(e){this.options=e,this.iframe=null,this.parentElement=null,this.messageListeners=new Map,this.defaultTimeout=3e4;const t=new URL(e.iframeUrl);this.targetOrigin=`${t.protocol}//${t.host}`}async initialize(){if(this.iframe)return this;if(this.parentElement=document.getElementById(this.options.parentElementId),!this.parentElement)throw new V(`Could not install the authentication UI because the parent element with id ${this.options.parentElementId} was not found.\nPlease make sure to pass a valid parentElementId when calling the method.`);return new Promise(((e,t)=>{this.iframe=document.createElement("iframe"),this.iframe.src=this.options.iframeUrl,this.iframe.style.width="100%",this.iframe.style.height="100%",this.iframe.style.border="none";const n=this.options.timeout||this.defaultTimeout,i=setTimeout((()=>{window.removeEventListener("message",a),t(new V(`Could not install the authentication UI because the timeout of ${n}ms was reached.\nPlease make sure the application can reach the Internet.`))}),n),a=t=>{t.data.eventId===o.READY&&(clearTimeout(i),window.removeEventListener("message",a),e(this))};window.addEventListener("message",a),this.parentElement?.appendChild(this.iframe)}))}postMessage(e){if(!this.iframe||!this.iframe.contentWindow)return Promise.reject(new V("Attempted to perform an Embed operation without having the authentication UI initialized."));const t=function({actionId:e,actionData:t}){const n=p.getMFAPreference();return{actionId:e,actionData:{...t,scaPreference:t.scaPreference||n,idempotencyKey:t.idempotencyKey||Z()}}}(e);return new Promise(((e,n)=>{const i=a=>{if(a.data?.actionId===t.actionId){if("error"===a.data.status)return this.removeMessageListener(t.actionId,i),n(new V(`An error occurred when performing the action ${t.actionId}.\n${JSON.stringify(a.data.payload)}`));this.removeMessageListener(t.actionId,i),e(a.data.payload)}};this.addMessageListener(t.actionId,i),this.iframe?.contentWindow?.postMessage(t,this.targetOrigin)}))}addMessageListener(e,t){this.messageListeners.has(e)||this.messageListeners.set(e,[]);this.messageListeners.get(e).push(t),window.addEventListener("message",t)}removeMessageListener(e,t){const n=this.messageListeners.get(e);if(n){const e=n.indexOf(t);-1!==e&&(n.splice(e,1),window.removeEventListener("message",t))}}destroy(){this.messageListeners.forEach((e=>{e.forEach((e=>{window.removeEventListener("message",e)}))})),this.messageListeners.clear(),this.iframe&&this.parentElement&&(this.parentElement.removeChild(this.iframe),this.iframe=null)}}function te({accessToken:e,stagingToken:t,locale:n,debugMode:i}){const a=i||!1,r=n||S.getLocale(),s=E.getEnvironmentUrls().IFRAME_URL,o=t?`;staging_token=${encodeURIComponent(t)}`:"";return`${s}?debug=${a}&lang=${encodeURIComponent(r)}#access_token=${encodeURIComponent(e)}${o}`}function ne({parentElementId:e,iframeUrl:t}){return new ee({parentElementId:e,iframeUrl:t}).initialize()}function ie(e){return"virtual"===e.cardLevel?function(e){const t=re(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:Z(),body:{card:{payment_monthly_limit:e.monthlyLimit,payment_daily_limit:e.dailyLimit,payment_daily_limit_option:e.hasDailyLimit,payment_transaction_limit:e.transactionLimit,payment_transaction_limit_option:e.hasTransactionLimit,active_days:e.activeDays||[],holder_id:e.membershipId,organization_id:e.organizationId,bank_account_id:e.bankAccountId,categories:t,card_level:e.cardLevel}}}}}(e):function(e){const t=re(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:Z(),body:{card:{payment_monthly_limit:e.monthlyLimit,payment_daily_limit:e.dailyLimit,payment_daily_limit_option:e.hasDailyLimit,payment_transaction_limit:e.transactionLimit,payment_transaction_limit_option:e.hasTransactionLimit,active_days:e.activeDays||[],holder_id:e.membershipId,organization_id:e.organizationId,bank_account_id:e.bankAccountId,categories:t,card_level:e.cardLevel,card_design:e.cardDesign,..."plus"===e.cardLevel&&{type_of_print:e.typeOfPrint},ship_to_business_address:e.shipToBusiness,atm_option:e.hasAtmOption,nfc_option:e.hasNfcOption,foreign_option:e.hasForeignPaymentOption,online_option:e.hasOnlinePaymentOption,atm_daily_limit:e.atmDailyLimit,atm_monthly_limit:e.atmMonthlyLimit,...!e.shipToBusiness&&{address:{contact_name:e.address?.contactName,first_line:e.address?.firstLine,second_line:e.address?.secondLine,third_line:e.address?.thirdLine,zipcode:e.address?.zipCode,city:e.address?.city,country:e.address?.country}}}}}}}(e)}function ae(e){return{id:e.id,nickname:e.nickname,embossedName:e.embossed_name,status:e.status,maskPan:e.mask_pan,expMonth:parseInt(e.exp_month,10),expYear:parseInt(e.exp_year,10),lastActivityAt:new Date(e.last_activity_at),lastDigits:e.last_digits,shipToBusiness:e.ship_to_business,atmOption:e.atm_option,atmDailyLimitOption:e.atm_daily_limit_option,nfcOption:e.nfc_option,onlineOption:e.online_option,foreignOption:e.foreign_option,atmMonthlyLimit:e.atm_monthly_limit,atmMonthlySpent:e.atm_monthly_spent,atmDailyLimit:e.atm_daily_limit,atmDailySpent:e.atm_daily_spent,paymentMonthlyLimit:e.payment_monthly_limit,paymentMonthlySpent:e.payment_monthly_spent,paymentDailyLimit:e.payment_daily_limit,paymentDailySpent:e.payment_daily_spent,paymentDailyLimitOption:e.payment_daily_limit_option,paymentTransactionLimit:e.payment_transaction_limit,paymentTransactionLimitOption:e.payment_transaction_limit_option,activeDays:e.active_days,holderId:e.holder_id,bankAccountId:e.bank_account_id,organizationId:e.organization_id,updatedAt:new Date(e.updated_at),createdAt:new Date(e.created_at),shippedAt:new Date(e.shipped_at),cardType:e.card_type,cardLevel:e.card_level,paymentLifespanLimit:e.payment_lifespan_limit,paymentLifespanSpent:e.payment_lifespan_spent,preExpiresAt:new Date(e.pre_expires_at),categories:e.categories,renewed:e.renewed,renewal:e.renewal,...e.parent_card_summary&&{parentCardSummary:{id:e.parent_card_summary.id,lastDigits:e.parent_card_summary.last_digits}},hadOperation:e.had_operation,hadPinOperation:e.had_pin_operation,cardDesign:e.card_design,typeOfPrint:e.type_of_print,upsold:e.upsold,upsell:e.upsell,discardOn:new Date(e.discard_on),reordered:e.reordered}}function re(e){const t=Object.values(M);return(e||[]).filter((e=>t.includes(e)))}const se={getCards:async function({membershipId:e,accessToken:t,stagingToken:n}){try{const i=t||r();if(e&&"string"!=typeof e)throw new s("membershipId must be a string");const a=await async function({membershipId:e,accessToken:t,stagingToken:n}){const i={method:"GET",headers:U({accessToken:t,stagingToken:n})},a=E.getEnvironmentUrls().THIRD_PARTY_API_URL,r=e?`${a}/v2/cards?holder_ids[]=${e}`:`${a}/v2/cards`,s=await fetch(r,i),o=await s.json();if(o.errors)throw new N(o.errors.map((e=>`${e.code}: ${e.detail}`)));return o.cards}({membershipId:e,accessToken:i,stagingToken:n});return a.map((e=>ae(e)))}catch(e){return Promise.reject(e)}},getCard:async function({cardId:e,accessToken:t,stagingToken:n}){try{const i=t||r();if(e&&"string"!=typeof e)throw new s("cardId must be a string");const a=await async function({cardId:e,accessToken:t,stagingToken:n}){const i={method:"GET",headers:U({accessToken:t,stagingToken:n})},a=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}/v2/cards?ids[]=${e}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.cards[0]}({cardId:e,accessToken:i,stagingToken:n});return ae(a)}catch(e){return Promise.reject(e)}},orderCard:async function(e){try{const t=r(),{uiParentElementId:i,debugMode:a}=w(e.operationSettings,{requiresUI:!0});H(e.cardSettings);const s=te({accessToken:t,stagingToken:n.getStagingToken()||void 0,debugMode:a}),o=await ne({iframeUrl:s,parentElementId:i}),c=ie(e.cardSettings),d=await o.postMessage(c);return o.destroy(),ae(d)}catch(e){return Promise.reject(e)}},unlockCard:async function(e){try{const t=r(),{uiParentElementId:i,debugMode:a}=w(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 t=j({cardId:e.cardId});if(t.length>0)throw new s(t)}(e.cardSettings);const o=te({accessToken:t,stagingToken:n.getStagingToken()||void 0,debugMode:a}),d=await ne({iframeUrl:o,parentElementId:i}),m=function(e){return{actionId:c.CARD_UNLOCK,actionData:{body:{cardId:e.cardSettings.cardId}}}}(e),l=await d.postMessage(m);return d.destroy(),ae(l)}catch(e){return Promise.reject(e)}},displayCard:async function(e){try{const{uiParentElementId:t,accessToken:n,stagingToken:i,debugMode:a,mfaPreference:o}=w(e.operationSettings,{requiresUI:!0}),c=n||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 t=j({cardId:e.cardId});if(t.length>0)throw new s(t);let n={};void 0!==e.allowPinReveal&&(n={allowPinReveal:e.allowPinReveal}),void 0!==e.allowBlocking&&(n={...n,allowBlocking:e.allowBlocking});const i=q(n);if(i.length>0)throw new s(i)}(e.cardSettings);const d=await async function(e){const{accessToken:t,stagingToken:n,mfaPreference:i}=e,a={method:"GET",headers:U({accessToken:t,stagingToken:n,mfaPreference:i})},r=E.getEnvironmentUrls().THIRD_PARTY_API_URL,s=await fetch(`${r}/v2/cards/${e.cardId}/data_view`,a),o=await s.json();if(o.errors)throw new N(o.errors.map((e=>`${e.code}: ${e.detail}`)));return o.iframe_url}({...e.cardSettings,accessToken:c,stagingToken:i,mfaPreference:o}),{allowPinReveal:m,allowBlocking:l}=e.cardSettings,u=function(e,t){const n=new URL(e);return"boolean"==typeof t.allowPinReveal&&n.searchParams.set("canSeePin",t.allowPinReveal.toString()),"boolean"==typeof t.allowBlocking&&n.searchParams.set("canBlock",t.allowBlocking.toString()),!0===t.debugMode&&n.searchParams.set("debug",t.debugMode.toString()),n.toString()}(d,{allowPinReveal:m,allowBlocking:l,debugMode:a}),f=await ne({iframeUrl:u,parentElementId:t});return{destroyEmbedUI:()=>{f.destroy()}}}catch(e){return Promise.reject(e)}}},oe=se;function ce({endpointUrl:e,paginationSettings:t}){const n=new URL(e);return t?.page&&n.searchParams.set("page",t.page.toString()),t?.itemsPerPage&&n.searchParams.set("per_page",t.itemsPerPage.toString()),n}function de(e){if(e)return{totalItems:e?.total_count,totalPages:e?.total_pages,currentPage:e?.current_page,itemsPerPage:e?.per_page,previousPage:e?.prev_page||null,nextPage:e?.next_page||null}}function me(e){return{id:e.id,name:e.name,email:e.email,activityTag:e.activity_tag,iban:e.iban,bic:e.bic,currency:e.currency,status:e.status,trusted:e.trusted,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at)}}function le(e){return{name:e.name,...e.email&&{email:e.email},...e.activityTag&&{activity_tag:e.activityTag},iban:e.iban,...e.bic&&{bic:e.bic}}}const ue="/v2/sepa/beneficiaries";async function fe({accessToken:e,stagingToken:t,beneficiaryId:n}){const i={method:"GET",headers:U({accessToken:e,stagingToken:t})},a=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${ue}/${n}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.beneficiary}const ge=[{name:"name"},{name:"iban"}];const pe={getBeneficiaries:async function(e){const t=e?.accessToken||r(),n=await async function({paginationSettings:e,accessToken:t,stagingToken:n}){const i={method:"GET",headers:U({accessToken:t,stagingToken:n})},a=ce({endpointUrl:new URL(E.getEnvironmentUrls().THIRD_PARTY_API_URL+ue),paginationSettings:e}),r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return{beneficiaries:s.beneficiaries,meta:s.meta}}({accessToken:t,stagingToken:e?.stagingToken,paginationSettings:e?.paginationSettings}),i=n.beneficiaries.map((e=>me(e))),a=de(n.meta);return{beneficiaries:i,...a?{meta:a}:{}}},getBeneficiary:async function({beneficiaryId:e,accessToken:t,stagingToken:n}){const i=t||r();return function(e){if(!e)throw new s("beneficiaryId parameter is required for the called function");if(e&&"string"!=typeof e)throw new s("beneficiaryId must be a string")}(e),me(await fe({beneficiaryId:e,accessToken:i,stagingToken:n}))},addBeneficiary:async function({beneficiary:e,accessToken:t,stagingToken:n}){const i=t||r();!function(e){if(!e)throw new s("beneficiary parameter is required for the called function");if("object"!=typeof e)throw new s("beneficiary must be an object");F(e,ge);const t=j({name:e.name,iban:e.iban,email:e.email,activityTag:e.activityTag,bic:e.bic});if(t.length>0)throw new s(t)}(e);return me(await async function({beneficiary:e,accessToken:t,stagingToken:n}){const i={method:"POST",headers:U({accessToken:t,stagingToken:n,idempotencyKey:Z()}),body:JSON.stringify({beneficiary:le(e)})},a=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${ue}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.beneficiary}({beneficiary:e,accessToken:i,stagingToken:n}))},untrustBeneficiaries:async function({beneficiaryIds:e,accessToken:t,stagingToken:n}){const i=t||r();!function(e){if(!e)throw new s("beneficiaryIds parameter is required for the called function");if(!Array.isArray(e)||!e.every((e=>"string"==typeof e)))throw new s("beneficiaryIds must be an array of strings")}(e);return(await async function({beneficiaryIds:e,accessToken:t,stagingToken:n}){const i={method:"PATCH",headers:U({accessToken:t,stagingToken:n}),body:JSON.stringify({ids:e})},a=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${ue}/untrust`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.beneficiaries}({beneficiaryIds:e,accessToken:i,stagingToken:n})).map(me)}};function he(e){return{id:e.id,initiatorId:e.initiator_id,bankAccountId:e.bank_account_id,amount:Number(e.amount),amountCents:Number(e.amount_cents),amountCurrency:e.amount_currency,status:e.status,beneficiaryId:e.beneficiary_id,reference:e.reference,note:e.note,declinedReason:e.declined_reason,scheduledDate:new Date(e.scheduled_date),createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),processedAt:new Date(e.processed_at),completedAt:new Date(e.completed_at),transactionId:e.transaction_id}}function _e(e){const t=e.beneficiaryId||e.beneficiary?.id;return{bank_account_id:e.bankAccountId,beneficiary_id:t,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachments?{attachments:e.attachments}:{}}}const ye="/v2/sepa/transfers";const Te=[{name:"bankAccountId"},{name:"reference"},{name:"amount"}];async function Ie({sepaTransferSettings:e,operationSettings:t}){if(e.beneficiary)return e.beneficiary;return me(await fe({beneficiaryId:e.beneficiaryId,accessToken:t?.accessToken,stagingToken:t?.stagingToken}))}const Ee="browser",be="server";class we extends Error{constructor(e){switch(super(),this.name="InvalidRuntimeError",e){case Ee:this.message="This code is running in a browser environment, but it is expected to run in a server environment.";break;case be:this.message="This code is running in a server environment, but it is expected to run in a browser environment.";break;default:this.message="This code is not expected to run in this environment. Check if the function was server-only or browser-only."}}}const Ae={getSepaTransfers:async function(e={}){const t=e?.accessToken||r(),n=await async function({accessToken:e,stagingToken:t,paginationSettings:n}){const i={method:"GET",headers:U({accessToken:e,stagingToken:t})},a=ce({endpointUrl:new URL(E.getEnvironmentUrls().THIRD_PARTY_API_URL+ye),paginationSettings:n}),r=await fetch(a,i);if(!r.ok)throw new 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:e?.stagingToken,paginationSettings:e?.paginationSettings}),i=n.transfers.map((e=>he(e))),a=de(n.meta);return{transfers:i,...a?{meta:a}:{}}},getSepaTransfer:async function({sepaTransferId:e,accessToken:t,stagingToken:n}){const i=t||r();!function(e){if(!e)throw new s("sepaTransferId parameter is required for the called function");if(e&&"string"!=typeof e)throw new s("sepaTransferId must be a string")}(e);return he(await async function({accessToken:e,stagingToken:t,sepaTransferId:n}){const i={method:"GET",headers:U({accessToken:e,stagingToken:t})},a=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${ye}/${n}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new N(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.external_transfer}({sepaTransferId:e,accessToken:i,stagingToken:n}))},createSepaTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const i=t?.accessToken||r(),a=t?.stagingToken||n.getStagingToken(),o=t?.idempotencyKey||Z();let d;!function(e){if(!e)throw new s("sepaTransferSettings parameter is required for the called function");if("object"!=typeof e)throw new s("sepaTransferSettings must be an object");if(F(e,Te),!e.beneficiaryId&&!e.beneficiary)throw new s("Either beneficiaryId or beneficiary must be provided");const t=[...j({beneficiaryId:e.beneficiaryId,bankAccountId:e.bankAccountId,note:e.note,reference:e.reference}),...Y({amount:e.amount})].flat();if(t.length>0)throw new s(t);if(e.amount>3e4&&(!e.attachments||0===e.attachments.length))throw new s("Attachments are required for transfers over €30,000")}(e);const m={...e,beneficiary:await Ie({sepaTransferSettings:e,operationSettings:{accessToken:i,stagingToken:a||void 0}})};if(m.beneficiary.trusted)d=await async function({transfer:e,accessToken:t,stagingToken:n,idempotencyKey:i}){const a=_e(e),r={method:"POST",headers:U({accessToken:t,stagingToken:n,idempotencyKey:i}),body:JSON.stringify({transfer:a})},s=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${ye}`,o=await fetch(s,r),c=await o.json();if(c.errors)throw new N(c.errors.map((e=>`${e.code}: ${e.detail}`)));return c.transfer}({transfer:m,accessToken:i,stagingToken:a||void 0,idempotencyKey:o});else{if("undefined"==typeof window||"undefined"==typeof document)throw new we(Ee);const{uiParentElementId:e,debugMode:n}=w(t,{requiresUI:!0});let r;try{const t=te({accessToken:i,stagingToken:a||void 0,debugMode:n});r=await ne({iframeUrl:t,parentElementId:e});const s=_e(m);d=await r.postMessage({actionId:c.TRANSFER_SINGLE_CREATE,actionData:{body:{transfer:{...s}},idempotencyKey:o}})}finally{r?.destroy()}}return he(d)}};e.beneficiaries=pe,e.cards=oe,e.constants=O,e.initialize=P,e.logout=D,e.sepaTransfers=Ae}));
@@ -1 +1 @@
1
- {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../src/mocks/handlers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,KAAK,EAEV,sBAAsB,EACvB,MAAM,sCAAsC,CAAC;AAG9C,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAK3D,eAAO,MAAM,iBAAiB,EAAE,qBAY/B,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;;;;CAOlC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,qBAAqB,EAe1D,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,sBAkBpC,CAAC;AAEF,eAAO,MAAM,wBAAwB,iEAC2B,CAAC;AAEjE,eAAO,MAAM,WAAW,6BAgRvB,CAAC"}
1
+ {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../src/mocks/handlers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,KAAK,EAEV,sBAAsB,EACvB,MAAM,sCAAsC,CAAC;AAG9C,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAK3D,eAAO,MAAM,iBAAiB,EAAE,qBAY/B,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;;;;CAOlC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,qBAAqB,EAe1D,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,sBAkBpC,CAAC;AAEF,eAAO,MAAM,wBAAwB,iEAC2B,CAAC;AAEjE,eAAO,MAAM,WAAW,6BAoSvB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sepa-transfers.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/sepa-transfers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAQtF,OAAO,KAAK,EACV,wBAAwB,EACxB,eAAe,EACf,YAAY,EAEb,MAAM,wBAAwB,CAAC;AAShC,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,2CAA2C,CAAC;AAUnD,UAAU,sBAAsB;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC;;;OAGG;IACH,oBAAoB,EAAE,CAAC,CAAC;IACxB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,gBAAgB,CACpC,sBAAsB,GAAE,sBAA2B,GAClD,OAAO,CAAC,wBAAwB,CAAC,CAqBnC;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CAAC,EACpC,cAAc,EACd,WAAW,EACX,YAAY,GACb,EAAE;IACD,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,YAAY,CAAC,CASxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,oBAAoB,EACpB,iBAAiB,GAClB,EAAE,kBAAkB,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CAuE7D"}
1
+ {"version":3,"file":"sepa-transfers.d.ts","sourceRoot":"","sources":["../../src/sepa-transfers/sepa-transfers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAQtF,OAAO,KAAK,EACV,wBAAwB,EACxB,eAAe,EACf,YAAY,EAEb,MAAM,wBAAwB,CAAC;AAShC,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,2CAA2C,CAAC;AAUnD,UAAU,sBAAsB;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC;;;OAGG;IACH,oBAAoB,EAAE,CAAC,CAAC;IACxB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,gBAAgB,CACpC,sBAAsB,GAAE,sBAA2B,GAClD,OAAO,CAAC,wBAAwB,CAAC,CAqBnC;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CAAC,EACpC,cAAc,EACd,WAAW,EACX,YAAY,GACb,EAAE;IACD,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,YAAY,CAAC,CASxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,oBAAoB,EACpB,iBAAiB,GAClB,EAAE,kBAAkB,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CA2E7D"}
@@ -1 +1 @@
1
- import{authManager as e}from"../common/auth/auth.js";import{validatePresenceOfAuthToken as t}from"../common/auth/auth.validate.js";import{getCardIframeURL as r,getCard as a,getCards as n}from"./cards.api.js";import"./cards.types.js";import{validateDisplayCardParams as o,validateUnlockCardParams as s,validateOrderCardParams as i}from"./cards.validate.js";import{createIframe as c,buildIframeUrl as m}from"../iframe/iframe-manager.js";import{serializeUnlockCardPayload as d,serializeCard as g,serializeOrderCardPayload as u}from"./cards.serializer.js";import{validateOperationSettingsParams as p}from"../validation/operation-settings-validation.js";import{InvalidParametersError as l}from"../errors/InvalidParametersError.js";import{getPopulatedIframeURL as f}from"./cards.helper.js";async function k({membershipId:e,accessToken:r,stagingToken:a}){try{const o=r||t();if(e&&"string"!=typeof e)throw new l("membershipId must be a string");return(await n({membershipId:e,accessToken:o,stagingToken:a})).map((e=>g(e)))}catch(e){return Promise.reject(e)}}async function T({cardId:e,accessToken:r,stagingToken:n}){try{const o=r||t();if(e&&"string"!=typeof e)throw new l("cardId must be a string");const s=await a({cardId:e,accessToken:o,stagingToken:n});return g(s)}catch(e){return Promise.reject(e)}}async function y(r){try{const a=t(),{uiParentElementId:n,debugMode:o}=p(r.operationSettings);i(r.cardSettings);const s=m({accessToken:a,stagingToken:e.getStagingToken()||void 0,debugMode:o}),d=await c({iframeUrl:s,parentElementId:n}),l=u(r.cardSettings),f=await d.postMessage(l);return d.destroy(),g(f)}catch(e){return Promise.reject(e)}}async function w(r){try{const a=t(),{uiParentElementId:n,debugMode:o}=p(r.operationSettings);s(r.cardSettings);const i=m({accessToken:a,stagingToken:e.getStagingToken()||void 0,debugMode:o}),u=await c({iframeUrl:i,parentElementId:n}),l=d(r),f=await u.postMessage(l);return u.destroy(),g(f)}catch(e){return Promise.reject(e)}}async function h(e){try{const{uiParentElementId:a,accessToken:n,stagingToken:s,debugMode:i,mfaPreference:m}=p(e.operationSettings),d=n||t();o(e.cardSettings);const g=await r({...e.cardSettings,accessToken:d,stagingToken:s,mfaPreference:m}),{allowPinReveal:u,allowBlocking:l}=e.cardSettings,k=f(g,{allowPinReveal:u,allowBlocking:l,debugMode:i}),T=await c({iframeUrl:k,parentElementId:a});return{destroyEmbedUI:()=>{T.destroy()}}}catch(e){return Promise.reject(e)}}export{h as displayCard,T as getCard,k as getCards,y as orderCard,w as unlockCard};
1
+ import{authManager as e}from"../common/auth/auth.js";import{validatePresenceOfAuthToken as t}from"../common/auth/auth.validate.js";import{getCardIframeURL as r,getCard as a,getCards as n}from"./cards.api.js";import"./cards.types.js";import{validateDisplayCardParams as s,validateUnlockCardParams as o,validateOrderCardParams as i}from"./cards.validate.js";import{createIframe as c,buildIframeUrl as m}from"../iframe/iframe-manager.js";import{serializeUnlockCardPayload as d,serializeCard as g,serializeOrderCardPayload as u}from"./cards.serializer.js";import{validateOperationSettingsParams as p}from"../validation/operation-settings-validation.js";import{InvalidParametersError as l}from"../errors/InvalidParametersError.js";import{getPopulatedIframeURL as f}from"./cards.helper.js";async function k({membershipId:e,accessToken:r,stagingToken:a}){try{const s=r||t();if(e&&"string"!=typeof e)throw new l("membershipId must be a string");return(await n({membershipId:e,accessToken:s,stagingToken:a})).map((e=>g(e)))}catch(e){return Promise.reject(e)}}async function T({cardId:e,accessToken:r,stagingToken:n}){try{const s=r||t();if(e&&"string"!=typeof e)throw new l("cardId must be a string");const o=await a({cardId:e,accessToken:s,stagingToken:n});return g(o)}catch(e){return Promise.reject(e)}}async function y(r){try{const a=t(),{uiParentElementId:n,debugMode:s}=p(r.operationSettings,{requiresUI:!0});i(r.cardSettings);const o=m({accessToken:a,stagingToken:e.getStagingToken()||void 0,debugMode:s}),d=await c({iframeUrl:o,parentElementId:n}),l=u(r.cardSettings),f=await d.postMessage(l);return d.destroy(),g(f)}catch(e){return Promise.reject(e)}}async function I(r){try{const a=t(),{uiParentElementId:n,debugMode:s}=p(r.operationSettings,{requiresUI:!0});o(r.cardSettings);const i=m({accessToken:a,stagingToken:e.getStagingToken()||void 0,debugMode:s}),u=await c({iframeUrl:i,parentElementId:n}),l=d(r),f=await u.postMessage(l);return u.destroy(),g(f)}catch(e){return Promise.reject(e)}}async function w(e){try{const{uiParentElementId:a,accessToken:n,stagingToken:o,debugMode:i,mfaPreference:m}=p(e.operationSettings,{requiresUI:!0}),d=n||t();s(e.cardSettings);const g=await r({...e.cardSettings,accessToken:d,stagingToken:o,mfaPreference:m}),{allowPinReveal:u,allowBlocking:l}=e.cardSettings,k=f(g,{allowPinReveal:u,allowBlocking:l,debugMode:i}),T=await c({iframeUrl:k,parentElementId:a});return{destroyEmbedUI:()=>{T.destroy()}}}catch(e){return Promise.reject(e)}}export{w as displayCard,T as getCard,k as getCards,y as orderCard,I as unlockCard};
@@ -1 +1 @@
1
- import{MFA_METHODS as e}from"../constants.js";class t{constructor(){this.uiParentElementId=null,this.mfaPreference=e.PASSKEY,this.debugMode=!1}static getInstance(){return t.instance||(t.instance=new t),t.instance}setSettings(e){e.uiParentElementId&&(this.uiParentElementId=e.uiParentElementId),e.mfaPreference&&(this.mfaPreference=e.mfaPreference),e.debugMode&&(this.debugMode=e.debugMode)}getUIParentElementId(){return this.uiParentElementId}getMFAPreference(){return this.mfaPreference}getDebugMode(){return this.debugMode}clearSettings(){this.uiParentElementId=null,this.mfaPreference=e.PASSKEY}}const n=t.getInstance();export{t as OperationSettingsManager,n as operationSettingsManager};
1
+ import{MFA_METHODS as e}from"../constants.js";class t{constructor(){this.mfaPreference=e.PASSKEY,this.debugMode=!1}static getInstance(){return t.instance||(t.instance=new t),t.instance}setSettings(e){e.uiParentElementId&&(this.uiParentElementId=e.uiParentElementId),e.mfaPreference&&(this.mfaPreference=e.mfaPreference),e.debugMode&&(this.debugMode=e.debugMode)}getUIParentElementId(){return this.uiParentElementId}getMFAPreference(){return this.mfaPreference}getDebugMode(){return this.debugMode}clearSettings(){this.uiParentElementId=void 0,this.mfaPreference=e.PASSKEY}}const n=t.getInstance();export{t as OperationSettingsManager,n as operationSettingsManager};
@@ -1 +1 @@
1
- import{authManager as e}from"../common/auth/auth.js";import{validatePresenceOfAuthToken as t}from"../common/auth/auth.validate.js";import{serializePaginationResponse as a}from"../common/api-pagination/api-pagination.js";import{createSepaTransfer as n,getSepaTransfer as s,getSepaTransfers as o}from"./sepa-transfers.api.js";import{serializeToNewSepaTransferDataObject as r,serializeSepaTransfer as i}from"./sepa-transfers.serializer.js";import{validateCreateSepaTransferParams as m,validateGetSepaTransferParams as c}from"./sepa-transfers.validate.js";import{validateOperationSettingsParams as p}from"../validation/operation-settings-validation.js";import{buildIframeUrl as f,createIframe as g}from"../iframe/iframe-manager.js";import{ACTIONS as d}from"../common/constants.js";import{findBeneficiary as T}from"./sepa-transfers.utils.js";import{isRunningInBrowser as u}from"../common/runtime/runtime.validation.js";import{InvalidRuntimeError as l,RUNTIME_ENVIRONMENT as k}from"../errors/InvalidRuntimeError.js";import y from"../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm-browser/v4.js";async function j(e={}){const n=e?.accessToken||t(),s=await o({accessToken:n,stagingToken:e?.stagingToken,paginationSettings:e?.paginationSettings}),r=s.transfers.map((e=>i(e))),m=a(s.meta);return{transfers:r,...m?{meta:m}:{}}}async function S({sepaTransferId:e,accessToken:a,stagingToken:n}){const o=a||t();c(e);const r=await s({sepaTransferId:e,accessToken:o,stagingToken:n});return i(r)}async function v({sepaTransferSettings:a,operationSettings:s}){const o=s?.accessToken||t(),c=s?.stagingToken||e.getStagingToken(),j=s?.idempotencyKey||y();let S;m(a);const v={...a,beneficiary:await T({sepaTransferSettings:a,operationSettings:{accessToken:o,stagingToken:c||void 0}})};if(v.beneficiary.trusted)S=await n({transfer:v,accessToken:o,stagingToken:c||void 0,idempotencyKey:j});else{if(!u())throw new l(k.BROWSER);const{uiParentElementId:e,debugMode:t}=p(s);let a;try{const n=f({accessToken:o,stagingToken:c||void 0,debugMode:t});a=await g({iframeUrl:n,parentElementId:e});const s=r(v);S=await a.postMessage({actionId:d.TRANSFER_SINGLE_CREATE,actionData:{body:{transfer:{...s}},idempotencyKey:j}})}finally{a?.destroy()}}return i(S)}export{v as createSepaTransfer,S as getSepaTransfer,j as getSepaTransfers};
1
+ import{authManager as e}from"../common/auth/auth.js";import{validatePresenceOfAuthToken as t}from"../common/auth/auth.validate.js";import{serializePaginationResponse as a}from"../common/api-pagination/api-pagination.js";import{createSepaTransfer as n,getSepaTransfer as s,getSepaTransfers as o}from"./sepa-transfers.api.js";import{serializeToNewSepaTransferDataObject as r,serializeSepaTransfer as i}from"./sepa-transfers.serializer.js";import{validateCreateSepaTransferParams as m,validateGetSepaTransferParams as c}from"./sepa-transfers.validate.js";import{validateOperationSettingsParams as p}from"../validation/operation-settings-validation.js";import{buildIframeUrl as f,createIframe as g}from"../iframe/iframe-manager.js";import{ACTIONS as d}from"../common/constants.js";import{findBeneficiary as T}from"./sepa-transfers.utils.js";import{isRunningInBrowser as u}from"../common/runtime/runtime.validation.js";import{InvalidRuntimeError as l,RUNTIME_ENVIRONMENT as k}from"../errors/InvalidRuntimeError.js";import y from"../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm-browser/v4.js";async function j(e={}){const n=e?.accessToken||t(),s=await o({accessToken:n,stagingToken:e?.stagingToken,paginationSettings:e?.paginationSettings}),r=s.transfers.map((e=>i(e))),m=a(s.meta);return{transfers:r,...m?{meta:m}:{}}}async function S({sepaTransferId:e,accessToken:a,stagingToken:n}){const o=a||t();c(e);const r=await s({sepaTransferId:e,accessToken:o,stagingToken:n});return i(r)}async function v({sepaTransferSettings:a,operationSettings:s}){const o=s?.accessToken||t(),c=s?.stagingToken||e.getStagingToken(),j=s?.idempotencyKey||y();let S;m(a);const v={...a,beneficiary:await T({sepaTransferSettings:a,operationSettings:{accessToken:o,stagingToken:c||void 0}})};if(v.beneficiary.trusted)S=await n({transfer:v,accessToken:o,stagingToken:c||void 0,idempotencyKey:j});else{if(!u())throw new l(k.BROWSER);const{uiParentElementId:e,debugMode:t}=p(s,{requiresUI:!0});let a;try{const n=f({accessToken:o,stagingToken:c||void 0,debugMode:t});a=await g({iframeUrl:n,parentElementId:e});const s=r(v);S=await a.postMessage({actionId:d.TRANSFER_SINGLE_CREATE,actionData:{body:{transfer:{...s}},idempotencyKey:j}})}finally{a?.destroy()}}return i(S)}export{v as createSepaTransfer,S as getSepaTransfer,j as getSepaTransfers};
@@ -1 +1 @@
1
- import{InvalidParametersError as e}from"../errors/InvalidParametersError.js";import{operationSettingsManager as n}from"../common/operation-settings/operation-settings.js";import{MFA_METHODS as t}from"../common/constants.js";import{environmentManager as o}from"../common/environment/environment-manager.js";function r(r){const i=r?.uiParentElementId||n.getUIParentElementId();if(!i)throw new e("operationSettings parameter must have a uiParentElementId for the called function.\nYou can pass it either to the initialize function or in a per function basis.");const a=r?.mfaPreference||n.getMFAPreference();if(a){const n=(m=Object.values(t),o.isProductionEnvironment()?m.filter((e=>e!==t.MOCK)):m);if(!n.includes(a))throw new e(`operationSettings.mfaPreference must be one of ${n.join(", ")}`);if(o.isProductionEnvironment()&&a===t.MOCK)throw new e("operationSettings.mfaPreference cannot be set to mock in production environment.")}var m;const s=r?.debugMode||n.getDebugMode();if(void 0!==s&&"boolean"!=typeof s)throw new e("operationSettings.debugMode must be a boolean.");return{...r,uiParentElementId:i,mfaPreference:a,debugMode:s,...r}}export{r 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:a}=r){const s=i?.uiParentElementId||n.getUIParentElementId();if(a&&!s)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 f=i?.debugMode||n.getDebugMode();if(void 0!==f&&"boolean"!=typeof f)throw new e("operationSettings.debugMode must be a boolean.");return{...i,uiParentElementId:s,mfaPreference:m,debugMode:f,...i}}export{i as validateOperationSettingsParams};
@@ -41,5 +41,12 @@ export interface OperationSettings {
41
41
  */
42
42
  idempotencyKey?: string;
43
43
  }
44
- export declare function validateOperationSettingsParams(params: OperationSettings | undefined): OperationSettings;
44
+ export interface OperationSettingsValidationConfiguration {
45
+ /**
46
+ * Whether the operation, due ot its nature or because it is a sensitive operation, requires a UI parent
47
+ * element to be specified.
48
+ */
49
+ requiresUI?: boolean;
50
+ }
51
+ export declare function validateOperationSettingsParams(params: OperationSettings | undefined, { requiresUI, }?: OperationSettingsValidationConfiguration): OperationSettings;
45
52
  //# sourceMappingURL=operation-settings-validation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"operation-settings-validation.d.ts","sourceRoot":"","sources":["../../src/validation/operation-settings-validation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qDAAqD,CAAC;AAIrF;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;OAIG;IACH,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,iBAAiB,GAAG,SAAS,GACpC,iBAAiB,CA6CnB"}
1
+ {"version":3,"file":"operation-settings-validation.d.ts","sourceRoot":"","sources":["../../src/validation/operation-settings-validation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qDAAqD,CAAC;AAIrF;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;OAIG;IACH,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,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,CA6CnB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qonto/embed-sdk",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "Library to embed Qonto features in your application",
5
5
  "type": "module",
6
6
  "exports": {