@qonto/embed-sdk 0.5.0 → 0.6.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 +18 -0
- package/dist/beneficiaries/beneficiaries.api.d.ts.map +1 -0
- package/dist/beneficiaries/beneficiaries.d.ts +37 -0
- package/dist/beneficiaries/beneficiaries.d.ts.map +1 -0
- package/dist/beneficiaries/beneficiaries.public-api.d.ts +7 -0
- package/dist/beneficiaries/beneficiaries.public-api.d.ts.map +1 -0
- package/dist/beneficiaries/beneficiaries.serializer.d.ts +3 -0
- package/dist/beneficiaries/beneficiaries.serializer.d.ts.map +1 -0
- package/dist/beneficiaries/beneficiaries.test.d.ts +2 -0
- package/dist/beneficiaries/beneficiaries.test.d.ts.map +1 -0
- package/dist/beneficiaries/beneficiaries.types.d.ts +28 -0
- package/dist/beneficiaries/beneficiaries.types.d.ts.map +1 -0
- package/dist/beneficiaries/beneficiaries.validate.d.ts +2 -0
- package/dist/beneficiaries/beneficiaries.validate.d.ts.map +1 -0
- package/dist/beneficiaries/index.d.ts +19 -0
- package/dist/beneficiaries/index.d.ts.map +1 -0
- package/dist/cards/cards.d.ts +4 -2
- package/dist/cards/cards.d.ts.map +1 -1
- package/dist/common/api-pagination/api-pagination.d.ts +9 -0
- package/dist/common/api-pagination/api-pagination.d.ts.map +1 -0
- package/dist/common/api-pagination/api-pagination.test.d.ts +2 -0
- package/dist/common/api-pagination/api-pagination.test.d.ts.map +1 -0
- package/dist/common/api-pagination/api-pagination.types.d.ts +21 -0
- package/dist/common/api-pagination/api-pagination.types.d.ts.map +1 -0
- package/dist/common/constants.d.ts +38 -0
- package/dist/common/constants.d.ts.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/mocks/handlers.d.ts +3 -0
- package/dist/mocks/handlers.d.ts.map +1 -1
- package/dist/src/beneficiaries/beneficiaries.api.js +1 -0
- package/dist/src/beneficiaries/beneficiaries.js +1 -0
- package/dist/src/beneficiaries/beneficiaries.public-api.js +1 -0
- package/dist/src/beneficiaries/beneficiaries.serializer.js +1 -0
- package/dist/src/beneficiaries/beneficiaries.validate.js +1 -0
- package/dist/src/beneficiaries/index.js +1 -0
- package/dist/src/common/api-pagination/api-pagination.js +1 -0
- package/dist/src/common/constants.js +1 -1
- package/dist/src/index.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 +3 -1
- package/dist/types/types.public-api.d.ts.map +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { BeneficiaryDataObject } from './beneficiaries.types';
|
|
2
|
+
import type { PaginationResponseDataObject, PaginationSettings } from '@common/api-pagination/api-pagination.types';
|
|
3
|
+
interface GetBeneficiariesParams {
|
|
4
|
+
accessToken: string;
|
|
5
|
+
paginationSettings?: PaginationSettings;
|
|
6
|
+
}
|
|
7
|
+
interface GetBeneficiaryParams {
|
|
8
|
+
accessToken: string;
|
|
9
|
+
beneficiaryId: string;
|
|
10
|
+
}
|
|
11
|
+
interface GetBeneficiariesResponse {
|
|
12
|
+
beneficiaries: BeneficiaryDataObject[];
|
|
13
|
+
meta: PaginationResponseDataObject;
|
|
14
|
+
}
|
|
15
|
+
export declare function getBeneficiaries({ paginationSettings, accessToken, }: GetBeneficiariesParams): Promise<GetBeneficiariesResponse>;
|
|
16
|
+
export declare function getBeneficiary({ accessToken, beneficiaryId, }: GetBeneficiaryParams): Promise<BeneficiaryDataObject>;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=beneficiaries.api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"beneficiaries.api.d.ts","sourceRoot":"","sources":["../../src/beneficiaries/beneficiaries.api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAInE,OAAO,KAAK,EACV,4BAA4B,EAC5B,kBAAkB,EACnB,MAAM,6CAA6C,CAAC;AAErD,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;AASD,UAAU,wBAAwB;IAChC,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,wBAAwB,CAAC,CA4B5D;AAED,wBAAsB,cAAc,CAAC,EACnC,WAAW,EACX,aAAa,GACd,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAkBvD"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Beneficiary } from './beneficiaries.types';
|
|
2
|
+
import type { PaginationSettings, PaginationState } from '@common/api-pagination/api-pagination.types';
|
|
3
|
+
interface GetBeneficiariesResponse {
|
|
4
|
+
beneficiaries: Beneficiary[];
|
|
5
|
+
meta: PaginationState;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Fetches the list of beneficiaries for the current user.
|
|
9
|
+
* @param getBeneficiariesParams - An optional object with the accessToken
|
|
10
|
+
* property. If not passed, the function only works if initialize has been
|
|
11
|
+
* previously called. Also, this function allows managing pagination by passing
|
|
12
|
+
* the paginationSettings property, which accepts an object with the page and
|
|
13
|
+
* itemsPerPage properties.
|
|
14
|
+
* @returns A promise that resolves to an array of beneficiaries and a `meta`
|
|
15
|
+
* object containing pagination state.
|
|
16
|
+
* @throws \{AuthenticationError\} If the access token is invalid or missing.
|
|
17
|
+
* Ensure initialize has been called before using this function if you are not
|
|
18
|
+
* passing the access token.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getBeneficiaries(getBeneficiariesParams?: {
|
|
21
|
+
accessToken?: string;
|
|
22
|
+
paginationSettings?: PaginationSettings;
|
|
23
|
+
}): Promise<GetBeneficiariesResponse>;
|
|
24
|
+
/**
|
|
25
|
+
* Fetches a single beneficiary of the current user by ID.
|
|
26
|
+
* @param Object - An object with the beneficiaryId and the accessToken properties.
|
|
27
|
+
* @returns A promise that resolves to a beneficiary.
|
|
28
|
+
* @throws \{AuthenticationError\} If the access token is invalid or missing.
|
|
29
|
+
* Ensure initialize has been called before using this function if you are not
|
|
30
|
+
* passing the access token.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getBeneficiary({ beneficiaryId, accessToken, }: {
|
|
33
|
+
beneficiaryId: string;
|
|
34
|
+
accessToken?: string;
|
|
35
|
+
}): Promise<Beneficiary>;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=beneficiaries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"beneficiaries.d.ts","sourceRoot":"","sources":["../../src/beneficiaries/beneficiaries.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAQzD,OAAO,KAAK,EACV,kBAAkB,EAClB,eAAe,EAChB,MAAM,6CAA6C,CAAC;AAErD,UAAU,wBAAwB;IAChC,aAAa,EAAE,WAAW,EAAE,CAAC;IAC7B,IAAI,EAAE,eAAe,CAAC;CACvB;AAED;;;;;;;;;;;;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;;;;;;;GAOG;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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { getBeneficiary, getBeneficiaries } from './beneficiaries';
|
|
2
|
+
declare const beneficiaries: {
|
|
3
|
+
getBeneficiaries: typeof getBeneficiaries;
|
|
4
|
+
getBeneficiary: typeof getBeneficiary;
|
|
5
|
+
};
|
|
6
|
+
export { beneficiaries };
|
|
7
|
+
//# sourceMappingURL=beneficiaries.public-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"beneficiaries.public-api.d.ts","sourceRoot":"","sources":["../../src/beneficiaries/beneficiaries.public-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnE,QAAA,MAAM,aAAa;;;CAGlB,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +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,EAC3B,MAAM,uBAAuB,CAAC;AAE/B,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,qBAAqB,GACjC,WAAW,CAcb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"beneficiaries.test.d.ts","sourceRoot":"","sources":["../../src/beneficiaries/beneficiaries.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type ACTIVITY_TAGS, BENEFICIARY_STATUSES } from '@common/constants';
|
|
2
|
+
export interface Beneficiary {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
email: string;
|
|
6
|
+
activityTag: (typeof ACTIVITY_TAGS)[keyof typeof ACTIVITY_TAGS];
|
|
7
|
+
iban: string;
|
|
8
|
+
bic: string;
|
|
9
|
+
currency: 'EUR';
|
|
10
|
+
status: (typeof BENEFICIARY_STATUSES)[keyof typeof BENEFICIARY_STATUSES];
|
|
11
|
+
trusted: boolean;
|
|
12
|
+
createdAt: Date;
|
|
13
|
+
updatedAt: Date;
|
|
14
|
+
}
|
|
15
|
+
export interface BeneficiaryDataObject {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
email: string;
|
|
19
|
+
activity_tag: (typeof ACTIVITY_TAGS)[keyof typeof ACTIVITY_TAGS];
|
|
20
|
+
iban: string;
|
|
21
|
+
bic: string;
|
|
22
|
+
currency: 'EUR';
|
|
23
|
+
status: (typeof BENEFICIARY_STATUSES)[keyof typeof BENEFICIARY_STATUSES];
|
|
24
|
+
trusted: boolean;
|
|
25
|
+
created_at: string;
|
|
26
|
+
updated_at: string;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=beneficiaries.types.d.ts.map
|
|
@@ -0,0 +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;AAE7E,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,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"beneficiaries.validate.d.ts","sourceRoot":"","sources":["../../src/beneficiaries/beneficiaries.validate.ts"],"names":[],"mappings":"AAEA,wBAAgB,4BAA4B,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAU1E"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The beneficiaries namespace contains all the functions related to beneficiary
|
|
3
|
+
* operations. It can be accessed like this:
|
|
4
|
+
* ```ts
|
|
5
|
+
* import { beneficiaries } from '@qonto/embed-sdk/beneficiaries';
|
|
6
|
+
* ```
|
|
7
|
+
*
|
|
8
|
+
* Then, the beneficiaries object contains the functions to perform beneficiary
|
|
9
|
+
* operations:
|
|
10
|
+
* ```ts
|
|
11
|
+
* await beneficiaries.getBeneficiaries();
|
|
12
|
+
* await beneficiaries.getBeneficiary(/* params here *\/);
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare const beneficiaries: {
|
|
16
|
+
getBeneficiaries: typeof import("./beneficiaries").getBeneficiaries;
|
|
17
|
+
getBeneficiary: typeof import("./beneficiaries").getBeneficiary;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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/cards/cards.d.ts
CHANGED
|
@@ -21,7 +21,8 @@ export interface CardParams<T> {
|
|
|
21
21
|
* @param Object - An object with the membershipId and the accessToken properties.
|
|
22
22
|
* @returns A promise that resolves to an array of cards.
|
|
23
23
|
* @throws \{AuthenticationError\} If the access token is invalid or missing.
|
|
24
|
-
* Ensure initialize has been called before using this function
|
|
24
|
+
* Ensure initialize has been called before using this function if you are not
|
|
25
|
+
* passing the access token.
|
|
25
26
|
*/
|
|
26
27
|
export declare function getCards({ membershipId, accessToken, }: {
|
|
27
28
|
membershipId?: string;
|
|
@@ -32,7 +33,8 @@ export declare function getCards({ membershipId, accessToken, }: {
|
|
|
32
33
|
* @param Object - An object with the cardId and the accessToken properties.
|
|
33
34
|
* @returns A promise that resolves to a card.
|
|
34
35
|
* @throws \{AuthenticationError\} If the access token is invalid or missing.
|
|
35
|
-
* Ensure initialize has been called before using this function
|
|
36
|
+
* Ensure initialize has been called before using this function if you are not
|
|
37
|
+
* passing the access token.
|
|
36
38
|
*/
|
|
37
39
|
export declare function getCard({ cardId, accessToken, }: {
|
|
38
40
|
cardId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cards.d.ts","sourceRoot":"","sources":["../../src/cards/cards.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,IAAI,EAET,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACxB,MAAM,eAAe,CAAC;AAYvB,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,2CAA2C,CAAC;AAGnD;;;;;;GAMG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B;;;OAGG;IACH,YAAY,EAAE,CAAC,CAAC;IAChB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED
|
|
1
|
+
{"version":3,"file":"cards.d.ts","sourceRoot":"","sources":["../../src/cards/cards.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,IAAI,EAET,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACxB,MAAM,eAAe,CAAC;AAYvB,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,2CAA2C,CAAC;AAGnD;;;;;;GAMG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B;;;OAGG;IACH,YAAY,EAAE,CAAC,CAAC;IAChB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED;;;;;;;;GAQG;AACH,wBAAsB,QAAQ,CAAC,EAC7B,YAAY,EACZ,WAAW,GACZ,EAAE;IACD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAWlB;AAED;;;;;;;GAOG;AACH,wBAAsB,OAAO,CAAC,EAC5B,MAAM,EACN,WAAW,GACZ,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,IAAI,CAAC,CAYhB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmFG;AACH,wBAAsB,SAAS,CAC7B,UAAU,EAAE,UAAU,CAAC,iBAAiB,CAAC,GACxC,OAAO,CAAC,IAAI,CAAC,CA2Bf;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,UAAU,CAC9B,UAAU,EAAE,UAAU,CAAC,kBAAkB,CAAC,GACzC,OAAO,CAAC,IAAI,CAAC,CA2Bf;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,WAAW,CAC/B,UAAU,EAAE,UAAU,CAAC,mBAAmB,CAAC,GAC1C,OAAO,CAAC,uBAAuB,CAAC,CAsBlC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PaginationResponseDataObject, PaginationSettings, PaginationState } from '@common/api-pagination/api-pagination.types';
|
|
2
|
+
interface AddPaginationParamsToUrlArgs {
|
|
3
|
+
endpointUrl: URL;
|
|
4
|
+
paginationSettings?: PaginationSettings;
|
|
5
|
+
}
|
|
6
|
+
export declare function addPaginationParamsToUrl({ endpointUrl, paginationSettings, }: AddPaginationParamsToUrlArgs): URL;
|
|
7
|
+
export declare function serializePaginationResponse(paginationResponse: PaginationResponseDataObject): PaginationState;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=api-pagination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-pagination.d.ts","sourceRoot":"","sources":["../../../src/common/api-pagination/api-pagination.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAC5B,kBAAkB,EAClB,eAAe,EAChB,MAAM,6CAA6C,CAAC;AAErD,UAAU,4BAA4B;IACpC,WAAW,EAAE,GAAG,CAAC;IACjB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC;AAED,wBAAgB,wBAAwB,CAAC,EACvC,WAAW,EACX,kBAAkB,GACnB,EAAE,4BAA4B,GAAG,GAAG,CAYpC;AAED,wBAAgB,2BAA2B,CACzC,kBAAkB,EAAE,4BAA4B,GAC/C,eAAe,CASjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-pagination.test.d.ts","sourceRoot":"","sources":["../../../src/common/api-pagination/api-pagination.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface PaginationSettings {
|
|
2
|
+
page?: number;
|
|
3
|
+
itemsPerPage?: number;
|
|
4
|
+
}
|
|
5
|
+
export interface PaginationResponseDataObject {
|
|
6
|
+
total_pages: number;
|
|
7
|
+
total_count: number;
|
|
8
|
+
current_page: number;
|
|
9
|
+
per_page: number;
|
|
10
|
+
next_page: number | null;
|
|
11
|
+
prev_page: number | null;
|
|
12
|
+
}
|
|
13
|
+
export interface PaginationState {
|
|
14
|
+
totalItems: number;
|
|
15
|
+
totalPages: number;
|
|
16
|
+
currentPage: number;
|
|
17
|
+
itemsPerPage: number;
|
|
18
|
+
previousPage: number | null;
|
|
19
|
+
nextPage: number | null;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=api-pagination.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-pagination.types.d.ts","sourceRoot":"","sources":["../../../src/common/api-pagination/api-pagination.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,4BAA4B;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB"}
|
|
@@ -35,4 +35,42 @@ export declare const BRANCHES: {
|
|
|
35
35
|
SANDBOX: string;
|
|
36
36
|
QA: string;
|
|
37
37
|
};
|
|
38
|
+
export declare const ACTIVITY_TAGS: {
|
|
39
|
+
ATM: string;
|
|
40
|
+
FALLBACK: string;
|
|
41
|
+
FEES: string;
|
|
42
|
+
FINANCE: string;
|
|
43
|
+
FOOD_AND_GROCERY: string;
|
|
44
|
+
GAS_STATION: string;
|
|
45
|
+
HARDWARE_AND_EQUIPMENT: string;
|
|
46
|
+
HOTEL_AND_LODGING: string;
|
|
47
|
+
INSURANCE: string;
|
|
48
|
+
IT_AND_ELECTRONICS: string;
|
|
49
|
+
LEGAL_AND_ACCOUNTING: string;
|
|
50
|
+
LOGISTICS: string;
|
|
51
|
+
MANUFACTURING: string;
|
|
52
|
+
MARKETING: string;
|
|
53
|
+
OFFICE_RENTAL: string;
|
|
54
|
+
OFFICE_SUPPLY: string;
|
|
55
|
+
ONLINE_SERVICE: string;
|
|
56
|
+
OTHER_EXPENSE: string;
|
|
57
|
+
OTHER_INCOME: string;
|
|
58
|
+
OTHER_SERVICE: string;
|
|
59
|
+
PENDING: string;
|
|
60
|
+
REFUND: string;
|
|
61
|
+
RESTAURANT_AND_BAR: string;
|
|
62
|
+
SALES: string;
|
|
63
|
+
SALARY: string;
|
|
64
|
+
SUBSCRIPTION: string;
|
|
65
|
+
TAX: string;
|
|
66
|
+
TRANSPORT: string;
|
|
67
|
+
TREASURY_AND_INTERCO: string;
|
|
68
|
+
UTILITY: string;
|
|
69
|
+
VOUCHER: string;
|
|
70
|
+
};
|
|
71
|
+
export declare const BENEFICIARY_STATUSES: {
|
|
72
|
+
PENDING: string;
|
|
73
|
+
VALIDATED: string;
|
|
74
|
+
DECLINED: string;
|
|
75
|
+
};
|
|
38
76
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,aAAa;IACxB;;OAEG;;CAEJ,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO;;;;;;;;CAQnB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY;;;;CAIxB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;CAIpB,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,aAAa;IACxB;;OAEG;;CAEJ,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO;;;;;;;;CAQnB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY;;;;CAIxB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;CAIpB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCzB,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;;CAIhC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { initialize, logout, constants } from '@common';
|
|
2
2
|
import { cards } from '@cards';
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
export
|
|
3
|
+
import { beneficiaries } from '@beneficiaries';
|
|
4
|
+
import type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings, Beneficiary } from '@types';
|
|
5
|
+
export { initialize, logout, cards, beneficiaries, constants };
|
|
6
|
+
export type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings, Beneficiary, };
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,WAAW,EACZ,MAAM,QAAQ,CAAC;AAEhB,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,CAAC;AAC/D,YAAY,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,WAAW,GACZ,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"},h={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},p={MASTER:"master",SANDBOX:"sandbox",QA:"qa"};var f=Object.freeze({__proto__:null,ACTIONS:u,BRANCHES:p,ENVIRONMENTS:h,IFRAME_EVENTS:l});const _="https://embed.qonto.com",y="https://embed-js{branch}.staging.qonto.co",g="https://embed.dev.qonto.co",I={[h.PRODUCTION]:{IFRAME_BASE_URL:_,IFRAME_URL:`${_}/connect`,THIRD_PARTY_API_URL:"https://thirdparty.qonto.com"},[h.STAGING]:{IFRAME_BASE_URL:y,IFRAME_URL:`${y}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"},[h.LOCAL]:{IFRAME_BASE_URL:g,IFRAME_URL:`${g}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"}};class E{constructor(){this.environment=h.PRODUCTION,this.branch=p.SANDBOX;const e=process.env.QONTO_EMBED_ENVIRONMENT,t=process.env.QONTO_EMBED_BRANCH;this.environment=Object.values(h).includes(e)?e:h.PRODUCTION,this.branch=Object.values(p).includes(t)?t:p.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=h.PRODUCTION,this.branch=p.MASTER}getEnvironmentUrls(){if(this.environment===h.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 w=E.getInstance();const A={initialize:function(e){const{accessToken:t,operationSettings:i,environment:a,branch:r}=m(e);n.setAccessToken(t),i&&c.setSettings(i),a&&(w.setEnvironment(a),r&&w.setBranch(r))},logout:function(){n.clearAccessToken()},constants:f},{initialize:L,logout:b,constants:v}=A;class D 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 T(e,t){const n={method:"GET",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json","Accept-Language":"en"}},i=w.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 D(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 P;!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"}(P||(P={}));const R={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 U(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 k(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"string"!=typeof e)).map((([e])=>`${e} must be a string`))}function N(e){return Object.entries(e).filter((([,e])=>void 0!==e&&!1!==e&&!0!==e)).map((([e])=>`${e} must be a boolean`))}function M(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 C=[{name:"organizationId"},{name:"membershipId"},{name:"bankAccountId"},{name:"monthlyLimit"},{name:"cardLevel"}],$=[...C,{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 U(e,C),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,h=function(e){return"virtual"!==e?['cardLevel must be "virtual"']:[]}(u),p=k({membershipId:t,organizationId:n,bankAccountId:i}),f=N({hasDailyLimit:a,hasTransactionLimit:r}),_=M({monthlyLimit:o,dailyLimit:c,transactionLimit:d}),y=z(m),g=q(l),I=[...h,...p,...f,..._,...y,...g];if(I.length>0)throw new s(I)}(e),e}(e):function(e){U(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:h,hasForeignPaymentOption:p,hasOnlinePaymentOption:f,shipToBusiness:_,hasAtmOption:y,hasAtmDailyLimit:g,atmDailyLimit:I,atmMonthlyLimit:E,address:w,cardDesign:A,typeOfPrint:L}=e,b=function(e){return Object.values(S).includes(e)?[]:['cardLevel must be one of "standard", "plus", "metal"']}(u),v=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),D=k({membershipId:t,organizationId:n,bankAccountId:i}),T=N({hasDailyLimit:a,hasTransactionLimit:r,hasAtmOption:y,hasNfcOption:h,hasForeignPaymentOption:p,hasOnlinePaymentOption:f,hasAtmDailyLimit:g,shipToBusiness:_}),P=M({monthlyLimit:o,dailyLimit:c,transactionLimit:d,atmDailyLimit:I,atmMonthlyLimit:E}),R=z(m),O=q(l),U=function(e){return["undefined","string"].includes(typeof e)?[]:["cardDesign must be a string"]}(A),C=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"]}(w,_),$=[...b,...D,...T,...P,...R,...O,...v,...U,...C];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 q(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 j extends i{constructor(e){super(),this.name="EmbedOperationError",this.message=e}}class x{constructor(e){this.options=e,this.iframe=null,this.parentElement=null,this.messageListeners=new Map,this.defaultTimeout=3e4;const t=new URL(e.iframeUrl);this.targetOrigin=`${t.protocol}//${t.host}`}async initialize(){if(this.iframe)return this;if(this.parentElement=document.getElementById(this.options.parentElementId),!this.parentElement)throw new j(`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 j(`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 j(`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 j("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 F({accessToken:e,language:t,debugMode:n}){const i=n||!1,a=t||"en";return`${w.getEnvironmentUrls().IFRAME_URL}?debug=${i}&lang=${encodeURIComponent(a)}#access_token=${encodeURIComponent(e)}`}function Y({parentElementId:e,iframeUrl:t}){return new x({parentElementId:e,iframeUrl:t}).initialize()}const G=[];for(let e=0;e<256;++e)G.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(G[e[t+0]]+G[e[t+1]]+G[e[t+2]]+G[e[t+3]]+"-"+G[e[t+4]]+G[e[t+5]]+"-"+G[e[t+6]]+G[e[t+7]]+"-"+G[e[t+8]]+G[e[t+9]]+"-"+G[e[t+10]]+G[e[t+11]]+G[e[t+12]]+G[e[t+13]]+G[e[t+14]]+G[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(R);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=w.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 D(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=`${w.getEnvironmentUrls().THIRD_PARTY_API_URL}/v2/cards?ids[]=${t}`,a=await fetch(i,n),r=await a.json();if(r.errors)throw new D(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=F({accessToken:t,debugMode:i}),s=await Y({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=k({cardId:e.cardId});if(t.length>0)throw new s(t)}(e.cardSettings);const a=F({accessToken:t,debugMode:i}),o=await Y({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=k({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=N(n);if(i.length>0)throw new s(i)}(e.cardSettings);const i=await T(e.cardSettings,t),a=await Y({iframeUrl:i,parentElementId:n});return{destroyEmbedUI:()=>{a.destroy()}}}catch(e){return Promise.reject(e)}}},ee=Z;e.cards=ee,e.constants=v,e.initialize=L,e.logout=b}));
|
|
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}));
|
package/dist/mocks/handlers.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { BeneficiaryDataObject } from '@beneficiaries/beneficiaries.types';
|
|
1
2
|
export declare const INVALID_ACCESS_TOKEN = "INVALID_ACCESS_TOKEN";
|
|
3
|
+
export declare const singleBeneficiary: BeneficiaryDataObject;
|
|
4
|
+
export declare const mockedBeneficiariesList: BeneficiaryDataObject[];
|
|
2
5
|
export declare const mswHandlers: import("msw").HttpHandler[];
|
|
3
6
|
//# sourceMappingURL=handlers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../src/mocks/handlers.ts"],"names":[],"mappings":"
|
|
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;AACF,eAAO,MAAM,uBAAuB,EAAE,qBAAqB,EAe1D,CAAC;AAEF,eAAO,MAAM,WAAW,6BAyIvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{EmbedApiError as e}from"../errors/EmbedApiError.js";import{environmentManager as n}from"../common/environment/environment-manager.js";import{addPaginationParamsToUrl as r}from"../common/api-pagination/api-pagination.js";const i="/v2/sepa/beneficiaries";async function o({paginationSettings:o,accessToken:t}){const a={method:"GET",headers:{Authorization:`Bearer ${t}`}},s=new URL(n.getEnvironmentUrls().THIRD_PARTY_API_URL+i),c=r({endpointUrl:s,paginationSettings:o}),m=await fetch(c,a),p=await m.json();if(p.errors)throw new e(p.errors.map((e=>`${e.code}: ${e.detail}`)));return{beneficiaries:p.beneficiaries,meta:p.meta}}async function t({accessToken:r,beneficiaryId:o}){const t={method:"GET",headers:{Authorization:`Bearer ${r}`}},a=`${n.getEnvironmentUrls().THIRD_PARTY_API_URL}${i}/${o}`,s=await fetch(a,t),c=await s.json();if(c.errors)throw new e(c.errors.map((e=>`${e.code}: ${e.detail}`)));return c.beneficiary}export{o as getBeneficiaries,t as getBeneficiary};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../common/auth/auth.js";import{validatePresenceOfAuthToken as i}from"../common/auth/auth.validate.js";import{getBeneficiary as e,getBeneficiaries as a}from"./beneficiaries.api.js";import{serializeBeneficiary as n}from"./beneficiaries.serializer.js";import{validateGetBeneficiaryParams as t}from"./beneficiaries.validate.js";import{serializePaginationResponse as o}from"../common/api-pagination/api-pagination.js";async function s(e){const t=e?.accessToken||i(),s=await a({accessToken:t,paginationSettings:e?.paginationSettings});return{beneficiaries:s.beneficiaries.map((i=>n(i))),meta:o(s.meta)}}async function c({beneficiaryId:a,accessToken:o}){const s=o||i();t(a);const c=await e({accessToken:s,beneficiaryId:a});return n(c)}export{s as getBeneficiaries,c as getBeneficiary};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getBeneficiary as e,getBeneficiaries as i}from"./beneficiaries.js";const r={getBeneficiaries:i,getBeneficiary:e};export{r as beneficiaries};
|
|
@@ -0,0 +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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{InvalidParametersError as r}from"../errors/InvalidParametersError.js";function e(e){if(!e)throw new r("beneficiaryId parameter is required for the called function");if(e&&"string"!=typeof e)throw new r("beneficiaryId must be a string");return e}export{e as validateGetBeneficiaryParams};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{beneficiaries as i}from"./beneficiaries.public-api.js";const e=i;export{e as beneficiaries};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e({endpointUrl:e,paginationSettings:t}){const a=new URL(e);return t?.page&&a.searchParams.set("page",t.page.toString()),t?.itemsPerPage&&a.searchParams.set("per_page",t.itemsPerPage.toString()),a}function t(e){return{totalItems:e.total_count,totalPages:e.total_pages,currentPage:e.current_page,itemsPerPage:e.per_page,previousPage:e.prev_page||null,nextPage:e.next_page||null}}export{e as addPaginationParamsToUrl,t as serializePaginationResponse};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const e={READY:"qonto.ready"},_={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"},E={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},a={MASTER:"master",SANDBOX:"sandbox",QA:"qa"},A={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"},n={PENDING:"pending",VALIDATED:"validated",DECLINED:"declined"};export{_ as ACTIONS,A as ACTIVITY_TAGS,n as BENEFICIARY_STATUSES,a as BRANCHES,E as ENVIRONMENTS,e as IFRAME_EVENTS};
|
package/dist/src/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{constants,initialize,logout}from"./common/index.js";export{cards}from"./cards/index.js";
|
|
1
|
+
export{constants,initialize,logout}from"./common/index.js";export{cards}from"./cards/index.js";export{beneficiaries}from"./beneficiaries/index.js";
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings } from './types.public-api';
|
|
2
|
-
export type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings, };
|
|
1
|
+
import type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings, Beneficiary, PaginationState } from './types.public-api';
|
|
2
|
+
export type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings, Beneficiary, 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,
|
|
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,3 +1,5 @@
|
|
|
1
1
|
import type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings } from '@cards/cards.types';
|
|
2
|
-
|
|
2
|
+
import type { Beneficiary } from '@beneficiaries/beneficiaries.types';
|
|
3
|
+
import type { PaginationState } from '@common/api-pagination/api-pagination.types';
|
|
4
|
+
export type { Card, VirtualCardOrderSettings, PhysicalCardOrderSettings, CardOrderSettings, Beneficiary, PaginationState, };
|
|
3
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;
|
|
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,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAEnF,YAAY,EACV,IAAI,EACJ,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,WAAW,EACX,eAAe,GAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qonto/embed-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Library to embed Qonto features in your application",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
"types": "./dist/cards/index.d.ts",
|
|
14
14
|
"import": "./dist/src/cards/index.js"
|
|
15
15
|
},
|
|
16
|
+
"./beneficiaries": {
|
|
17
|
+
"types": "./dist/beneficiaries/index.d.ts",
|
|
18
|
+
"import": "./dist/src/beneficiaries/index.js"
|
|
19
|
+
},
|
|
16
20
|
"./common": {
|
|
17
21
|
"types": "./dist/common/index.d.ts",
|
|
18
22
|
"import": "./dist/src/common/index.js"
|