@qonto/embed-sdk 0.7.0 → 0.8.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.
@@ -2,22 +2,25 @@ import type { BeneficiaryDataObject, NewBeneficiary } from './beneficiaries.type
2
2
  import type { PaginationResponseDataObject, PaginationSettings } from '@common/api-pagination/api-pagination.types';
3
3
  interface GetBeneficiariesParams {
4
4
  accessToken: string;
5
+ stagingToken?: string;
5
6
  paginationSettings?: PaginationSettings;
6
7
  }
7
8
  interface GetBeneficiaryParams {
8
9
  accessToken: string;
10
+ stagingToken?: string;
9
11
  beneficiaryId: string;
10
12
  }
11
13
  interface AddBeneficiaryParams {
12
- accessToken: string;
13
14
  beneficiary: NewBeneficiary;
15
+ accessToken: string;
16
+ stagingToken?: string;
14
17
  }
15
18
  interface GetBeneficiariesApiResponse {
16
19
  beneficiaries: BeneficiaryDataObject[];
17
20
  meta: PaginationResponseDataObject;
18
21
  }
19
- export declare function getBeneficiaries({ paginationSettings, accessToken, }: GetBeneficiariesParams): Promise<GetBeneficiariesApiResponse>;
20
- export declare function getBeneficiary({ accessToken, beneficiaryId, }: GetBeneficiaryParams): Promise<BeneficiaryDataObject>;
21
- export declare function addBeneficiary({ accessToken, beneficiary, }: AddBeneficiaryParams): Promise<any>;
22
+ export declare function getBeneficiaries({ paginationSettings, accessToken, stagingToken, }: GetBeneficiariesParams): Promise<GetBeneficiariesApiResponse>;
23
+ export declare function getBeneficiary({ accessToken, stagingToken, beneficiaryId, }: GetBeneficiaryParams): Promise<BeneficiaryDataObject>;
24
+ export declare function addBeneficiary({ beneficiary, accessToken, stagingToken, }: AddBeneficiaryParams): Promise<any>;
22
25
  export {};
23
26
  //# sourceMappingURL=beneficiaries.api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"beneficiaries.api.d.ts","sourceRoot":"","sources":["../../src/beneficiaries/beneficiaries.api.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,qBAAqB,EACrB,cAAc,EACf,MAAM,uBAAuB,CAAC;AAI/B,OAAO,KAAK,EACV,4BAA4B,EAC5B,kBAAkB,EACnB,MAAM,6CAA6C,CAAC;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
+ {"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;AAIrD,UAAU,sBAAsB;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC;AAED,UAAU,oBAAoB;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,oBAAoB;IAC5B,WAAW,EAAE,cAAc,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AASD,UAAU,2BAA2B;IACnC,aAAa,EAAE,qBAAqB,EAAE,CAAC;IACvC,IAAI,EAAE,4BAA4B,CAAC;CACpC;AAED,wBAAsB,gBAAgB,CAAC,EACrC,kBAAkB,EAClB,WAAW,EACX,YAAY,GACb,EAAE,sBAAsB,GAAG,OAAO,CAAC,2BAA2B,CAAC,CA+B/D;AAED,wBAAsB,cAAc,CAAC,EACnC,WAAW,EACX,YAAY,EACZ,aAAa,GACd,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAqBvD;AAED,wBAAsB,cAAc,CAAC,EACnC,WAAW,EACX,WAAW,EACX,YAAY,GACb,EAAE,oBAAoB,gBAyBtB"}
@@ -15,6 +15,7 @@ import type { PaginationSettings } from '@common/api-pagination/api-pagination.t
15
15
  */
16
16
  export declare function getBeneficiaries(getBeneficiariesParams?: {
17
17
  accessToken?: string;
18
+ stagingToken?: string;
18
19
  paginationSettings?: PaginationSettings;
19
20
  }): Promise<GetBeneficiariesResponse>;
20
21
  /**
@@ -27,9 +28,10 @@ export declare function getBeneficiaries(getBeneficiariesParams?: {
27
28
  * @throws \{InvalidParametersError\} If the `beneficiaryId` parameter is not a
28
29
  * string or is missing.
29
30
  */
30
- export declare function getBeneficiary({ beneficiaryId, accessToken, }: {
31
+ export declare function getBeneficiary({ beneficiaryId, accessToken, stagingToken, }: {
31
32
  beneficiaryId: string;
32
33
  accessToken?: string;
34
+ stagingToken?: string;
33
35
  }): Promise<Beneficiary>;
34
36
  /**
35
37
  * Adds a new beneficiary in the current user's account.
@@ -42,8 +44,9 @@ export declare function getBeneficiary({ beneficiaryId, accessToken, }: {
42
44
  * @throws \{InvalidParametersError\} If the `beneficiary` parameter is not an
43
45
  * object or if it does not contain the required properties.
44
46
  */
45
- export declare function addBeneficiary({ beneficiary, accessToken, }: {
47
+ export declare function addBeneficiary({ beneficiary, accessToken, stagingToken, }: {
46
48
  beneficiary: NewBeneficiary;
47
49
  accessToken?: string;
50
+ stagingToken?: string;
48
51
  }): Promise<Beneficiary>;
49
52
  //# sourceMappingURL=beneficiaries.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"beneficiaries.d.ts","sourceRoot":"","sources":["../../src/beneficiaries/beneficiaries.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,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
+ {"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,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAmBpC;AAED;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAAC,EACnC,aAAa,EACb,WAAW,EACX,YAAY,GACb,EAAE;IACD,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,WAAW,CAAC,CASvB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CAAC,EACnC,WAAW,EACX,WAAW,EACX,YAAY,GACb,EAAE;IACD,WAAW,EAAE,cAAc,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,WAAW,CAAC,CASvB"}
@@ -1,14 +1,16 @@
1
1
  import type { CardDataObject, DisplayCardSettings } from './cards.types';
2
2
  interface GetCardsParams {
3
- accessToken: string;
4
3
  membershipId?: string;
4
+ accessToken: string;
5
+ stagingToken?: string;
5
6
  }
6
7
  interface GetCardParams {
7
- accessToken: string;
8
8
  cardId: string;
9
+ accessToken: string;
10
+ stagingToken?: string;
9
11
  }
10
- export declare function getCards({ accessToken, membershipId, }: GetCardsParams): Promise<CardDataObject[]>;
11
- export declare function getCard({ accessToken, cardId, }: GetCardParams): Promise<CardDataObject>;
12
- export declare function getCardIframeURL(cardSettings: DisplayCardSettings, accessToken: string): Promise<string>;
12
+ export declare function getCards({ membershipId, accessToken, stagingToken, }: GetCardsParams): Promise<CardDataObject[]>;
13
+ export declare function getCard({ cardId, accessToken, stagingToken, }: GetCardParams): Promise<CardDataObject>;
14
+ export declare function getCardIframeURL(cardSettings: DisplayCardSettings, accessToken: string, stagingToken?: string): Promise<string>;
13
15
  export {};
14
16
  //# sourceMappingURL=cards.api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cards.api.d.ts","sourceRoot":"","sources":["../../src/cards/cards.api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAKzE,UAAU,cAAc;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,aAAa;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAOD,wBAAsB,QAAQ,CAAC,EAC7B,WAAW,EACX,YAAY,GACb,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAoB5C;AAED,wBAAsB,OAAO,CAAC,EAC5B,WAAW,EACX,MAAM,GACP,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAkBzC;AAED,wBAAsB,gBAAgB,CACpC,YAAY,EAAE,mBAAmB,EACjC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,CA8BjB"}
1
+ {"version":3,"file":"cards.api.d.ts","sourceRoot":"","sources":["../../src/cards/cards.api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAMzE,UAAU,cAAc;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,aAAa;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAOD,wBAAsB,QAAQ,CAAC,EAC7B,YAAY,EACZ,WAAW,EACX,YAAY,GACb,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAoB5C;AAED,wBAAsB,OAAO,CAAC,EAC5B,MAAM,EACN,WAAW,EACX,YAAY,GACb,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAkBzC;AAED,wBAAsB,gBAAgB,CACpC,YAAY,EAAE,mBAAmB,EACjC,WAAW,EAAE,MAAM,EACnB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,MAAM,CAAC,CAsBjB"}
@@ -24,9 +24,10 @@ export interface CardParams<T> {
24
24
  * Ensure initialize has been called before using this function if you are not
25
25
  * passing the access token.
26
26
  */
27
- export declare function getCards({ membershipId, accessToken, }: {
27
+ export declare function getCards({ membershipId, accessToken, stagingToken, }: {
28
28
  membershipId?: string;
29
29
  accessToken?: string;
30
+ stagingToken?: string;
30
31
  }): Promise<Card[]>;
31
32
  /**
32
33
  * Fetches a card by its id.
@@ -36,9 +37,10 @@ export declare function getCards({ membershipId, accessToken, }: {
36
37
  * Ensure initialize has been called before using this function if you are not
37
38
  * passing the access token.
38
39
  */
39
- export declare function getCard({ cardId, accessToken, }: {
40
+ export declare function getCard({ cardId, accessToken, stagingToken, }: {
40
41
  cardId: string;
41
42
  accessToken?: string;
43
+ stagingToken?: string;
42
44
  }): Promise<Card>;
43
45
  /**
44
46
  * Requests the creation of a card by showing the user the UI to perform MFA in the calling page.
@@ -1 +1 @@
1
- {"version":3,"file":"cards.d.ts","sourceRoot":"","sources":["../../src/cards/cards.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,IAAI,EAET,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACxB,MAAM,eAAe,CAAC;AAYvB,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,2CAA2C,CAAC;AAGnD;;;;;;GAMG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B;;;OAGG;IACH,YAAY,EAAE,CAAC,CAAC;IAChB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED;;;;;;;;GAQG;AACH,wBAAsB,QAAQ,CAAC,EAC7B,YAAY,EACZ,WAAW,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"}
1
+ {"version":3,"file":"cards.d.ts","sourceRoot":"","sources":["../../src/cards/cards.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,IAAI,EAET,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACxB,MAAM,eAAe,CAAC;AAYvB,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,2CAA2C,CAAC;AAGnD;;;;;;GAMG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B;;;OAGG;IACH,YAAY,EAAE,CAAC,CAAC;IAChB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED;;;;;;;;GAQG;AACH,wBAAsB,QAAQ,CAAC,EAC7B,YAAY,EACZ,WAAW,EACX,YAAY,GACb,EAAE;IACD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAelB;AAED;;;;;;;GAOG;AACH,wBAAsB,OAAO,CAAC,EAC5B,MAAM,EACN,WAAW,EACX,YAAY,GACb,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,IAAI,CAAC,CAYhB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmFG;AACH,wBAAsB,SAAS,CAC7B,UAAU,EAAE,UAAU,CAAC,iBAAiB,CAAC,GACxC,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,UAAU,CAC9B,UAAU,EAAE,UAAU,CAAC,kBAAkB,CAAC,GACzC,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,WAAW,CAC/B,UAAU,EAAE,UAAU,CAAC,mBAAmB,CAAC,GAC1C,OAAO,CAAC,uBAAuB,CAAC,CAsBlC"}
@@ -4,6 +4,7 @@
4
4
  export declare class AuthManager {
5
5
  private static instance;
6
6
  private accessToken;
7
+ private stagingToken;
7
8
  private constructor();
8
9
  /**
9
10
  * Gets the singleton instance of AuthManager
@@ -28,6 +29,10 @@ export declare class AuthManager {
28
29
  * Clears the current access token
29
30
  */
30
31
  clearAccessToken(): void;
32
+ setStagingToken(token: string): void;
33
+ getStagingToken(): string | null;
34
+ hasStagingToken(): boolean;
35
+ clearStagingToken(): void;
31
36
  }
32
37
  export declare const authManager: AuthManager;
33
38
  //# sourceMappingURL=auth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/common/auth/auth.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAc;IACrC,OAAO,CAAC,WAAW,CAAuB;IAE1C,OAAO;IAIP;;OAEG;WACW,WAAW,IAAI,WAAW;IAOxC;;;OAGG;IACI,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI1C;;;OAGG;IACI,cAAc,IAAI,MAAM,GAAG,IAAI;IAItC;;;OAGG;IACI,cAAc,IAAI,OAAO;IAIhC;;OAEG;IACI,gBAAgB,IAAI,IAAI;CAGhC;AAGD,eAAO,MAAM,WAAW,aAA4B,CAAC"}
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/common/auth/auth.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAc;IACrC,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,YAAY,CAAuB;IAE3C,OAAO;IAIP;;OAEG;WACW,WAAW,IAAI,WAAW;IAOxC;;;OAGG;IACI,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI1C;;;OAGG;IACI,cAAc,IAAI,MAAM,GAAG,IAAI;IAItC;;;OAGG;IACI,cAAc,IAAI,OAAO;IAIhC;;OAEG;IACI,gBAAgB,IAAI,IAAI;IAIxB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAIpC,eAAe,IAAI,MAAM,GAAG,IAAI;IAIhC,eAAe,IAAI,OAAO;IAI1B,iBAAiB,IAAI,IAAI;CAGjC;AAGD,eAAO,MAAM,WAAW,aAA4B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../../../src/common/initialize/initialize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAK3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,wBAAgB,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,QAc5D;AAED;;;;GAIG;AACH,wBAAgB,MAAM,SAErB"}
1
+ {"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../../../src/common/initialize/initialize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAK3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,wBAAgB,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,QAiB5D;AAED;;;;GAIG;AACH,wBAAgB,MAAM,SAGrB"}
@@ -9,6 +9,11 @@ export interface InitializeParams {
9
9
  * generated using the OAuth authentication flow.
10
10
  */
11
11
  accessToken: string;
12
+ /**
13
+ * The staging token allows users outside Qonto to access the staging environment.
14
+ * This is helpful for testing purposes, and it is irrelevant in production.
15
+ */
16
+ stagingToken?: string;
12
17
  locale?: 'en' | 'fr' | 'es' | 'de' | 'it' | 'pt';
13
18
  /**
14
19
  * Optional parameter to set the SDK's environment. If not provided,
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.types.d.ts","sourceRoot":"","sources":["../../../src/common/initialize/initialize.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAEnF;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IACjD;;;;OAIG;IACH,WAAW,CAAC,EAAE,YAAY,GAAG,SAAS,GAAG,OAAO,CAAC;IACjD;;;;;OAKG;IACH,MAAM,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,IAAI,CAAC;IACrC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC"}
1
+ {"version":3,"file":"initialize.types.d.ts","sourceRoot":"","sources":["../../../src/common/initialize/initialize.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAEnF;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IACjD;;;;OAIG;IACH,WAAW,CAAC,EAAE,YAAY,GAAG,SAAS,GAAG,OAAO,CAAC;IACjD;;;;;OAKG;IACH,MAAM,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,IAAI,CAAC;IACrC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC"}
@@ -0,0 +1,8 @@
1
+ interface BuildRequestHeadersParams {
2
+ accessToken: string;
3
+ stagingToken?: string;
4
+ idempotencyKey?: string;
5
+ }
6
+ export declare function buildRequestHeaders({ accessToken, stagingToken, idempotencyKey, }: BuildRequestHeadersParams): Headers;
7
+ export {};
8
+ //# sourceMappingURL=network.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../../src/common/network/network.ts"],"names":[],"mappings":"AAEA,UAAU,yBAAyB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,mBAAmB,CAAC,EAClC,WAAW,EACX,YAAY,EACZ,cAAc,GACf,EAAE,yBAAyB,GAAG,OAAO,CAcrC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=network.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network.test.d.ts","sourceRoot":"","sources":["../../../src/common/network/network.test.ts"],"names":[],"mappings":""}
@@ -1,6 +1,7 @@
1
1
  import { EmbedIframe } from './embed-iframe';
2
2
  interface BuildIframeUrlParams {
3
3
  accessToken: string;
4
+ stagingToken?: string;
4
5
  language?: string;
5
6
  debugMode?: boolean;
6
7
  }
@@ -8,7 +9,7 @@ interface CreateIframeParams {
8
9
  parentElementId: string;
9
10
  iframeUrl: string;
10
11
  }
11
- export declare function buildIframeUrl({ accessToken, language, debugMode, }: BuildIframeUrlParams): string;
12
+ export declare function buildIframeUrl({ accessToken, stagingToken, language, debugMode, }: BuildIframeUrlParams): string;
12
13
  export declare function createIframe({ parentElementId, iframeUrl, }: CreateIframeParams): Promise<EmbedIframe>;
13
14
  export {};
14
15
  //# sourceMappingURL=iframe-manager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"iframe-manager.d.ts","sourceRoot":"","sources":["../../src/iframe/iframe-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,UAAU,oBAAoB;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,UAAU,kBAAkB;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,cAAc,CAAC,EAC7B,WAAW,EACX,QAAQ,EACR,SAAS,GACV,EAAE,oBAAoB,UAKtB;AAED,wBAAgB,YAAY,CAAC,EAC3B,eAAe,EACf,SAAS,GACV,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC,CAG3C"}
1
+ {"version":3,"file":"iframe-manager.d.ts","sourceRoot":"","sources":["../../src/iframe/iframe-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,UAAU,oBAAoB;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,UAAU,kBAAkB;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,cAAc,CAAC,EAC7B,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,SAAS,GACV,EAAE,oBAAoB,UAQtB;AAED,wBAAgB,YAAY,CAAC,EAC3B,eAAe,EACf,SAAS,GACV,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC,CAG3C"}
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 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}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).QontoEmbed={})}(this,(function(e){"use strict";class t{constructor(){this.accessToken=null,this.stagingToken=null}static getInstance(){return t.instance||(t.instance=new t),t.instance}setAccessToken(e){this.accessToken=e}getAccessToken(){return this.accessToken}hasAccessToken(){return null!==this.accessToken&&""!==this.accessToken}clearAccessToken(){this.accessToken=null}setStagingToken(e){this.stagingToken=e}getStagingToken(){return this.stagingToken}hasStagingToken(){return null!==this.stagingToken&&""!==this.stagingToken}clearStagingToken(){this.stagingToken=null}}const n=t.getInstance();class i extends Error{constructor(){super(),this.stack=""}toString(){return`${this.name}: ${this.message}`}}class a extends i{constructor(){super(),this.name="AuthenticationError",this.message="Authentication failed due to missing or invalid access token.\nEnsure you have called the initialize function with a valid access token."}}function r(){if(!n.hasAccessToken())throw new a;return n.getAccessToken()}class s extends i{constructor(e){super(),this.name="InvalidParametersError",this.invalidParameters=Array.isArray(e)?e:[e],this.message=`Invalid parameters were passed to the function:\n${this.invalidParameters.map((e=>e)).join("\n")}`}}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 g=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 f="https://embed.qonto.com",_="https://embed-js{branch}.staging.qonto.co",y="https://embed.dev.qonto.co",T={[p.PRODUCTION]:{IFRAME_BASE_URL:f,IFRAME_URL:`${f}/connect`,THIRD_PARTY_API_URL:"https://thirdparty.qonto.com"},[p.STAGING]:{IFRAME_BASE_URL:_,IFRAME_URL:`${_}/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 I{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 I.instance||(I.instance=new I),I.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 T.production;{const e=T[this.environment];return Object.entries(e).reduce(((e,[t,n])=>({...e,[t]:n.replace("{branch}",`-${this.branch}`)})),{})}}}const E=I.getInstance();const A={initialize:function(e){const{accessToken:t,stagingToken:i,operationSettings:a,environment:r,branch:s}=m(e);n.setAccessToken(t),i&&n.setStagingToken(i),a&&c.setSettings(a),r&&(E.setEnvironment(r),s&&E.setBranch(s))},logout:function(){n.clearAccessToken(),n.clearStagingToken()},constants:g},{initialize:b,logout:w,constants:L}=A;class v extends i{constructor(e){super();const t=Array.isArray(e)?e.join("\n"):e;this.name="EmbedApiError",this.message=`The call to the Embed API failed with the following errors:\n${t}`}}function R({accessToken:e,stagingToken:t,idempotencyKey:i}){const a=new Headers;a.append("Authorization",`Bearer ${e}`);const r=t||n.getStagingToken();return r&&a.append("X-Qonto-Staging-Token",r),i&&a.append("X-Qonto-Idempotency-Key",i),a.append("Content-Type","application/json"),a.append("Accept-Language","en"),a}async function D(e,t,n){const i={method:"GET",headers:R({accessToken:t,stagingToken:n})},a=E.getEnvironmentUrls().THIRD_PARTY_API_URL,r=await fetch(`${a}/v2/cards/${e.cardId}/data_view`,i),s=await r.json();if(s.errors)throw new v(s.errors.map((e=>`${e.code}: ${e.detail}`)));return function(e,t){const n=new URL(e);return"boolean"==typeof t.allowPinReveal&&n.searchParams.set("canSeePin",t.allowPinReveal?"true":"false"),"boolean"==typeof t.allowBlocking&&n.searchParams.set("canBlock",t.allowBlocking?"true":"false"),n.toString()}(s.iframe_url,e)}var 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 k={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 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 $=[{name:"organizationId"},{name:"membershipId"},{name:"bankAccountId"},{name:"monthlyLimit"},{name:"cardLevel"}],B=[...$,{name:"atmDailyLimit",requiredIfPresent:"hasAtmDailyLimit"},{name:"hasAtmDailyLimit",requiredIfPresent:"hasAtmOption"},{name:"atmMonthlyLimit",requiredIfPresent:"hasAtmOption"},{name:"shipToBusiness"},{name:"cardLevel"}];function j(e){if(!e)throw new s("cardSettings parameter is required for the called function");return"virtual"===e.cardLevel?function(e){return 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}=e,p=function(e){return"virtual"!==e?['cardLevel must be "virtual"']:[]}(u),h=U({membershipId:t,organizationId:n,bankAccountId:i}),g=C({hasDailyLimit:a,hasTransactionLimit:r}),f=M({monthlyLimit:o,dailyLimit:c,transactionLimit:d}),_=F(m),y=q(l),T=[...p,...h,...g,...f,..._,...y];if(T.length>0)throw new s(T)}(e),e}(e):function(e){N(e,B),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:g,shipToBusiness:f,hasAtmOption:_,hasAtmDailyLimit:y,atmDailyLimit:T,atmMonthlyLimit:I,address:E,cardDesign:A,typeOfPrint:b}=e,w=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']:[]}(b),v=U({membershipId:t,organizationId:n,bankAccountId:i}),R=C({hasDailyLimit:a,hasTransactionLimit:r,hasAtmOption:_,hasNfcOption:p,hasForeignPaymentOption:h,hasOnlinePaymentOption:g,hasAtmDailyLimit:y,shipToBusiness:f}),D=M({monthlyLimit:o,dailyLimit:c,transactionLimit:d,atmDailyLimit:T,atmMonthlyLimit:I}),P=F(m),k=q(l),O=function(e){return["undefined","string"].includes(typeof e)?[]:["cardDesign must be a string"]}(A),N=function(e,t){if(t)return[];return!e||e.contactName&&e.firstLine&&e.zipCode&&e.city&&e.country?[]:["address must contain at least contactName, firstLine, zipCode, city and country properties"]}(E,f),$=[...w,...v,...R,...D,...P,...k,...L,...O,...N];if($.length>0)throw new s($)}(e)}(e)}function F(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 G extends i{constructor(e){super(),this.name="EmbedOperationError",this.message=e}}class z{constructor(e){this.options=e,this.iframe=null,this.parentElement=null,this.messageListeners=new Map,this.defaultTimeout=3e4;const t=new URL(e.iframeUrl);this.targetOrigin=`${t.protocol}//${t.host}`}async initialize(){if(this.iframe)return this;if(this.parentElement=document.getElementById(this.options.parentElementId),!this.parentElement)throw new G(`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 G(`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 G(`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 G("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 x({accessToken:e,stagingToken:t,language:n,debugMode:i}){const a=i||!1,r=n||"en",s=E.getEnvironmentUrls().IFRAME_URL,o=t?`&staging_token=${encodeURIComponent(t)}`:"";return`${s}?debug=${a}&lang=${encodeURIComponent(r)}#access_token=${encodeURIComponent(e)}${o}`}function Y({parentElementId:e,iframeUrl:t}){return new z({parentElementId:e,iframeUrl:t}).initialize()}const H=[];for(let e=0;e<256;++e)H.push((e+256).toString(16).slice(1));let V;const X=new Uint8Array(16);var K={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Q(e,t,n){if(K.randomUUID&&!e)return K.randomUUID();const i=(e=e||{}).random??e.rng?.()??function(){if(!V){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");V=crypto.getRandomValues.bind(crypto)}return V(X)}();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(H[e[t+0]]+H[e[t+1]]+H[e[t+2]]+H[e[t+3]]+"-"+H[e[t+4]]+H[e[t+5]]+"-"+H[e[t+6]]+H[e[t+7]]+"-"+H[e[t+8]]+H[e[t+9]]+"-"+H[e[t+10]]+H[e[t+11]]+H[e[t+12]]+H[e[t+13]]+H[e[t+14]]+H[e[t+15]]).toLowerCase()}(i)}function W(e){return"virtual"===e.cardLevel?function(e){const t=Z(e.categories);return{actionId:u.CARD_ORDER,actionData:{idempotencyKey:Q(),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=Z(e.categories);return{actionId:u.CARD_ORDER,actionData:{idempotencyKey:Q(),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 J(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 Z(e){const t=Object.values(k);return(e||[]).filter((e=>t.includes(e)))}const ee={getCards:async function({membershipId:e,accessToken:t,stagingToken:n}){try{const i=t||r();if(e&&"string"!=typeof e)throw new s("membershipId must be a string");const a=await async function({membershipId:e,accessToken:t,stagingToken:n}){const i={method:"GET",headers:R({accessToken:t,stagingToken:n})},a=E.getEnvironmentUrls().THIRD_PARTY_API_URL,r=e?`${a}/v2/cards?holder_ids[]=${e}`:`${a}/v2/cards`,s=await fetch(r,i),o=await s.json();if(o.errors)throw new v(o.errors.map((e=>`${e.code}: ${e.detail}`)));return o.cards}({membershipId:e,accessToken:i,stagingToken:n});return a.map((e=>J(e)))}catch(e){return Promise.reject(e)}},getCard:async function({cardId:e,accessToken:t,stagingToken:n}){try{const i=t||r();if(e&&"string"!=typeof e)throw new s("cardId must be a string");const a=await async function({cardId:e,accessToken:t,stagingToken:n}){const i={method:"GET",headers:R({accessToken:t,stagingToken:n})},a=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}/v2/cards?ids[]=${e}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new v(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.cards[0]}({cardId:e,accessToken:i,stagingToken:n});return J(a)}catch(e){return Promise.reject(e)}},orderCard:async function(e){try{const t=r(),{uiParentElementId:i,debugMode:a}=d(e.operationSettings);j(e.cardSettings);const s=x({accessToken:t,stagingToken:n.getStagingToken()||void 0,debugMode:a}),o=await Y({iframeUrl:s,parentElementId:i}),c=W(e.cardSettings),m=await o.postMessage(c);return o.destroy(),J(m)}catch(e){return Promise.reject(e)}},unlockCard:async function(e){try{const t=r(),{uiParentElementId:i,debugMode:a}=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 o=x({accessToken:t,stagingToken:n.getStagingToken()||void 0,debugMode:a}),c=await Y({iframeUrl:o,parentElementId:i}),m=function(e){return{actionId:u.CARD_UNLOCK,actionData:{cardId:e.cardSettings.cardId}}}(e),l=await c.postMessage(m);return c.destroy(),J(l)}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 D(e.cardSettings,t),a=await Y({iframeUrl:i,parentElementId:n});return{destroyEmbedUI:()=>{a.destroy()}}}catch(e){return Promise.reject(e)}}},te=ee;function ne(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 ie(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 ae="/v2/sepa/beneficiaries";async function re({paginationSettings:e,accessToken:t,stagingToken:n}){const i={method:"GET",headers:R({accessToken:t,stagingToken:n})},a=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(E.getEnvironmentUrls().THIRD_PARTY_API_URL+ae),paginationSettings:e}),r=await fetch(a,i),s=await r.json();if(s.errors)throw new v(s.errors.map((e=>`${e.code}: ${e.detail}`)));return{beneficiaries:s.beneficiaries,meta:s.meta}}const se=[{name:"name"},{name:"iban"}];const oe={getBeneficiaries:async function(e){const t=e?.accessToken||r(),n=await re({accessToken:t,stagingToken:e?.stagingToken,paginationSettings:e?.paginationSettings});var i;return{beneficiaries:n.beneficiaries.map((e=>ne(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,stagingToken:n}){const i=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 ne(await async function({accessToken:e,stagingToken:t,beneficiaryId:n}){const i={method:"GET",headers:R({accessToken:e,stagingToken:t})},a=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${ae}/${n}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new v(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.beneficiary}({beneficiaryId:e,accessToken:i,stagingToken:n}))},addBeneficiary:async function({beneficiary:e,accessToken:t,stagingToken:n}){const i=t||r();!function(e){if(!e)throw new s("beneficiary parameter is required for the called function");if("object"!=typeof e)throw new s("beneficiary must be an object");N(e,se);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 ne(await async function({beneficiary:e,accessToken:t,stagingToken:n}){const i={method:"POST",headers:R({accessToken:t,stagingToken:n,idempotencyKey:Q()}),body:JSON.stringify({beneficiary:ie(e)})},a=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${ae}`,r=await fetch(a,i),s=await r.json();if(s.errors)throw new v(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.beneficiary}({beneficiary:e,accessToken:i,stagingToken:n}))}};e.beneficiaries=oe,e.cards=te,e.constants=L,e.initialize=b,e.logout=w}));
@@ -1 +1 @@
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
+ import{EmbedApiError as e}from"../errors/EmbedApiError.js";import{environmentManager as n}from"../common/environment/environment-manager.js";import{addPaginationParamsToUrl as o}from"../common/api-pagination/api-pagination.js";import{serializeToNewBeneficiaryDataObject as i}from"./beneficiaries.serializer.js";import{buildRequestHeaders as r}from"../common/network/network.js";import t from"../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm-browser/v4.js";const a="/v2/sepa/beneficiaries";async function s({paginationSettings:i,accessToken:t,stagingToken:s}){const c={method:"GET",headers:r({accessToken:t,stagingToken:s})},m=new URL(n.getEnvironmentUrls().THIRD_PARTY_API_URL+a),f=o({endpointUrl:m,paginationSettings:i}),d=await fetch(f,c),g=await d.json();if(g.errors)throw new e(g.errors.map((e=>`${e.code}: ${e.detail}`)));return{beneficiaries:g.beneficiaries,meta:g.meta}}async function c({accessToken:o,stagingToken:i,beneficiaryId:t}){const s={method:"GET",headers:r({accessToken:o,stagingToken:i})},c=`${n.getEnvironmentUrls().THIRD_PARTY_API_URL}${a}/${t}`,m=await fetch(c,s),f=await m.json();if(f.errors)throw new e(f.errors.map((e=>`${e.code}: ${e.detail}`)));return f.beneficiary}async function m({beneficiary:o,accessToken:s,stagingToken:c}){const m={method:"POST",headers:r({accessToken:s,stagingToken:c,idempotencyKey:t()}),body:JSON.stringify({beneficiary:i(o)})},f=`${n.getEnvironmentUrls().THIRD_PARTY_API_URL}${a}`,d=await fetch(f,m),g=await d.json();if(g.errors)throw new e(g.errors.map((e=>`${e.code}: ${e.detail}`)));return g.beneficiary}export{m as addBeneficiary,s as getBeneficiaries,c as getBeneficiary};
@@ -1 +1 @@
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
+ 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 s,validateGetBeneficiaryParams as o}from"./beneficiaries.validate.js";import{serializePaginationResponse as c}from"../common/api-pagination/api-pagination.js";async function r(e){const a=e?.accessToken||i(),s=await n({accessToken:a,stagingToken:e?.stagingToken,paginationSettings:e?.paginationSettings});return{beneficiaries:s.beneficiaries.map((i=>t(i))),meta:c(s.meta)}}async function f({beneficiaryId:e,accessToken:n,stagingToken:s}){const c=n||i();o(e);const r=await a({beneficiaryId:e,accessToken:c,stagingToken:s});return t(r)}async function g({beneficiary:a,accessToken:n,stagingToken:o}){const c=n||i();s(a);const r=await e({beneficiary:a,accessToken:c,stagingToken:o});return t(r)}export{g as addBeneficiary,r as getBeneficiaries,f as getBeneficiary};
@@ -1 +1 @@
1
- import{EmbedApiError as r}from"../errors/EmbedApiError.js";import{getPopulatedIframeURL as e}from"./cards.helper.js";import{environmentManager as o}from"../common/environment/environment-manager.js";async function a({accessToken:e,membershipId:a}){const t={method:"GET",headers:{Authorization:`Bearer ${e}`}},n=o.getEnvironmentUrls().THIRD_PARTY_API_URL,s=a?`${n}/v2/cards?holder_ids[]=${a}`:`${n}/v2/cards`,i=await fetch(s,t),c=await i.json();if(c.errors)throw new r(c.errors.map((r=>`${r.code}: ${r.detail}`)));return c.cards}async function t({accessToken:e,cardId:a}){const t={method:"GET",headers:{Authorization:`Bearer ${e}`}},n=`${o.getEnvironmentUrls().THIRD_PARTY_API_URL}/v2/cards?ids[]=${a}`,s=await fetch(n,t),i=await s.json();if(i.errors)throw new r(i.errors.map((r=>`${r.code}: ${r.detail}`)));return i.cards[0]}async function n(a,t){const n={method:"GET",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json","Accept-Language":"en"}},s=o.getEnvironmentUrls().THIRD_PARTY_API_URL,i=await fetch(`${s}/v2/cards/${a.cardId}/data_view`,n),c=await i.json();if(c.errors)throw new r(c.errors.map((r=>`${r.code}: ${r.detail}`)));return e(c.iframe_url,a)}export{t as getCard,n as getCardIframeURL,a as getCards};
1
+ import{EmbedApiError as r}from"../errors/EmbedApiError.js";import{getPopulatedIframeURL as e}from"./cards.helper.js";import{environmentManager as o}from"../common/environment/environment-manager.js";import{buildRequestHeaders as n}from"../common/network/network.js";async function s({membershipId:e,accessToken:s,stagingToken:a}){const t={method:"GET",headers:n({accessToken:s,stagingToken:a})},c=o.getEnvironmentUrls().THIRD_PARTY_API_URL,i=e?`${c}/v2/cards?holder_ids[]=${e}`:`${c}/v2/cards`,d=await fetch(i,t),m=await d.json();if(m.errors)throw new r(m.errors.map((r=>`${r.code}: ${r.detail}`)));return m.cards}async function a({cardId:e,accessToken:s,stagingToken:a}){const t={method:"GET",headers:n({accessToken:s,stagingToken:a})},c=`${o.getEnvironmentUrls().THIRD_PARTY_API_URL}/v2/cards?ids[]=${e}`,i=await fetch(c,t),d=await i.json();if(d.errors)throw new r(d.errors.map((r=>`${r.code}: ${r.detail}`)));return d.cards[0]}async function t(s,a,t){const c={method:"GET",headers:n({accessToken:a,stagingToken:t})},i=o.getEnvironmentUrls().THIRD_PARTY_API_URL,d=await fetch(`${i}/v2/cards/${s.cardId}/data_view`,c),m=await d.json();if(m.errors)throw new r(m.errors.map((r=>`${r.code}: ${r.detail}`)));return e(m.iframe_url,s)}export{a as getCard,t as getCardIframeURL,s as getCards};
@@ -1 +1 @@
1
- import"../common/auth/auth.js";import{validatePresenceOfAuthToken as t}from"../common/auth/auth.validate.js";import{getCardIframeURL as e,getCard as r,getCards as a}from"./cards.api.js";import"./cards.types.js";import{validateDisplayCardParams as s,validateUnlockCardParams as n,validateOrderCardParams as o}from"./cards.validate.js";import{createIframe as i,buildIframeUrl as c}from"../iframe/iframe-manager.js";import{serializeUnlockCardPayload as m,serializeCard as d,serializeOrderCardPayload as u}from"./cards.serializer.js";import{validateOperationSettingsParams as p}from"../validation/operation-settings-validation.js";import{InvalidParametersError as g}from"../errors/InvalidParametersError.js";async function f({membershipId:e,accessToken:r}){try{const s=r||t();if(e&&"string"!=typeof e)throw new g("membershipId must be a string");return(await a({accessToken:s,membershipId:e})).map((t=>d(t)))}catch(t){return Promise.reject(t)}}async function y({cardId:e,accessToken:a}){try{const s=a||t();if(e&&"string"!=typeof e)throw new g("cardId must be a string");const n=await r({accessToken:s,cardId:e});return d(n)}catch(t){return Promise.reject(t)}}async function l(e){try{const r=t(),{uiParentElementId:a,debugMode:s}=p(e.operationSettings);o(e.cardSettings);const n=c({accessToken:r,debugMode:s}),m=await i({iframeUrl:n,parentElementId:a}),g=u(e.cardSettings),f=await m.postMessage(g);return m.destroy(),d(f)}catch(t){return Promise.reject(t)}}async function h(e){try{const r=t(),{uiParentElementId:a,debugMode:s}=p(e.operationSettings);n(e.cardSettings);const o=c({accessToken:r,debugMode:s}),u=await i({iframeUrl:o,parentElementId:a}),g=m(e),f=await u.postMessage(g);return u.destroy(),d(f)}catch(t){return Promise.reject(t)}}async function j(r){try{const a=t(),{uiParentElementId:n}=p(r.operationSettings);s(r.cardSettings);const o=await e(r.cardSettings,a),c=await i({iframeUrl:o,parentElementId:n});return{destroyEmbedUI:()=>{c.destroy()}}}catch(t){return Promise.reject(t)}}export{j as displayCard,y as getCard,f as getCards,l as orderCard,h as unlockCard};
1
+ import{authManager as t}from"../common/auth/auth.js";import{validatePresenceOfAuthToken as e}from"../common/auth/auth.validate.js";import{getCardIframeURL as r,getCard as a,getCards as n}from"./cards.api.js";import"./cards.types.js";import{validateDisplayCardParams as s,validateUnlockCardParams as o,validateOrderCardParams as i}from"./cards.validate.js";import{createIframe as c,buildIframeUrl as m}from"../iframe/iframe-manager.js";import{serializeUnlockCardPayload as d,serializeCard as g,serializeOrderCardPayload as u}from"./cards.serializer.js";import{validateOperationSettingsParams as p}from"../validation/operation-settings-validation.js";import{InvalidParametersError as f}from"../errors/InvalidParametersError.js";async function y({membershipId:t,accessToken:r,stagingToken:a}){try{const s=r||e();if(t&&"string"!=typeof t)throw new f("membershipId must be a string");return(await n({membershipId:t,accessToken:s,stagingToken:a})).map((t=>g(t)))}catch(t){return Promise.reject(t)}}async function l({cardId:t,accessToken:r,stagingToken:n}){try{const s=r||e();if(t&&"string"!=typeof t)throw new f("cardId must be a string");const o=await a({cardId:t,accessToken:s,stagingToken:n});return g(o)}catch(t){return Promise.reject(t)}}async function h(r){try{const a=e(),{uiParentElementId:n,debugMode:s}=p(r.operationSettings);i(r.cardSettings);const o=m({accessToken:a,stagingToken:t.getStagingToken()||void 0,debugMode:s}),d=await c({iframeUrl:o,parentElementId:n}),f=u(r.cardSettings),y=await d.postMessage(f);return d.destroy(),g(y)}catch(t){return Promise.reject(t)}}async function j(r){try{const a=e(),{uiParentElementId:n,debugMode:s}=p(r.operationSettings);o(r.cardSettings);const i=m({accessToken:a,stagingToken:t.getStagingToken()||void 0,debugMode:s}),u=await c({iframeUrl:i,parentElementId:n}),f=d(r),y=await u.postMessage(f);return u.destroy(),g(y)}catch(t){return Promise.reject(t)}}async function k(t){try{const a=e(),{uiParentElementId:n}=p(t.operationSettings);s(t.cardSettings);const o=await r(t.cardSettings,a),i=await c({iframeUrl:o,parentElementId:n});return{destroyEmbedUI:()=>{i.destroy()}}}catch(t){return Promise.reject(t)}}export{k as displayCard,l as getCard,y as getCards,h as orderCard,j as unlockCard};
@@ -1 +1 @@
1
- class s{constructor(){this.accessToken=null}static getInstance(){return s.instance||(s.instance=new s),s.instance}setAccessToken(s){this.accessToken=s}getAccessToken(){return this.accessToken}hasAccessToken(){return null!==this.accessToken&&""!==this.accessToken}clearAccessToken(){this.accessToken=null}}const e=s.getInstance();export{s as AuthManager,e as authManager};
1
+ class n{constructor(){this.accessToken=null,this.stagingToken=null}static getInstance(){return n.instance||(n.instance=new n),n.instance}setAccessToken(n){this.accessToken=n}getAccessToken(){return this.accessToken}hasAccessToken(){return null!==this.accessToken&&""!==this.accessToken}clearAccessToken(){this.accessToken=null}setStagingToken(n){this.stagingToken=n}getStagingToken(){return this.stagingToken}hasStagingToken(){return null!==this.stagingToken&&""!==this.stagingToken}clearStagingToken(){this.stagingToken=null}}const s=n.getInstance();export{n as AuthManager,s as authManager};
@@ -1 +1 @@
1
- import{authManager as n}from"../auth/auth.js";import{validateInitializeParams as t}from"./initialize.validate.js";import{operationSettingsManager as e}from"../operation-settings/operation-settings.js";import{environmentManager as o}from"../environment/environment-manager.js";function i(i){const{accessToken:s,operationSettings:r,environment:a,branch:m}=t(i);n.setAccessToken(s),r&&e.setSettings(r),a&&(o.setEnvironment(a),m&&o.setBranch(m))}function s(){n.clearAccessToken()}export{i as initialize,s as logout};
1
+ import{authManager as n}from"../auth/auth.js";import{validateInitializeParams as t}from"./initialize.validate.js";import{operationSettingsManager as e}from"../operation-settings/operation-settings.js";import{environmentManager as o}from"../environment/environment-manager.js";function i(i){const{accessToken:s,stagingToken:r,operationSettings:a,environment:c,branch:m}=t(i);n.setAccessToken(s),r&&n.setStagingToken(r),a&&e.setSettings(a),c&&(o.setEnvironment(c),m&&o.setBranch(m))}function s(){n.clearAccessToken(),n.clearStagingToken()}export{i as initialize,s as logout};
@@ -0,0 +1 @@
1
+ import{authManager as e}from"../auth/auth.js";function n({accessToken:n,stagingToken:t,idempotencyKey:o}){const a=new Headers;a.append("Authorization",`Bearer ${n}`);const p=t||e.getStagingToken();return p&&a.append("X-Qonto-Staging-Token",p),o&&a.append("X-Qonto-Idempotency-Key",o),a.append("Content-Type","application/json"),a.append("Accept-Language","en"),a}export{n as buildRequestHeaders};
@@ -1 +1 @@
1
- import{EmbedIframe as e}from"./embed-iframe.js";import{environmentManager as n}from"../common/environment/environment-manager.js";function o({accessToken:e,language:o,debugMode:r}){const t=r||!1,m=o||"en";return`${n.getEnvironmentUrls().IFRAME_URL}?debug=${t}&lang=${encodeURIComponent(m)}#access_token=${encodeURIComponent(e)}`}function r({parentElementId:n,iframeUrl:o}){return new e({parentElementId:n,iframeUrl:o}).initialize()}export{o as buildIframeUrl,r as createIframe};
1
+ import{EmbedIframe as e}from"./embed-iframe.js";import{environmentManager as n}from"../common/environment/environment-manager.js";function o({accessToken:e,stagingToken:o,language:t,debugMode:r}){const m=r||!1,i=t||"en",a=n.getEnvironmentUrls().IFRAME_URL,c=o?`&staging_token=${encodeURIComponent(o)}`:"";return`${a}?debug=${m}&lang=${encodeURIComponent(i)}#access_token=${encodeURIComponent(e)}${c}`}function t({parentElementId:n,iframeUrl:o}){return new e({parentElementId:n,iframeUrl:o}).initialize()}export{o as buildIframeUrl,t as createIframe};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qonto/embed-sdk",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Library to embed Qonto features in your application",
5
5
  "type": "module",
6
6
  "exports": {