@qonto/embed-sdk 0.6.0 → 0.7.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.
- package/dist/beneficiaries/beneficiaries.api.d.ts +8 -3
- package/dist/beneficiaries/beneficiaries.api.d.ts.map +1 -1
- package/dist/beneficiaries/beneficiaries.d.ts +19 -7
- package/dist/beneficiaries/beneficiaries.d.ts.map +1 -1
- package/dist/beneficiaries/beneficiaries.public-api.d.ts +2 -1
- package/dist/beneficiaries/beneficiaries.public-api.d.ts.map +1 -1
- package/dist/beneficiaries/beneficiaries.serializer.d.ts +2 -1
- package/dist/beneficiaries/beneficiaries.serializer.d.ts.map +1 -1
- package/dist/beneficiaries/beneficiaries.types.d.ts +34 -0
- package/dist/beneficiaries/beneficiaries.types.d.ts.map +1 -1
- package/dist/beneficiaries/beneficiaries.validate.d.ts +2 -0
- package/dist/beneficiaries/beneficiaries.validate.d.ts.map +1 -1
- package/dist/beneficiaries/index.d.ts +1 -0
- package/dist/beneficiaries/index.d.ts.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/mocks/handlers.d.ts +8 -0
- package/dist/mocks/handlers.d.ts.map +1 -1
- package/dist/src/beneficiaries/beneficiaries.api.js +1 -1
- package/dist/src/beneficiaries/beneficiaries.js +1 -1
- package/dist/src/beneficiaries/beneficiaries.public-api.js +1 -1
- package/dist/src/beneficiaries/beneficiaries.serializer.js +1 -1
- package/dist/src/beneficiaries/beneficiaries.validate.js +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.public-api.d.ts +2 -2
- package/dist/types/types.public-api.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BeneficiaryDataObject } from './beneficiaries.types';
|
|
1
|
+
import type { BeneficiaryDataObject, NewBeneficiary } from './beneficiaries.types';
|
|
2
2
|
import type { PaginationResponseDataObject, PaginationSettings } from '@common/api-pagination/api-pagination.types';
|
|
3
3
|
interface GetBeneficiariesParams {
|
|
4
4
|
accessToken: string;
|
|
@@ -8,11 +8,16 @@ interface GetBeneficiaryParams {
|
|
|
8
8
|
accessToken: string;
|
|
9
9
|
beneficiaryId: string;
|
|
10
10
|
}
|
|
11
|
-
interface
|
|
11
|
+
interface AddBeneficiaryParams {
|
|
12
|
+
accessToken: string;
|
|
13
|
+
beneficiary: NewBeneficiary;
|
|
14
|
+
}
|
|
15
|
+
interface GetBeneficiariesApiResponse {
|
|
12
16
|
beneficiaries: BeneficiaryDataObject[];
|
|
13
17
|
meta: PaginationResponseDataObject;
|
|
14
18
|
}
|
|
15
|
-
export declare function getBeneficiaries({ paginationSettings, accessToken, }: GetBeneficiariesParams): Promise<
|
|
19
|
+
export declare function getBeneficiaries({ paginationSettings, accessToken, }: GetBeneficiariesParams): Promise<GetBeneficiariesApiResponse>;
|
|
16
20
|
export declare function getBeneficiary({ accessToken, beneficiaryId, }: GetBeneficiaryParams): Promise<BeneficiaryDataObject>;
|
|
21
|
+
export declare function addBeneficiary({ accessToken, beneficiary, }: AddBeneficiaryParams): Promise<any>;
|
|
17
22
|
export {};
|
|
18
23
|
//# 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":"
|
|
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;AAGrD,UAAU,sBAAsB;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC;AAED,UAAU,oBAAoB;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,oBAAoB;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,cAAc,CAAC;CAC7B;AASD,UAAU,2BAA2B;IACnC,aAAa,EAAE,qBAAqB,EAAE,CAAC;IACvC,IAAI,EAAE,4BAA4B,CAAC;CACpC;AAED,wBAAsB,gBAAgB,CAAC,EACrC,kBAAkB,EAClB,WAAW,GACZ,EAAE,sBAAsB,GAAG,OAAO,CAAC,2BAA2B,CAAC,CA4B/D;AAED,wBAAsB,cAAc,CAAC,EACnC,WAAW,EACX,aAAa,GACd,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAkBvD;AAED,wBAAsB,cAAc,CAAC,EACnC,WAAW,EACX,WAAW,GACZ,EAAE,oBAAoB,gBA0BtB"}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import type { Beneficiary } from './beneficiaries.types';
|
|
2
|
-
import type { PaginationSettings
|
|
3
|
-
interface GetBeneficiariesResponse {
|
|
4
|
-
beneficiaries: Beneficiary[];
|
|
5
|
-
meta: PaginationState;
|
|
6
|
-
}
|
|
1
|
+
import type { Beneficiary, GetBeneficiariesResponse, NewBeneficiary } from './beneficiaries.types';
|
|
2
|
+
import type { PaginationSettings } from '@common/api-pagination/api-pagination.types';
|
|
7
3
|
/**
|
|
8
4
|
* Fetches the list of beneficiaries for the current user.
|
|
9
5
|
* @param getBeneficiariesParams - An optional object with the accessToken
|
|
@@ -28,10 +24,26 @@ export declare function getBeneficiaries(getBeneficiariesParams?: {
|
|
|
28
24
|
* @throws \{AuthenticationError\} If the access token is invalid or missing.
|
|
29
25
|
* Ensure initialize has been called before using this function if you are not
|
|
30
26
|
* passing the access token.
|
|
27
|
+
* @throws \{InvalidParametersError\} If the `beneficiaryId` parameter is not a
|
|
28
|
+
* string or is missing.
|
|
31
29
|
*/
|
|
32
30
|
export declare function getBeneficiary({ beneficiaryId, accessToken, }: {
|
|
33
31
|
beneficiaryId: string;
|
|
34
32
|
accessToken?: string;
|
|
35
33
|
}): Promise<Beneficiary>;
|
|
36
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Adds a new beneficiary in the current user's account.
|
|
36
|
+
* @param Object - An object containing the new beneficiary's details and an
|
|
37
|
+
* `accessToken`. The `beneficiary` parameter object requires at least the `name`
|
|
38
|
+
* and `iban` properties to be present. The rest of the properties are optional.
|
|
39
|
+
* @throws \{AuthenticationError\} If the access token is invalid or missing.
|
|
40
|
+
* Ensure initialize has been called before using this function if you are not
|
|
41
|
+
* passing the access token.
|
|
42
|
+
* @throws \{InvalidParametersError\} If the `beneficiary` parameter is not an
|
|
43
|
+
* object or if it does not contain the required properties.
|
|
44
|
+
*/
|
|
45
|
+
export declare function addBeneficiary({ beneficiary, accessToken, }: {
|
|
46
|
+
beneficiary: NewBeneficiary;
|
|
47
|
+
accessToken?: string;
|
|
48
|
+
}): Promise<Beneficiary>;
|
|
37
49
|
//# sourceMappingURL=beneficiaries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"beneficiaries.d.ts","sourceRoot":"","sources":["../../src/beneficiaries/beneficiaries.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
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;AAY/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAEtF;;;;;;;;;;;;GAYG;AACH,wBAAsB,gBAAgB,CAAC,sBAAsB,CAAC,EAAE;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAkBpC;AAED;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAAC,EACnC,aAAa,EACb,WAAW,GACZ,EAAE;IACD,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,WAAW,CAAC,CAQvB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CAAC,EACnC,WAAW,EACX,WAAW,GACZ,EAAE;IACD,WAAW,EAAE,cAAc,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,WAAW,CAAC,CAQvB"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { getBeneficiary, getBeneficiaries } from './beneficiaries';
|
|
1
|
+
import { getBeneficiary, getBeneficiaries, addBeneficiary } from './beneficiaries';
|
|
2
2
|
declare const beneficiaries: {
|
|
3
3
|
getBeneficiaries: typeof getBeneficiaries;
|
|
4
4
|
getBeneficiary: typeof getBeneficiary;
|
|
5
|
+
addBeneficiary: typeof addBeneficiary;
|
|
5
6
|
};
|
|
6
7
|
export { beneficiaries };
|
|
7
8
|
//# sourceMappingURL=beneficiaries.public-api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"beneficiaries.public-api.d.ts","sourceRoot":"","sources":["../../src/beneficiaries/beneficiaries.public-api.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"beneficiaries.public-api.d.ts","sourceRoot":"","sources":["../../src/beneficiaries/beneficiaries.public-api.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,cAAc,EACf,MAAM,iBAAiB,CAAC;AAEzB,QAAA,MAAM,aAAa;;;;CAIlB,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { type Beneficiary, type BeneficiaryDataObject } from './beneficiaries.types';
|
|
1
|
+
import { type Beneficiary, type BeneficiaryDataObject, type NewBeneficiary, type NewBeneficiaryDataObject } from './beneficiaries.types';
|
|
2
2
|
export declare function serializeBeneficiary(beneficiary: BeneficiaryDataObject): Beneficiary;
|
|
3
|
+
export declare function serializeToNewBeneficiaryDataObject(beneficiary: NewBeneficiary): NewBeneficiaryDataObject;
|
|
3
4
|
//# sourceMappingURL=beneficiaries.serializer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"beneficiaries.serializer.d.ts","sourceRoot":"","sources":["../../src/beneficiaries/beneficiaries.serializer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,qBAAqB,
|
|
1
|
+
{"version":3,"file":"beneficiaries.serializer.d.ts","sourceRoot":"","sources":["../../src/beneficiaries/beneficiaries.serializer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAC9B,MAAM,uBAAuB,CAAC;AAE/B,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,qBAAqB,GACjC,WAAW,CAcb;AAED,wBAAgB,mCAAmC,CACjD,WAAW,EAAE,cAAc,GAC1B,wBAAwB,CAQ1B"}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { type ACTIVITY_TAGS, BENEFICIARY_STATUSES } from '@common/constants';
|
|
2
|
+
import type { PaginationState } from '@common/api-pagination/api-pagination.types';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a beneficiary in the system. Beneficiaries are used to perform SEPA
|
|
5
|
+
* transfers.
|
|
6
|
+
*/
|
|
2
7
|
export interface Beneficiary {
|
|
3
8
|
id: string;
|
|
4
9
|
name: string;
|
|
@@ -12,6 +17,16 @@ export interface Beneficiary {
|
|
|
12
17
|
createdAt: Date;
|
|
13
18
|
updatedAt: Date;
|
|
14
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Represents a new beneficiary to be added to the system. This type excludes
|
|
22
|
+
* fields that are automatically generated or managed by the system, such as
|
|
23
|
+
* `id`, `currency`, `status`, `trusted`, `createdAt`, and `updatedAt`.
|
|
24
|
+
*/
|
|
25
|
+
export type NewBeneficiary = Pick<Beneficiary, 'name' | 'iban'> & {
|
|
26
|
+
email?: string;
|
|
27
|
+
bic?: string;
|
|
28
|
+
activityTag?: (typeof ACTIVITY_TAGS)[keyof typeof ACTIVITY_TAGS];
|
|
29
|
+
};
|
|
15
30
|
export interface BeneficiaryDataObject {
|
|
16
31
|
id: string;
|
|
17
32
|
name: string;
|
|
@@ -25,4 +40,23 @@ export interface BeneficiaryDataObject {
|
|
|
25
40
|
created_at: string;
|
|
26
41
|
updated_at: string;
|
|
27
42
|
}
|
|
43
|
+
export type NewBeneficiaryDataObject = Pick<BeneficiaryDataObject, 'name'> & {
|
|
44
|
+
email?: string;
|
|
45
|
+
iban?: string;
|
|
46
|
+
bic?: string;
|
|
47
|
+
activityTag?: (typeof ACTIVITY_TAGS)[keyof typeof ACTIVITY_TAGS];
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Represents the response structure for fetching a list of beneficiaries.
|
|
51
|
+
*/
|
|
52
|
+
export interface GetBeneficiariesResponse {
|
|
53
|
+
/**
|
|
54
|
+
* An array of beneficiary objects, each containing details about a specific beneficiary.
|
|
55
|
+
*/
|
|
56
|
+
beneficiaries: Beneficiary[];
|
|
57
|
+
/**
|
|
58
|
+
* Metadata about the pagination state of the response, such as the current page and total pages.
|
|
59
|
+
*/
|
|
60
|
+
meta: PaginationState;
|
|
61
|
+
}
|
|
28
62
|
//# sourceMappingURL=beneficiaries.types.d.ts.map
|
|
@@ -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;
|
|
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,EAAE,eAAe,CAAC;CACvB"}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import type { NewBeneficiary } from '@beneficiaries/beneficiaries.types';
|
|
1
2
|
export declare function validateGetBeneficiaryParams(beneficiaryId: string): string;
|
|
3
|
+
export declare function validateAddBeneficiaryParams(beneficiary: NewBeneficiary): NewBeneficiary;
|
|
2
4
|
//# 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":"
|
|
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"}
|
|
@@ -15,5 +15,6 @@
|
|
|
15
15
|
export declare const beneficiaries: {
|
|
16
16
|
getBeneficiaries: typeof import("./beneficiaries").getBeneficiaries;
|
|
17
17
|
getBeneficiary: typeof import("./beneficiaries").getBeneficiary;
|
|
18
|
+
addBeneficiary: typeof import("./beneficiaries").addBeneficiary;
|
|
18
19
|
};
|
|
19
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/beneficiaries/index.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/beneficiaries/index.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa;;;;CAAuC,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}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}}const n=t.getInstance();class i extends Error{constructor(){super(),this.stack=""}toString(){return`${this.name}: ${this.message}`}}class a extends i{constructor(){super(),this.name="AuthenticationError",this.message="Authentication failed due to missing or invalid access token.\nEnsure you have called the initialize function with a valid access token."}}function r(){if(!n.hasAccessToken())throw new a;return n.getAccessToken()}class s extends i{constructor(e){super(),this.name="InvalidParametersError",this.invalidParameters=Array.isArray(e)?e:[e],this.message=`Invalid parameters were passed to the function:\n${this.invalidParameters.map((e=>e)).join("\n")}`}}class o{constructor(){this.uiParentElementId=null,this.mfaPreference=null,this.debugMode=!1}static getInstance(){return o.instance||(o.instance=new o),o.instance}setSettings(e){e.uiParentElementId&&(this.uiParentElementId=e.uiParentElementId),e.mfaPreference&&(this.mfaPreference=e.mfaPreference),e.debugMode&&(this.debugMode=e.debugMode)}getUIParentElementId(){return this.uiParentElementId}getMFAPreference(){return this.mfaPreference}getDebugMode(){return this.debugMode}clearSettings(){this.uiParentElementId=null,this.mfaPreference=null}}const c=o.getInstance();function d(e){const t=e?.uiParentElementId||c.getUIParentElementId();if(!t)throw new s("operationSettings parameter must have a uiParentElementId for the called function.\nYou can pass it either to the initialize function or in a per function basis.");const n=e?.mfaPreference||c.getMFAPreference();if(n&&!["passkey","paired-device","sms-otp"].includes(n))throw new s("operationSettings.mfaPreference must be one of passkey, paired-device or sms-otp.");const i=e?.debugMode||c.getDebugMode();if(void 0!==i&&"boolean"!=typeof i)throw new s("operationSettings.debugMode must be a boolean.");return{uiParentElementId:t,mfaPreference:n,debugMode:i}}function m(e){if(!e?.accessToken)throw new s("Access token is required when calling initialize()");return e?.operationSettings&&d(e.operationSettings),function(e){if(e.environment){if(!["production","staging","local"].includes(e.environment))throw new s('If provided, environment must be either "production" or "staging"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.environment.PRODUCTION" or "constants.environment.STAGING"');if(e.branch&&!["master","sandbox","qa"].includes(e.branch))throw new s('If provided, branch must be either "master", "sandbox" or "qa"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.branch.MASTER" or "constants.environment.SANDBOX" and so on')}}(e),e}const l={READY:"qonto.ready"},u={CARD_SEE:"card.see",CARD_SEE_DETAILS:"card.see-details",CARD_ORDER:"card.order",CARD_UNLOCK:"card.unlock",CARD_SHOW_PIN:"card.show.pin",CARD_SET_PIN:"card.set.pin",TRANSFERS_CREATE:"transfers.create"},p={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},h={MASTER:"master",SANDBOX:"sandbox",QA:"qa"};var f=Object.freeze({__proto__:null,ACTIONS:u,ACTIVITY_TAGS:{ATM:"atm",FALLBACK:"fallback",FEES:"fees",FINANCE:"finance",FOOD_AND_GROCERY:"food_and_grocery",GAS_STATION:"gas_station",HARDWARE_AND_EQUIPMENT:"hardware_and_equipment",HOTEL_AND_LODGING:"hotel_and_lodging",INSURANCE:"insurance",IT_AND_ELECTRONICS:"it_and_electronics",LEGAL_AND_ACCOUNTING:"legal_and_accounting",LOGISTICS:"logistics",MANUFACTURING:"manufacturing",MARKETING:"marketing",OFFICE_RENTAL:"office_rental",OFFICE_SUPPLY:"office_supply",ONLINE_SERVICE:"online_service",OTHER_EXPENSE:"other_expense",OTHER_INCOME:"other_income",OTHER_SERVICE:"other_service",PENDING:"pending",REFUND:"refund",RESTAURANT_AND_BAR:"restaurant_and_bar",SALES:"sales",SALARY:"salary",SUBSCRIPTION:"subscription",TAX:"tax",TRANSPORT:"transport",TREASURY_AND_INTERCO:"treasury_and_interco",UTILITY:"utility",VOUCHER:"voucher"},BENEFICIARY_STATUSES:{PENDING:"pending",VALIDATED:"validated",DECLINED:"declined"},BRANCHES:h,ENVIRONMENTS:p,IFRAME_EVENTS:l});const _="https://embed.qonto.com",g="https://embed-js{branch}.staging.qonto.co",y="https://embed.dev.qonto.co",I={[p.PRODUCTION]:{IFRAME_BASE_URL:_,IFRAME_URL:`${_}/connect`,THIRD_PARTY_API_URL:"https://thirdparty.qonto.com"},[p.STAGING]:{IFRAME_BASE_URL:g,IFRAME_URL:`${g}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"},[p.LOCAL]:{IFRAME_BASE_URL:y,IFRAME_URL:`${y}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"}};class E{constructor(){this.environment=p.PRODUCTION,this.branch=h.SANDBOX;const e=process.env.QONTO_EMBED_ENVIRONMENT,t=process.env.QONTO_EMBED_BRANCH;this.environment=Object.values(p).includes(e)?e:p.PRODUCTION,this.branch=Object.values(h).includes(t)?t:h.SANDBOX}static getInstance(){return E.instance||(E.instance=new E),E.instance}setEnvironment(e){this.environment=e}getEnvironment(){return this.environment}setBranch(e){this.branch=e}getBranch(){return this.branch}clear(){this.environment=p.PRODUCTION,this.branch=h.MASTER}getEnvironmentUrls(){if(this.environment===p.PRODUCTION)return I.production;{const e=I[this.environment];return Object.entries(e).reduce(((e,[t,n])=>({...e,[t]:n.replace("{branch}",`-${this.branch}`)})),{})}}}const A=E.getInstance();const w={initialize:function(e){const{accessToken:t,operationSettings:i,environment:a,branch:r}=m(e);n.setAccessToken(t),i&&c.setSettings(i),a&&(A.setEnvironment(a),r&&A.setBranch(r))},logout:function(){n.clearAccessToken()},constants:f},{initialize:L,logout:T,constants:b}=w;class R 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}`}}async function v(e,t){const n={method:"GET",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json","Accept-Language":"en"}},i=A.getEnvironmentUrls().THIRD_PARTY_API_URL,a=await fetch(`${i}/v2/cards/${e.cardId}/data_view`,n),r=await a.json();if(r.errors)throw new R(r.errors.map((e=>`${e.code}: ${e.detail}`)));return function(e,t){const n=new URL(e);return"boolean"==typeof t.allowPinReveal&&n.searchParams.set("canSeePin",t.allowPinReveal?"true":"false"),"boolean"==typeof t.allowBlocking&&n.searchParams.set("canBlock",t.allowBlocking?"true":"false"),n.toString()}(r.iframe_url,e)}var D;!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"}(D||(D={}));const P={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 O,S;function N(e,t){const n=t.filter((t=>t.requiredIfPresent?!e[t.name]&&e[t.requiredIfPresent]:void 0===e[t.name])).map((e=>e.name));if(n.length>0)throw new s(n.map((e=>`Missing required parameter: ${e}`)))}function U(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"string"!=typeof e)).map((([e])=>`${e} must be a string`))}function C(e){return Object.entries(e).filter((([,e])=>void 0!==e&&!1!==e&&!0!==e)).map((([e])=>`${e} must be a boolean`))}function k(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"number"!=typeof e)).map((([e])=>`${e} must be a number`))}!function(e){e.VIRTUAL="virtual"}(O||(O={})),function(e){e.METAL="metal",e.PLUS="plus",e.STANDARD="standard"}(S||(S={}));const M=[{name:"organizationId"},{name:"membershipId"},{name:"bankAccountId"},{name:"monthlyLimit"},{name:"cardLevel"}],$=[...M,{name:"atmDailyLimit",requiredIfPresent:"hasAtmDailyLimit"},{name:"hasAtmDailyLimit",requiredIfPresent:"hasAtmOption"},{name:"atmMonthlyLimit",requiredIfPresent:"hasAtmOption"},{name:"shipToBusiness"},{name:"cardLevel"}];function B(e){if(!e)throw new s("cardSettings parameter is required for the called function");return"virtual"===e.cardLevel?function(e){return N(e,M),function(e){const{membershipId:t,organizationId:n,bankAccountId:i,hasDailyLimit:a,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:m,categories:l,cardLevel:u}=e,p=function(e){return"virtual"!==e?['cardLevel must be "virtual"']:[]}(u),h=U({membershipId:t,organizationId:n,bankAccountId:i}),f=C({hasDailyLimit:a,hasTransactionLimit:r}),_=k({monthlyLimit:o,dailyLimit:c,transactionLimit:d}),g=z(m),y=F(l),I=[...p,...h,...f,..._,...g,...y];if(I.length>0)throw new s(I)}(e),e}(e):function(e){N(e,$),function(e){const{membershipId:t,organizationId:n,bankAccountId:i,hasDailyLimit:a,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:m,categories:l,cardLevel:u,hasNfcOption:p,hasForeignPaymentOption:h,hasOnlinePaymentOption:f,shipToBusiness:_,hasAtmOption:g,hasAtmDailyLimit:y,atmDailyLimit:I,atmMonthlyLimit:E,address:A,cardDesign:w,typeOfPrint:L}=e,T=function(e){return Object.values(S).includes(e)?[]:['cardLevel must be one of "standard", "plus", "metal"']}(u),b=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']:[]}(L),R=U({membershipId:t,organizationId:n,bankAccountId:i}),v=C({hasDailyLimit:a,hasTransactionLimit:r,hasAtmOption:g,hasNfcOption:p,hasForeignPaymentOption:h,hasOnlinePaymentOption:f,hasAtmDailyLimit:y,shipToBusiness:_}),D=k({monthlyLimit:o,dailyLimit:c,transactionLimit:d,atmDailyLimit:I,atmMonthlyLimit:E}),P=z(m),O=F(l),N=function(e){return["undefined","string"].includes(typeof e)?[]:["cardDesign must be a string"]}(w),M=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"]}(A,_),$=[...T,...R,...v,...D,...P,...O,...b,...N,...M];if($.length>0)throw new s($)}(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 F(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 q extends i{constructor(e){super(),this.name="EmbedOperationError",this.message=e}}class G{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 q(`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 q(`Could not install the authentication UI because the timeout of ${n}ms was reached.\nPlease make sure the application can reach the Internet.`))}),n),a=t=>{t.data.eventId===l.READY&&(clearTimeout(i),window.removeEventListener("message",a),e(this))};window.addEventListener("message",a),this.parentElement?.appendChild(this.iframe)}))}postMessage(e){return this.iframe&&this.iframe.contentWindow?new Promise(((t,n)=>{const i=a=>{if(a.data?.actionId===e.actionId){if("error"===a.data.status)return this.removeMessageListener(e.actionId,i),n(new q(`An error occurred when performing the action ${e.actionId}.\n${JSON.stringify(a.data.payload)}`));this.removeMessageListener(e.actionId,i),t(a.data.payload)}};this.addMessageListener(e.actionId,i),this.iframe?.contentWindow?.postMessage(e,this.targetOrigin)})):Promise.reject(new q("Attempted to perform an Embed operation without having the authentication UI initialized."))}addMessageListener(e,t){this.messageListeners.has(e)||this.messageListeners.set(e,[]);this.messageListeners.get(e).push(t),window.addEventListener("message",t)}removeMessageListener(e,t){const n=this.messageListeners.get(e);if(n){const e=n.indexOf(t);-1!==e&&(n.splice(e,1),window.removeEventListener("message",t))}}destroy(){this.messageListeners.forEach((e=>{e.forEach((e=>{window.removeEventListener("message",e)}))})),this.messageListeners.clear(),this.iframe&&this.parentElement&&(this.parentElement.removeChild(this.iframe),this.iframe=null)}}function j({accessToken:e,language:t,debugMode:n}){const i=n||!1,a=t||"en";return`${A.getEnvironmentUrls().IFRAME_URL}?debug=${i}&lang=${encodeURIComponent(a)}#access_token=${encodeURIComponent(e)}`}function x({parentElementId:e,iframeUrl:t}){return new G({parentElementId:e,iframeUrl:t}).initialize()}const Y=[];for(let e=0;e<256;++e)Y.push((e+256).toString(16).slice(1));let H;const V=new Uint8Array(16);var X={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function K(e,t,n){if(X.randomUUID&&!e)return X.randomUUID();const i=(e=e||{}).random??e.rng?.()??function(){if(!H){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");H=crypto.getRandomValues.bind(crypto)}return H(V)}();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(Y[e[t+0]]+Y[e[t+1]]+Y[e[t+2]]+Y[e[t+3]]+"-"+Y[e[t+4]]+Y[e[t+5]]+"-"+Y[e[t+6]]+Y[e[t+7]]+"-"+Y[e[t+8]]+Y[e[t+9]]+"-"+Y[e[t+10]]+Y[e[t+11]]+Y[e[t+12]]+Y[e[t+13]]+Y[e[t+14]]+Y[e[t+15]]).toLowerCase()}(i)}function Q(e){return"virtual"===e.cardLevel?function(e){const t=J(e.categories);return{actionId:u.CARD_ORDER,actionData:{idempotencyKey:K(),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=J(e.categories);return{actionId:u.CARD_ORDER,actionData:{idempotencyKey:K(),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 W(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 J(e){const t=Object.values(P);return(e||[]).filter((e=>t.includes(e)))}const Z={getCards:async function({membershipId:e,accessToken:t}){try{const n=t||r();if(e&&"string"!=typeof e)throw new s("membershipId must be a string");const i=await async function({accessToken:e,membershipId:t}){const n={method:"GET",headers:{Authorization:`Bearer ${e}`}},i=A.getEnvironmentUrls().THIRD_PARTY_API_URL,a=t?`${i}/v2/cards?holder_ids[]=${t}`:`${i}/v2/cards`,r=await fetch(a,n),s=await r.json();if(s.errors)throw new R(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.cards}({accessToken:n,membershipId:e});return i.map((e=>W(e)))}catch(e){return Promise.reject(e)}},getCard:async function({cardId:e,accessToken:t}){try{const n=t||r();if(e&&"string"!=typeof e)throw new s("cardId must be a string");const i=await async function({accessToken:e,cardId:t}){const n={method:"GET",headers:{Authorization:`Bearer ${e}`}},i=`${A.getEnvironmentUrls().THIRD_PARTY_API_URL}/v2/cards?ids[]=${t}`,a=await fetch(i,n),r=await a.json();if(r.errors)throw new R(r.errors.map((e=>`${e.code}: ${e.detail}`)));return r.cards[0]}({accessToken:n,cardId:e});return W(i)}catch(e){return Promise.reject(e)}},orderCard:async function(e){try{const t=r(),{uiParentElementId:n,debugMode:i}=d(e.operationSettings);B(e.cardSettings);const a=j({accessToken:t,debugMode:i}),s=await x({iframeUrl:a,parentElementId:n}),o=Q(e.cardSettings),c=await s.postMessage(o);return s.destroy(),W(c)}catch(e){return Promise.reject(e)}},unlockCard:async function(e){try{const t=r(),{uiParentElementId:n,debugMode:i}=d(e.operationSettings);!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId is required for the called function");const t=U({cardId:e.cardId});if(t.length>0)throw new s(t)}(e.cardSettings);const a=j({accessToken:t,debugMode:i}),o=await x({iframeUrl:a,parentElementId:n}),c=function(e){return{actionId:u.CARD_UNLOCK,actionData:{cardId:e.cardSettings.cardId}}}(e),m=await o.postMessage(c);return o.destroy(),W(m)}catch(e){return Promise.reject(e)}},displayCard:async function(e){try{const t=r(),{uiParentElementId:n}=d(e.operationSettings);!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId is required for the called function");const t=U({cardId:e.cardId});if(t.length>0)throw new s(t);let n={};void 0!==e.allowPinReveal&&(n={allowPinReveal:e.allowPinReveal}),void 0!==e.allowBlocking&&(n={...n,allowBlocking:e.allowBlocking});const i=C(n);if(i.length>0)throw new s(i)}(e.cardSettings);const i=await v(e.cardSettings,t),a=await x({iframeUrl:i,parentElementId:n});return{destroyEmbedUI:()=>{a.destroy()}}}catch(e){return Promise.reject(e)}}},ee=Z;const te="/v2/sepa/beneficiaries";async function ne({paginationSettings:e,accessToken:t}){const n={method:"GET",headers:{Authorization:`Bearer ${t}`}},i=function({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}({endpointUrl:new URL(A.getEnvironmentUrls().THIRD_PARTY_API_URL+te),paginationSettings:e}),a=await fetch(i,n),r=await a.json();if(r.errors)throw new R(r.errors.map((e=>`${e.code}: ${e.detail}`)));return{beneficiaries:r.beneficiaries,meta:r.meta}}function ie(e){return{id:e.id,name:e.name,email:e.email,activityTag:e.activity_tag,iban:e.iban,bic:e.bic,currency:e.currency,status:e.status,trusted:e.trusted,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at)}}const ae={getBeneficiaries:async function(e){const t=e?.accessToken||r(),n=await ne({accessToken:t,paginationSettings:e?.paginationSettings});var i;return{beneficiaries:n.beneficiaries.map((e=>ie(e))),meta:{totalItems:(i=n.meta).total_count,totalPages:i.total_pages,currentPage:i.current_page,itemsPerPage:i.per_page,previousPage:i.prev_page||null,nextPage:i.next_page||null}}},getBeneficiary:async function({beneficiaryId:e,accessToken:t}){const n=t||r();!function(e){if(!e)throw new s("beneficiaryId parameter is required for the called function");if(e&&"string"!=typeof e)throw new s("beneficiaryId must be a string")}(e);return ie(await async function({accessToken:e,beneficiaryId:t}){const n={method:"GET",headers:{Authorization:`Bearer ${e}`}},i=`${A.getEnvironmentUrls().THIRD_PARTY_API_URL}${te}/${t}`,a=await fetch(i,n),r=await a.json();if(r.errors)throw new R(r.errors.map((e=>`${e.code}: ${e.detail}`)));return r.beneficiary}({accessToken:n,beneficiaryId:e}))}};e.beneficiaries=ae,e.cards=ee,e.constants=b,e.initialize=L,e.logout=T}));
|
|
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}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}}const n=t.getInstance();class i extends Error{constructor(){super(),this.stack=""}toString(){return`${this.name}: ${this.message}`}}class a extends i{constructor(){super(),this.name="AuthenticationError",this.message="Authentication failed due to missing or invalid access token.\nEnsure you have called the initialize function with a valid access token."}}function r(){if(!n.hasAccessToken())throw new a;return n.getAccessToken()}class s extends i{constructor(e){super(),this.name="InvalidParametersError",this.invalidParameters=Array.isArray(e)?e:[e],this.message=`Invalid parameters were passed to the function:\n${this.invalidParameters.map((e=>e)).join("\n")}`}}class o{constructor(){this.uiParentElementId=null,this.mfaPreference=null,this.debugMode=!1}static getInstance(){return o.instance||(o.instance=new o),o.instance}setSettings(e){e.uiParentElementId&&(this.uiParentElementId=e.uiParentElementId),e.mfaPreference&&(this.mfaPreference=e.mfaPreference),e.debugMode&&(this.debugMode=e.debugMode)}getUIParentElementId(){return this.uiParentElementId}getMFAPreference(){return this.mfaPreference}getDebugMode(){return this.debugMode}clearSettings(){this.uiParentElementId=null,this.mfaPreference=null}}const c=o.getInstance();function d(e){const t=e?.uiParentElementId||c.getUIParentElementId();if(!t)throw new s("operationSettings parameter must have a uiParentElementId for the called function.\nYou can pass it either to the initialize function or in a per function basis.");const n=e?.mfaPreference||c.getMFAPreference();if(n&&!["passkey","paired-device","sms-otp"].includes(n))throw new s("operationSettings.mfaPreference must be one of passkey, paired-device or sms-otp.");const i=e?.debugMode||c.getDebugMode();if(void 0!==i&&"boolean"!=typeof i)throw new s("operationSettings.debugMode must be a boolean.");return{uiParentElementId:t,mfaPreference:n,debugMode:i}}function m(e){if(!e?.accessToken)throw new s("Access token is required when calling initialize()");return e?.operationSettings&&d(e.operationSettings),function(e){if(e.environment){if(!["production","staging","local"].includes(e.environment))throw new s('If provided, environment must be either "production" or "staging"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.environment.PRODUCTION" or "constants.environment.STAGING"');if(e.branch&&!["master","sandbox","qa"].includes(e.branch))throw new s('If provided, branch must be either "master", "sandbox" or "qa"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.branch.MASTER" or "constants.environment.SANDBOX" and so on')}}(e),e}const l={READY:"qonto.ready"},u={CARD_SEE:"card.see",CARD_SEE_DETAILS:"card.see-details",CARD_ORDER:"card.order",CARD_UNLOCK:"card.unlock",CARD_SHOW_PIN:"card.show.pin",CARD_SET_PIN:"card.set.pin",TRANSFERS_CREATE:"transfers.create"},p={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},h={MASTER:"master",SANDBOX:"sandbox",QA:"qa"};var f=Object.freeze({__proto__:null,ACTIONS:u,ACTIVITY_TAGS:{ATM:"atm",FALLBACK:"fallback",FEES:"fees",FINANCE:"finance",FOOD_AND_GROCERY:"food_and_grocery",GAS_STATION:"gas_station",HARDWARE_AND_EQUIPMENT:"hardware_and_equipment",HOTEL_AND_LODGING:"hotel_and_lodging",INSURANCE:"insurance",IT_AND_ELECTRONICS:"it_and_electronics",LEGAL_AND_ACCOUNTING:"legal_and_accounting",LOGISTICS:"logistics",MANUFACTURING:"manufacturing",MARKETING:"marketing",OFFICE_RENTAL:"office_rental",OFFICE_SUPPLY:"office_supply",ONLINE_SERVICE:"online_service",OTHER_EXPENSE:"other_expense",OTHER_INCOME:"other_income",OTHER_SERVICE:"other_service",PENDING:"pending",REFUND:"refund",RESTAURANT_AND_BAR:"restaurant_and_bar",SALES:"sales",SALARY:"salary",SUBSCRIPTION:"subscription",TAX:"tax",TRANSPORT:"transport",TREASURY_AND_INTERCO:"treasury_and_interco",UTILITY:"utility",VOUCHER:"voucher"},BENEFICIARY_STATUSES:{PENDING:"pending",VALIDATED:"validated",DECLINED:"declined"},BRANCHES:h,ENVIRONMENTS:p,IFRAME_EVENTS:l});const _="https://embed.qonto.com",g="https://embed-js{branch}.staging.qonto.co",y="https://embed.dev.qonto.co",I={[p.PRODUCTION]:{IFRAME_BASE_URL:_,IFRAME_URL:`${_}/connect`,THIRD_PARTY_API_URL:"https://thirdparty.qonto.com"},[p.STAGING]:{IFRAME_BASE_URL:g,IFRAME_URL:`${g}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"},[p.LOCAL]:{IFRAME_BASE_URL:y,IFRAME_URL:`${y}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"}};class E{constructor(){this.environment=p.PRODUCTION,this.branch=h.SANDBOX;const e=process.env.QONTO_EMBED_ENVIRONMENT,t=process.env.QONTO_EMBED_BRANCH;this.environment=Object.values(p).includes(e)?e:p.PRODUCTION,this.branch=Object.values(h).includes(t)?t:h.SANDBOX}static getInstance(){return E.instance||(E.instance=new E),E.instance}setEnvironment(e){this.environment=e}getEnvironment(){return this.environment}setBranch(e){this.branch=e}getBranch(){return this.branch}clear(){this.environment=p.PRODUCTION,this.branch=h.MASTER}getEnvironmentUrls(){if(this.environment===p.PRODUCTION)return I.production;{const e=I[this.environment];return Object.entries(e).reduce(((e,[t,n])=>({...e,[t]:n.replace("{branch}",`-${this.branch}`)})),{})}}}const A=E.getInstance();const b={initialize:function(e){const{accessToken:t,operationSettings:i,environment:a,branch:r}=m(e);n.setAccessToken(t),i&&c.setSettings(i),a&&(A.setEnvironment(a),r&&A.setBranch(r))},logout:function(){n.clearAccessToken()},constants:f},{initialize:w,logout:T,constants:L}=b;class R 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}`}}async function v(e,t){const n={method:"GET",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json","Accept-Language":"en"}},i=A.getEnvironmentUrls().THIRD_PARTY_API_URL,a=await fetch(`${i}/v2/cards/${e.cardId}/data_view`,n),r=await a.json();if(r.errors)throw new R(r.errors.map((e=>`${e.code}: ${e.detail}`)));return function(e,t){const n=new URL(e);return"boolean"==typeof t.allowPinReveal&&n.searchParams.set("canSeePin",t.allowPinReveal?"true":"false"),"boolean"==typeof t.allowBlocking&&n.searchParams.set("canBlock",t.allowBlocking?"true":"false"),n.toString()}(r.iframe_url,e)}var D;!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"}(D||(D={}));const P={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 O,S;function N(e,t){const n=t.filter((t=>t.requiredIfPresent?!e[t.name]&&e[t.requiredIfPresent]:void 0===e[t.name])).map((e=>e.name));if(n.length>0)throw new s(n.map((e=>`Missing required parameter: ${e}`)))}function U(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"string"!=typeof e)).map((([e])=>`${e} must be a string`))}function C(e){return Object.entries(e).filter((([,e])=>void 0!==e&&!1!==e&&!0!==e)).map((([e])=>`${e} must be a boolean`))}function k(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"number"!=typeof e)).map((([e])=>`${e} must be a number`))}!function(e){e.VIRTUAL="virtual"}(O||(O={})),function(e){e.METAL="metal",e.PLUS="plus",e.STANDARD="standard"}(S||(S={}));const M=[{name:"organizationId"},{name:"membershipId"},{name:"bankAccountId"},{name:"monthlyLimit"},{name:"cardLevel"}],$=[...M,{name:"atmDailyLimit",requiredIfPresent:"hasAtmDailyLimit"},{name:"hasAtmDailyLimit",requiredIfPresent:"hasAtmOption"},{name:"atmMonthlyLimit",requiredIfPresent:"hasAtmOption"},{name:"shipToBusiness"},{name:"cardLevel"}];function B(e){if(!e)throw new s("cardSettings parameter is required for the called function");return"virtual"===e.cardLevel?function(e){return N(e,M),function(e){const{membershipId:t,organizationId:n,bankAccountId:i,hasDailyLimit:a,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:m,categories:l,cardLevel:u}=e,p=function(e){return"virtual"!==e?['cardLevel must be "virtual"']:[]}(u),h=U({membershipId:t,organizationId:n,bankAccountId:i}),f=C({hasDailyLimit:a,hasTransactionLimit:r}),_=k({monthlyLimit:o,dailyLimit:c,transactionLimit:d}),g=z(m),y=j(l),I=[...p,...h,...f,..._,...g,...y];if(I.length>0)throw new s(I)}(e),e}(e):function(e){N(e,$),function(e){const{membershipId:t,organizationId:n,bankAccountId:i,hasDailyLimit:a,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:m,categories:l,cardLevel:u,hasNfcOption:p,hasForeignPaymentOption:h,hasOnlinePaymentOption:f,shipToBusiness:_,hasAtmOption:g,hasAtmDailyLimit:y,atmDailyLimit:I,atmMonthlyLimit:E,address:A,cardDesign:b,typeOfPrint:w}=e,T=function(e){return Object.values(S).includes(e)?[]:['cardLevel must be one of "standard", "plus", "metal"']}(u),L=function(e){const t=null!=e&&"string"!=typeof e,n=!["print","embossed",void 0,null].includes(e);return t||n?['typeOfPrint must be one of "print", "embossed" or null']:[]}(w),R=U({membershipId:t,organizationId:n,bankAccountId:i}),v=C({hasDailyLimit:a,hasTransactionLimit:r,hasAtmOption:g,hasNfcOption:p,hasForeignPaymentOption:h,hasOnlinePaymentOption:f,hasAtmDailyLimit:y,shipToBusiness:_}),D=k({monthlyLimit:o,dailyLimit:c,transactionLimit:d,atmDailyLimit:I,atmMonthlyLimit:E}),P=z(m),O=j(l),N=function(e){return["undefined","string"].includes(typeof e)?[]:["cardDesign must be a string"]}(b),M=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"]}(A,_),$=[...T,...R,...v,...D,...P,...O,...L,...N,...M];if($.length>0)throw new s($)}(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 j(e){const t=!Array.isArray(e)||e.some((e=>"string"!=typeof e));return void 0!==e&&t?["categories must be an array of strings"]:[]}class F extends i{constructor(e){super(),this.name="EmbedOperationError",this.message=e}}class q{constructor(e){this.options=e,this.iframe=null,this.parentElement=null,this.messageListeners=new Map,this.defaultTimeout=3e4;const t=new URL(e.iframeUrl);this.targetOrigin=`${t.protocol}//${t.host}`}async initialize(){if(this.iframe)return this;if(this.parentElement=document.getElementById(this.options.parentElementId),!this.parentElement)throw new F(`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 F(`Could not install the authentication UI because the timeout of ${n}ms was reached.\nPlease make sure the application can reach the Internet.`))}),n),a=t=>{t.data.eventId===l.READY&&(clearTimeout(i),window.removeEventListener("message",a),e(this))};window.addEventListener("message",a),this.parentElement?.appendChild(this.iframe)}))}postMessage(e){return this.iframe&&this.iframe.contentWindow?new Promise(((t,n)=>{const i=a=>{if(a.data?.actionId===e.actionId){if("error"===a.data.status)return this.removeMessageListener(e.actionId,i),n(new F(`An error occurred when performing the action ${e.actionId}.\n${JSON.stringify(a.data.payload)}`));this.removeMessageListener(e.actionId,i),t(a.data.payload)}};this.addMessageListener(e.actionId,i),this.iframe?.contentWindow?.postMessage(e,this.targetOrigin)})):Promise.reject(new F("Attempted to perform an Embed operation without having the authentication UI initialized."))}addMessageListener(e,t){this.messageListeners.has(e)||this.messageListeners.set(e,[]);this.messageListeners.get(e).push(t),window.addEventListener("message",t)}removeMessageListener(e,t){const n=this.messageListeners.get(e);if(n){const e=n.indexOf(t);-1!==e&&(n.splice(e,1),window.removeEventListener("message",t))}}destroy(){this.messageListeners.forEach((e=>{e.forEach((e=>{window.removeEventListener("message",e)}))})),this.messageListeners.clear(),this.iframe&&this.parentElement&&(this.parentElement.removeChild(this.iframe),this.iframe=null)}}function G({accessToken:e,language:t,debugMode:n}){const i=n||!1,a=t||"en";return`${A.getEnvironmentUrls().IFRAME_URL}?debug=${i}&lang=${encodeURIComponent(a)}#access_token=${encodeURIComponent(e)}`}function x({parentElementId:e,iframeUrl:t}){return new q({parentElementId:e,iframeUrl:t}).initialize()}const Y=[];for(let e=0;e<256;++e)Y.push((e+256).toString(16).slice(1));let H;const V=new Uint8Array(16);var X={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function K(e,t,n){if(X.randomUUID&&!e)return X.randomUUID();const i=(e=e||{}).random??e.rng?.()??function(){if(!H){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");H=crypto.getRandomValues.bind(crypto)}return H(V)}();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(Y[e[t+0]]+Y[e[t+1]]+Y[e[t+2]]+Y[e[t+3]]+"-"+Y[e[t+4]]+Y[e[t+5]]+"-"+Y[e[t+6]]+Y[e[t+7]]+"-"+Y[e[t+8]]+Y[e[t+9]]+"-"+Y[e[t+10]]+Y[e[t+11]]+Y[e[t+12]]+Y[e[t+13]]+Y[e[t+14]]+Y[e[t+15]]).toLowerCase()}(i)}function Q(e){return"virtual"===e.cardLevel?function(e){const t=J(e.categories);return{actionId:u.CARD_ORDER,actionData:{idempotencyKey:K(),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=J(e.categories);return{actionId:u.CARD_ORDER,actionData:{idempotencyKey:K(),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 W(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 J(e){const t=Object.values(P);return(e||[]).filter((e=>t.includes(e)))}const Z={getCards:async function({membershipId:e,accessToken:t}){try{const n=t||r();if(e&&"string"!=typeof e)throw new s("membershipId must be a string");const i=await async function({accessToken:e,membershipId:t}){const n={method:"GET",headers:{Authorization:`Bearer ${e}`}},i=A.getEnvironmentUrls().THIRD_PARTY_API_URL,a=t?`${i}/v2/cards?holder_ids[]=${t}`:`${i}/v2/cards`,r=await fetch(a,n),s=await r.json();if(s.errors)throw new R(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.cards}({accessToken:n,membershipId:e});return i.map((e=>W(e)))}catch(e){return Promise.reject(e)}},getCard:async function({cardId:e,accessToken:t}){try{const n=t||r();if(e&&"string"!=typeof e)throw new s("cardId must be a string");const i=await async function({accessToken:e,cardId:t}){const n={method:"GET",headers:{Authorization:`Bearer ${e}`}},i=`${A.getEnvironmentUrls().THIRD_PARTY_API_URL}/v2/cards?ids[]=${t}`,a=await fetch(i,n),r=await a.json();if(r.errors)throw new R(r.errors.map((e=>`${e.code}: ${e.detail}`)));return r.cards[0]}({accessToken:n,cardId:e});return W(i)}catch(e){return Promise.reject(e)}},orderCard:async function(e){try{const t=r(),{uiParentElementId:n,debugMode:i}=d(e.operationSettings);B(e.cardSettings);const a=G({accessToken:t,debugMode:i}),s=await x({iframeUrl:a,parentElementId:n}),o=Q(e.cardSettings),c=await s.postMessage(o);return s.destroy(),W(c)}catch(e){return Promise.reject(e)}},unlockCard:async function(e){try{const t=r(),{uiParentElementId:n,debugMode:i}=d(e.operationSettings);!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId is required for the called function");const t=U({cardId:e.cardId});if(t.length>0)throw new s(t)}(e.cardSettings);const a=G({accessToken:t,debugMode:i}),o=await x({iframeUrl:a,parentElementId:n}),c=function(e){return{actionId:u.CARD_UNLOCK,actionData:{cardId:e.cardSettings.cardId}}}(e),m=await o.postMessage(c);return o.destroy(),W(m)}catch(e){return Promise.reject(e)}},displayCard:async function(e){try{const t=r(),{uiParentElementId:n}=d(e.operationSettings);!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId is required for the called function");const t=U({cardId:e.cardId});if(t.length>0)throw new s(t);let n={};void 0!==e.allowPinReveal&&(n={allowPinReveal:e.allowPinReveal}),void 0!==e.allowBlocking&&(n={...n,allowBlocking:e.allowBlocking});const i=C(n);if(i.length>0)throw new s(i)}(e.cardSettings);const i=await v(e.cardSettings,t),a=await x({iframeUrl:i,parentElementId:n});return{destroyEmbedUI:()=>{a.destroy()}}}catch(e){return Promise.reject(e)}}},ee=Z;function te(e){return{id:e.id,name:e.name,email:e.email,activityTag:e.activity_tag,iban:e.iban,bic:e.bic,currency:e.currency,status:e.status,trusted:e.trusted,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at)}}function ne(e){return{name:e.name,...e.email&&{email:e.email},...e.activityTag&&{activity_tag:e.activityTag},iban:e.iban,...e.bic&&{bic:e.bic}}}const ie="/v2/sepa/beneficiaries";async function ae({paginationSettings:e,accessToken:t}){const n={method:"GET",headers:{Authorization:`Bearer ${t}`}},i=function({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}({endpointUrl:new URL(A.getEnvironmentUrls().THIRD_PARTY_API_URL+ie),paginationSettings:e}),a=await fetch(i,n),r=await a.json();if(r.errors)throw new R(r.errors.map((e=>`${e.code}: ${e.detail}`)));return{beneficiaries:r.beneficiaries,meta:r.meta}}const re=[{name:"name"},{name:"iban"}];const se={getBeneficiaries:async function(e){const t=e?.accessToken||r(),n=await ae({accessToken:t,paginationSettings:e?.paginationSettings});var i;return{beneficiaries:n.beneficiaries.map((e=>te(e))),meta:{totalItems:(i=n.meta).total_count,totalPages:i.total_pages,currentPage:i.current_page,itemsPerPage:i.per_page,previousPage:i.prev_page||null,nextPage:i.next_page||null}}},getBeneficiary:async function({beneficiaryId:e,accessToken:t}){const n=t||r();!function(e){if(!e)throw new s("beneficiaryId parameter is required for the called function");if(e&&"string"!=typeof e)throw new s("beneficiaryId must be a string")}(e);return te(await async function({accessToken:e,beneficiaryId:t}){const n={method:"GET",headers:{Authorization:`Bearer ${e}`}},i=`${A.getEnvironmentUrls().THIRD_PARTY_API_URL}${ie}/${t}`,a=await fetch(i,n),r=await a.json();if(r.errors)throw new R(r.errors.map((e=>`${e.code}: ${e.detail}`)));return r.beneficiary}({accessToken:n,beneficiaryId:e}))},addBeneficiary:async function({beneficiary:e,accessToken:t}){const n=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");N(e,re);const t=U({name:e.name,iban:e.iban,email:e.email,activityTag:e.activityTag,bic:e.bic});if(t.length>0)throw new s(t)}(e);return te(await async function({accessToken:e,beneficiary:t}){const n={method:"POST",headers:{Authorization:`Bearer ${e}`,"X-Qonto-Idempotency-Key":K(),"Content-Type":"application/json"},body:JSON.stringify({beneficiary:ne(t)})},i=`${A.getEnvironmentUrls().THIRD_PARTY_API_URL}${ie}`,a=await fetch(i,n),r=await a.json();if(r.errors)throw new R(r.errors.map((e=>`${e.code}: ${e.detail}`)));return r.beneficiary}({accessToken:n,beneficiary:e}))}};e.beneficiaries=se,e.cards=ee,e.constants=L,e.initialize=w,e.logout=T}));
|
package/dist/mocks/handlers.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import type { BeneficiaryDataObject } from '@beneficiaries/beneficiaries.types';
|
|
2
2
|
export declare const INVALID_ACCESS_TOKEN = "INVALID_ACCESS_TOKEN";
|
|
3
3
|
export declare const singleBeneficiary: BeneficiaryDataObject;
|
|
4
|
+
export declare const newBeneficiaryDbFields: {
|
|
5
|
+
id: string;
|
|
6
|
+
status: string;
|
|
7
|
+
currency: string;
|
|
8
|
+
created_at: string;
|
|
9
|
+
updated_at: string;
|
|
10
|
+
trusted: boolean;
|
|
11
|
+
};
|
|
4
12
|
export declare const mockedBeneficiariesList: BeneficiaryDataObject[];
|
|
5
13
|
export declare const mswHandlers: import("msw").HttpHandler[];
|
|
6
14
|
//# sourceMappingURL=handlers.d.ts.map
|
|
@@ -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;AAEhF,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAK3D,eAAO,MAAM,iBAAiB,EAAE,qBAY/B,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;AAEhF,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,WAAW,6BAiLvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EmbedApiError as e}from"../errors/EmbedApiError.js";import{environmentManager as
|
|
1
|
+
import{EmbedApiError as e}from"../errors/EmbedApiError.js";import{environmentManager as r}from"../common/environment/environment-manager.js";import{addPaginationParamsToUrl as n}from"../common/api-pagination/api-pagination.js";import{serializeToNewBeneficiaryDataObject as i}from"./beneficiaries.serializer.js";import o from"../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm-browser/v4.js";const t="/v2/sepa/beneficiaries";async function a({paginationSettings:i,accessToken:o}){const a={method:"GET",headers:{Authorization:`Bearer ${o}`}},s=new URL(r.getEnvironmentUrls().THIRD_PARTY_API_URL+t),c=n({endpointUrl:s,paginationSettings:i}),m=await fetch(c,a),d=await m.json();if(d.errors)throw new e(d.errors.map((e=>`${e.code}: ${e.detail}`)));return{beneficiaries:d.beneficiaries,meta:d.meta}}async function s({accessToken:n,beneficiaryId:i}){const o={method:"GET",headers:{Authorization:`Bearer ${n}`}},a=`${r.getEnvironmentUrls().THIRD_PARTY_API_URL}${t}/${i}`,s=await fetch(a,o),c=await s.json();if(c.errors)throw new e(c.errors.map((e=>`${e.code}: ${e.detail}`)));return c.beneficiary}async function c({accessToken:n,beneficiary:a}){const s={method:"POST",headers:{Authorization:`Bearer ${n}`,"X-Qonto-Idempotency-Key":o(),"Content-Type":"application/json"},body:JSON.stringify({beneficiary:i(a)})},c=`${r.getEnvironmentUrls().THIRD_PARTY_API_URL}${t}`,m=await fetch(c,s),d=await m.json();if(d.errors)throw new e(d.errors.map((e=>`${e.code}: ${e.detail}`)));return d.beneficiary}export{c as addBeneficiary,a as getBeneficiaries,s as getBeneficiary};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../common/auth/auth.js";import{validatePresenceOfAuthToken as i}from"../common/auth/auth.validate.js";import{
|
|
1
|
+
import"../common/auth/auth.js";import{validatePresenceOfAuthToken as i}from"../common/auth/auth.validate.js";import{addBeneficiary as e,getBeneficiary as a,getBeneficiaries as n}from"./beneficiaries.api.js";import{serializeBeneficiary as t}from"./beneficiaries.serializer.js";import{validateAddBeneficiaryParams as c,validateGetBeneficiaryParams as s}from"./beneficiaries.validate.js";import{serializePaginationResponse as o}from"../common/api-pagination/api-pagination.js";async function r(e){const a=e?.accessToken||i(),c=await n({accessToken:a,paginationSettings:e?.paginationSettings});return{beneficiaries:c.beneficiaries.map((i=>t(i))),meta:o(c.meta)}}async function f({beneficiaryId:e,accessToken:n}){const c=n||i();s(e);const o=await a({accessToken:c,beneficiaryId:e});return t(o)}async function m({beneficiary:a,accessToken:n}){const s=n||i();c(a);const o=await e({accessToken:s,beneficiary:a});return t(o)}export{m as addBeneficiary,r as getBeneficiaries,f as getBeneficiary};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{addBeneficiary as e,getBeneficiary as i,getBeneficiaries as r}from"./beneficiaries.js";const a={getBeneficiaries:r,getBeneficiary:i,addBeneficiary:e};export{a as beneficiaries};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(t){return{id:t.id,name:t.name,email:t.email,activityTag:t.activity_tag,iban:t.iban,bic:t.bic,currency:t.currency,status:t.status,trusted:t.trusted,createdAt:new Date(t.created_at),updatedAt:new Date(t.updated_at)}}export{t as serializeBeneficiary};
|
|
1
|
+
function t(t){return{id:t.id,name:t.name,email:t.email,activityTag:t.activity_tag,iban:t.iban,bic:t.bic,currency:t.currency,status:t.status,trusted:t.trusted,createdAt:new Date(t.created_at),updatedAt:new Date(t.updated_at)}}function a(t){return{name:t.name,...t.email&&{email:t.email},...t.activityTag&&{activity_tag:t.activityTag},iban:t.iban,...t.bic&&{bic:t.bic}}}export{t as serializeBeneficiary,a as serializeToNewBeneficiaryDataObject};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{InvalidParametersError as
|
|
1
|
+
import{InvalidParametersError as e}from"../errors/InvalidParametersError.js";import{validatePresenceOfRequiredParams as i,validateExpectedStringValues as r}from"../validation/input-param-validation.js";const n=[{name:"name"},{name:"iban"}];function t(i){if(!i)throw new e("beneficiaryId parameter is required for the called function");if(i&&"string"!=typeof i)throw new e("beneficiaryId must be a string");return i}function a(t){if(!t)throw new e("beneficiary parameter is required for the called function");if("object"!=typeof t)throw new e("beneficiary must be an object");i(t,n);const a=r({name:t.name,iban:t.iban,email:t.email,activityTag:t.activityTag,bic:t.bic});if(a.length>0)throw new e(a);return t}export{a as validateAddBeneficiaryParams,t as validateGetBeneficiaryParams};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings, Beneficiary, PaginationState } from './types.public-api';
|
|
2
|
-
export type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings, Beneficiary, PaginationState, };
|
|
1
|
+
import type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings, Beneficiary, GetBeneficiariesResponse, PaginationState } from './types.public-api';
|
|
2
|
+
export type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings, Beneficiary, GetBeneficiariesResponse, PaginationState, };
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,WAAW,EACX,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAM5B,YAAY,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,WAAW,EACX,eAAe,GAChB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,WAAW,EACX,wBAAwB,EACxB,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAM5B,YAAY,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,WAAW,EACX,wBAAwB,EACxB,eAAe,GAChB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings } from '@cards/cards.types';
|
|
2
|
-
import type { Beneficiary } from '@beneficiaries/beneficiaries.types';
|
|
2
|
+
import type { Beneficiary, GetBeneficiariesResponse } from '@beneficiaries/beneficiaries.types';
|
|
3
3
|
import type { PaginationState } from '@common/api-pagination/api-pagination.types';
|
|
4
|
-
export type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings, Beneficiary, PaginationState, };
|
|
4
|
+
export type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings, Beneficiary, GetBeneficiariesResponse, PaginationState, };
|
|
5
5
|
//# sourceMappingURL=types.public-api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.public-api.d.ts","sourceRoot":"","sources":["../../src/types/types.public-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.public-api.d.ts","sourceRoot":"","sources":["../../src/types/types.public-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EACV,WAAW,EACX,wBAAwB,EACzB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAEnF,YAAY,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,WAAW,EACX,wBAAwB,EACxB,eAAe,GAChB,CAAC"}
|