@nuvei-connect/nc-websdk 1.12.0 → 1.12.2
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 +184 -365
- package/dist/cdn-index.js +14 -13
- package/dist/cdn-index.min.js +2 -2
- package/dist/interfaces/index.d.ts +1 -1
- package/dist/interfaces/index.d.ts.map +1 -1
- package/dist/utils/iframe-url.utils.d.ts.map +1 -1
- package/dist/utils/iframe-url.utils.js +13 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,11 +3,21 @@
|
|
|
3
3
|
|
|
4
4
|
A practical guide for integrating **Nuvei WebSDK** into a React application using the `@nuvei-connect/nc-websdk` package.
|
|
5
5
|
|
|
6
|
+
---
|
|
7
|
+
## Prerequisites
|
|
8
|
+
|
|
9
|
+
| Item | Description | Example |
|
|
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` |
|
|
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
|
+
|
|
6
16
|
---
|
|
7
17
|
|
|
8
18
|
# Step 1 - Installation
|
|
9
19
|
|
|
10
|
-
Install the Nuvei WebSDK package:
|
|
20
|
+
Install the Nuvei WebSDK package in your `React` project:
|
|
11
21
|
|
|
12
22
|
```bash
|
|
13
23
|
npm install @nuvei-connect/nc-websdk
|
|
@@ -32,31 +42,31 @@ import React, { useEffect, useRef } from "react";
|
|
|
32
42
|
|
|
33
43
|
import NuveiSDK, { ModulesNameEnum } from "@nuvei-connect/nc-websdk";
|
|
34
44
|
|
|
35
|
-
const containerRef = useRef<HTMLDivElement>(null);
|
|
36
45
|
```
|
|
37
46
|
|
|
38
47
|
---
|
|
39
48
|
|
|
40
49
|
# Step 3 – Mount the Nuvei WebSDK
|
|
41
50
|
|
|
42
|
-
Initialize the SDK once the container is available.
|
|
51
|
+
Initialize the SDK once the container is available. Inside `App.tsx`.
|
|
43
52
|
|
|
44
53
|
```ts
|
|
45
|
-
|
|
54
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
55
|
+
|
|
56
|
+
useEffect(() => {
|
|
46
57
|
if (!containerRef.current) {
|
|
47
58
|
return;
|
|
48
59
|
}
|
|
49
60
|
|
|
50
61
|
NuveiSDK.mount({
|
|
51
|
-
config: {environment: "
|
|
62
|
+
config: {environment: "websdk_environment"},
|
|
52
63
|
container: containerRef.current.id,
|
|
53
|
-
componentName: ModulesNameEnum.
|
|
64
|
+
componentName: ModulesNameEnum.ONBOARDING_PARTNER,
|
|
54
65
|
fetchClientSession : async() => {
|
|
55
|
-
const response = await fetch(`${backendApiUrl}/api/
|
|
66
|
+
const response = await fetch(`${backendApiUrl}/api/auth/session`, { method: "POST"});
|
|
56
67
|
if (!response.ok) { throw new Error(`Session error: ${response.status}`);}
|
|
57
68
|
return await response.json();
|
|
58
|
-
}
|
|
59
|
-
|
|
69
|
+
},
|
|
60
70
|
onError: (error: any) => { console.error("NuveiWebSDK Error:", error)},
|
|
61
71
|
}).catch((error: any) => {
|
|
62
72
|
console.error("NuveiWebSDK Mount Error:", error);
|
|
@@ -70,12 +80,12 @@ return (
|
|
|
70
80
|
|
|
71
81
|
# Step 4. Backend Configuration
|
|
72
82
|
|
|
73
|
-
The backend then calls the Nuvei token/session endpoint :
|
|
83
|
+
The backend then calls the Nuvei token/session endpoint : `server.ts`
|
|
74
84
|
|
|
75
85
|
```ts
|
|
76
|
-
app.post("/api/
|
|
86
|
+
app.post("/api/auth/session", async (_req: Request, res: Response) => {
|
|
77
87
|
try {
|
|
78
|
-
const response = await fetch('
|
|
88
|
+
const response = await fetch('nuvei_auth_endpoint_for_mfe_token', {
|
|
79
89
|
method: "POST",
|
|
80
90
|
headers: {
|
|
81
91
|
"Content-Type": "application/json",
|
|
@@ -88,8 +98,6 @@ app.post("/api/nuvei/auth/session", async (_req: Request, res: Response) => {
|
|
|
88
98
|
},
|
|
89
99
|
],
|
|
90
100
|
isGuest: false,
|
|
91
|
-
emailAddress: "your_email_address",
|
|
92
|
-
partnerId:"your_partner_id"
|
|
93
101
|
}),
|
|
94
102
|
});
|
|
95
103
|
|
|
@@ -102,179 +110,126 @@ app.post("/api/nuvei/auth/session", async (_req: Request, res: Response) => {
|
|
|
102
110
|
});
|
|
103
111
|
|
|
104
112
|
```
|
|
113
|
+
These are the **minimum requirements** needed to integrate the Nuvei Web SDK.
|
|
105
114
|
|
|
115
|
+
If additional configuration or advanced options are required, please refer to the **sections below in this documentation** for detailed configuration references and usage examples.
|
|
106
116
|
|
|
107
|
-
---
|
|
108
|
-
|
|
109
|
-
# Complete React Implementation
|
|
110
|
-
|
|
111
|
-
## `App.tsx`
|
|
112
|
-
|
|
113
|
-
The following is the complete minimal React implementation:
|
|
114
117
|
|
|
115
|
-
|
|
116
|
-
import React, { useEffect, useRef } from "react";
|
|
117
|
-
|
|
118
|
-
import NuveiSDK, { ModulesNameEnum } from "@nuvei-connect/nc-websdk";
|
|
119
|
-
|
|
120
|
-
const App: React.FC = () => {
|
|
121
|
-
const containerRef = useRef<HTMLDivElement>(null);
|
|
122
|
-
|
|
123
|
-
const backendApiUrl =
|
|
124
|
-
import.meta.env.BACKEND_API_URL || "http://localhost:3005";
|
|
118
|
+
---
|
|
125
119
|
|
|
126
|
-
|
|
127
|
-
if (!containerRef.current) {
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
120
|
+
# Loading Different Modules
|
|
130
121
|
|
|
131
|
-
|
|
132
|
-
config: {environment: "dev2"},
|
|
133
|
-
container: containerRef.current.id,
|
|
134
|
-
componentName: ModulesNameEnum.ONBOARDING_MERCHANT,
|
|
135
|
-
fetchClientSession : async() => {
|
|
136
|
-
const response = await fetch(`${backendApiUrl}/api/nuvei/auth/session`, { method: "POST"});
|
|
137
|
-
if (!response.ok) { throw new Error(`Session error: ${response.status}`);}
|
|
138
|
-
return await response.json();
|
|
139
|
-
},
|
|
122
|
+
The Nuvei WebSDK supports separate modules for different use cases:
|
|
140
123
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}, []);
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
return (
|
|
149
|
-
<div className="app-container">
|
|
150
|
-
<header className="app-header">
|
|
151
|
-
<h1>Nuvei WebSDK React Demo</h1>
|
|
152
|
-
|
|
153
|
-
<p>
|
|
154
|
-
Minimal implementation using <code>@nuvei-connect/nc-websdk</code>.
|
|
155
|
-
</p>
|
|
156
|
-
</header>
|
|
157
|
-
|
|
158
|
-
<main className="app-main">
|
|
159
|
-
<div
|
|
160
|
-
id="nuvei-websdk-container"
|
|
161
|
-
ref={containerRef}
|
|
162
|
-
style={{
|
|
163
|
-
width: "100%",
|
|
164
|
-
minHeight: "calc(100vh - 100px)",
|
|
165
|
-
border: "none",
|
|
166
|
-
}}
|
|
167
|
-
/>
|
|
168
|
-
</main>
|
|
169
|
-
</div>
|
|
170
|
-
);
|
|
171
|
-
};
|
|
124
|
+
| Module | Purpose | Component |
|
|
125
|
+
| --------------- | ------------------------------- | -------------------------------------------- |
|
|
126
|
+
| **ONBOARDING** | Merchant Onboarding and Merchant Invitation | `ONBOARDING_MERCHANT` / `ONBOARDING_PARTNER` |
|
|
127
|
+
| **DOC_UTILITY** | Document utility operations | `DOC_UTILITY` |
|
|
172
128
|
|
|
173
|
-
|
|
174
|
-
```
|
|
129
|
+
For **Onboarding**, the backend authentication request and the SDK `componentName` determine whether the flow is for a **Merchant** or **Partner**.
|
|
175
130
|
|
|
176
131
|
---
|
|
177
132
|
|
|
178
|
-
|
|
133
|
+
## a. Merchant Invitation
|
|
179
134
|
|
|
180
|
-
|
|
135
|
+
For Merchant Invitation, provide the following values when authenticating with the Nuvei backend:
|
|
181
136
|
|
|
182
|
-
|
|
137
|
+
* **Module:** `ONBOARDING`
|
|
138
|
+
* **isGuest:** `false`
|
|
139
|
+
* **partnerId(required for partnerStaff, optional for nuveiStaff):** Partner ID
|
|
183
140
|
|
|
184
|
-
|
|
141
|
+
Backend Authentication Request:
|
|
185
142
|
|
|
186
|
-
```
|
|
187
|
-
|
|
143
|
+
```ts
|
|
144
|
+
body: JSON.stringify({
|
|
145
|
+
modules: [
|
|
146
|
+
{
|
|
147
|
+
name: "ONBOARDING",
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
isGuest: false,
|
|
151
|
+
partnerId: "your_partner_id",
|
|
152
|
+
}),
|
|
188
153
|
```
|
|
189
154
|
|
|
190
|
-
|
|
155
|
+
Then, load the Partner onboarding component using:
|
|
191
156
|
|
|
192
157
|
```tsx
|
|
193
158
|
NuveiSDK.mount({
|
|
194
|
-
container: containerRef.current.id,
|
|
195
159
|
componentName: ModulesNameEnum.ONBOARDING_PARTNER,
|
|
196
|
-
|
|
197
|
-
fetchClientSession,
|
|
198
|
-
|
|
199
|
-
onError: (error: any) => {
|
|
200
|
-
console.error("NuveiWebSDK Error:", error);
|
|
201
|
-
},
|
|
202
|
-
|
|
203
|
-
config: {
|
|
204
|
-
environment: "dev2",
|
|
205
|
-
},
|
|
206
160
|
});
|
|
207
161
|
```
|
|
208
162
|
|
|
163
|
+
|
|
209
164
|
---
|
|
210
165
|
|
|
211
|
-
## Merchant Onboarding
|
|
166
|
+
## b. Merchant Onboarding
|
|
212
167
|
|
|
213
|
-
|
|
168
|
+
For Merchant onboarding, provide the following values when authenticating with the Nuvei backend:
|
|
214
169
|
|
|
215
|
-
|
|
216
|
-
|
|
170
|
+
* **Module:** `ONBOARDING`
|
|
171
|
+
* **isGuest:** `true`
|
|
172
|
+
* **emailAddress:** Merchant email address
|
|
173
|
+
* **partnerId(optional):** Partner ID to which specific merchant belongs to
|
|
174
|
+
|
|
175
|
+
Backend Authentication Request:
|
|
176
|
+
|
|
177
|
+
```ts
|
|
178
|
+
body: JSON.stringify({
|
|
179
|
+
modules: [
|
|
180
|
+
{
|
|
181
|
+
name: "ONBOARDING",
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
isGuest: true,
|
|
185
|
+
emailAddress: "your_merchant_email_address"
|
|
186
|
+
}),
|
|
217
187
|
```
|
|
218
188
|
|
|
219
|
-
|
|
189
|
+
Then, load the Merchant onboarding component using:
|
|
220
190
|
|
|
221
191
|
```tsx
|
|
222
192
|
NuveiSDK.mount({
|
|
223
|
-
container: containerRef.current.id,
|
|
224
193
|
componentName: ModulesNameEnum.ONBOARDING_MERCHANT,
|
|
225
|
-
|
|
226
|
-
fetchClientSession,
|
|
227
|
-
|
|
228
|
-
onError: (error: any) => {
|
|
229
|
-
console.error("NuveiWebSDK Error:", error);
|
|
230
|
-
},
|
|
231
|
-
|
|
232
|
-
config: {
|
|
233
|
-
environment: "dev2",
|
|
234
|
-
},
|
|
235
194
|
});
|
|
236
195
|
```
|
|
237
196
|
|
|
238
197
|
---
|
|
239
198
|
|
|
240
|
-
## Document Utility
|
|
199
|
+
## c. Document Utility
|
|
200
|
+
|
|
201
|
+
Document Utility is a separate module from Onboarding.
|
|
241
202
|
|
|
242
|
-
|
|
203
|
+
When using Document Utility:
|
|
243
204
|
|
|
244
|
-
|
|
205
|
+
* **Module:** `DOC_UTILITY`
|
|
206
|
+
* **Component:** `ModulesNameEnum.DOC_UTILITY`
|
|
207
|
+
|
|
208
|
+
Example:
|
|
245
209
|
|
|
246
210
|
```tsx
|
|
247
211
|
NuveiSDK.mount({
|
|
248
212
|
container: containerRef.current.id,
|
|
249
|
-
componentName: ModulesNameEnum.
|
|
250
|
-
|
|
251
|
-
fetchClientSession,
|
|
252
|
-
|
|
253
|
-
onError: (error: any) => {
|
|
254
|
-
console.error("NuveiWebSDK Error:", error);
|
|
255
|
-
},
|
|
256
|
-
|
|
257
|
-
config: {
|
|
258
|
-
environment: "dev2",
|
|
259
|
-
},
|
|
213
|
+
componentName: ModulesNameEnum.DOC_UTILITY,
|
|
214
|
+
config: {environment: "websdk_environment" , documentRequestId : 'your_document_request_id'},
|
|
260
215
|
});
|
|
261
216
|
```
|
|
262
217
|
|
|
263
|
-
|
|
218
|
+
The authentication/session request should include the module required by the Document Utility flow.
|
|
264
219
|
|
|
265
220
|
---
|
|
266
221
|
|
|
267
|
-
# 6. Session Lifecycle Callbacks
|
|
268
222
|
|
|
269
|
-
For applications that need full session lifecycle management, the SDK can receive:
|
|
270
223
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
224
|
+
# Session Lifecycle Callbacks
|
|
225
|
+
|
|
226
|
+
For applications that need full session lifecycle management, the SDK can receive:
|
|
274
227
|
|
|
228
|
+
a. `fetchClientSession`
|
|
229
|
+
Creates or retrieves the each session required by the SDK to communicate with the Nuvei backend.
|
|
275
230
|
```tsx
|
|
276
231
|
const fetchClientSession = async () => {
|
|
277
|
-
const response = await fetch(`${apiBaseUrl}/api/
|
|
232
|
+
const response = await fetch(`${apiBaseUrl}/api/auth/session`, {
|
|
278
233
|
method: "POST",
|
|
279
234
|
});
|
|
280
235
|
|
|
@@ -286,9 +241,11 @@ const fetchClientSession = async () => {
|
|
|
286
241
|
};
|
|
287
242
|
```
|
|
288
243
|
|
|
244
|
+
b.`refreshClientSession`
|
|
245
|
+
Refreshes the current session using the refresh token. The SDK can use this callback when the existing session is expired or approaching expiration
|
|
289
246
|
```tsx
|
|
290
247
|
const refreshClientSession = async (refreshToken: string) => {
|
|
291
|
-
const response = await fetch(`${apiBaseUrl}/api/
|
|
248
|
+
const response = await fetch(`${apiBaseUrl}/api/auth/session/refresh`, {
|
|
292
249
|
method: "POST",
|
|
293
250
|
|
|
294
251
|
headers: {
|
|
@@ -308,9 +265,11 @@ const refreshClientSession = async (refreshToken: string) => {
|
|
|
308
265
|
};
|
|
309
266
|
```
|
|
310
267
|
|
|
268
|
+
c.`destroySession`
|
|
269
|
+
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.
|
|
311
270
|
```tsx
|
|
312
271
|
const destroySession = async () => {
|
|
313
|
-
const response = await fetch(`${apiBaseUrl}/api/
|
|
272
|
+
const response = await fetch(`${apiBaseUrl}/api/auth/session/destroy`, {
|
|
314
273
|
method: "POST",
|
|
315
274
|
});
|
|
316
275
|
|
|
@@ -324,267 +283,127 @@ const destroySession = async () => {
|
|
|
324
283
|
|
|
325
284
|
---
|
|
326
285
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
When all callbacks are available, pass them to `NuveiSDK.mount()`:
|
|
330
|
-
|
|
331
|
-
```tsx
|
|
332
|
-
NuveiSDK.mount({
|
|
333
|
-
container: containerRef.current.id,
|
|
334
|
-
|
|
335
|
-
componentName: ModulesNameEnum.ONBOARDING_MERCHANT,
|
|
336
|
-
|
|
337
|
-
fetchClientSession,
|
|
338
|
-
refreshClientSession,
|
|
339
|
-
destroySession,
|
|
340
|
-
|
|
341
|
-
onError: (error: any) => {
|
|
342
|
-
console.error("NuveiWebSDK Error:", error);
|
|
343
|
-
},
|
|
344
|
-
|
|
345
|
-
config: {
|
|
346
|
-
environment: "dev2",
|
|
347
|
-
},
|
|
348
|
-
}).catch((error: any) => {
|
|
349
|
-
console.error("NuveiWebSDK Mount Error:", error);
|
|
350
|
-
});
|
|
351
|
-
```
|
|
352
|
-
|
|
353
|
-
---
|
|
354
|
-
|
|
355
|
-
# 8. Backend Session Refresh
|
|
356
|
-
|
|
357
|
-
The frontend refresh callback should call your backend.
|
|
358
|
-
|
|
359
|
-
Example:
|
|
360
|
-
|
|
361
|
-
```ts
|
|
362
|
-
app.post("/api/nuvei/auth/refresh", async (req: Request, res: Response) => {
|
|
363
|
-
try {
|
|
364
|
-
const { refreshToken } = req.body as {
|
|
365
|
-
refreshToken?: string;
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
if (!refreshToken) {
|
|
369
|
-
return res.status(400).json({
|
|
370
|
-
isSuccess: false,
|
|
371
|
-
message: "refreshToken is required",
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
console.log("Refreshing Nuvei session...");
|
|
286
|
+
## Modules Switching
|
|
376
287
|
|
|
377
|
-
|
|
378
|
-
// Nuvei refresh-token endpoint.
|
|
379
|
-
const refreshUrl = "YOUR_NUVEI_REFRESH_ENDPOINT";
|
|
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:
|
|
380
289
|
|
|
381
|
-
|
|
382
|
-
|
|
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` |
|
|
383
296
|
|
|
384
|
-
|
|
385
|
-
"Content-Type": "application/json",
|
|
386
|
-
Authorization: NUVEI_AUTHORIZATION,
|
|
387
|
-
},
|
|
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.
|
|
388
298
|
|
|
389
|
-
|
|
390
|
-
refreshToken,
|
|
391
|
-
}),
|
|
392
|
-
});
|
|
393
|
-
|
|
394
|
-
const data: unknown = await response.json();
|
|
299
|
+
### 1. Mount the partner and merchant modules
|
|
395
300
|
|
|
396
|
-
|
|
397
|
-
console.error("Nuvei refresh failed:", data);
|
|
301
|
+
The partner page uses `ONBOARDING_PARTNER` and the merchant page uses `ONBOARDING_MERCHANT`. Both pages listen for the `SWITCH_MODULE` message.
|
|
398
302
|
|
|
399
|
-
|
|
303
|
+
```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}`);
|
|
400
322
|
}
|
|
401
|
-
|
|
402
|
-
console.log("Nuvei session refreshed");
|
|
403
|
-
|
|
404
|
-
return res.json(data);
|
|
405
|
-
} catch (error) {
|
|
406
|
-
console.error("Session refresh error:", error);
|
|
407
|
-
|
|
408
|
-
return res.status(500).json({
|
|
409
|
-
isSuccess: false,
|
|
410
|
-
message: "Internal server error while refreshing session",
|
|
411
|
-
});
|
|
412
|
-
}
|
|
413
|
-
});
|
|
414
|
-
```
|
|
415
|
-
|
|
416
|
-
---
|
|
417
|
-
|
|
418
|
-
# 9. Backend Logout / Destroy Session
|
|
419
|
-
|
|
420
|
-
```ts
|
|
421
|
-
app.post("/api/nuvei/auth/logout", async (_req: Request, res: Response) => {
|
|
422
|
-
try {
|
|
423
|
-
console.log("Destroying Nuvei session...");
|
|
424
|
-
|
|
425
|
-
return res.json({
|
|
426
|
-
isSuccess: true,
|
|
427
|
-
});
|
|
428
|
-
} catch (error) {
|
|
429
|
-
console.error("Logout error:", error);
|
|
430
|
-
|
|
431
|
-
return res.status(500).json({
|
|
432
|
-
isSuccess: false,
|
|
433
|
-
message: "Failed to destroy session",
|
|
434
|
-
});
|
|
435
|
-
}
|
|
323
|
+
},
|
|
436
324
|
});
|
|
437
325
|
```
|
|
438
326
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
---
|
|
442
|
-
|
|
443
|
-
# 13. Configuration Reference
|
|
444
|
-
|
|
445
|
-
| Property | Type | Default | Description |
|
|
446
|
-
| ------------------- | --------------------------- | ----------------------- | --------------------------------- |
|
|
447
|
-
| `componentName` | `ModulesNameEnum \| string` | `ONBOARDING_MERCHANT` | Nuvei module to render |
|
|
448
|
-
| `requestId` | `string` | `undefined` | Onboarding application ID |
|
|
449
|
-
| `documentRequestId` | `string` | `undefined` | Document Utility request ID |
|
|
450
|
-
| `environment` | `string` | — | Target environment |
|
|
451
|
-
| `backendApiUrl` | `string` | `http://localhost:3005` | Backend API base URL |
|
|
452
|
-
| `onCompleted` | `(data) => void` | `undefined` | Called when the flow is completed |
|
|
453
|
-
| `onError` | `(error) => void` | `undefined` | Called when an error occurs |
|
|
454
|
-
| `style` | `React.CSSProperties` | `undefined` | Optional container styling |
|
|
455
|
-
|
|
456
|
-
---
|
|
457
|
-
|
|
458
|
-
# 15. Production Checklist
|
|
459
|
-
|
|
460
|
-
Before deploying the integration, verify:
|
|
461
|
-
|
|
462
|
-
### Frontend
|
|
463
|
-
|
|
464
|
-
- [ ] `@nuvei-connect/nc-websdk` is installed.
|
|
465
|
-
- [ ] Correct `ModulesNameEnum` is selected.
|
|
466
|
-
- [ ] SDK container has a stable `id`.
|
|
467
|
-
- [ ] `BACKEND_API_URL` points to the correct backend.
|
|
468
|
-
- [ ] `onError` is configured.
|
|
469
|
-
- [ ] Required session callbacks are supplied.
|
|
470
|
-
|
|
471
|
-
### Backend
|
|
472
|
-
|
|
473
|
-
- [ ] Nuvei authorization is stored securely.
|
|
474
|
-
- [ ] Nuvei credentials are never exposed to the browser.
|
|
475
|
-
- [ ] `/api/nuvei/auth/session` is implemented.
|
|
476
|
-
- [ ] Refresh endpoint is implemented when required.
|
|
477
|
-
- [ ] Destroy/logout endpoint is implemented when required.
|
|
478
|
-
- [ ] `emailAddress`, `partnerId`, and `isGuest` are populated from the appropriate application context.
|
|
479
|
-
- [ ] Correct Nuvei environment endpoints are configured.
|
|
480
|
-
|
|
481
|
-
### Environment
|
|
482
|
-
|
|
483
|
-
- [ ] Development environment is verified.
|
|
484
|
-
- [ ] UAT environment is verified.
|
|
485
|
-
- [ ] Production configuration is separated from development configuration.
|
|
486
|
-
- [ ] Backend API uses HTTPS in production.
|
|
487
|
-
|
|
488
|
-
---
|
|
489
|
-
|
|
490
|
-
# 16. Common Errors
|
|
491
|
-
|
|
492
|
-
## SDK does not render
|
|
493
|
-
|
|
494
|
-
Check:
|
|
327
|
+
For the merchant page, only the component name changes:
|
|
495
328
|
|
|
496
329
|
```tsx
|
|
497
|
-
|
|
498
|
-
return;
|
|
499
|
-
}
|
|
330
|
+
componentName: ModulesNameEnum.ONBOARDING_MERCHANT
|
|
500
331
|
```
|
|
501
332
|
|
|
502
|
-
|
|
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`:
|
|
503
334
|
|
|
504
335
|
```tsx
|
|
505
|
-
|
|
336
|
+
body: JSON.stringify({
|
|
337
|
+
modules: [{ name: "ONBOARDING" }],
|
|
338
|
+
isGuest: false,
|
|
339
|
+
}),
|
|
506
340
|
```
|
|
507
341
|
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
## Session request fails
|
|
511
|
-
|
|
512
|
-
Check the browser network request:
|
|
342
|
+
### 2. Mount Document Utility on its own page
|
|
513
343
|
|
|
514
|
-
|
|
515
|
-
POST /api/nuvei/auth/session
|
|
516
|
-
```
|
|
517
|
-
|
|
518
|
-
Then verify:
|
|
519
|
-
|
|
520
|
-
1. Backend is running.
|
|
521
|
-
2. `BACKEND_API_URL` is correct.
|
|
522
|
-
3. Backend can reach Nuvei.
|
|
523
|
-
4. `NUVEI_AUTHORIZATION` is valid.
|
|
524
|
-
5. Required session parameters are populated.
|
|
525
|
-
6. The backend returns valid JSON.
|
|
526
|
-
|
|
527
|
-
---
|
|
528
|
-
|
|
529
|
-
## SDK mount fails
|
|
530
|
-
|
|
531
|
-
Check the SDK error callback:
|
|
344
|
+
The document utility page reads `documentRequestId` from the current URL and passes it to the SDK configuration:
|
|
532
345
|
|
|
533
346
|
```tsx
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
```
|
|
538
|
-
|
|
539
|
-
Also check the promise rejection:
|
|
347
|
+
const documentRequestId = new URLSearchParams(
|
|
348
|
+
window.location.search,
|
|
349
|
+
).get("documentRequestId");
|
|
540
350
|
|
|
541
|
-
|
|
542
|
-
.
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
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
|
+
},
|
|
547
367
|
});
|
|
548
368
|
```
|
|
549
369
|
|
|
550
|
-
|
|
370
|
+
When an onboarding module sends `SWITCH_MODULE`, the app navigates to a URL such as:
|
|
551
371
|
|
|
552
|
-
|
|
372
|
+
```text
|
|
373
|
+
/doc-utility?documentRequestId=your_document_request_id
|
|
374
|
+
```
|
|
553
375
|
|
|
554
|
-
|
|
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:
|
|
555
377
|
|
|
556
378
|
```tsx
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
if (!response.ok) {
|
|
563
|
-
throw new Error(`Session error: ${response.status}`);
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
return response.json();
|
|
567
|
-
};
|
|
568
|
-
|
|
569
|
-
useEffect(() => {
|
|
570
|
-
if (!containerRef.current) {
|
|
571
|
-
return;
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
NuveiSDK.mount({
|
|
575
|
-
container: containerRef.current.id,
|
|
576
|
-
componentName: ModulesNameEnum.ONBOARDING_MERCHANT,
|
|
577
|
-
fetchClientSession,
|
|
578
|
-
|
|
579
|
-
config: {
|
|
580
|
-
environment: "dev2",
|
|
581
|
-
},
|
|
582
|
-
});
|
|
583
|
-
}, []);
|
|
379
|
+
body: JSON.stringify({
|
|
380
|
+
modules: [{ name: "DOC_UTILITY" }],
|
|
381
|
+
isGuest: true,
|
|
382
|
+
}),
|
|
584
383
|
```
|
|
585
384
|
|
|
586
|
-
|
|
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. |
|
|
587
408
|
|
|
588
409
|
---
|
|
589
|
-
|
|
590
|
-
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,14 +311,16 @@
|
|
|
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: "https://ignite.nuvei.com"
|
|
314
|
+
"prod-na": "https://ignite.nuvei.com",
|
|
315
|
+
"prod-eu": "https://ignite-eu.nuvei.com"
|
|
315
316
|
};
|
|
316
317
|
var DOCUMENT_UTILITY_BASE_URLS = {
|
|
317
318
|
local: "http://localhost:5000",
|
|
318
319
|
dev3: "https://dev3-non-pci.eastus.cloudapp.azure.com",
|
|
319
320
|
dev2: "https://dev2-non-pci.eastus.cloudapp.azure.com",
|
|
320
321
|
uat: "https://ignite-preprod.nuvei.com",
|
|
321
|
-
prod: "https://ignite.nuvei.com"
|
|
322
|
+
"prod-na": "https://ignite.nuvei.com",
|
|
323
|
+
"prod-eu": "https://ignite-eu.nuvei.com"
|
|
322
324
|
};
|
|
323
325
|
var MODULE_PATHS = {
|
|
324
326
|
["ONBOARDING_PARTNER" /* ONBOARDING_PARTNER */]: "/_onboarding/partner/application",
|
|
@@ -327,11 +329,11 @@
|
|
|
327
329
|
};
|
|
328
330
|
var DOCUMENT_REQUEST_ID_PARAM = "documentRequestId";
|
|
329
331
|
var REQUEST_ID_PARAM = "requestId";
|
|
330
|
-
var getEnvironmentBaseUrl = (environment
|
|
332
|
+
var getEnvironmentBaseUrl = (environment) => {
|
|
331
333
|
var _a;
|
|
332
334
|
return (_a = ENVIRONMENT_BASE_URLS[environment]) != null ? _a : ENVIRONMENT_BASE_URLS.prod;
|
|
333
335
|
};
|
|
334
|
-
var getDocumentUtilityBaseUrl = (environment
|
|
336
|
+
var getDocumentUtilityBaseUrl = (environment) => {
|
|
335
337
|
var _a;
|
|
336
338
|
return (_a = DOCUMENT_UTILITY_BASE_URLS[environment]) != null ? _a : DOCUMENT_UTILITY_BASE_URLS.prod;
|
|
337
339
|
};
|
|
@@ -363,22 +365,21 @@
|
|
|
363
365
|
return getEnvironmentBaseUrl(environment);
|
|
364
366
|
};
|
|
365
367
|
var resolveIframeUrl = (componentName, config) => {
|
|
366
|
-
var _a, _b
|
|
367
|
-
const environment =
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
);
|
|
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);
|
|
373
374
|
const path = getModulePath(componentName);
|
|
374
375
|
let queryParams = {};
|
|
375
376
|
if (componentName === "DOC_UTILITY" /* DOC_UTILITY */) {
|
|
376
|
-
const documentRequestId = (
|
|
377
|
+
const documentRequestId = (_a = config.documentRequestId) != null ? _a : getDocumentRequestIdFromUrl();
|
|
377
378
|
queryParams = {
|
|
378
379
|
[DOCUMENT_REQUEST_ID_PARAM]: documentRequestId
|
|
379
380
|
};
|
|
380
381
|
} else if (componentName === "ONBOARDING_MERCHANT" /* ONBOARDING_MERCHANT */ || componentName === "ONBOARDING_PARTNER" /* ONBOARDING_PARTNER */) {
|
|
381
|
-
const requestId = (
|
|
382
|
+
const requestId = (_b = config.requestId) != null ? _b : getRequestIdFromUrl();
|
|
382
383
|
queryParams = {
|
|
383
384
|
[REQUEST_ID_PARAM]: requestId
|
|
384
385
|
};
|
package/dist/cdn-index.min.js
CHANGED
|
@@ -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},
|
|
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(`
|
|
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:
|
|
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;})();
|
|
@@ -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';
|
|
56
|
+
environment: 'local' | 'dev3' | 'dev2' | 'uat' | 'prod-na' | 'prod-eu';
|
|
57
57
|
iframeBaseUrl?: string;
|
|
58
58
|
requestId?: string;
|
|
59
59
|
documentRequestId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index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IACb,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,YAAY,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IAEd,cAAc,IAAI,QAAQ,GAAG,IAAI,CAAC;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 +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;
|
|
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"}
|
|
@@ -9,14 +9,16 @@ var ENVIRONMENT_BASE_URLS = {
|
|
|
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: 'https://ignite.nuvei.com',
|
|
12
|
+
'prod-na': 'https://ignite.nuvei.com',
|
|
13
|
+
'prod-eu': 'https://ignite-eu.nuvei.com',
|
|
13
14
|
};
|
|
14
15
|
var DOCUMENT_UTILITY_BASE_URLS = {
|
|
15
16
|
local: 'http://localhost:5000',
|
|
16
17
|
dev3: 'https://dev3-non-pci.eastus.cloudapp.azure.com',
|
|
17
18
|
dev2: 'https://dev2-non-pci.eastus.cloudapp.azure.com',
|
|
18
19
|
uat: 'https://ignite-preprod.nuvei.com',
|
|
19
|
-
prod: 'https://ignite.nuvei.com',
|
|
20
|
+
'prod-na': 'https://ignite.nuvei.com',
|
|
21
|
+
'prod-eu': 'https://ignite-eu.nuvei.com',
|
|
20
22
|
};
|
|
21
23
|
var MODULE_PATHS = (_a = {},
|
|
22
24
|
_a[enums_1.ModulesNameEnum.ONBOARDING_PARTNER] = '/_onboarding/partner/application',
|
|
@@ -27,13 +29,11 @@ var DOCUMENT_REQUEST_ID_PARAM = 'documentRequestId';
|
|
|
27
29
|
var REQUEST_ID_PARAM = 'requestId';
|
|
28
30
|
var getEnvironmentBaseUrl = function (environment) {
|
|
29
31
|
var _a;
|
|
30
|
-
|
|
31
|
-
return ((_a = ENVIRONMENT_BASE_URLS[environment]) !== null && _a !== void 0 ? _a : ENVIRONMENT_BASE_URLS.prod);
|
|
32
|
+
return (_a = ENVIRONMENT_BASE_URLS[environment]) !== null && _a !== void 0 ? _a : ENVIRONMENT_BASE_URLS.prod;
|
|
32
33
|
};
|
|
33
34
|
var getDocumentUtilityBaseUrl = function (environment) {
|
|
34
35
|
var _a;
|
|
35
|
-
|
|
36
|
-
return ((_a = DOCUMENT_UTILITY_BASE_URLS[environment]) !== null && _a !== void 0 ? _a : DOCUMENT_UTILITY_BASE_URLS.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,20 +87,23 @@ 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 =
|
|
90
|
+
var _c, _d;
|
|
91
|
+
var environment = config.environment;
|
|
92
|
+
if (!environment) {
|
|
93
|
+
throw new Error("Websdk Environment is not configured");
|
|
94
|
+
}
|
|
92
95
|
var baseUrl = getBaseUrl(componentName, environment, config);
|
|
93
96
|
var path = (0, exports.getModulePath)(componentName);
|
|
94
97
|
var queryParams = {};
|
|
95
98
|
if (componentName === enums_1.ModulesNameEnum.DOC_UTILITY) {
|
|
96
|
-
var documentRequestId = (
|
|
99
|
+
var documentRequestId = (_c = config.documentRequestId) !== null && _c !== void 0 ? _c : getDocumentRequestIdFromUrl();
|
|
97
100
|
queryParams = (_a = {},
|
|
98
101
|
_a[DOCUMENT_REQUEST_ID_PARAM] = documentRequestId,
|
|
99
102
|
_a);
|
|
100
103
|
}
|
|
101
104
|
else if (componentName === enums_1.ModulesNameEnum.ONBOARDING_MERCHANT ||
|
|
102
105
|
componentName === enums_1.ModulesNameEnum.ONBOARDING_PARTNER) {
|
|
103
|
-
var requestId = (
|
|
106
|
+
var requestId = (_d = config.requestId) !== null && _d !== void 0 ? _d : getRequestIdFromUrl();
|
|
104
107
|
queryParams = (_b = {},
|
|
105
108
|
_b[REQUEST_ID_PARAM] = requestId,
|
|
106
109
|
_b);
|