@nuvei-connect/nc-websdk 1.12.2 → 1.12.3

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/README.md CHANGED
@@ -8,16 +8,15 @@ A practical guide for integrating **Nuvei WebSDK** into a React application usin
8
8
 
9
9
  | Item | Description | Example |
10
10
  |---|---|---|
11
- | **Backend Access Token** | A valid access token required by your backend to authenticate with Nuvei services. | `634f59fa0917b38886a2a781d24362c405:79ac4c2087d6053430e6abc2734f4c42fd` |
12
- | **Authentication Endpoint** | Backend nuvei endpoint to create the MFE session. | `POST https://nuvei_backend_url/auth/micro-frontend/tokens` |
11
+ | **Backend Access Token** | A valid access token required by the backend to authenticate with Nuvei services. | `634f59fa0917b38886a2a781d24362c405:79ac4c2087d6053430e6abc2734f4c42fd` |
12
+ | **Authentication Endpoint** | Backend endpoint used by the WebSDK to create the MFE session. | `POST https://api.example.com/api/auth/session` |
13
13
  | **Module Name** | The Nuvei module to be loaded by the WebSDK. | `ONBOARDING`,`DOC_UTILITY` |
14
- | **Merchant / Partner Distinguishers** | Values used to identify whether the current request is for a Merchant or Partner. | **Partner:** `isGuest: false`,`partnerId(optional):'your_partner_id'`, <br>**Merchant:** `isGuest: true`, `emailAddress: "user@example.com"` |
15
-
14
+ | **Merchant / Partner Distinguishers** | Values used to identify whether the current request is for a Merchant or Partner. | `isGuest: true`, `emailAddress: "user@example.com"`, `partnerId: "partner_123"` |
16
15
  ---
17
16
 
18
17
  # Step 1 - Installation
19
18
 
20
- Install the Nuvei WebSDK package in your `React` project:
19
+ Install the Nuvei WebSDK package:
21
20
 
22
21
  ```bash
23
22
  npm install @nuvei-connect/nc-websdk
@@ -42,31 +41,31 @@ import React, { useEffect, useRef } from "react";
42
41
 
43
42
  import NuveiSDK, { ModulesNameEnum } from "@nuvei-connect/nc-websdk";
44
43
 
44
+ const containerRef = useRef<HTMLDivElement>(null);
45
45
  ```
46
46
 
47
47
  ---
48
48
 
49
49
  # Step 3 – Mount the Nuvei WebSDK
50
50
 
51
- Initialize the SDK once the container is available. Inside `App.tsx`.
51
+ Initialize the SDK once the container is available. In `App.tsx`.
52
52
 
53
53
  ```ts
54
- const containerRef = useRef<HTMLDivElement>(null);
55
-
56
- useEffect(() => {
54
+ useEffect(() => {
57
55
  if (!containerRef.current) {
58
56
  return;
59
57
  }
60
58
 
61
59
  NuveiSDK.mount({
62
- config: {environment: "websdk_environment"},
60
+ config: {environment: "dev2"},
63
61
  container: containerRef.current.id,
64
- componentName: ModulesNameEnum.ONBOARDING_PARTNER,
62
+ componentName: ModulesNameEnum.ONBOARDING_MERCHANT,
65
63
  fetchClientSession : async() => {
66
64
  const response = await fetch(`${backendApiUrl}/api/auth/session`, { method: "POST"});
67
65
  if (!response.ok) { throw new Error(`Session error: ${response.status}`);}
68
66
  return await response.json();
69
- },
67
+ };,
68
+
70
69
  onError: (error: any) => { console.error("NuveiWebSDK Error:", error)},
71
70
  }).catch((error: any) => {
72
71
  console.error("NuveiWebSDK Mount Error:", error);
@@ -80,12 +79,12 @@ return (
80
79
 
81
80
  # Step 4. Backend Configuration
82
81
 
83
- The backend then calls the Nuvei token/session endpoint : `server.ts`
82
+ The backend then calls the Nuvei token/session endpoint : in nodejs backend
84
83
 
85
84
  ```ts
86
85
  app.post("/api/auth/session", async (_req: Request, res: Response) => {
87
86
  try {
88
- const response = await fetch('nuvei_auth_endpoint_for_mfe_token', {
87
+ const response = await fetch('https://nuvei_backend_url/dev2/v1/auth/micro-frontend/tokens', {
89
88
  method: "POST",
90
89
  headers: {
91
90
  "Content-Type": "application/json",
@@ -98,6 +97,8 @@ app.post("/api/auth/session", async (_req: Request, res: Response) => {
98
97
  },
99
98
  ],
100
99
  isGuest: false,
100
+ emailAddress: "your_email_address",
101
+ partnerId:"your_partner_id"
101
102
  }),
102
103
  });
103
104
 
@@ -114,29 +115,76 @@ These are the **minimum requirements** needed to integrate the Nuvei Web SDK.
114
115
 
115
116
  If additional configuration or advanced options are required, please refer to the **sections below in this documentation** for detailed configuration references and usage examples.
116
117
 
118
+ ---
119
+
120
+ # Complete React Implementation
121
+
122
+ ## `App.tsx`
123
+
124
+ The following is the complete minimal React implementation:
125
+
126
+ ```tsx
127
+ import React, { useEffect, useRef } from "react";
128
+
129
+ import NuveiSDK, { ModulesNameEnum } from "@nuvei-connect/nc-websdk";
130
+
131
+ const App: React.FC = () => {
132
+ const containerRef = useRef<HTMLDivElement>(null);
133
+
134
+ const backendApiUrl =
135
+ import.meta.env.BACKEND_API_URL || "http://localhost:3005";
136
+
137
+ useEffect(() => {
138
+ if (!containerRef.current) {
139
+ return;
140
+ }
141
+
142
+ NuveiSDK.mount({
143
+ config: {environment: "dev2"},
144
+ container: containerRef.current.id,
145
+ componentName: ModulesNameEnum.ONBOARDING_MERCHANT,
146
+ fetchClientSession : async() => {
147
+ const response = await fetch(`${backendApiUrl}/api/auth/session`, { method: "POST"});
148
+ if (!response.ok) { throw new Error(`Session error: ${response.status}`);}
149
+ return await response.json();
150
+ },
151
+
152
+ onError: (error: any) => { console.error("NuveiWebSDK Error:", error)},
153
+ }).catch((error: any) => {
154
+ console.error("NuveiWebSDK Mount Error:", error);
155
+ });
156
+ }, []);
157
+
158
+
159
+ return (<div id="nuvei-websdk-container" ref={containerRef} style={{width: "100%",height: "100%" }}/>);
160
+ };
161
+
162
+ export default App;
163
+ ```
117
164
 
118
165
  ---
119
166
 
120
- # Loading Different Modules
167
+ # 5. Loading Different Modules
121
168
 
122
169
  The Nuvei WebSDK supports separate modules for different use cases:
123
170
 
124
171
  | Module | Purpose | Component |
125
172
  | --------------- | ------------------------------- | -------------------------------------------- |
126
- | **ONBOARDING** | Merchant Onboarding and Merchant Invitation | `ONBOARDING_MERCHANT` / `ONBOARDING_PARTNER` |
173
+ | **ONBOARDING** | Merchant and Partner onboarding | `ONBOARDING_MERCHANT` / `ONBOARDING_PARTNER` |
127
174
  | **DOC_UTILITY** | Document utility operations | `DOC_UTILITY` |
128
175
 
129
176
  For **Onboarding**, the backend authentication request and the SDK `componentName` determine whether the flow is for a **Merchant** or **Partner**.
130
177
 
131
178
  ---
132
179
 
133
- ## a. Merchant Invitation
180
+ ## 5.1 Partner Onboarding
134
181
 
135
- For Merchant Invitation, provide the following values when authenticating with the Nuvei backend:
182
+ For Partner onboarding, provide the following values when authenticating with the Nuvei backend:
136
183
 
137
184
  * **Module:** `ONBOARDING`
138
185
  * **isGuest:** `false`
139
- * **partnerId(required for partnerStaff, optional for nuveiStaff):** Partner ID
186
+ * **emailAddress(optional):** Partner email address
187
+ * **partnerId(optional):** Partner ID
140
188
 
141
189
  Backend Authentication Request:
142
190
 
@@ -148,6 +196,7 @@ body: JSON.stringify({
148
196
  },
149
197
  ],
150
198
  isGuest: false,
199
+ emailAddress: "your_partner_email_address",
151
200
  partnerId: "your_partner_id",
152
201
  }),
153
202
  ```
@@ -163,14 +212,14 @@ NuveiSDK.mount({
163
212
 
164
213
  ---
165
214
 
166
- ## b. Merchant Onboarding
215
+ ## 5.2 Merchant Onboarding
167
216
 
168
217
  For Merchant onboarding, provide the following values when authenticating with the Nuvei backend:
169
218
 
170
219
  * **Module:** `ONBOARDING`
171
220
  * **isGuest:** `true`
172
221
  * **emailAddress:** Merchant email address
173
- * **partnerId(optional):** Partner ID to which specific merchant belongs to
222
+ * **partnerId(optional):** Partner ID
174
223
 
175
224
  Backend Authentication Request:
176
225
 
@@ -182,7 +231,8 @@ body: JSON.stringify({
182
231
  },
183
232
  ],
184
233
  isGuest: true,
185
- emailAddress: "your_merchant_email_address"
234
+ emailAddress: "your_merchant_email_address",
235
+ partnerId: "your_partner_id",
186
236
  }),
187
237
  ```
188
238
 
@@ -196,7 +246,7 @@ NuveiSDK.mount({
196
246
 
197
247
  ---
198
248
 
199
- ## c. Document Utility
249
+ ## 5.3 Document Utility
200
250
 
201
251
  Document Utility is a separate module from Onboarding.
202
252
 
@@ -211,7 +261,6 @@ Example:
211
261
  NuveiSDK.mount({
212
262
  container: containerRef.current.id,
213
263
  componentName: ModulesNameEnum.DOC_UTILITY,
214
- config: {environment: "websdk_environment" , documentRequestId : 'your_document_request_id'},
215
264
  });
216
265
  ```
217
266
 
@@ -221,11 +270,11 @@ The authentication/session request should include the module required by the Doc
221
270
 
222
271
 
223
272
 
224
- # Session Lifecycle Callbacks
273
+ # 6. Session Lifecycle Callbacks
225
274
 
226
275
  For applications that need full session lifecycle management, the SDK can receive:
227
276
 
228
- a. `fetchClientSession`
277
+ 1.`fetchClientSession`
229
278
  Creates or retrieves the each session required by the SDK to communicate with the Nuvei backend.
230
279
  ```tsx
231
280
  const fetchClientSession = async () => {
@@ -241,7 +290,7 @@ const fetchClientSession = async () => {
241
290
  };
242
291
  ```
243
292
 
244
- b.`refreshClientSession`
293
+ 2.`refreshClientSession`
245
294
  Refreshes the current session using the refresh token. The SDK can use this callback when the existing session is expired or approaching expiration
246
295
  ```tsx
247
296
  const refreshClientSession = async (refreshToken: string) => {
@@ -265,7 +314,7 @@ const refreshClientSession = async (refreshToken: string) => {
265
314
  };
266
315
  ```
267
316
 
268
- c.`destroySession`
317
+ 3.`destroySession`
269
318
  Terminates the current session on the backend. This is typically used when the user logs out or when the SDK session needs to be explicitly invalidated.
270
319
  ```tsx
271
320
  const destroySession = async () => {
@@ -283,127 +332,154 @@ const destroySession = async () => {
283
332
 
284
333
  ---
285
334
 
286
- ## Modules Switching
335
+ ## 13. Configuration References
287
336
 
288
- Module switching should be implemented with one React page for each WebSDK module. In the demo project, the pages are exposed through these routes:
337
+ | Property | Type | Default | Description |
338
+ | ----------------------- | --------------------------- | ----------------------- | ---------------------------------------------------------- |
339
+ | **`moduleName`** | `ModulesNameEnum \| string` | `ONBOARDING_MERCHANT` | Nuvei module to render |
340
+ | **`requestId`** | `string` | `undefined` | Onboarding application/request ID |
341
+ | **`documentRequestId`** | `string` | `undefined` | Document Utility request ID |
342
+ | **`environment`** | `string` | — | Target environment |
343
+ | **`apiBaseUrl`** | `string` | `http://localhost:3005` | Base URL for your backend API
344
+ | **`nuveiBackendUrl`** | `string` | `https://nuvei_backend_url/dev2/v1/auth/micro-frontend/tokens` | Base URL for the Nuvei backend API |
345
+ | **`isGuest`** | `boolean` | `false` | Indicates whether the current user is a guest |
346
+ | **`emailAddress`** | `string` | `undefined` | Email address used to identify the current user |
347
+ | **`partnerId`** | `string` | `undefined` | Partner ID used when accessing the Partner onboarding flow |
348
+ | **`onCompleted`** | `(data) => void` | `undefined` | Callback invoked when the flow is completed |
349
+ | **`onError`** | `(error) => void` | `undefined` | Callback invoked when an error occurs |
350
+ | **`style`** | `React.CSSProperties` | `undefined` | Optional container styling |
289
351
 
290
- | Route | Page | WebSDK component |
291
- |---|---|---|
292
- | `/` | Redirects to the partner page | — |
293
- | `/partner` | Partner invitation | `ModulesNameEnum.ONBOARDING_PARTNER` |
294
- | `/merchant` | Merchant onboarding | `ModulesNameEnum.ONBOARDING_MERCHANT` |
295
- | `/doc-utility` | Document utility | `ModulesNameEnum.DOC_UTILITY` |
296
352
 
297
- The partner page is the default page when the React application starts. The merchant and partner pages mount the onboarding modules. The document utility page is mounted separately and receives its `documentRequestId` from the URL.
353
+ # 15. Production Checklist
354
+
355
+ Before deploying the integration, verify:
356
+
357
+ ### Frontend
358
+
359
+ - [ ] `@nuvei-connect/nc-websdk` is installed.
360
+ - [ ] Correct `ModulesNameEnum` is selected.
361
+ - [ ] SDK container has a stable `id`.
362
+ - [ ] `BACKEND_API_URL` points to the correct backend.
363
+ - [ ] `onError` is configured.
364
+ - [ ] Required session callbacks are supplied.
365
+
366
+ ### Backend
367
+
368
+ - [ ] Nuvei authorization is stored securely.
369
+ - [ ] Nuvei credentials are never exposed to the browser.
370
+ - [ ] `/api/auth/session` is implemented.
371
+ - [ ] Refresh endpoint is implemented when required.
372
+ - [ ] Destroy/logout endpoint is implemented when required.
373
+ - [ ] `emailAddress`, `partnerId`, and `isGuest` are populated from the appropriate application context.
374
+ - [ ] Correct Nuvei environment endpoints are configured.
298
375
 
299
- ### 1. Mount the partner and merchant modules
376
+ ### Environment
300
377
 
301
- The partner page uses `ONBOARDING_PARTNER` and the merchant page uses `ONBOARDING_MERCHANT`. Both pages listen for the `SWITCH_MODULE` message.
378
+ - [ ] Development environment is verified.
379
+ - [ ] UAT environment is verified.
380
+ - [ ] Production configuration is separated from development configuration.
381
+ - [ ] Backend API uses HTTPS in production.
382
+
383
+ ---
384
+
385
+ # 16. Common Errors
386
+
387
+ ## SDK does not render
388
+
389
+ Check:
302
390
 
303
391
  ```tsx
304
- NuveiSDK.mount({
305
- container: containerRef.current,
306
- componentName: ModulesNameEnum.ONBOARDING_PARTNER,
307
- config: { environment: "uat" },
308
- fetchClientSession,
309
- onMessage: (message: any) => {
310
- if (
311
- message.source === "NUVEI_IFRAME" &&
312
- message.action === "SWITCH_MODULE"
313
- ) {
314
- const documentRequestId =
315
- message.data?.payload?.documentRequestId;
316
-
317
- const query = documentRequestId
318
- ? `?documentRequestId=${encodeURIComponent(documentRequestId)}`
319
- : "";
320
-
321
- navigate(`/doc-utility${query}`);
322
- }
323
- },
324
- });
392
+ if (!containerRef.current) {
393
+ return;
394
+ }
325
395
  ```
326
396
 
327
- For the merchant page, only the component name changes:
397
+ and confirm that the container exists:
328
398
 
329
399
  ```tsx
330
- componentName: ModulesNameEnum.ONBOARDING_MERCHANT
400
+ <div id="nuvei-websdk-container" ref={containerRef} />
331
401
  ```
332
402
 
333
- The session request must also use the correct onboarding details for the page. For example, partner invitation uses `isGuest: false`, while merchant onboarding uses `isGuest: true`:
403
+ ---
334
404
 
335
- ```tsx
336
- body: JSON.stringify({
337
- modules: [{ name: "ONBOARDING" }],
338
- isGuest: false,
339
- }),
405
+ ## Session request fails
406
+
407
+ Check the browser network request:
408
+
409
+ ```text
410
+ POST /api/auth/session
340
411
  ```
341
412
 
342
- ### 2. Mount Document Utility on its own page
413
+ Then verify:
414
+
415
+ 1. Backend is running.
416
+ 2. `BACKEND_API_URL` is correct.
417
+ 3. Backend can reach Nuvei.
418
+ 4. `NUVEI_AUTHORIZATION` is valid.
419
+ 5. Required session parameters are populated.
420
+ 6. The backend returns valid JSON.
343
421
 
344
- The document utility page reads `documentRequestId` from the current URL and passes it to the SDK configuration:
422
+ ---
423
+
424
+ ## SDK mount fails
425
+
426
+ Check the SDK error callback:
345
427
 
346
428
  ```tsx
347
- const documentRequestId = new URLSearchParams(
348
- window.location.search,
349
- ).get("documentRequestId");
429
+ onError: (error) => {
430
+ console.error("NuveiWebSDK Error:", error);
431
+ };
432
+ ```
350
433
 
351
- NuveiSDK.mount({
352
- container: containerRef.current,
353
- componentName: ModulesNameEnum.DOC_UTILITY,
354
- config: {
355
- environment: "uat",
356
- documentRequestId: documentRequestId ?? undefined,
357
- },
358
- fetchClientSession,
359
- onMessage: (message: any) => {
360
- if (
361
- message.source === "NUVEI_IFRAME" &&
362
- message.action === "SWITCH_MODULE"
363
- ) {
364
- navigate("/partner");
365
- }
366
- },
434
+ Also check the promise rejection:
435
+
436
+ ```tsx
437
+ .catch((error) => {
438
+ console.error(
439
+ "NuveiWebSDK Mount Error:",
440
+ error
441
+ );
367
442
  });
368
443
  ```
369
444
 
370
- When an onboarding module sends `SWITCH_MODULE`, the app navigates to a URL such as:
445
+ ---
371
446
 
372
- ```text
373
- /doc-utility?documentRequestId=your_document_request_id
374
- ```
447
+ # 17. Minimal Integration
375
448
 
376
- The document utility page then uses that value to initialize the requested document flow. The backend session request for this page must include the `DOC_UTILITY` module:
449
+ If you only need the simplest integration, the essential flow is:
377
450
 
378
451
  ```tsx
379
- body: JSON.stringify({
380
- modules: [{ name: "DOC_UTILITY" }],
381
- isGuest: true,
382
- }),
452
+ const fetchClientSession = async () => {
453
+ const response = await fetch(`${backendApiUrl}/api/auth/session`, {
454
+ method: "POST",
455
+ });
456
+
457
+ if (!response.ok) {
458
+ throw new Error(`Session error: ${response.status}`);
459
+ }
460
+
461
+ return response.json();
462
+ };
463
+
464
+ useEffect(() => {
465
+ if (!containerRef.current) {
466
+ return;
467
+ }
468
+
469
+ NuveiSDK.mount({
470
+ container: containerRef.current.id,
471
+ componentName: ModulesNameEnum.ONBOARDING_MERCHANT,
472
+ fetchClientSession,
473
+
474
+ config: {
475
+ environment: "dev2",
476
+ },
477
+ });
478
+ }, []);
383
479
  ```
384
480
 
385
- Each page is responsible for mounting its own SDK component. The partner and merchant pages navigate to Document Utility with `documentRequestId`. The Document Utility page listens for `SWITCH_MODULE` and navigates back to the partner page.
386
-
387
-
388
- ## Configuration References
389
-
390
- | Property | Type | Example / Default | Configure in | Description |
391
- |---|---|---|---|---|
392
- | `componentName` | `ModulesNameEnum` | `ModulesNameEnum.ONBOARDING_MERCHANT` | `NuveiSDK.mount()` | SDK component to render. Use `ONBOARDING_MERCHANT`, `ONBOARDING_PARTNER`, or `DOC_UTILITY`. |
393
- | `config.environment` | ` "uat" \| "prod"` | `config` inside `NuveiSDK.mount()` | Nuvei environment used by the WebSDK. This value must be provided inside the `config` object. |
394
- | `config.requestId` | `string` | `"onboarding-request-123"` | `config` inside `NuveiSDK.mount()` | Optional onboarding application or request identifier. Provide this inside `config` when continuing or loading a specific onboarding request. |
395
- | `config.documentRequestId` | `string` | `"document-request-456"` | `config` inside `NuveiSDK.mount()` | Optional Document Utility request identifier. Provide this inside `config` when operating on a specific document request. |
396
- | `container` | `HTMLElement \| string` | `"nuvei-websdk-container"` | `NuveiSDK.mount()` | DOM element or element ID where the SDK iframe will be rendered. |
397
- | `fetchClientSession` | `() => Promise<IClientSession>` | `fetchClientSession` | `NuveiSDK.mount()` | Required callback that requests a client session from your backend. |
398
- | `refreshClientSession` | `(params: { refreshToken: string; accessToken: string }) => Promise<IClientRefreshSession>` | `refreshClientSession` | `NuveiSDK.mount()` | Optional callback used to refresh an expired or expiring client session. |
399
- | `destroySession` | `() => Promise<boolean>` | `destroySession` | `NuveiSDK.mount()` | Optional callback used to invalidate or destroy the backend session. |
400
- | `onReady` | `(instance) => void` | `onReady` | `NuveiSDK.mount()` | Optional callback invoked when the SDK is initialized and ready. |
401
- | `onError` | `(error: unknown) => void` | `onError` | `NuveiSDK.mount()` | Optional callback invoked when the SDK encounters an error. |
402
- | `onMessage` | `(message: unknown) => void` | `onMessage` | `NuveiSDK.mount()` | Optional callback for messages received from the SDK iframe. Use this if the SDK integration provides completion events through messages. |
403
- | `apiBaseUrl` | `string` | `"/api"` | Frontend application configuration | Base URL of your own backend API. This is not a Nuvei SDK configuration property. |
404
- | `nuveiBackendUrl` | `string` | `"https://<nuvei-host>/dev2/v1/auth/micro-frontend/tokens"` | Backend environment configuration | Nuvei session endpoint called by your backend. Keep this value on the server. |
405
- | `isGuest` | `boolean` | `true` or `false` | Backend session request | Indicates whether the session is being created for a guest merchant or an authenticated partner. |
406
- | `emailAddress` | `string` | `"merchant@example.com"` | Backend session request | Email address used by Nuvei to identify the current user or merchant. |
407
- | `partnerId` | `string` | `"partner_123"` | Backend session request | Optional partner identifier used for partner-related onboarding flows. |
481
+ This is the recommended starting point for a basic React integration.
408
482
 
409
483
  ---
484
+
485
+ The frontend remains responsible for rendering the WebSDK, while the backend handles the Nuvei session lifecycle and secure communication with Nuvei
package/dist/cdn-index.js CHANGED
@@ -311,16 +311,14 @@
311
311
  dev3: "https://dev3-non-pci.eastus.cloudapp.azure.com",
312
312
  dev2: "https://dev2-non-pci.eastus.cloudapp.azure.com",
313
313
  uat: "https://ignite-preprod.nuvei.com",
314
- "prod-na": "https://ignite.nuvei.com",
315
- "prod-eu": "https://ignite-eu.nuvei.com"
314
+ prod: "https://ignite.nuvei.com"
316
315
  };
317
316
  var DOCUMENT_UTILITY_BASE_URLS = {
318
317
  local: "http://localhost:5000",
319
318
  dev3: "https://dev3-non-pci.eastus.cloudapp.azure.com",
320
319
  dev2: "https://dev2-non-pci.eastus.cloudapp.azure.com",
321
320
  uat: "https://ignite-preprod.nuvei.com",
322
- "prod-na": "https://ignite.nuvei.com",
323
- "prod-eu": "https://ignite-eu.nuvei.com"
321
+ prod: "https://ignite.nuvei.com"
324
322
  };
325
323
  var MODULE_PATHS = {
326
324
  ["ONBOARDING_PARTNER" /* ONBOARDING_PARTNER */]: "/_onboarding/partner/application",
@@ -329,11 +327,11 @@
329
327
  };
330
328
  var DOCUMENT_REQUEST_ID_PARAM = "documentRequestId";
331
329
  var REQUEST_ID_PARAM = "requestId";
332
- var getEnvironmentBaseUrl = (environment) => {
330
+ var getEnvironmentBaseUrl = (environment = "prod") => {
333
331
  var _a;
334
332
  return (_a = ENVIRONMENT_BASE_URLS[environment]) != null ? _a : ENVIRONMENT_BASE_URLS.prod;
335
333
  };
336
- var getDocumentUtilityBaseUrl = (environment) => {
334
+ var getDocumentUtilityBaseUrl = (environment = "prod") => {
337
335
  var _a;
338
336
  return (_a = DOCUMENT_UTILITY_BASE_URLS[environment]) != null ? _a : DOCUMENT_UTILITY_BASE_URLS.prod;
339
337
  };
@@ -365,21 +363,22 @@
365
363
  return getEnvironmentBaseUrl(environment);
366
364
  };
367
365
  var resolveIframeUrl = (componentName, config) => {
368
- var _a, _b;
369
- const environment = config.environment;
370
- if (!environment) {
371
- throw new Error("Websdk Environment is not configured");
372
- }
373
- const baseUrl = getBaseUrl(componentName, environment, config);
366
+ var _a, _b, _c;
367
+ const environment = (_a = config.environment) != null ? _a : "prod";
368
+ const baseUrl = getBaseUrl(
369
+ componentName,
370
+ environment,
371
+ config
372
+ );
374
373
  const path = getModulePath(componentName);
375
374
  let queryParams = {};
376
375
  if (componentName === "DOC_UTILITY" /* DOC_UTILITY */) {
377
- const documentRequestId = (_a = config.documentRequestId) != null ? _a : getDocumentRequestIdFromUrl();
376
+ const documentRequestId = (_b = config.documentRequestId) != null ? _b : getDocumentRequestIdFromUrl();
378
377
  queryParams = {
379
378
  [DOCUMENT_REQUEST_ID_PARAM]: documentRequestId
380
379
  };
381
380
  } else if (componentName === "ONBOARDING_MERCHANT" /* ONBOARDING_MERCHANT */ || componentName === "ONBOARDING_PARTNER" /* ONBOARDING_PARTNER */) {
382
- const requestId = (_b = config.requestId) != null ? _b : getRequestIdFromUrl();
381
+ const requestId = (_c = config.requestId) != null ? _c : getRequestIdFromUrl();
383
382
  queryParams = {
384
383
  [REQUEST_ID_PARAM]: requestId
385
384
  };
@@ -786,6 +785,7 @@
786
785
  this.isListeningToIframeEvents = true;
787
786
  };
788
787
  this.handleIframeMessage = (event) => {
788
+ var _a, _b, _c;
789
789
  if (!this.iframeUrl) return;
790
790
  const expectedOrigin = new URL(this.iframeUrl).origin;
791
791
  if (event.origin !== expectedOrigin) return;
@@ -793,6 +793,21 @@
793
793
  if ((data == null ? void 0 : data.source) !== "NUVEI_IFRAME") return;
794
794
  if (this.isDestroyed) return;
795
795
  console.log("Received from iframe:(Web SDK)", data);
796
+ if (data.action === "CHECK_SESSION_EXPIRY" && typeof data.requestId === "string") {
797
+ const expiry = (_a = this.cachedSession) == null ? void 0 : _a.accessTokenExpiry;
798
+ const expiryTime = expiry ? new Date(expiry).getTime() : Number.NaN;
799
+ if (Number.isFinite(expiryTime)) {
800
+ (_c = (_b = this.currentIframe) == null ? void 0 : _b.contentWindow) == null ? void 0 : _c.postMessage(
801
+ {
802
+ source: "NUVEI_PORTAL",
803
+ action: "CHECK_SESSION_EXPIRY_RESULT",
804
+ requestId: data.requestId,
805
+ data: { valid: expiryTime > Date.now() }
806
+ },
807
+ expectedOrigin
808
+ );
809
+ }
810
+ }
796
811
  if (this.onMessage) {
797
812
  this.onMessage(data);
798
813
  }
@@ -1,3 +1,3 @@
1
- "use strict";(()=>{var P=Object.defineProperty,U=Object.defineProperties;var _=Object.getOwnPropertyDescriptors;var w=Object.getOwnPropertySymbols;var L=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var C=(r,e,s)=>e in r?P(r,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[e]=s,h=(r,e)=>{for(var s in e||(e={}))L.call(e,s)&&C(r,s,e[s]);if(w)for(var s of w(e))F.call(e,s)&&C(r,s,e[s]);return r},S=(r,e)=>U(r,_(e));var u=(r,e,s)=>new Promise((t,n)=>{var i=c=>{try{o(s.next(c))}catch(l){n(l)}},a=c=>{try{o(s.throw(c))}catch(l){n(l)}},o=c=>c.done?t(c.value):Promise.resolve(c.value).then(i,a);o((s=s.apply(r,e)).next())});var m=(t=>(t.ONBOARDING_PARTNER="ONBOARDING_PARTNER",t.ONBOARDING_MERCHANT="ONBOARDING_MERCHANT",t.DOC_UTILITY="DOC_UTILITY",t))(m||{});var v=r=>{if(r&&typeof r=="object"){let e=Object.keys(r),s=e.length,t=e.length?"?":"";return e.forEach((n,i)=>{let a=i+1,o=r[n],c=r[e[a]];if(a<s&&y(o)){let l=t+n+"="+o;y(c)?t=l+"&":t=l}else y(o)&&(t=t+n+"="+o)}),t}return""},y=r=>!(r==null||r===""||typeof r=="number"&&Number.isNaN(r)||typeof r=="string"&&r.trim()===""),p=r=>{let e=t=>t!=null&&!(Array.isArray(t)&&t.length===0)&&!(typeof t=="object"&&Object.keys(t).length===0)&&!(typeof t=="string"&&t.trim()==="");if(!r||typeof r!="object")return;let s={};for(let t in r)if(r.hasOwnProperty(t)){let n=r[t];if(e(n))if(Array.isArray(n)){let i=n.filter(a=>e(a)).map(p).filter(a=>e(a));i.length&&(s[t]=i)}else if(typeof n=="object"){let i=p(n);e(i)&&(s[t]=i)}else s[t]=n}return Object.keys(s).length?s:void 0};var K={isSuccess:!1,accessToken:"",accessTokenExpiry:"",refreshToken:"",refreshTokenExpiry:""},W={isSuccess:!1,accessToken:"",accessTokenExpiry:""},g=class{constructor(e,s){this.currentAccessToken="";this.fetchClientSession=()=>u(this,null,function*(){let e=this.getAuthUrl("/auth/micro-frontend/tokens"),s=p({modules:[{name:this.getAuthModuleName()}],referenceId:this.authConfig.referenceId});try{let t=yield fetch(e,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(s)}),n=yield this.parseJsonResponse(t,e,"Frontend AccessToken");return this.currentAccessToken=n.accessToken||"",S(h(h({},K),n),{isSuccess:!0})}catch(t){throw this.createAuthError("Frontend AccessToken",e,t)}});this.refreshClientSession=e=>u(this,null,function*(){let s=this.getAuthUrl("/auth/micro-frontend/tokens/refresh");try{let t=yield fetch(s,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(p(e))}),n=yield this.parseJsonResponse(t,s,"Frontend AccessToken Refresh");return this.currentAccessToken=n.accessToken||this.currentAccessToken,S(h(h({},W),n),{isSuccess:!0})}catch(t){throw this.createAuthError("Frontend AccessToken Refresh",s,t)}});this.destroySession=()=>u(this,null,function*(){if(!this.currentAccessToken)return!0;let e=this.getAuthUrl("/auth/access-token/revoke");try{let s=yield fetch(e,{method:"POST",headers:this.getHeaders(),body:JSON.stringify({accessToken:this.currentAccessToken})});if(!s.ok){let t=yield s.text();throw new Error(`Session revoke failed(Web SDK): ${s.status} ${s.statusText}. URL: ${e}. Response: ${t.slice(0,200)}`)}return this.currentAccessToken="",!0}catch(s){return console.error(this.createAuthError("Session revoke",e,s).message),!1}});this.getAuthModuleName=()=>{switch(this.moduleName){case"ONBOARDING_PARTNER":case"ONBOARDING_MERCHANT":return"ONBOARDING";default:return this.moduleName||""}};this.getHeaders=()=>({Authorization:this.authConfig.authToken||"","Content-Type":"application/json"});this.getAuthUrl=e=>{var t;let s=(t=this.authConfig.authApiUrl)==null?void 0:t.trim();if(!s)throw new Error("authConfig.authApiUrl is required(Web SDK)");return`${s.replace(/\/$/,"")}${e}`};this.parseJsonResponse=(e,s,t)=>u(null,null,function*(){let n=yield e.text();if(!e.ok)throw new Error(`${t} Error Response(Web SDK): ${e.status} ${e.statusText}. URL: ${s}. Response: ${n.slice(0,200)}`);let i=e.headers.get("content-type")||"";if(!i.includes("application/json"))throw new Error(`${t} expected JSON response(Web SDK). URL: ${s}. Content-Type: ${i||"unknown"}. Response: ${n.slice(0,200)}`);try{return JSON.parse(n)}catch(a){throw new Error(`${t} JSON parse failed(Web SDK). URL: ${s}. Response: ${n.slice(0,200)}`)}});this.createAuthError=(e,s,t)=>{if(t instanceof Error&&t.message.includes("(Web SDK)"))return t;let i=(t instanceof Error?t.message:String(t)).includes("Failed to fetch")?" This usually means the browser blocked the request because of CORS, the URL is unreachable, or the request was blocked before a response was returned.":"";return new Error(`${e} Request Failed(Web SDK). URL: ${s}.${i}`)};this.authConfig=e,this.moduleName=s}};function T(r,e){let s=h({},r);for(let t of Object.keys(e))r[t]&&typeof r[t]=="object"&&typeof e[t]=="object"&&!Array.isArray(r[t])&&!Array.isArray(e[t])?s[t]=T(r[t],e[t]):s[t]=e[t];return s}var E={iframeId:"nc-web-sdk-iframe",containerId:"websdk-container",iframeStyle:{width:"100%",height:"100vh",border:"none",display:"block"},sessionValidation:(r,e)=>!r||!e?!1:new Date(e)>new Date,sessionCheckInterval:10*60*1e3,environment:"uat"};var D=r=>{if(!r)return!0;let e;if(r instanceof Date)e=r;else if(typeof r=="number")e=new Date(r);else if(typeof r=="string"){let s=r.trim().replace(" ","T");e=new Date(s)}else return!0;return isNaN(e.getTime())?!0:Date.now()>e.getTime()};var N={local:"http://localhost:4000",dev3:"https://dev3-non-pci.eastus.cloudapp.azure.com",dev2:"https://dev2-non-pci.eastus.cloudapp.azure.com",uat:"https://ignite-preprod.nuvei.com","prod-na":"https://ignite.nuvei.com","prod-eu":"https://ignite-eu.nuvei.com"},b={local:"http://localhost:5000",dev3:"https://dev3-non-pci.eastus.cloudapp.azure.com",dev2:"https://dev2-non-pci.eastus.cloudapp.azure.com",uat:"https://ignite-preprod.nuvei.com","prod-na":"https://ignite.nuvei.com","prod-eu":"https://ignite-eu.nuvei.com"},$={ONBOARDING_PARTNER:"/_onboarding/partner/application",ONBOARDING_MERCHANT:"/_onboarding/merchant/application",DOC_UTILITY:"/_document-upload"},M="documentRequestId",O="requestId",B=r=>{var e;return(e=N[r])!=null?e:N.prod},H=r=>{var e;return(e=b[r])!=null?e:b.prod},V=r=>{var e;return(e=$[r])!=null?e:""},q=()=>typeof window=="undefined"?null:new URLSearchParams(window.location.search).get(M),G=()=>typeof window=="undefined"?null:new URLSearchParams(window.location.search).get(O),Q=(r,e,s)=>s.iframeBaseUrl?s.iframeBaseUrl:r==="DOC_UTILITY"?H(e):B(e),x=(r,e)=>{var o,c;let s=e.environment;if(!s)throw new Error("Websdk Environment is not configured");let t=Q(r,s,e),n=V(r),i={};if(r==="DOC_UTILITY"){let l=(o=e.documentRequestId)!=null?o:q();i={[M]:l}}else if(r==="ONBOARDING_MERCHANT"||r==="ONBOARDING_PARTNER"){let l=(c=e.requestId)!=null?c:G();i={[O]:l}}let a=v(i);return`${t}${n}${a}`};var f=class f{constructor(e){this.sdkConfig=h({},E);this.currentIframe=null;this.iframeUrl="";this.isIframeReady=!1;this.messageQueue=[];this.cachedSession=null;this.sessionCheckInterval=null;this.expiryTimeout=null;this.retryAttempts=0;this.MAX_RETRIES=3;this.REFRESH_BUFFER_MS=60*1e3;this.isListeningToIframeEvents=!1;this.isDestroyed=!1;this.initialize=()=>u(this,null,function*(){var e,s;if(this.isDestroyed=!1,!this.componentName)throw new Error("componentName is required to initialize the SDK(Web SDK)");try{let t=yield this.loadComponent(this.componentName);return this.isDestroyed||(yield(e=this.onReady)==null?void 0:e.call(this,this)),t}catch(t){throw(s=this.onError)==null||s.call(this,t),t}});this.loadComponent=e=>u(this,null,function*(){console.log("Component Requested to Load(Web SDK): ",e);try{let s=yield this.getClientSession();if(!this.sdkConfig.sessionValidation(s==null?void 0:s.accessToken,s==null?void 0:s.accessTokenExpiry))throw new Error("Token Validation FailedLoad(Web SDK)");this.iframeUrl=x(e,this.sdkConfig),console.log(`
1
+ "use strict";(()=>{var P=Object.defineProperty,U=Object.defineProperties;var _=Object.getOwnPropertyDescriptors;var C=Object.getOwnPropertySymbols;var K=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;var w=(r,e,s)=>e in r?P(r,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[e]=s,h=(r,e)=>{for(var s in e||(e={}))K.call(e,s)&&w(r,s,e[s]);if(C)for(var s of C(e))L.call(e,s)&&w(r,s,e[s]);return r},E=(r,e)=>U(r,_(e));var u=(r,e,s)=>new Promise((t,n)=>{var i=c=>{try{o(s.next(c))}catch(l){n(l)}},a=c=>{try{o(s.throw(c))}catch(l){n(l)}},o=c=>c.done?t(c.value):Promise.resolve(c.value).then(i,a);o((s=s.apply(r,e)).next())});var p=(t=>(t.ONBOARDING_PARTNER="ONBOARDING_PARTNER",t.ONBOARDING_MERCHANT="ONBOARDING_MERCHANT",t.DOC_UTILITY="DOC_UTILITY",t))(p||{});var N=r=>{if(r&&typeof r=="object"){let e=Object.keys(r),s=e.length,t=e.length?"?":"";return e.forEach((n,i)=>{let a=i+1,o=r[n],c=r[e[a]];if(a<s&&I(o)){let l=t+n+"="+o;I(c)?t=l+"&":t=l}else I(o)&&(t=t+n+"="+o)}),t}return""},I=r=>!(r==null||r===""||typeof r=="number"&&Number.isNaN(r)||typeof r=="string"&&r.trim()===""),y=r=>{let e=t=>t!=null&&!(Array.isArray(t)&&t.length===0)&&!(typeof t=="object"&&Object.keys(t).length===0)&&!(typeof t=="string"&&t.trim()==="");if(!r||typeof r!="object")return;let s={};for(let t in r)if(r.hasOwnProperty(t)){let n=r[t];if(e(n))if(Array.isArray(n)){let i=n.filter(a=>e(a)).map(y).filter(a=>e(a));i.length&&(s[t]=i)}else if(typeof n=="object"){let i=y(n);e(i)&&(s[t]=i)}else s[t]=n}return Object.keys(s).length?s:void 0};var F={isSuccess:!1,accessToken:"",accessTokenExpiry:"",refreshToken:"",refreshTokenExpiry:""},W={isSuccess:!1,accessToken:"",accessTokenExpiry:""},g=class{constructor(e,s){this.currentAccessToken="";this.fetchClientSession=()=>u(this,null,function*(){let e=this.getAuthUrl("/auth/micro-frontend/tokens"),s=y({modules:[{name:this.getAuthModuleName()}],referenceId:this.authConfig.referenceId});try{let t=yield fetch(e,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(s)}),n=yield this.parseJsonResponse(t,e,"Frontend AccessToken");return this.currentAccessToken=n.accessToken||"",E(h(h({},F),n),{isSuccess:!0})}catch(t){throw this.createAuthError("Frontend AccessToken",e,t)}});this.refreshClientSession=e=>u(this,null,function*(){let s=this.getAuthUrl("/auth/micro-frontend/tokens/refresh");try{let t=yield fetch(s,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(y(e))}),n=yield this.parseJsonResponse(t,s,"Frontend AccessToken Refresh");return this.currentAccessToken=n.accessToken||this.currentAccessToken,E(h(h({},W),n),{isSuccess:!0})}catch(t){throw this.createAuthError("Frontend AccessToken Refresh",s,t)}});this.destroySession=()=>u(this,null,function*(){if(!this.currentAccessToken)return!0;let e=this.getAuthUrl("/auth/access-token/revoke");try{let s=yield fetch(e,{method:"POST",headers:this.getHeaders(),body:JSON.stringify({accessToken:this.currentAccessToken})});if(!s.ok){let t=yield s.text();throw new Error(`Session revoke failed(Web SDK): ${s.status} ${s.statusText}. URL: ${e}. Response: ${t.slice(0,200)}`)}return this.currentAccessToken="",!0}catch(s){return console.error(this.createAuthError("Session revoke",e,s).message),!1}});this.getAuthModuleName=()=>{switch(this.moduleName){case"ONBOARDING_PARTNER":case"ONBOARDING_MERCHANT":return"ONBOARDING";default:return this.moduleName||""}};this.getHeaders=()=>({Authorization:this.authConfig.authToken||"","Content-Type":"application/json"});this.getAuthUrl=e=>{var t;let s=(t=this.authConfig.authApiUrl)==null?void 0:t.trim();if(!s)throw new Error("authConfig.authApiUrl is required(Web SDK)");return`${s.replace(/\/$/,"")}${e}`};this.parseJsonResponse=(e,s,t)=>u(null,null,function*(){let n=yield e.text();if(!e.ok)throw new Error(`${t} Error Response(Web SDK): ${e.status} ${e.statusText}. URL: ${s}. Response: ${n.slice(0,200)}`);let i=e.headers.get("content-type")||"";if(!i.includes("application/json"))throw new Error(`${t} expected JSON response(Web SDK). URL: ${s}. Content-Type: ${i||"unknown"}. Response: ${n.slice(0,200)}`);try{return JSON.parse(n)}catch(a){throw new Error(`${t} JSON parse failed(Web SDK). URL: ${s}. Response: ${n.slice(0,200)}`)}});this.createAuthError=(e,s,t)=>{if(t instanceof Error&&t.message.includes("(Web SDK)"))return t;let i=(t instanceof Error?t.message:String(t)).includes("Failed to fetch")?" This usually means the browser blocked the request because of CORS, the URL is unreachable, or the request was blocked before a response was returned.":"";return new Error(`${e} Request Failed(Web SDK). URL: ${s}.${i}`)};this.authConfig=e,this.moduleName=s}};function T(r,e){let s=h({},r);for(let t of Object.keys(e))r[t]&&typeof r[t]=="object"&&typeof e[t]=="object"&&!Array.isArray(r[t])&&!Array.isArray(e[t])?s[t]=T(r[t],e[t]):s[t]=e[t];return s}var R={iframeId:"nc-web-sdk-iframe",containerId:"websdk-container",iframeStyle:{width:"100%",height:"100vh",border:"none",display:"block"},sessionValidation:(r,e)=>!r||!e?!1:new Date(e)>new Date,sessionCheckInterval:600*1e3,environment:"uat"};var D=r=>{if(!r)return!0;let e;if(r instanceof Date)e=r;else if(typeof r=="number")e=new Date(r);else if(typeof r=="string"){let s=r.trim().replace(" ","T");e=new Date(s)}else return!0;return isNaN(e.getTime())?!0:Date.now()>e.getTime()};var v={local:"http://localhost:4000",dev3:"https://dev3-non-pci.eastus.cloudapp.azure.com",dev2:"https://dev2-non-pci.eastus.cloudapp.azure.com",uat:"https://ignite-preprod.nuvei.com",prod:"https://ignite.nuvei.com"},b={local:"http://localhost:5000",dev3:"https://dev3-non-pci.eastus.cloudapp.azure.com",dev2:"https://dev2-non-pci.eastus.cloudapp.azure.com",uat:"https://ignite-preprod.nuvei.com",prod:"https://ignite.nuvei.com"},$={ONBOARDING_PARTNER:"/_onboarding/partner/application",ONBOARDING_MERCHANT:"/_onboarding/merchant/application",DOC_UTILITY:"/_document-upload"},M="documentRequestId",O="requestId",B=(r="prod")=>{var e;return(e=v[r])!=null?e:v.prod},H=(r="prod")=>{var e;return(e=b[r])!=null?e:b.prod},V=r=>{var e;return(e=$[r])!=null?e:""},q=()=>typeof window=="undefined"?null:new URLSearchParams(window.location.search).get(M),G=()=>typeof window=="undefined"?null:new URLSearchParams(window.location.search).get(O),Q=(r,e,s)=>s.iframeBaseUrl?s.iframeBaseUrl:r==="DOC_UTILITY"?H(e):B(e),x=(r,e)=>{var o,c,l;let s=(o=e.environment)!=null?o:"prod",t=Q(r,s,e),n=V(r),i={};if(r==="DOC_UTILITY"){let d=(c=e.documentRequestId)!=null?c:q();i={[M]:d}}else if(r==="ONBOARDING_MERCHANT"||r==="ONBOARDING_PARTNER"){let d=(l=e.requestId)!=null?l:G();i={[O]:d}}let a=N(i);return`${t}${n}${a}`};var f=class f{constructor(e){this.sdkConfig=h({},R);this.currentIframe=null;this.iframeUrl="";this.isIframeReady=!1;this.messageQueue=[];this.cachedSession=null;this.sessionCheckInterval=null;this.expiryTimeout=null;this.retryAttempts=0;this.MAX_RETRIES=3;this.REFRESH_BUFFER_MS=60*1e3;this.isListeningToIframeEvents=!1;this.isDestroyed=!1;this.initialize=()=>u(this,null,function*(){var e,s;if(this.isDestroyed=!1,!this.componentName)throw new Error("componentName is required to initialize the SDK(Web SDK)");try{let t=yield this.loadComponent(this.componentName);return this.isDestroyed||(yield(e=this.onReady)==null?void 0:e.call(this,this)),t}catch(t){throw(s=this.onError)==null||s.call(this,t),t}});this.loadComponent=e=>u(this,null,function*(){console.log("Component Requested to Load(Web SDK): ",e);try{let s=yield this.getClientSession();if(!this.sdkConfig.sessionValidation(s==null?void 0:s.accessToken,s==null?void 0:s.accessTokenExpiry))throw new Error("Token Validation FailedLoad(Web SDK)");this.iframeUrl=x(e,this.sdkConfig),console.log(`
2
2
  Iframe URL(Web SDK): `,this.iframeUrl,`
3
- `);let t=yield this.createIframeWithSource(this.iframeUrl,e);return this.currentIframe=t,this.updateIframeToken(s.accessToken),t}catch(s){throw this.destroyIframe(),s}});this.destroyIframe=()=>{this.currentIframe&&(this.currentIframe.remove(),this.currentIframe=null),this.stopSessionExpiryCheck()};this.destroy=()=>{this.isDestroyed=!0,this.destroyIframe(),this.messageQueue=[],this.isIframeReady=!1,window.removeEventListener("message",this.handleIframeMessage),this.isListeningToIframeEvents=!1};this.logout=()=>u(this,null,function*(){let e=!0;this.authProvider.destroySession&&(e=yield this.authProvider.destroySession()),e?(this.stopSessionExpiryCheck(),this.destroyIframe()):console.error("Logout failed(Web SDK)")});this.updateIframeNavigation=e=>{this.enqueueMessage("NAVIGATE",e)};this.sendCustomDataToIframe=e=>{this.enqueueMessage("CUSTOM_DATA",e)};this.getClientSession=()=>u(this,null,function*(){var e,s,t,n;try{if(this.cachedSession&&((t=this.sdkConfig)!=null&&t.sessionValidation((e=this.cachedSession)==null?void 0:e.accessToken,(s=this.cachedSession)==null?void 0:s.accessTokenExpiry)))return this.cachedSession;{let i=yield this.authProvider.fetchClientSession();if(!(i!=null&&i.accessToken))throw new Error("Client Session Fetch Failed(Web SDK)");if(!((n=this.sdkConfig)!=null&&n.sessionValidation(i.accessToken,i.accessTokenExpiry)))throw new Error("Client Session Validation Failed(Web SDK)");return this.cachedSession=i,this.retryAttempts=0,i}}catch(i){throw i}});this.refreshedClientSession=()=>u(this,null,function*(){var e,s;if(!((e=this.cachedSession)!=null&&e.refreshToken)||!this.cachedSession.accessToken)throw console.error("Invalid or missing refreshToken or accessToken in cashed session. Destroying iframe(Web SDK)."),this.destroyIframe(),new Error("No session found(Web SDK)");if(!this.authProvider.refreshClientSession)throw new Error("refreshClientSession is not provided(Web SDK)");try{let t=yield this.authProvider.refreshClientSession({accessToken:this.cachedSession.accessToken,refreshToken:this.cachedSession.refreshToken});if(!(t!=null&&t.accessToken))throw console.log("Invalid refresh session token(Called From Web SDK)"),new Error("Refresh Client Session Failed");if(!((s=this.sdkConfig)!=null&&s.sessionValidation(t.accessToken,t.accessTokenExpiry)))throw console.log("Invalid refresh session token(Called From Web SDK)"),new Error("Refresh Client Session Validation Failed");let n=h({},this.cachedSession);return n.accessToken=t.accessToken,n.accessTokenExpiry=t.accessTokenExpiry,this.cachedSession=n,this.retryAttempts=0,t}catch(t){throw console.error("Session Refresh Failed(Web SDK):",t),t}});this.createIframeWithSource=(e,s)=>new Promise((t,n)=>{let i=this.getContainerElement();if(!i)return n(new Error("SDK container not found(Web SDK)"));let a=this.getIframeId(s),o=document.getElementById(a);if(o){console.log(`Iframe with Id: ${a} already exists, reusing it(Web SDK)`),t(o);return}o=document.createElement("iframe"),o.src=e,o.id=a;let c=h({},this.sdkConfig.iframeStyle);c&&Object.assign(o.style,c),o.setAttribute("allow","clipboard-write *"),o.onload=()=>{console.log("Iframe loaded successfully(Web SDK)"),this.startSessionExpiryCheck(),t(o)},o.onerror=()=>{n(new Error("Iframe failed to load(Web SDK)"))},i.appendChild(o)});this.getContainerElement=()=>this.container instanceof HTMLElement?this.container:typeof this.container=="string"?document.querySelector(this.container)||document.getElementById(this.container):document.getElementById(this.sdkConfig.containerId);this.getIframeId=e=>{let s=String(e).toLowerCase().replace(/_/g,"-");return`${this.sdkConfig.iframeId}-${s}`};this.startSessionExpiryCheck=()=>u(this,null,function*(){var o,c;if(!this.authProvider.refreshClientSession){console.warn("refreshClientSession not provided, session will not be refreshed automatically(Web SDK)");return}if(D((o=this.cachedSession)==null?void 0:o.refreshTokenExpiry)){console.error("Refresh token is expired. Stopping session expiry check(Web SDK)."),this.destroyIframe();return}let s=new Date,t=(c=this.cachedSession)==null?void 0:c.accessTokenExpiry,n=t?new Date(t):null;if(!n||isNaN(n.getTime())){console.error("Invalid or missing accessTokenExpiry in session. Stopping session expiry check(Web SDK)."),this.destroyIframe();return}let i=n.getTime()-s.getTime()-this.REFRESH_BUFFER_MS,a=()=>u(this,null,function*(){try{if(this.retryAttempts>=this.MAX_RETRIES){console.warn(`Max retry attempts (${this.MAX_RETRIES}) reached. Stopping session check(Web SDK).`),this.stopSessionExpiryCheck(),this.destroyIframe();return}let l=yield this.refreshedClientSession();this.updateIframeToken(l.accessToken),this.retryAttempts=0,this.startSessionExpiryCheck()}catch(l){console.error("Failed to perform session refresh(Web SDK):",l),this.retryAttempts++,this.stopSessionExpiryCheck(),this.expiryTimeout=setTimeout(a,5e3)}});this.stopSessionExpiryCheck(),i<=0?a():this.expiryTimeout=setTimeout(a,i)});this.stopSessionExpiryCheck=()=>{this.expiryTimeout&&(clearTimeout(this.expiryTimeout),this.expiryTimeout=null),this.sessionCheckInterval&&(clearInterval(this.sessionCheckInterval),this.sessionCheckInterval=null)};this.updateIframeToken=e=>{this.enqueueMessage("UPDATE_TOKEN",e)};this.enqueueMessage=(e,s)=>{let t={action:e,source:"NUVEI_WEB_SDK",data:s};if(!this.isIframeReady){console.log("Iframe not ready, queueing message(Web SDK):",t),this.messageQueue.push(t);return}this.postMessageToIframe(t)};this.flushMessageQueue=()=>{for(console.log("Flushing message queue(Web SDK):",this.messageQueue);this.messageQueue.length>0;){let e=this.messageQueue.shift();e&&this.postMessageToIframe(e)}};this.listenToIframeEvents=()=>{this.isListeningToIframeEvents||(window.addEventListener("message",this.handleIframeMessage),this.isListeningToIframeEvents=!0)};this.handleIframeMessage=e=>{if(!this.iframeUrl)return;let s=new URL(this.iframeUrl).origin;if(e.origin!==s)return;let t=e.data;if((t==null?void 0:t.source)==="NUVEI_IFRAME"&&!this.isDestroyed)switch(console.log("Received from iframe:(Web SDK)",t),this.onMessage&&this.onMessage(t),t.action){case"IFRAME_READY":this.handleIframeReady();break;default:break}};this.handleIframeReady=()=>{console.log("Iframe is READY(Web SDK)"),this.isIframeReady=!0,this.flushMessageQueue()};this.postMessageToIframe=e=>{var t;if(!((t=this==null?void 0:this.currentIframe)!=null&&t.contentWindow)){console.warn("Iframe not available(Web SDK)");return}let s=new URL(this.iframeUrl).origin;console.log("Sending message to microfrontend(Web SDK):",e),this.currentIframe.contentWindow.postMessage(e,s)};let{fetchClientSession:s,refreshClientSession:t,destroySession:n,componentName:i,container:a,authConfig:o,config:c,onReady:l,onError:R,onMessage:k}=e;if(o){let I=new g(o,i);this.authProvider={fetchClientSession:s!=null?s:I.fetchClientSession,refreshClientSession:t!=null?t:I.refreshClientSession,destroySession:n!=null?n:I.destroySession}}else if(typeof s=="function")this.authProvider={fetchClientSession:s,refreshClientSession:t,destroySession:n};else throw new Error("authConfig or fetchClientSession is required to initialize SDK(Web SDK)");this.componentName=i,this.container=a,c&&(this.sdkConfig=T(E,c)),l&&(this.onReady=l),R&&(this.onError=R),k&&(this.onMessage=k),this.listenToIframeEvents()}};f.mount=e=>u(null,null,function*(){let s=new f(e);return yield s.initialize(),s}),f.create=f.mount;var d=f;var A=window;A.NCWebSDK=d;A.NuveiSDK=d;A.ModulesNameEnum=m;})();
3
+ `);let t=yield this.createIframeWithSource(this.iframeUrl,e);return this.currentIframe=t,this.updateIframeToken(s.accessToken),t}catch(s){throw this.destroyIframe(),s}});this.destroyIframe=()=>{this.currentIframe&&(this.currentIframe.remove(),this.currentIframe=null),this.stopSessionExpiryCheck()};this.destroy=()=>{this.isDestroyed=!0,this.destroyIframe(),this.messageQueue=[],this.isIframeReady=!1,window.removeEventListener("message",this.handleIframeMessage),this.isListeningToIframeEvents=!1};this.logout=()=>u(this,null,function*(){let e=!0;this.authProvider.destroySession&&(e=yield this.authProvider.destroySession()),e?(this.stopSessionExpiryCheck(),this.destroyIframe()):console.error("Logout failed(Web SDK)")});this.updateIframeNavigation=e=>{this.enqueueMessage("NAVIGATE",e)};this.sendCustomDataToIframe=e=>{this.enqueueMessage("CUSTOM_DATA",e)};this.getClientSession=()=>u(this,null,function*(){var e,s,t,n;try{if(this.cachedSession&&((t=this.sdkConfig)!=null&&t.sessionValidation((e=this.cachedSession)==null?void 0:e.accessToken,(s=this.cachedSession)==null?void 0:s.accessTokenExpiry)))return this.cachedSession;{let i=yield this.authProvider.fetchClientSession();if(!(i!=null&&i.accessToken))throw new Error("Client Session Fetch Failed(Web SDK)");if(!((n=this.sdkConfig)!=null&&n.sessionValidation(i.accessToken,i.accessTokenExpiry)))throw new Error("Client Session Validation Failed(Web SDK)");return this.cachedSession=i,this.retryAttempts=0,i}}catch(i){throw i}});this.refreshedClientSession=()=>u(this,null,function*(){var e,s;if(!((e=this.cachedSession)!=null&&e.refreshToken)||!this.cachedSession.accessToken)throw console.error("Invalid or missing refreshToken or accessToken in cashed session. Destroying iframe(Web SDK)."),this.destroyIframe(),new Error("No session found(Web SDK)");if(!this.authProvider.refreshClientSession)throw new Error("refreshClientSession is not provided(Web SDK)");try{let t=yield this.authProvider.refreshClientSession({accessToken:this.cachedSession.accessToken,refreshToken:this.cachedSession.refreshToken});if(!(t!=null&&t.accessToken))throw console.log("Invalid refresh session token(Called From Web SDK)"),new Error("Refresh Client Session Failed");if(!((s=this.sdkConfig)!=null&&s.sessionValidation(t.accessToken,t.accessTokenExpiry)))throw console.log("Invalid refresh session token(Called From Web SDK)"),new Error("Refresh Client Session Validation Failed");let n=h({},this.cachedSession);return n.accessToken=t.accessToken,n.accessTokenExpiry=t.accessTokenExpiry,this.cachedSession=n,this.retryAttempts=0,t}catch(t){throw console.error("Session Refresh Failed(Web SDK):",t),t}});this.createIframeWithSource=(e,s)=>new Promise((t,n)=>{let i=this.getContainerElement();if(!i)return n(new Error("SDK container not found(Web SDK)"));let a=this.getIframeId(s),o=document.getElementById(a);if(o){console.log(`Iframe with Id: ${a} already exists, reusing it(Web SDK)`),t(o);return}o=document.createElement("iframe"),o.src=e,o.id=a;let c=h({},this.sdkConfig.iframeStyle);c&&Object.assign(o.style,c),o.setAttribute("allow","clipboard-write *"),o.onload=()=>{console.log("Iframe loaded successfully(Web SDK)"),this.startSessionExpiryCheck(),t(o)},o.onerror=()=>{n(new Error("Iframe failed to load(Web SDK)"))},i.appendChild(o)});this.getContainerElement=()=>this.container instanceof HTMLElement?this.container:typeof this.container=="string"?document.querySelector(this.container)||document.getElementById(this.container):document.getElementById(this.sdkConfig.containerId);this.getIframeId=e=>{let s=String(e).toLowerCase().replace(/_/g,"-");return`${this.sdkConfig.iframeId}-${s}`};this.startSessionExpiryCheck=()=>u(this,null,function*(){var o,c;if(!this.authProvider.refreshClientSession){console.warn("refreshClientSession not provided, session will not be refreshed automatically(Web SDK)");return}if(D((o=this.cachedSession)==null?void 0:o.refreshTokenExpiry)){console.error("Refresh token is expired. Stopping session expiry check(Web SDK)."),this.destroyIframe();return}let s=new Date,t=(c=this.cachedSession)==null?void 0:c.accessTokenExpiry,n=t?new Date(t):null;if(!n||isNaN(n.getTime())){console.error("Invalid or missing accessTokenExpiry in session. Stopping session expiry check(Web SDK)."),this.destroyIframe();return}let i=n.getTime()-s.getTime()-this.REFRESH_BUFFER_MS,a=()=>u(this,null,function*(){try{if(this.retryAttempts>=this.MAX_RETRIES){console.warn(`Max retry attempts (${this.MAX_RETRIES}) reached. Stopping session check(Web SDK).`),this.stopSessionExpiryCheck(),this.destroyIframe();return}let l=yield this.refreshedClientSession();this.updateIframeToken(l.accessToken),this.retryAttempts=0,this.startSessionExpiryCheck()}catch(l){console.error("Failed to perform session refresh(Web SDK):",l),this.retryAttempts++,this.stopSessionExpiryCheck(),this.expiryTimeout=setTimeout(a,5e3)}});this.stopSessionExpiryCheck(),i<=0?a():this.expiryTimeout=setTimeout(a,i)});this.stopSessionExpiryCheck=()=>{this.expiryTimeout&&(clearTimeout(this.expiryTimeout),this.expiryTimeout=null),this.sessionCheckInterval&&(clearInterval(this.sessionCheckInterval),this.sessionCheckInterval=null)};this.updateIframeToken=e=>{this.enqueueMessage("UPDATE_TOKEN",e)};this.enqueueMessage=(e,s)=>{let t={action:e,source:"NUVEI_WEB_SDK",data:s};if(!this.isIframeReady){console.log("Iframe not ready, queueing message(Web SDK):",t),this.messageQueue.push(t);return}this.postMessageToIframe(t)};this.flushMessageQueue=()=>{for(console.log("Flushing message queue(Web SDK):",this.messageQueue);this.messageQueue.length>0;){let e=this.messageQueue.shift();e&&this.postMessageToIframe(e)}};this.listenToIframeEvents=()=>{this.isListeningToIframeEvents||(window.addEventListener("message",this.handleIframeMessage),this.isListeningToIframeEvents=!0)};this.handleIframeMessage=e=>{var n,i,a;if(!this.iframeUrl)return;let s=new URL(this.iframeUrl).origin;if(e.origin!==s)return;let t=e.data;if((t==null?void 0:t.source)==="NUVEI_IFRAME"&&!this.isDestroyed){if(console.log("Received from iframe:(Web SDK)",t),t.action==="CHECK_SESSION_EXPIRY"&&typeof t.requestId=="string"){let o=(n=this.cachedSession)==null?void 0:n.accessTokenExpiry,c=o?new Date(o).getTime():Number.NaN;Number.isFinite(c)&&((a=(i=this.currentIframe)==null?void 0:i.contentWindow)==null||a.postMessage({source:"NUVEI_PORTAL",action:"CHECK_SESSION_EXPIRY_RESULT",requestId:t.requestId,data:{valid:c>Date.now()}},s))}switch(this.onMessage&&this.onMessage(t),t.action){case"IFRAME_READY":this.handleIframeReady();break;default:break}}};this.handleIframeReady=()=>{console.log("Iframe is READY(Web SDK)"),this.isIframeReady=!0,this.flushMessageQueue()};this.postMessageToIframe=e=>{var t;if(!((t=this==null?void 0:this.currentIframe)!=null&&t.contentWindow)){console.warn("Iframe not available(Web SDK)");return}let s=new URL(this.iframeUrl).origin;console.log("Sending message to microfrontend(Web SDK):",e),this.currentIframe.contentWindow.postMessage(e,s)};let{fetchClientSession:s,refreshClientSession:t,destroySession:n,componentName:i,container:a,authConfig:o,config:c,onReady:l,onError:d,onMessage:k}=e;if(o){let S=new g(o,i);this.authProvider={fetchClientSession:s!=null?s:S.fetchClientSession,refreshClientSession:t!=null?t:S.refreshClientSession,destroySession:n!=null?n:S.destroySession}}else if(typeof s=="function")this.authProvider={fetchClientSession:s,refreshClientSession:t,destroySession:n};else throw new Error("authConfig or fetchClientSession is required to initialize SDK(Web SDK)");this.componentName=i,this.container=a,c&&(this.sdkConfig=T(R,c)),l&&(this.onReady=l),d&&(this.onError=d),k&&(this.onMessage=k),this.listenToIframeEvents()}};f.mount=e=>u(null,null,function*(){let s=new f(e);return yield s.initialize(),s}),f.create=f.mount;var m=f;var A=window;A.NCWebSDK=m;A.NuveiSDK=m;A.ModulesNameEnum=p;})();
@@ -11,7 +11,8 @@ export declare enum PostMessageActionEnum {
11
11
  }
12
12
  export type PostMessageActionType = keyof typeof PostMessageActionEnum;
13
13
  export declare enum AcknowledgeMessageActionEnum {
14
- IFRAME_READY = "IFRAME_READY"
14
+ IFRAME_READY = "IFRAME_READY",
15
+ CHECK_SESSION_EXPIRY = "CHECK_SESSION_EXPIRY"
15
16
  }
16
17
  export type AcknowledgeMessageActionType = keyof typeof AcknowledgeMessageActionEnum;
17
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/enums/index.ts"],"names":[],"mappings":"AACA,oBAAY,eAAe;IACzB,kBAAkB,uBAAuB;IACzC,mBAAmB,wBAAwB;IAC3C,WAAW,gBAAgB;CAC5B;AACD,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,eAAe,CAAC;AAG3D,oBAAY,qBAAqB;IAC/B,YAAY,iBAAiB;IAC7B,QAAQ,aAAa;IACrB,WAAW,gBAAgB;CAC5B;AACD,MAAM,MAAM,qBAAqB,GAAG,MAAM,OAAO,qBAAqB,CAAC;AAGvE,oBAAY,4BAA4B;IACtC,YAAY,iBAAiB;CAC9B;AACD,MAAM,MAAM,4BAA4B,GAAG,MAAM,OAAO,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/enums/index.ts"],"names":[],"mappings":"AACA,oBAAY,eAAe;IACzB,kBAAkB,uBAAuB;IACzC,mBAAmB,wBAAwB;IAC3C,WAAW,gBAAgB;CAC5B;AACD,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,eAAe,CAAC;AAG3D,oBAAY,qBAAqB;IAC/B,YAAY,iBAAiB;IAC7B,QAAQ,aAAa;IACrB,WAAW,gBAAgB;CAC5B;AACD,MAAM,MAAM,qBAAqB,GAAG,MAAM,OAAO,qBAAqB,CAAC;AAGvE,oBAAY,4BAA4B;IACtC,YAAY,iBAAiB;IAC7B,oBAAoB,yBAAyB;CAC9C;AACD,MAAM,MAAM,4BAA4B,GAAG,MAAM,OAAO,4BAA4B,CAAC"}
@@ -18,4 +18,5 @@ var PostMessageActionEnum;
18
18
  var AcknowledgeMessageActionEnum;
19
19
  (function (AcknowledgeMessageActionEnum) {
20
20
  AcknowledgeMessageActionEnum["IFRAME_READY"] = "IFRAME_READY";
21
+ AcknowledgeMessageActionEnum["CHECK_SESSION_EXPIRY"] = "CHECK_SESSION_EXPIRY";
21
22
  })(AcknowledgeMessageActionEnum || (exports.AcknowledgeMessageActionEnum = AcknowledgeMessageActionEnum = {}));
@@ -1,3 +1,3 @@
1
- import { INuveiSdkConfig } from "../interfaces/index";
1
+ import { INuveiSdkConfig } from "../interfaces/index.js";
2
2
  export declare const DEFAULT_CONFIG: INuveiSdkConfig;
3
3
  //# sourceMappingURL=default-config.d.ts.map
@@ -1,4 +1,4 @@
1
- import { ModulesNameEnum } from '../common/enums';
1
+ import { ModulesNameEnum } from '../common/enums/index.js';
2
2
  import { HTMLIFrameElement, INuveiInitParams } from '../interfaces';
3
3
  export default class NuveiSDK {
4
4
  private sdkConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EAGhB,MAAM,eAAe,CAAC;AAQvB,OAAO,EACL,iBAAiB,EAKjB,gBAAgB,EAEjB,MAAM,eAAe,CAAC;AAIvB,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC3B,OAAO,CAAC,SAAS,CAA0C;IAE3D,OAAO,CAAC,aAAa,CAAkC;IACvD,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,aAAa,CAAkB;IACvC,OAAO,CAAC,YAAY,CAAgC;IAEpD,OAAO,CAAC,aAAa,CAA+B;IACpD,OAAO,CAAC,oBAAoB,CAA+C;IAC3E,OAAO,CAAC,aAAa,CAA8C;IACnE,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAK;IACjC,OAAO,CAAC,iBAAiB,CAAa;IACtC,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,aAAa,CAAC,CAAkB;IACxC,OAAO,CAAC,SAAS,CAAC,CAAuB;IACzC,OAAO,CAAC,yBAAyB,CAAS;IAC1C,OAAO,CAAC,WAAW,CAAS;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OAAO,CAAC,QAAQ,CAAC,CASnC;IAE/C;;;;;OAKG;IACI,UAAU,QAAa,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAgB7D;IAEF;;;;;;;;;;;;;;;OAeG;IACI,aAAa,GAClB,eAAe,eAAe,KAC7B,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CA2BlC;IAEF;;;OAGG;IACI,aAAa,aAOlB;IAEF;;OAEG;IACI,OAAO,aAOZ;IAEF;;;;;;;OAOG;IACI,MAAM,sBAYX;IAEF;;;OAGG;IACI,sBAAsB,GAAI,MAAM,MAAM,UAE3C;IAEF;;;;OAIG;IACI,sBAAsB,GAAI,MAAM,GAAG,UAExC;IAIF;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,gBAAgB,CA4BtB;IAEF;;;;;;OAMG;IACH,OAAO,CAAC,sBAAsB,CAwC5B;IAEF;;;;;;;OAOG;IACH,OAAO,CAAC,sBAAsB,CAgD5B;IAEF,OAAO,CAAC,mBAAmB,CAUzB;IAEF,OAAO,CAAC,WAAW,CAGjB;IAEF;;;;;;;;OAQG;IACH,OAAO,CAAC,uBAAuB,CAgE7B;IAEF;;;;OAIG;IACH,OAAO,CAAC,sBAAsB,CAW5B;IAEF;;;OAGG;IACH,OAAO,CAAC,iBAAiB,CAEvB;IAEF;;;;;OAKG;IACH,OAAO,CAAC,cAAc,CAcpB;IAEF;;;;OAIG;IACH,OAAO,CAAC,iBAAiB,CAOvB;IAEF;;;OAGG;IACH,OAAO,CAAC,oBAAoB,CAK1B;IAEF,OAAO,CAAC,mBAAmB,CA8CzB;IAEF;;;OAGG;IACH,OAAO,CAAC,iBAAiB,CAIvB;IAEF;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB,CASzB;CACH"}
@@ -50,12 +50,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
50
50
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
51
  };
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
- var enums_1 = require("../common/enums");
54
- var default_auth_provider_1 = __importDefault(require("../services/default-auth-provider"));
55
- var object_utils_1 = require("../utils/object.utils");
53
+ var enums_1 = require("../common/enums/index.js");
54
+ var default_auth_provider_1 = __importDefault(require("../services/default-auth-provider.js"));
55
+ var object_utils_1 = require("../utils/object.utils.js");
56
56
  var default_config_1 = require("../config/default-config");
57
- var date_utils_1 = require("../utils/date.utils");
58
- var iframe_url_utils_1 = require("../utils/iframe-url.utils");
57
+ var date_utils_1 = require("../utils/date.utils.js");
58
+ var iframe_url_utils_1 = require("../utils/iframe-url.utils.js");
59
59
  var NuveiSDK = /** @class */ (function () {
60
60
  /**
61
61
  * Initializes the Nuvei SDK instance
@@ -530,6 +530,7 @@ var NuveiSDK = /** @class */ (function () {
530
530
  _this.isListeningToIframeEvents = true;
531
531
  };
532
532
  this.handleIframeMessage = function (event) {
533
+ var _b, _c, _d;
533
534
  if (!_this.iframeUrl)
534
535
  return;
535
536
  var expectedOrigin = new URL(_this.iframeUrl).origin;
@@ -541,6 +542,23 @@ var NuveiSDK = /** @class */ (function () {
541
542
  if (_this.isDestroyed)
542
543
  return;
543
544
  console.log('Received from iframe:(Web SDK)', data);
545
+ if (data.action === 'CHECK_SESSION_EXPIRY' && typeof data.requestId === 'string') {
546
+ var expiry = (_b = _this.cachedSession) === null || _b === void 0 ? void 0 : _b.accessTokenExpiry;
547
+ var expiryTime = expiry ? new Date(expiry).getTime() : Number.NaN;
548
+ /*
549
+ Let existing integrations keep receiving this event, while the SDK
550
+ answers the iframe's session check itself when it has an expiry value.
551
+ If expiry is unavailable, leave the message to the existing host handler.
552
+ */
553
+ if (Number.isFinite(expiryTime)) {
554
+ (_d = (_c = _this.currentIframe) === null || _c === void 0 ? void 0 : _c.contentWindow) === null || _d === void 0 ? void 0 : _d.postMessage({
555
+ source: 'NUVEI_PORTAL',
556
+ action: 'CHECK_SESSION_EXPIRY_RESULT',
557
+ requestId: data.requestId,
558
+ data: { valid: expiryTime > Date.now() },
559
+ }, expectedOrigin);
560
+ }
561
+ }
544
562
  if (_this.onMessage) {
545
563
  _this.onMessage(data);
546
564
  }
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import NuveiSDK from "./core/index";
2
- import { ModulesNameEnum } from "./common/enums/index";
3
- import { IAuthConfig, IAuthProvider, INuveiInstance, INuveiInitParams, INuveiSdkConfig } from "./interfaces/index";
1
+ import NuveiSDK from "./core/index.js";
2
+ import { ModulesNameEnum } from "./common/enums/index.js";
3
+ import { IAuthConfig, IAuthProvider, INuveiInstance, INuveiInitParams, INuveiSdkConfig } from "./interfaces/index.js";
4
4
  export default NuveiSDK;
5
5
  export { ModulesNameEnum, IAuthConfig, IAuthProvider, INuveiInstance, INuveiSdkConfig, INuveiInitParams };
6
6
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ModulesNameEnum = void 0;
7
- var index_1 = __importDefault(require("./core/index"));
8
- var index_2 = require("./common/enums/index");
7
+ var index_1 = __importDefault(require("./core/index.js"));
8
+ var index_2 = require("./common/enums/index.js");
9
9
  Object.defineProperty(exports, "ModulesNameEnum", { enumerable: true, get: function () { return index_2.ModulesNameEnum; } });
10
10
  exports.default = index_1.default;
@@ -1,4 +1,4 @@
1
- import { ModulesNameEnum } from "../common/enums";
1
+ import { ModulesNameEnum } from "../common/enums/index.js";
2
2
  export type AuthOptions = {
3
3
  authConfig: IAuthConfig;
4
4
  fetchClientSession?: () => Promise<IClientSession>;
@@ -53,7 +53,7 @@ export interface INuveiSdkConfig {
53
53
  iframeStyle: Record<string, string>;
54
54
  sessionValidation: (token: string, tokenExpiry?: string) => boolean;
55
55
  sessionCheckInterval: number;
56
- environment: 'local' | 'dev3' | 'dev2' | 'uat' | 'prod-na' | 'prod-eu';
56
+ environment: 'local' | 'dev3' | 'dev2' | 'uat' | 'prod';
57
57
  iframeBaseUrl?: string;
58
58
  requestId?: string;
59
59
  documentRequestId?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,MAAM,WAAW,GACnB;IACE,UAAU,EAAE,WAAW,CAAC;IACxB,kBAAkB,CAAC,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC,CAAC;IACnD,oBAAoB,CAAC,EAAE,CAAC,OAAO,EAAE,2BAA2B,KAAK,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAChG,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CACzC,GACD;IACE,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,kBAAkB,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC,CAAC;IAClD,oBAAoB,CAAC,EAAE,CAAC,OAAO,EAAE,2BAA2B,KAAK,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAChG,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CACzC,CAAC;AAEN,MAAM,MAAM,gBAAgB,GAAG;IAC7B,aAAa,EAAE,eAAe,CAAC;IAC/B,SAAS,EAAE,WAAW,GAAG,MAAM,CAAC;IAChC,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IAClC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;CACpC,GAAG,WAAW,CAAC;AAEhB,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAA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AC;CACnC;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;IACpD,aAAa,EAAE,CAAC,aAAa,EAAE,eAAe,KAAK,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;IACrF,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,MAAM,EAAE,MAAM,IAAI,CAAC;CAGpB"}
@@ -1,4 +1,4 @@
1
- import { AcknowledgeMessageActionType, ModulesNameType, PostMessageActionType } from "../common/enums";
1
+ import { AcknowledgeMessageActionType, ModulesNameType, PostMessageActionType } from "../common/enums/index.js";
2
2
  export interface ICommonISdkData {
3
3
  frontendAccessToken: string;
4
4
  componentName: ModulesNameType;
@@ -13,5 +13,6 @@ export interface ISdkAcknowledgeMessage {
13
13
  action: AcknowledgeMessageActionType;
14
14
  source: 'NUVEI_IFRAME';
15
15
  data: any;
16
+ requestId?: string;
16
17
  }
17
18
  //# sourceMappingURL=post-message.interfaces.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"post-message.interfaces.d.ts","sourceRoot":"","sources":["../../src/interfaces/post-message.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAErG,MAAM,WAAW,eAAe;IAC5B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,aAAa,EAAE,eAAe,CAAC;IAC/B,KAAK,CAAC,EAAE,GAAG,CAAC;CACf;AAED,MAAM,WAAW,sBAAsB;IACnC,MAAM,EAAE,qBAAqB,CAAC;IAC9B,MAAM,EAAE,eAAe,CAAC;IACxB,IAAI,EAAE,GAAG,CAAC;CACb;AAED,MAAM,WAAW,sBAAsB;IACnC,MAAM,EAAE,4BAA4B,CAAC;IACrC,MAAM,EAAE,cAAc,CAAC;IACvB,IAAI,EAAE,GAAG,CAAC;CACb"}
1
+ {"version":3,"file":"post-message.interfaces.d.ts","sourceRoot":"","sources":["../../src/interfaces/post-message.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAErG,MAAM,WAAW,eAAe;IAC5B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,aAAa,EAAE,eAAe,CAAC;IAC/B,KAAK,CAAC,EAAE,GAAG,CAAC;CACf;AAED,MAAM,WAAW,sBAAsB;IACnC,MAAM,EAAE,qBAAqB,CAAC;IAC9B,MAAM,EAAE,eAAe,CAAC;IACxB,IAAI,EAAE,GAAG,CAAC;CACb;AAED,MAAM,WAAW,sBAAsB;IACnC,MAAM,EAAE,4BAA4B,CAAC;IACrC,MAAM,EAAE,cAAc,CAAC;IACvB,IAAI,EAAE,GAAG,CAAC;IACV,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB"}
@@ -1,5 +1,5 @@
1
- import { ModulesNameEnum } from '../common/enums';
2
- import { IAuthConfig, IAuthProvider, IClientRefreshSession, IClientSession, IRefreshClientSessionParams } from '../interfaces/index';
1
+ import { ModulesNameEnum } from '../common/enums/index.js';
2
+ import { IAuthConfig, IAuthProvider, IClientRefreshSession, IClientSession, IRefreshClientSessionParams } from '../interfaces/index.js';
3
3
  export default class DefaultAuthProvider implements IAuthProvider {
4
4
  private readonly authConfig;
5
5
  private readonly moduleName?;
@@ -47,8 +47,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  }
48
48
  };
49
49
  Object.defineProperty(exports, "__esModule", { value: true });
50
- var enums_1 = require("../common/enums");
51
- var common_utils_1 = require("../utils/common.utils");
50
+ var enums_1 = require("../common/enums/index.js");
51
+ var common_utils_1 = require("../utils/common.utils.js");
52
52
  var SESSION_FAILED_RESPONSE = {
53
53
  isSuccess: false,
54
54
  accessToken: '',
@@ -1,4 +1,4 @@
1
- import { IQueryBuilderParams } from "../interfaces/utils.interfaces";
1
+ import { IQueryBuilderParams } from "../interfaces/utils.interfaces.js";
2
2
  /**
3
3
  * Constructs a query string from an object of query parameters.
4
4
  * Each key-value pair in the object is transformed into a query parameter
@@ -1,5 +1,5 @@
1
- import { ModulesNameEnum } from '../common/enums';
2
- import { INuveiSdkConfig } from '../interfaces/index';
1
+ import { ModulesNameEnum } from '../common/enums/index.js';
2
+ import { INuveiSdkConfig } from '../interfaces/index.js';
3
3
  export declare const getModulePath: (componentName: ModulesNameEnum) => string;
4
4
  /**
5
5
  * Resolves the complete iframe URL for a module.
@@ -1 +1 @@
1
- {"version":3,"file":"iframe-url.utils.d.ts","sourceRoot":"","sources":["../../src/utils/iframe-url.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAwCpD,eAAO,MAAM,aAAa,GAAI,eAAe,eAAe,KAAG,MAE9D,CAAC;AAqDF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAC3B,eAAe,eAAe,EAC9B,QAAQ,eAAe,KACtB,MAgCF,CAAC"}
1
+ {"version":3,"file":"iframe-url.utils.d.ts","sourceRoot":"","sources":["../../src/utils/iframe-url.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAmDpD,eAAO,MAAM,aAAa,GACxB,eAAe,eAAe,KAC7B,MAEF,CAAC;AAqDF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAC3B,eAAe,eAAe,EAC9B,QAAQ,eAAe,KACtB,MAiCF,CAAC"}
@@ -2,23 +2,21 @@
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.resolveIframeUrl = exports.getModulePath = void 0;
5
- var enums_1 = require("../common/enums");
5
+ var enums_1 = require("../common/enums/index.js");
6
6
  var common_utils_1 = require("./common.utils");
7
7
  var ENVIRONMENT_BASE_URLS = {
8
8
  local: 'http://localhost:4000',
9
9
  dev3: 'https://dev3-non-pci.eastus.cloudapp.azure.com',
10
10
  dev2: 'https://dev2-non-pci.eastus.cloudapp.azure.com',
11
11
  uat: 'https://ignite-preprod.nuvei.com',
12
- 'prod-na': 'https://ignite.nuvei.com',
13
- 'prod-eu': 'https://ignite-eu.nuvei.com',
12
+ prod: 'https://ignite.nuvei.com',
14
13
  };
15
14
  var DOCUMENT_UTILITY_BASE_URLS = {
16
15
  local: 'http://localhost:5000',
17
16
  dev3: 'https://dev3-non-pci.eastus.cloudapp.azure.com',
18
17
  dev2: 'https://dev2-non-pci.eastus.cloudapp.azure.com',
19
18
  uat: 'https://ignite-preprod.nuvei.com',
20
- 'prod-na': 'https://ignite.nuvei.com',
21
- 'prod-eu': 'https://ignite-eu.nuvei.com',
19
+ prod: 'https://ignite.nuvei.com',
22
20
  };
23
21
  var MODULE_PATHS = (_a = {},
24
22
  _a[enums_1.ModulesNameEnum.ONBOARDING_PARTNER] = '/_onboarding/partner/application',
@@ -29,11 +27,13 @@ var DOCUMENT_REQUEST_ID_PARAM = 'documentRequestId';
29
27
  var REQUEST_ID_PARAM = 'requestId';
30
28
  var getEnvironmentBaseUrl = function (environment) {
31
29
  var _a;
32
- return (_a = ENVIRONMENT_BASE_URLS[environment]) !== null && _a !== void 0 ? _a : ENVIRONMENT_BASE_URLS.prod;
30
+ if (environment === void 0) { environment = 'prod'; }
31
+ return ((_a = ENVIRONMENT_BASE_URLS[environment]) !== null && _a !== void 0 ? _a : ENVIRONMENT_BASE_URLS.prod);
33
32
  };
34
33
  var getDocumentUtilityBaseUrl = function (environment) {
35
34
  var _a;
36
- return (_a = DOCUMENT_UTILITY_BASE_URLS[environment]) !== null && _a !== void 0 ? _a : DOCUMENT_UTILITY_BASE_URLS.prod;
35
+ if (environment === void 0) { environment = 'prod'; }
36
+ return ((_a = DOCUMENT_UTILITY_BASE_URLS[environment]) !== null && _a !== void 0 ? _a : DOCUMENT_UTILITY_BASE_URLS.prod);
37
37
  };
38
38
  var getModulePath = function (componentName) {
39
39
  var _a;
@@ -87,23 +87,20 @@ var getBaseUrl = function (componentName, environment, config) {
87
87
  */
88
88
  var resolveIframeUrl = function (componentName, config) {
89
89
  var _a, _b;
90
- var _c, _d;
91
- var environment = config.environment;
92
- if (!environment) {
93
- throw new Error("Websdk Environment is not configured");
94
- }
90
+ var _c, _d, _e;
91
+ var environment = (_c = config.environment) !== null && _c !== void 0 ? _c : 'prod';
95
92
  var baseUrl = getBaseUrl(componentName, environment, config);
96
93
  var path = (0, exports.getModulePath)(componentName);
97
94
  var queryParams = {};
98
95
  if (componentName === enums_1.ModulesNameEnum.DOC_UTILITY) {
99
- var documentRequestId = (_c = config.documentRequestId) !== null && _c !== void 0 ? _c : getDocumentRequestIdFromUrl();
96
+ var documentRequestId = (_d = config.documentRequestId) !== null && _d !== void 0 ? _d : getDocumentRequestIdFromUrl();
100
97
  queryParams = (_a = {},
101
98
  _a[DOCUMENT_REQUEST_ID_PARAM] = documentRequestId,
102
99
  _a);
103
100
  }
104
101
  else if (componentName === enums_1.ModulesNameEnum.ONBOARDING_MERCHANT ||
105
102
  componentName === enums_1.ModulesNameEnum.ONBOARDING_PARTNER) {
106
- var requestId = (_d = config.requestId) !== null && _d !== void 0 ? _d : getRequestIdFromUrl();
103
+ var requestId = (_e = config.requestId) !== null && _e !== void 0 ? _e : getRequestIdFromUrl();
107
104
  queryParams = (_b = {},
108
105
  _b[REQUEST_ID_PARAM] = requestId,
109
106
  _b);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuvei-connect/nc-websdk",
3
- "version": "1.12.2",
3
+ "version": "1.12.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",