@nuvei-connect/nc-websdk 1.0.9 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +541 -100
- package/dist/cdn-index.js +16 -6
- package/dist/cdn-index.min.js +2 -2
- package/dist/common/enums/index.d.ts +0 -8
- package/dist/common/enums/index.d.ts.map +1 -1
- package/dist/common/enums/index.js +1 -9
- package/dist/config/default-config.d.ts.map +1 -1
- package/dist/config/default-config.js +1 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +17 -5
- package/dist/interfaces/index.d.ts +16 -9
- package/dist/interfaces/index.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,149 +1,590 @@
|
|
|
1
|
-
# 🧩 WebSDK
|
|
2
1
|
|
|
3
|
-
|
|
2
|
+
# Nuvei WebSDK – React Integration Guide
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
A practical guide for integrating **Nuvei WebSDK** into a React application using the `@nuvei-connect/nc-websdk` package.
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Step 1 - Installation
|
|
9
|
+
|
|
10
|
+
Install the Nuvei WebSDK package:
|
|
8
11
|
|
|
9
12
|
```bash
|
|
10
13
|
npm install @nuvei-connect/nc-websdk
|
|
11
14
|
```
|
|
15
|
+
or:
|
|
16
|
+
```bash
|
|
17
|
+
yarn add @nuvei-connect/nc-websdk
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
> **Important:** Nuvei authorization credentials should remain on the backend. They should not be exposed in the React application.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
# Step 2 – Import the SDK
|
|
25
|
+
|
|
26
|
+
Import `NuveiSDK` and `ModulesNameEnum`. In `App.tsx`.
|
|
27
|
+
|
|
28
|
+
Create a reference for the DOM container where the SDK will be rendered.
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import React, { useEffect, useRef } from "react";
|
|
32
|
+
|
|
33
|
+
import NuveiSDK, { ModulesNameEnum } from "@nuvei-connect/nc-websdk";
|
|
34
|
+
|
|
35
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
# Step 3 – Mount the Nuvei WebSDK
|
|
41
|
+
|
|
42
|
+
Initialize the SDK once the container is available. In `App.tsx`.
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (!containerRef.current) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
NuveiSDK.mount({
|
|
51
|
+
config: {environment: "dev2"},
|
|
52
|
+
container: containerRef.current.id,
|
|
53
|
+
componentName: ModulesNameEnum.ONBOARDING_MERCHANT,
|
|
54
|
+
fetchClientSession : async() => {
|
|
55
|
+
const response = await fetch(`${backendApiUrl}/api/nuvei/auth/session`, { method: "POST"});
|
|
56
|
+
if (!response.ok) { throw new Error(`Session error: ${response.status}`);}
|
|
57
|
+
return await response.json();
|
|
58
|
+
};,
|
|
59
|
+
|
|
60
|
+
onError: (error: any) => { console.error("NuveiWebSDK Error:", error)},
|
|
61
|
+
}).catch((error: any) => {
|
|
62
|
+
console.error("NuveiWebSDK Mount Error:", error);
|
|
63
|
+
});
|
|
64
|
+
}, []);
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<div id="nuvei-websdk-container" ref={containerRef} style={{width: "100%",height: "100%" }}/>
|
|
68
|
+
);
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
# Step 4. Backend Configuration
|
|
72
|
+
|
|
73
|
+
The backend then calls the Nuvei token/session endpoint : in nodejs backend
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
app.post("/api/nuvei/auth/session", async (_req: Request, res: Response) => {
|
|
77
|
+
try {
|
|
78
|
+
const response = await fetch('https://nonprodmanagement-us-e.azure-api.net/dev2/v1/auth/micro-frontend/tokens', {
|
|
79
|
+
method: "POST",
|
|
80
|
+
headers: {
|
|
81
|
+
"Content-Type": "application/json",
|
|
82
|
+
Authorization: 'your_provided_backend_token',
|
|
83
|
+
},
|
|
84
|
+
body: JSON.stringify({
|
|
85
|
+
modules: [
|
|
86
|
+
{
|
|
87
|
+
name: "ONBOARDING",
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
isGuest: false,
|
|
91
|
+
emailAddress: "your_email_address",
|
|
92
|
+
partnerId:"your_partner_id"
|
|
93
|
+
}),
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const data = await response.json();
|
|
97
|
+
|
|
98
|
+
return res.json(data);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
console.log("error", error)
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
# Complete React Implementation
|
|
110
|
+
|
|
111
|
+
## `App.tsx`
|
|
112
|
+
|
|
113
|
+
The following is the complete minimal React implementation:
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
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";
|
|
125
|
+
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
if (!containerRef.current) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
NuveiSDK.mount({
|
|
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
|
+
},
|
|
140
|
+
|
|
141
|
+
onError: (error: any) => { console.error("NuveiWebSDK Error:", error)},
|
|
142
|
+
}).catch((error: any) => {
|
|
143
|
+
console.error("NuveiWebSDK Mount Error:", error);
|
|
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
|
+
};
|
|
172
|
+
|
|
173
|
+
export default App;
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
# 5. Loading Different Modules
|
|
179
|
+
|
|
180
|
+
The module is selected through `componentName`.
|
|
181
|
+
|
|
182
|
+
## Partner Onboarding
|
|
183
|
+
|
|
184
|
+
Use:
|
|
185
|
+
|
|
186
|
+
```tsx
|
|
187
|
+
componentName: ModulesNameEnum.ONBOARDING_PARTNER;
|
|
188
|
+
```
|
|
12
189
|
|
|
13
|
-
|
|
190
|
+
Example:
|
|
14
191
|
|
|
15
|
-
|
|
16
|
-
|
|
192
|
+
```tsx
|
|
193
|
+
NuveiSDK.mount({
|
|
194
|
+
container: containerRef.current.id,
|
|
195
|
+
componentName: ModulesNameEnum.ONBOARDING_PARTNER,
|
|
17
196
|
|
|
18
|
-
|
|
19
|
-
import NuveiSDK from "@nuvei-connect/nc-websdk";
|
|
197
|
+
fetchClientSession,
|
|
20
198
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
199
|
+
onError: (error: any) => {
|
|
200
|
+
console.error("NuveiWebSDK Error:", error);
|
|
201
|
+
},
|
|
24
202
|
|
|
25
203
|
config: {
|
|
26
|
-
environment: "
|
|
204
|
+
environment: "dev2",
|
|
27
205
|
},
|
|
28
206
|
});
|
|
29
207
|
```
|
|
30
208
|
|
|
31
|
-
|
|
32
|
-
when the host component is unmounted or the integration is no longer needed.
|
|
209
|
+
---
|
|
33
210
|
|
|
34
|
-
|
|
211
|
+
## Merchant Onboarding
|
|
35
212
|
|
|
36
|
-
|
|
37
|
-
conditionally replaces the container, `containerRef.current` will be `null` when
|
|
38
|
-
the SDK is initialized.
|
|
213
|
+
Use:
|
|
39
214
|
|
|
40
215
|
```tsx
|
|
41
|
-
|
|
216
|
+
componentName: ModulesNameEnum.ONBOARDING_MERCHANT;
|
|
217
|
+
```
|
|
42
218
|
|
|
43
|
-
|
|
44
|
-
import NuveiSDK from "@nuvei-connect/nc-websdk";
|
|
219
|
+
Example:
|
|
45
220
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
221
|
+
```tsx
|
|
222
|
+
NuveiSDK.mount({
|
|
223
|
+
container: containerRef.current.id,
|
|
224
|
+
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
|
+
});
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## Document Utility
|
|
241
|
+
|
|
242
|
+
Use the document utility module exposed by your SDK.
|
|
243
|
+
|
|
244
|
+
Example structure:
|
|
245
|
+
|
|
246
|
+
```tsx
|
|
247
|
+
NuveiSDK.mount({
|
|
248
|
+
container: containerRef.current.id,
|
|
249
|
+
componentName: ModulesNameEnum.ONBOARDING_MERCHANT,
|
|
50
250
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
251
|
+
fetchClientSession,
|
|
252
|
+
|
|
253
|
+
onError: (error: any) => {
|
|
254
|
+
console.error("NuveiWebSDK Error:", error);
|
|
255
|
+
},
|
|
256
|
+
|
|
257
|
+
config: {
|
|
258
|
+
environment: "dev2",
|
|
259
|
+
},
|
|
260
|
+
});
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
> **Note:** Verify the exact `ModulesNameEnum` value for Document Utility in the installed SDK version before using it. The original implementation should not be changed here unless that enum is confirmed.
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
# 6. Session Lifecycle Callbacks
|
|
268
|
+
|
|
269
|
+
For applications that need full session lifecycle management, the SDK can receive:
|
|
270
|
+
|
|
271
|
+
- `fetchClientSession`
|
|
272
|
+
- `refreshClientSession`
|
|
273
|
+
- `destroySession`
|
|
274
|
+
|
|
275
|
+
```tsx
|
|
276
|
+
const fetchClientSession = async () => {
|
|
277
|
+
const response = await fetch(`${apiBaseUrl}/api/nuvei/auth/session`, {
|
|
56
278
|
method: "POST",
|
|
57
|
-
headers: { "Content-Type": "application/json" },
|
|
58
|
-
body: JSON.stringify(payload),
|
|
59
279
|
});
|
|
60
|
-
return response.json();
|
|
61
|
-
}
|
|
62
280
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
281
|
+
if (!response.ok) {
|
|
282
|
+
throw new Error(`Session error: ${response.status}`);
|
|
283
|
+
}
|
|
67
284
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
285
|
+
return await response.json();
|
|
286
|
+
};
|
|
287
|
+
```
|
|
72
288
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
289
|
+
```tsx
|
|
290
|
+
const refreshClientSession = async (refreshToken: string) => {
|
|
291
|
+
const response = await fetch(`${apiBaseUrl}/api/nuvei/auth/session/refresh`, {
|
|
292
|
+
method: "POST",
|
|
293
|
+
|
|
294
|
+
headers: {
|
|
295
|
+
"Content-Type": "application/json",
|
|
296
|
+
},
|
|
297
|
+
|
|
298
|
+
body: JSON.stringify({
|
|
299
|
+
refreshToken,
|
|
300
|
+
}),
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
if (!response.ok) {
|
|
304
|
+
throw new Error(`Session refresh error: ${response.status}`);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
return await response.json();
|
|
308
|
+
};
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
```tsx
|
|
312
|
+
const destroySession = async () => {
|
|
313
|
+
const response = await fetch(`${apiBaseUrl}/api/nuvei/auth/session/destroy`, {
|
|
314
|
+
method: "POST",
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
if (!response.ok) {
|
|
318
|
+
throw new Error(`Session destroy error: ${response.status}`);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
return await response.json();
|
|
322
|
+
};
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
---
|
|
326
|
+
|
|
327
|
+
# 7. Mount With Full Session Lifecycle
|
|
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",
|
|
86
372
|
});
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
console.log("Refreshing Nuvei session...");
|
|
87
376
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
377
|
+
// Replace this URL with your actual
|
|
378
|
+
// Nuvei refresh-token endpoint.
|
|
379
|
+
const refreshUrl = "YOUR_NUVEI_REFRESH_ENDPOINT";
|
|
92
380
|
|
|
93
|
-
|
|
94
|
-
|
|
381
|
+
const response = await fetch(refreshUrl, {
|
|
382
|
+
method: "POST",
|
|
383
|
+
|
|
384
|
+
headers: {
|
|
385
|
+
"Content-Type": "application/json",
|
|
386
|
+
Authorization: NUVEI_AUTHORIZATION,
|
|
387
|
+
},
|
|
388
|
+
|
|
389
|
+
body: JSON.stringify({
|
|
390
|
+
refreshToken,
|
|
391
|
+
}),
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
const data: unknown = await response.json();
|
|
395
|
+
|
|
396
|
+
if (!response.ok) {
|
|
397
|
+
console.error("Nuvei refresh failed:", data);
|
|
398
|
+
|
|
399
|
+
return res.status(response.status).json(data);
|
|
95
400
|
}
|
|
96
401
|
|
|
97
|
-
|
|
402
|
+
console.log("Nuvei session refreshed");
|
|
98
403
|
|
|
99
|
-
return ()
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
instanceRef.current = null;
|
|
103
|
-
};
|
|
104
|
-
}, [componentName]);
|
|
404
|
+
return res.json(data);
|
|
405
|
+
} catch (error) {
|
|
406
|
+
console.error("Session refresh error:", error);
|
|
105
407
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
+
}
|
|
436
|
+
});
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
> The exact Nuvei destroy/logout behavior should follow the session API supported by the environment you are integrating with.
|
|
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:
|
|
495
|
+
|
|
496
|
+
```tsx
|
|
497
|
+
if (!containerRef.current) {
|
|
498
|
+
return;
|
|
112
499
|
}
|
|
113
500
|
```
|
|
114
501
|
|
|
115
|
-
|
|
502
|
+
and confirm that the container exists:
|
|
503
|
+
|
|
504
|
+
```tsx
|
|
505
|
+
<div id="nuvei-websdk-container" ref={containerRef} />
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
---
|
|
116
509
|
|
|
117
|
-
|
|
510
|
+
## Session request fails
|
|
118
511
|
|
|
119
|
-
|
|
512
|
+
Check the browser network request:
|
|
120
513
|
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
container: containerRef.current,
|
|
514
|
+
```text
|
|
515
|
+
POST /api/nuvei/auth/session
|
|
516
|
+
```
|
|
125
517
|
|
|
126
|
-
|
|
127
|
-
environment: "preprod",
|
|
128
|
-
},
|
|
518
|
+
Then verify:
|
|
129
519
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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:
|
|
532
|
+
|
|
533
|
+
```tsx
|
|
534
|
+
onError: (error) => {
|
|
535
|
+
console.error("NuveiWebSDK Error:", error);
|
|
536
|
+
};
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
Also check the promise rejection:
|
|
540
|
+
|
|
541
|
+
```tsx
|
|
542
|
+
.catch((error) => {
|
|
543
|
+
console.error(
|
|
544
|
+
"NuveiWebSDK Mount Error:",
|
|
545
|
+
error
|
|
546
|
+
);
|
|
133
547
|
});
|
|
134
548
|
```
|
|
135
549
|
|
|
136
|
-
|
|
550
|
+
---
|
|
551
|
+
|
|
552
|
+
# 17. Minimal Integration
|
|
553
|
+
|
|
554
|
+
If you only need the simplest integration, the essential flow is:
|
|
555
|
+
|
|
556
|
+
```tsx
|
|
557
|
+
const fetchClientSession = async () => {
|
|
558
|
+
const response = await fetch(`${backendApiUrl}/api/nuvei/auth/session`, {
|
|
559
|
+
method: "POST",
|
|
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
|
+
}, []);
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
This is the recommended starting point for a basic React integration.
|
|
137
587
|
|
|
138
|
-
|
|
139
|
-
| ---------------------- | -------- | --------------------------------------------------- |
|
|
140
|
-
| `componentName` | Yes | Micro Frontend component to load |
|
|
141
|
-
| `container` | Yes | DOM element where the component will be mounted |
|
|
142
|
-
| `config.environment` | Yes | SDK environment (`local`, `dev`, `preprod`, `prod`) |
|
|
143
|
-
| `fetchClientSession` | No | Custom authentication/session callback |
|
|
144
|
-
| `refreshClientSession` | No | Custom session refresh callback |
|
|
145
|
-
| `destroySession` | No | Custom session destroy/logout callback |
|
|
146
|
-
| `config.requestId` | No | Merchant request ID; falls back to the host URL |
|
|
147
|
-
| `config.documentRequestId` | No | Document Utility request ID; falls back to the host URL |
|
|
588
|
+
---
|
|
148
589
|
|
|
149
|
-
|
|
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
|
@@ -284,7 +284,7 @@
|
|
|
284
284
|
},
|
|
285
285
|
sessionCheckInterval: 10 * 60 * 1e3,
|
|
286
286
|
// 5 minutes
|
|
287
|
-
environment: "uat"
|
|
287
|
+
environment: "uat"
|
|
288
288
|
};
|
|
289
289
|
|
|
290
290
|
// src/utils/date.utils.ts
|
|
@@ -503,7 +503,10 @@
|
|
|
503
503
|
* @throws {Error} Throws an error if something goes wrong during logout.
|
|
504
504
|
*/
|
|
505
505
|
this.logout = () => __async(this, null, function* () {
|
|
506
|
-
|
|
506
|
+
let logoutRes = true;
|
|
507
|
+
if (this.authProvider.destroySession) {
|
|
508
|
+
logoutRes = yield this.authProvider.destroySession();
|
|
509
|
+
}
|
|
507
510
|
if (logoutRes) {
|
|
508
511
|
this.stopSessionExpiryCheck();
|
|
509
512
|
this.destroyIframe();
|
|
@@ -549,7 +552,7 @@
|
|
|
549
552
|
return this.cachedSession;
|
|
550
553
|
} else {
|
|
551
554
|
const session = yield this.authProvider.fetchClientSession();
|
|
552
|
-
if (!session.
|
|
555
|
+
if (!(session == null ? void 0 : session.accessToken)) {
|
|
553
556
|
throw new Error("Client Session Fetch Failed(Web SDK)");
|
|
554
557
|
}
|
|
555
558
|
if (!((_d = this.sdkConfig) == null ? void 0 : _d.sessionValidation(session.accessToken, session.accessTokenExpiry))) {
|
|
@@ -579,12 +582,15 @@
|
|
|
579
582
|
this.destroyIframe();
|
|
580
583
|
throw new Error("No session found(Web SDK)");
|
|
581
584
|
}
|
|
585
|
+
if (!this.authProvider.refreshClientSession) {
|
|
586
|
+
throw new Error("refreshClientSession is not provided(Web SDK)");
|
|
587
|
+
}
|
|
582
588
|
try {
|
|
583
589
|
const response = yield this.authProvider.refreshClientSession({
|
|
584
590
|
accessToken: this.cachedSession.accessToken,
|
|
585
591
|
refreshToken: this.cachedSession.refreshToken
|
|
586
592
|
});
|
|
587
|
-
if (!response.
|
|
593
|
+
if (!(response == null ? void 0 : response.accessToken)) {
|
|
588
594
|
console.log("Invalid refresh session token(Called From Web SDK)");
|
|
589
595
|
throw new Error("Refresh Client Session Failed");
|
|
590
596
|
}
|
|
@@ -667,6 +673,10 @@
|
|
|
667
673
|
*/
|
|
668
674
|
this.startSessionExpiryCheck = () => __async(this, null, function* () {
|
|
669
675
|
var _a, _b;
|
|
676
|
+
if (!this.authProvider.refreshClientSession) {
|
|
677
|
+
console.warn("refreshClientSession not provided, session will not be refreshed automatically(Web SDK)");
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
670
680
|
const isRefreshExpired = isDateExpired((_a = this.cachedSession) == null ? void 0 : _a.refreshTokenExpiry);
|
|
671
681
|
if (isRefreshExpired) {
|
|
672
682
|
console.error("Refresh token is expired. Stopping session expiry check(Web SDK).");
|
|
@@ -837,7 +847,7 @@
|
|
|
837
847
|
refreshClientSession: refreshClientSession != null ? refreshClientSession : defaultAuthProvider.refreshClientSession,
|
|
838
848
|
destroySession: destroySession != null ? destroySession : defaultAuthProvider.destroySession
|
|
839
849
|
};
|
|
840
|
-
} else if (fetchClientSession
|
|
850
|
+
} else if (typeof fetchClientSession === "function") {
|
|
841
851
|
this.authProvider = {
|
|
842
852
|
fetchClientSession,
|
|
843
853
|
refreshClientSession,
|
|
@@ -845,7 +855,7 @@
|
|
|
845
855
|
};
|
|
846
856
|
} else {
|
|
847
857
|
throw new Error(
|
|
848
|
-
"authConfig is required
|
|
858
|
+
"authConfig or fetchClientSession is required to initialize SDK(Web SDK)"
|
|
849
859
|
);
|
|
850
860
|
}
|
|
851
861
|
this.componentName = componentName;
|
package/dist/cdn-index.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";(()=>{var
|
|
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},T=(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 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&&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 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=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||"",T(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(y(e))}),n=yield this.parseJsonResponse(t,s,"Frontend AccessToken Refresh");return this.currentAccessToken=n.accessToken||this.currentAccessToken,T(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 E(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]=E(r[t],e[t]):s[t]=e[t];return s}var A={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:"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=N[r])!=null?e:N.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=v(i);return`${t}${n}${a}`};var f=class f{constructor(e){this.sdkConfig=h({},A);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*(){(yield this.authProvider.destroySession())?(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.
|
|
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: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=E(A,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 R=window;R.NCWebSDK=m;R.NuveiSDK=m;R.ModulesNameEnum=p;})();
|
|
@@ -14,12 +14,4 @@ export declare enum AcknowledgeMessageActionEnum {
|
|
|
14
14
|
IFRAME_READY = "IFRAME_READY"
|
|
15
15
|
}
|
|
16
16
|
export type AcknowledgeMessageActionType = keyof typeof AcknowledgeMessageActionEnum;
|
|
17
|
-
export declare enum EnvironmentEnum {
|
|
18
|
-
LOCAL = "local",
|
|
19
|
-
DEV3 = "dev3",
|
|
20
|
-
DEV2 = "dev2",
|
|
21
|
-
UAT = "uat",
|
|
22
|
-
PROD = "prod"
|
|
23
|
-
}
|
|
24
|
-
export type EnvironmentType = keyof typeof EnvironmentEnum;
|
|
25
17
|
//# 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;CAC9B;AACD,MAAM,MAAM,4BAA4B,GAAG,MAAM,OAAO,4BAA4B,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.AcknowledgeMessageActionEnum = exports.PostMessageActionEnum = exports.ModulesNameEnum = void 0;
|
|
4
4
|
// Define the Enum for component names
|
|
5
5
|
var ModulesNameEnum;
|
|
6
6
|
(function (ModulesNameEnum) {
|
|
@@ -19,11 +19,3 @@ var AcknowledgeMessageActionEnum;
|
|
|
19
19
|
(function (AcknowledgeMessageActionEnum) {
|
|
20
20
|
AcknowledgeMessageActionEnum["IFRAME_READY"] = "IFRAME_READY";
|
|
21
21
|
})(AcknowledgeMessageActionEnum || (exports.AcknowledgeMessageActionEnum = AcknowledgeMessageActionEnum = {}));
|
|
22
|
-
var EnvironmentEnum;
|
|
23
|
-
(function (EnvironmentEnum) {
|
|
24
|
-
EnvironmentEnum["LOCAL"] = "local";
|
|
25
|
-
EnvironmentEnum["DEV3"] = "dev3";
|
|
26
|
-
EnvironmentEnum["DEV2"] = "dev2";
|
|
27
|
-
EnvironmentEnum["UAT"] = "uat";
|
|
28
|
-
EnvironmentEnum["PROD"] = "prod";
|
|
29
|
-
})(EnvironmentEnum || (exports.EnvironmentEnum = EnvironmentEnum = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-config.d.ts","sourceRoot":"","sources":["../../src/config/default-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"default-config.d.ts","sourceRoot":"","sources":["../../src/config/default-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,eAAO,MAAM,cAAc,EAAE,eAmB5B,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DEFAULT_CONFIG = void 0;
|
|
4
|
-
var enums_1 = require("../common/enums");
|
|
5
4
|
// Configuration Constants
|
|
6
5
|
exports.DEFAULT_CONFIG = {
|
|
7
6
|
iframeId: 'nc-web-sdk-iframe',
|
|
@@ -21,5 +20,5 @@ exports.DEFAULT_CONFIG = {
|
|
|
21
20
|
return expiryDate > currentDate;
|
|
22
21
|
},
|
|
23
22
|
sessionCheckInterval: 10 * 60 * 1000, // 5 minutes
|
|
24
|
-
environment:
|
|
23
|
+
environment: 'uat',
|
|
25
24
|
};
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -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,YA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E3C;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,CAwBzB;IAEF;;;OAGG;IACH,OAAO,CAAC,iBAAiB,CAIvB;IAEF;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB,CASzB;CACH"}
|
package/dist/core/index.js
CHANGED
|
@@ -200,9 +200,14 @@ var NuveiSDK = /** @class */ (function () {
|
|
|
200
200
|
var logoutRes;
|
|
201
201
|
return __generator(this, function (_b) {
|
|
202
202
|
switch (_b.label) {
|
|
203
|
-
case 0:
|
|
203
|
+
case 0:
|
|
204
|
+
logoutRes = true;
|
|
205
|
+
if (!this.authProvider.destroySession) return [3 /*break*/, 2];
|
|
206
|
+
return [4 /*yield*/, this.authProvider.destroySession()];
|
|
204
207
|
case 1:
|
|
205
208
|
logoutRes = _b.sent();
|
|
209
|
+
_b.label = 2;
|
|
210
|
+
case 2:
|
|
206
211
|
if (logoutRes) {
|
|
207
212
|
this.stopSessionExpiryCheck();
|
|
208
213
|
this.destroyIframe();
|
|
@@ -255,7 +260,7 @@ var NuveiSDK = /** @class */ (function () {
|
|
|
255
260
|
case 1: return [4 /*yield*/, this.authProvider.fetchClientSession()];
|
|
256
261
|
case 2:
|
|
257
262
|
session = _f.sent();
|
|
258
|
-
if (!session.
|
|
263
|
+
if (!(session === null || session === void 0 ? void 0 : session.accessToken)) {
|
|
259
264
|
throw new Error('Client Session Fetch Failed(Web SDK)');
|
|
260
265
|
}
|
|
261
266
|
if (!((_e = this.sdkConfig) === null || _e === void 0 ? void 0 : _e.sessionValidation(session.accessToken, session.accessTokenExpiry))) {
|
|
@@ -290,6 +295,9 @@ var NuveiSDK = /** @class */ (function () {
|
|
|
290
295
|
this.destroyIframe();
|
|
291
296
|
throw new Error('No session found(Web SDK)');
|
|
292
297
|
}
|
|
298
|
+
if (!this.authProvider.refreshClientSession) {
|
|
299
|
+
throw new Error('refreshClientSession is not provided(Web SDK)');
|
|
300
|
+
}
|
|
293
301
|
_d.label = 1;
|
|
294
302
|
case 1:
|
|
295
303
|
_d.trys.push([1, 3, , 4]);
|
|
@@ -299,7 +307,7 @@ var NuveiSDK = /** @class */ (function () {
|
|
|
299
307
|
})];
|
|
300
308
|
case 2:
|
|
301
309
|
response = _d.sent();
|
|
302
|
-
if (!response.
|
|
310
|
+
if (!(response === null || response === void 0 ? void 0 : response.accessToken)) {
|
|
303
311
|
console.log('Invalid refresh session token(Called From Web SDK)');
|
|
304
312
|
throw new Error('Refresh Client Session Failed');
|
|
305
313
|
}
|
|
@@ -394,6 +402,10 @@ var NuveiSDK = /** @class */ (function () {
|
|
|
394
402
|
var _this = this;
|
|
395
403
|
var _b, _c;
|
|
396
404
|
return __generator(this, function (_d) {
|
|
405
|
+
if (!this.authProvider.refreshClientSession) {
|
|
406
|
+
console.warn('refreshClientSession not provided, session will not be refreshed automatically(Web SDK)');
|
|
407
|
+
return [2 /*return*/];
|
|
408
|
+
}
|
|
397
409
|
isRefreshExpired = (0, date_utils_1.isDateExpired)((_b = this.cachedSession) === null || _b === void 0 ? void 0 : _b.refreshTokenExpiry);
|
|
398
410
|
if (isRefreshExpired) {
|
|
399
411
|
console.error('Refresh token is expired. Stopping session expiry check(Web SDK).');
|
|
@@ -574,7 +586,7 @@ var NuveiSDK = /** @class */ (function () {
|
|
|
574
586
|
destroySession: destroySession !== null && destroySession !== void 0 ? destroySession : defaultAuthProvider.destroySession,
|
|
575
587
|
};
|
|
576
588
|
}
|
|
577
|
-
else if (fetchClientSession
|
|
589
|
+
else if (typeof fetchClientSession === 'function') {
|
|
578
590
|
this.authProvider = {
|
|
579
591
|
fetchClientSession: fetchClientSession,
|
|
580
592
|
refreshClientSession: refreshClientSession,
|
|
@@ -582,7 +594,7 @@ var NuveiSDK = /** @class */ (function () {
|
|
|
582
594
|
};
|
|
583
595
|
}
|
|
584
596
|
else {
|
|
585
|
-
throw new Error('authConfig is required
|
|
597
|
+
throw new Error('authConfig or fetchClientSession is required to initialize SDK(Web SDK)');
|
|
586
598
|
}
|
|
587
599
|
this.componentName = componentName;
|
|
588
600
|
this.container = container;
|
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
1
|
+
import { ModulesNameEnum } from "../common/enums";
|
|
2
|
+
export type AuthOptions = {
|
|
3
|
+
authConfig: IAuthConfig;
|
|
3
4
|
fetchClientSession?: () => Promise<IClientSession>;
|
|
4
5
|
refreshClientSession?: (payload: IRefreshClientSessionParams) => Promise<IClientRefreshSession>;
|
|
5
6
|
destroySession?: () => Promise<boolean>;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
} | {
|
|
8
|
+
authConfig?: never;
|
|
9
|
+
fetchClientSession: () => Promise<IClientSession>;
|
|
10
|
+
refreshClientSession?: (payload: IRefreshClientSessionParams) => Promise<IClientRefreshSession>;
|
|
11
|
+
destroySession?: () => Promise<boolean>;
|
|
12
|
+
};
|
|
13
|
+
export type INuveiInitParams = {
|
|
14
|
+
componentName: ModulesNameEnum;
|
|
15
|
+
container: HTMLElement | string;
|
|
9
16
|
config?: Partial<INuveiSdkConfig>;
|
|
10
17
|
onReady?: (instance: INuveiInstance) => void | Promise<void>;
|
|
11
18
|
onError?: (error: unknown) => void;
|
|
12
19
|
onMessage?: (message: any) => void;
|
|
13
|
-
}
|
|
20
|
+
} & AuthOptions;
|
|
14
21
|
export interface IBaseClientSession {
|
|
15
22
|
accessToken: string;
|
|
16
23
|
accessTokenExpiry: string;
|
|
@@ -32,8 +39,8 @@ export interface IClientRefreshSession {
|
|
|
32
39
|
}
|
|
33
40
|
export interface IAuthProvider {
|
|
34
41
|
fetchClientSession: () => Promise<IClientSession>;
|
|
35
|
-
refreshClientSession
|
|
36
|
-
destroySession
|
|
42
|
+
refreshClientSession?: (payload: IRefreshClientSessionParams) => Promise<IClientRefreshSession>;
|
|
43
|
+
destroySession?: () => Promise<boolean>;
|
|
37
44
|
}
|
|
38
45
|
export interface IAuthConfig {
|
|
39
46
|
authApiUrl: string;
|
|
@@ -46,7 +53,7 @@ export interface INuveiSdkConfig {
|
|
|
46
53
|
iframeStyle: Record<string, string>;
|
|
47
54
|
sessionValidation: (token: string, tokenExpiry?: string) => boolean;
|
|
48
55
|
sessionCheckInterval: number;
|
|
49
|
-
environment:
|
|
56
|
+
environment: 'local' | 'dev3' | 'dev2' | 'uat' | 'prod';
|
|
50
57
|
iframeBaseUrl?: string;
|
|
51
58
|
requestId?: string;
|
|
52
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,
|
|
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,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