@nibssplc/cams-sdk-react 1.0.0-rc.44 → 1.0.0-rc.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/useCAMSMSALAuth.d.ts +5 -1
- package/dist/index.cjs.js +199 -45
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +199 -45
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -60,7 +60,7 @@ function __rest(s, e) {
|
|
|
60
60
|
return t;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
63
|
+
function __awaiter$1(thisArg, _arguments, P, generator) {
|
|
64
64
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
65
65
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
66
66
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -70,7 +70,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
function __generator(thisArg, body) {
|
|
73
|
+
function __generator$1(thisArg, body) {
|
|
74
74
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
75
75
|
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
76
76
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
@@ -167,10 +167,10 @@ function useCAMSAuth(options) {
|
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
}, [options.storageKey]);
|
|
170
|
-
var login = useCallback(function (config) { return __awaiter(_this, void 0, void 0, function () {
|
|
170
|
+
var login = useCallback(function (config) { return __awaiter$1(_this, void 0, void 0, function () {
|
|
171
171
|
var loginConfig, userProfile, err_1, e, isPopupClosedError, restoredToken, userProfile;
|
|
172
172
|
var _a, _b, _c;
|
|
173
|
-
return __generator(this, function (_d) {
|
|
173
|
+
return __generator$1(this, function (_d) {
|
|
174
174
|
switch (_d.label) {
|
|
175
175
|
case 0:
|
|
176
176
|
if (!sessionManagerRef.current)
|
|
@@ -218,8 +218,8 @@ function useCAMSAuth(options) {
|
|
|
218
218
|
}
|
|
219
219
|
});
|
|
220
220
|
}); }, [options.idleTimeout]);
|
|
221
|
-
var logout = useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
222
|
-
return __generator(this, function (_a) {
|
|
221
|
+
var logout = useCallback(function () { return __awaiter$1(_this, void 0, void 0, function () {
|
|
222
|
+
return __generator$1(this, function (_a) {
|
|
223
223
|
switch (_a.label) {
|
|
224
224
|
case 0:
|
|
225
225
|
if (!sessionManagerRef.current)
|
|
@@ -249,6 +249,147 @@ function useCAMSAuth(options) {
|
|
|
249
249
|
};
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
+
var _a;
|
|
253
|
+
// Crypto polyfill for MSAL browser compatibility
|
|
254
|
+
// Only apply if crypto.subtle is completely missing
|
|
255
|
+
if (typeof window !== "undefined" && !((_a = window.crypto) === null || _a === void 0 ? void 0 : _a.subtle)) {
|
|
256
|
+
// Ensure crypto object exists
|
|
257
|
+
if (!window.crypto) {
|
|
258
|
+
window.crypto = {};
|
|
259
|
+
}
|
|
260
|
+
// Polyfill getRandomValues
|
|
261
|
+
if (!window.crypto.getRandomValues) {
|
|
262
|
+
window.crypto.getRandomValues = function (array) {
|
|
263
|
+
var bytes = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
|
|
264
|
+
for (var i = 0; i < bytes.length; i++) {
|
|
265
|
+
bytes[i] = Math.floor(Math.random() * 256);
|
|
266
|
+
}
|
|
267
|
+
return array;
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
var sha256_1 = function (data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
271
|
+
var toUint8, bytes, hash, k, ml, msg, dv, high, low, i, w, j, j, s0, s1, a, b, c, d, e, f, g, h, j, S1, ch, temp1, S0, maj, temp2, result, i;
|
|
272
|
+
return __generator(this, function (_a) {
|
|
273
|
+
toUint8 = function (src) {
|
|
274
|
+
if (src instanceof ArrayBuffer)
|
|
275
|
+
return new Uint8Array(src);
|
|
276
|
+
if (ArrayBuffer.isView(src)) {
|
|
277
|
+
var view = src;
|
|
278
|
+
return new Uint8Array(view.buffer, view.byteOffset || 0, view.byteLength);
|
|
279
|
+
}
|
|
280
|
+
throw new TypeError("Unsupported BufferSource");
|
|
281
|
+
};
|
|
282
|
+
bytes = toUint8(data);
|
|
283
|
+
hash = new Uint32Array(8);
|
|
284
|
+
k = new Uint32Array([
|
|
285
|
+
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1,
|
|
286
|
+
0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
|
|
287
|
+
0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786,
|
|
288
|
+
0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
289
|
+
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,
|
|
290
|
+
0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
|
|
291
|
+
0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b,
|
|
292
|
+
0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
293
|
+
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a,
|
|
294
|
+
0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
|
|
295
|
+
0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
|
|
296
|
+
]);
|
|
297
|
+
hash[0] = 0x6a09e667;
|
|
298
|
+
hash[1] = 0xbb67ae85;
|
|
299
|
+
hash[2] = 0x3c6ef372;
|
|
300
|
+
hash[3] = 0xa54ff53a;
|
|
301
|
+
hash[4] = 0x510e527f;
|
|
302
|
+
hash[5] = 0x9b05688c;
|
|
303
|
+
hash[6] = 0x1f83d9ab;
|
|
304
|
+
hash[7] = 0x5be0cd19;
|
|
305
|
+
ml = bytes.length * 8;
|
|
306
|
+
msg = new Uint8Array(bytes.length + 64 + ((64 - ((bytes.length + 9) % 64)) % 64));
|
|
307
|
+
msg.set(bytes);
|
|
308
|
+
msg[bytes.length] = 0x80;
|
|
309
|
+
dv = new DataView(msg.buffer);
|
|
310
|
+
high = Math.floor(ml / 0x100000000);
|
|
311
|
+
low = ml >>> 0;
|
|
312
|
+
dv.setUint32(msg.length - 8, high, false);
|
|
313
|
+
dv.setUint32(msg.length - 4, low, false);
|
|
314
|
+
for (i = 0; i < msg.length; i += 64) {
|
|
315
|
+
w = new Uint32Array(64);
|
|
316
|
+
for (j = 0; j < 16; j++)
|
|
317
|
+
w[j] = new DataView(msg.buffer).getUint32(i + j * 4, false);
|
|
318
|
+
for (j = 16; j < 64; j++) {
|
|
319
|
+
s0 = ((w[j - 15] >>> 7) | (w[j - 15] << 25)) ^
|
|
320
|
+
((w[j - 15] >>> 18) | (w[j - 15] << 14)) ^
|
|
321
|
+
(w[j - 15] >>> 3);
|
|
322
|
+
s1 = ((w[j - 2] >>> 17) | (w[j - 2] << 15)) ^
|
|
323
|
+
((w[j - 2] >>> 19) | (w[j - 2] << 13)) ^
|
|
324
|
+
(w[j - 2] >>> 10);
|
|
325
|
+
w[j] = (w[j - 16] + s0 + w[j - 7] + s1) >>> 0;
|
|
326
|
+
}
|
|
327
|
+
a = hash[0], b = hash[1], c = hash[2], d = hash[3], e = hash[4], f = hash[5], g = hash[6], h = hash[7];
|
|
328
|
+
for (j = 0; j < 64; j++) {
|
|
329
|
+
S1 = ((e >>> 6) | (e << 26)) ^
|
|
330
|
+
((e >>> 11) | (e << 21)) ^
|
|
331
|
+
((e >>> 25) | (e << 7));
|
|
332
|
+
ch = (e & f) ^ (~e & g);
|
|
333
|
+
temp1 = (h + S1 + ch + k[j] + w[j]) >>> 0;
|
|
334
|
+
S0 = ((a >>> 2) | (a << 30)) ^
|
|
335
|
+
((a >>> 13) | (a << 19)) ^
|
|
336
|
+
((a >>> 22) | (a << 10));
|
|
337
|
+
maj = (a & b) ^ (a & c) ^ (b & c);
|
|
338
|
+
temp2 = (S0 + maj) >>> 0;
|
|
339
|
+
h = g;
|
|
340
|
+
g = f;
|
|
341
|
+
f = e;
|
|
342
|
+
e = (d + temp1) >>> 0;
|
|
343
|
+
d = c;
|
|
344
|
+
c = b;
|
|
345
|
+
b = a;
|
|
346
|
+
a = (temp1 + temp2) >>> 0;
|
|
347
|
+
}
|
|
348
|
+
hash[0] = (hash[0] + a) >>> 0;
|
|
349
|
+
hash[1] = (hash[1] + b) >>> 0;
|
|
350
|
+
hash[2] = (hash[2] + c) >>> 0;
|
|
351
|
+
hash[3] = (hash[3] + d) >>> 0;
|
|
352
|
+
hash[4] = (hash[4] + e) >>> 0;
|
|
353
|
+
hash[5] = (hash[5] + f) >>> 0;
|
|
354
|
+
hash[6] = (hash[6] + g) >>> 0;
|
|
355
|
+
hash[7] = (hash[7] + h) >>> 0;
|
|
356
|
+
}
|
|
357
|
+
result = new Uint8Array(32);
|
|
358
|
+
for (i = 0; i < 8; i++)
|
|
359
|
+
new DataView(result.buffer).setUint32(i * 4, hash[i], false);
|
|
360
|
+
return [2 /*return*/, result.buffer];
|
|
361
|
+
});
|
|
362
|
+
}); };
|
|
363
|
+
// Create the polyfilled subtle object
|
|
364
|
+
var polyfillSubtle = {
|
|
365
|
+
digest: function (algorithm, data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
366
|
+
var alg;
|
|
367
|
+
return __generator(this, function (_a) {
|
|
368
|
+
alg = typeof algorithm === "string"
|
|
369
|
+
? algorithm
|
|
370
|
+
: algorithm.name;
|
|
371
|
+
if (alg === "SHA-256")
|
|
372
|
+
return [2 /*return*/, sha256_1(data)];
|
|
373
|
+
throw new Error("Unsupported algorithm: ".concat(alg));
|
|
374
|
+
});
|
|
375
|
+
}); },
|
|
376
|
+
};
|
|
377
|
+
// Set the polyfilled subtle object
|
|
378
|
+
window.crypto.subtle = polyfillSubtle;
|
|
379
|
+
// Polyfill randomUUID
|
|
380
|
+
if (!window.crypto.randomUUID) {
|
|
381
|
+
window.crypto.randomUUID =
|
|
382
|
+
function () {
|
|
383
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
|
|
384
|
+
var r = (Math.random() * 16) | 0;
|
|
385
|
+
var v = c === "x" ? r : (r & 0x3) | 0x8;
|
|
386
|
+
return v.toString(16);
|
|
387
|
+
});
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
console.log("Crypto polyfill applied (native crypto.subtle not available)");
|
|
391
|
+
}
|
|
392
|
+
|
|
252
393
|
var setCookie = function (name, value, days) {
|
|
253
394
|
if (days === void 0) { days = 1; }
|
|
254
395
|
var expires = new Date(Date.now() + days * 24 * 60 * 60 * 1000).toUTCString();
|
|
@@ -356,10 +497,10 @@ function useCAMSMSALAuth(options) {
|
|
|
356
497
|
// };
|
|
357
498
|
// handleRedirect();
|
|
358
499
|
// }, []);
|
|
359
|
-
var login = useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
500
|
+
var login = useCallback(function () { return __awaiter$1(_this, void 0, void 0, function () {
|
|
360
501
|
var response, mfaConfig, authenticator, err_1, camsError_1, camsError;
|
|
361
502
|
var _a;
|
|
362
|
-
return __generator(this, function (_b) {
|
|
503
|
+
return __generator$1(this, function (_b) {
|
|
363
504
|
switch (_b.label) {
|
|
364
505
|
case 0:
|
|
365
506
|
if (inProgress !== InteractionStatus.None) {
|
|
@@ -401,7 +542,10 @@ function useCAMSMSALAuth(options) {
|
|
|
401
542
|
idToken: response.idToken,
|
|
402
543
|
}));
|
|
403
544
|
}
|
|
404
|
-
onAuthSuccess === null || onAuthSuccess === void 0 ? void 0 : onAuthSuccess(
|
|
545
|
+
onAuthSuccess === null || onAuthSuccess === void 0 ? void 0 : onAuthSuccess({
|
|
546
|
+
accessToken: response.accessToken,
|
|
547
|
+
idToken: response.idToken,
|
|
548
|
+
});
|
|
405
549
|
return [3 /*break*/, 4];
|
|
406
550
|
case 3:
|
|
407
551
|
err_1 = _b.sent();
|
|
@@ -431,9 +575,19 @@ function useCAMSMSALAuth(options) {
|
|
|
431
575
|
case 4: return [2 /*return*/];
|
|
432
576
|
}
|
|
433
577
|
});
|
|
434
|
-
}); }, [
|
|
435
|
-
|
|
436
|
-
|
|
578
|
+
}); }, [
|
|
579
|
+
instance,
|
|
580
|
+
scopes,
|
|
581
|
+
prompt,
|
|
582
|
+
appCode,
|
|
583
|
+
MFAEndpoint,
|
|
584
|
+
onAuthSuccess,
|
|
585
|
+
onAuthError,
|
|
586
|
+
storageKey,
|
|
587
|
+
inProgress,
|
|
588
|
+
]);
|
|
589
|
+
var completeMFA = useCallback(function (data) { return __awaiter$1(_this, void 0, void 0, function () {
|
|
590
|
+
return __generator$1(this, function (_a) {
|
|
437
591
|
if (!mfaAuthenticator) {
|
|
438
592
|
throw new CAMSError(CAMSErrorType.API_VALIDATION_ERROR, "MFA Authenticator not initialized");
|
|
439
593
|
}
|
|
@@ -467,8 +621,8 @@ function useCAMSMSALAuth(options) {
|
|
|
467
621
|
return [2 /*return*/];
|
|
468
622
|
});
|
|
469
623
|
}); }, [mfaAuthenticator, accessToken, idToken, storageKey, activeCookiePeriod]);
|
|
470
|
-
var sendEmailOTP = useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
471
|
-
return __generator(this, function (_a) {
|
|
624
|
+
var sendEmailOTP = useCallback(function () { return __awaiter$1(_this, void 0, void 0, function () {
|
|
625
|
+
return __generator$1(this, function (_a) {
|
|
472
626
|
switch (_a.label) {
|
|
473
627
|
case 0:
|
|
474
628
|
if (!mfaAuthenticator) {
|
|
@@ -479,9 +633,9 @@ function useCAMSMSALAuth(options) {
|
|
|
479
633
|
}
|
|
480
634
|
});
|
|
481
635
|
}); }, [mfaAuthenticator]);
|
|
482
|
-
var logout = useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
636
|
+
var logout = useCallback(function () { return __awaiter$1(_this, void 0, void 0, function () {
|
|
483
637
|
var err_2, camsError;
|
|
484
|
-
return __generator(this, function (_a) {
|
|
638
|
+
return __generator$1(this, function (_a) {
|
|
485
639
|
switch (_a.label) {
|
|
486
640
|
case 0:
|
|
487
641
|
_a.trys.push([0, 2, , 3]);
|
|
@@ -566,10 +720,10 @@ function arrayBufferToBase64url(buffer) {
|
|
|
566
720
|
* @returns A promise that resolves to a JSON-serializable representation of the PublicKeyCredential.
|
|
567
721
|
*/
|
|
568
722
|
function register(options) {
|
|
569
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
723
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
570
724
|
var createOptions, credential, publicKeyCredential, attestationResponse, transports, err_1;
|
|
571
725
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
572
|
-
return __generator(this, function (_k) {
|
|
726
|
+
return __generator$1(this, function (_k) {
|
|
573
727
|
switch (_k.label) {
|
|
574
728
|
case 0:
|
|
575
729
|
_k.trys.push([0, 2, , 3]);
|
|
@@ -627,10 +781,10 @@ function register(options) {
|
|
|
627
781
|
* @returns A promise that resolves to a JSON-serializable representation of the PublicKeyCredential.
|
|
628
782
|
*/
|
|
629
783
|
function authenticate(options) {
|
|
630
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
784
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
631
785
|
var getOptions, credential, publicKeyCredential, assertionResponse;
|
|
632
786
|
var _a;
|
|
633
|
-
return __generator(this, function (_b) {
|
|
787
|
+
return __generator$1(this, function (_b) {
|
|
634
788
|
switch (_b.label) {
|
|
635
789
|
case 0:
|
|
636
790
|
getOptions = __assign(__assign({}, options), { challenge: base64urlToArrayBuffer(options.challenge), allowCredentials: (_a = options.allowCredentials) === null || _a === void 0 ? void 0 : _a.map(function (cred) { return (__assign(__assign({}, cred), { id: base64urlToArrayBuffer(cred.id) })); }) });
|
|
@@ -1180,8 +1334,8 @@ function CAMSMSALProviderInner(_a) {
|
|
|
1180
1334
|
}
|
|
1181
1335
|
}, [userProfile, profileStorageKey]);
|
|
1182
1336
|
// Enhanced logout that also clears profile
|
|
1183
|
-
var enhancedLogout = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1184
|
-
return __generator(this, function (_a) {
|
|
1337
|
+
var enhancedLogout = function () { return __awaiter$1(_this, void 0, void 0, function () {
|
|
1338
|
+
return __generator$1(this, function (_a) {
|
|
1185
1339
|
switch (_a.label) {
|
|
1186
1340
|
case 0: return [4 /*yield*/, auth.logout()];
|
|
1187
1341
|
case 1:
|
|
@@ -1282,8 +1436,8 @@ function CAMSProviderCore(props) {
|
|
|
1282
1436
|
}
|
|
1283
1437
|
}
|
|
1284
1438
|
}, [userProfile, profileStorageKey]);
|
|
1285
|
-
var enhancedLogout = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1286
|
-
return __generator(this, function (_a) {
|
|
1439
|
+
var enhancedLogout = function () { return __awaiter$1(_this, void 0, void 0, function () {
|
|
1440
|
+
return __generator$1(this, function (_a) {
|
|
1287
1441
|
switch (_a.label) {
|
|
1288
1442
|
case 0: return [4 /*yield*/, auth.logout()];
|
|
1289
1443
|
case 1:
|
|
@@ -1780,9 +1934,9 @@ var useOTPHandler = function (_a) {
|
|
|
1780
1934
|
var _b = useState(false), loading = _b[0], setLoading = _b[1];
|
|
1781
1935
|
var _c = useState(0), attemptCount = _c[0], setAttemptCount = _c[1];
|
|
1782
1936
|
var _d = useState(false), isMaxAttemptsReached = _d[0], setIsMaxAttemptsReached = _d[1];
|
|
1783
|
-
var handleSubmitOTP = useMemo(function () { return function (authenticationValue) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1937
|
+
var handleSubmitOTP = useMemo(function () { return function (authenticationValue) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
1784
1938
|
var currentAttempt, response, error_1, currentAttempt;
|
|
1785
|
-
return __generator(this, function (_a) {
|
|
1939
|
+
return __generator$1(this, function (_a) {
|
|
1786
1940
|
switch (_a.label) {
|
|
1787
1941
|
case 0:
|
|
1788
1942
|
if (isMaxAttemptsReached) {
|
|
@@ -1872,9 +2026,9 @@ var useCredentialsHandler = function (onAuthComplete) {
|
|
|
1872
2026
|
var _b = useState(0), attemptCount = _b[0], setAttemptCount = _b[1];
|
|
1873
2027
|
var _c = useState(false), isMaxAttemptsReached = _c[0], setIsMaxAttemptsReached = _c[1];
|
|
1874
2028
|
var handleSubmitCredentials = useMemo(function () {
|
|
1875
|
-
return function (CredAuthEndpoint, credentials, appCode) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2029
|
+
return function (CredAuthEndpoint, credentials, appCode) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
1876
2030
|
var currentAttempt, response, error_2, currentAttempt;
|
|
1877
|
-
return __generator(this, function (_a) {
|
|
2031
|
+
return __generator$1(this, function (_a) {
|
|
1878
2032
|
switch (_a.label) {
|
|
1879
2033
|
case 0:
|
|
1880
2034
|
_a.trys.push([0, 2, 3, 4]);
|
|
@@ -1946,15 +2100,15 @@ var MFAOptions = function (_a) {
|
|
|
1946
2100
|
var context = useCAMSContext();
|
|
1947
2101
|
var _f = context.authMode === "MSAL" && "sendEmailOTP" in context
|
|
1948
2102
|
? context
|
|
1949
|
-
: { sendEmailOTP: null, completeMFA: null, logout: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
2103
|
+
: { sendEmailOTP: null, completeMFA: null, logout: function () { return __awaiter$1(void 0, void 0, void 0, function () { return __generator$1(this, function (_a) {
|
|
1950
2104
|
return [2 /*return*/];
|
|
1951
2105
|
}); }); } }, sendEmailOTP = _f.sendEmailOTP, completeMFA = _f.completeMFA, logout = _f.logout;
|
|
1952
2106
|
var accessToken = context.authMode === "MSAL" ? context.accessToken : "";
|
|
1953
2107
|
var idToken = context.authMode === "MSAL" ? context.idToken : "";
|
|
1954
2108
|
var authenticate = useWebAuthn().authenticate;
|
|
1955
|
-
var handleFIDOLogin = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
2109
|
+
var handleFIDOLogin = function () { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
1956
2110
|
var options, assertionResponse, error_1;
|
|
1957
|
-
return __generator(this, function (_a) {
|
|
2111
|
+
return __generator$1(this, function (_a) {
|
|
1958
2112
|
switch (_a.label) {
|
|
1959
2113
|
case 0:
|
|
1960
2114
|
_a.trys.push([0, 4, , 5]);
|
|
@@ -2034,9 +2188,9 @@ var MFAOptions = function (_a) {
|
|
|
2034
2188
|
}
|
|
2035
2189
|
var content = jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {});
|
|
2036
2190
|
if (!authType) {
|
|
2037
|
-
content = (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 text-center mb-6", children: "Choose your preferred authentication method:" }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-3", children: [jsxRuntimeExports.jsxs(Button, { variant: "outline", className: "w-full flex items-center justify-start gap-3 p-4 h-auto border-2 hover:border-[#506f4a] hover:bg-[#506f4a]/5 transition-all", onClick: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
2191
|
+
content = (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 text-center mb-6", children: "Choose your preferred authentication method:" }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-3", children: [jsxRuntimeExports.jsxs(Button, { variant: "outline", className: "w-full flex items-center justify-start gap-3 p-4 h-auto border-2 hover:border-[#506f4a] hover:bg-[#506f4a]/5 transition-all", onClick: function () { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
2038
2192
|
var success;
|
|
2039
|
-
return __generator(this, function (_a) {
|
|
2193
|
+
return __generator$1(this, function (_a) {
|
|
2040
2194
|
switch (_a.label) {
|
|
2041
2195
|
case 0:
|
|
2042
2196
|
// resetAttempts();
|
|
@@ -2107,16 +2261,16 @@ var ADLoginModal = function (_a) {
|
|
|
2107
2261
|
resolver: a$1(credentialsSchema),
|
|
2108
2262
|
defaultValues: { username: "", password: "" },
|
|
2109
2263
|
});
|
|
2110
|
-
var handleCredentialsSubmit = function (values) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2111
|
-
return __generator(this, function (_a) {
|
|
2264
|
+
var handleCredentialsSubmit = function (values) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
2265
|
+
return __generator$1(this, function (_a) {
|
|
2112
2266
|
setCredentials(values);
|
|
2113
2267
|
setStep("mfa");
|
|
2114
2268
|
return [2 /*return*/];
|
|
2115
2269
|
});
|
|
2116
2270
|
}); };
|
|
2117
|
-
var handleMFASubmit = function (code) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2271
|
+
var handleMFASubmit = function (code) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
2118
2272
|
var error_1;
|
|
2119
|
-
return __generator(this, function (_a) {
|
|
2273
|
+
return __generator$1(this, function (_a) {
|
|
2120
2274
|
switch (_a.label) {
|
|
2121
2275
|
case 0:
|
|
2122
2276
|
setIsLoading(true);
|
|
@@ -2177,8 +2331,8 @@ var DefaultLoginPage = function (_a) {
|
|
|
2177
2331
|
var login = context.login, isLoading = context.isLoading, authMode = context.authMode;
|
|
2178
2332
|
var _b = useState(false), showADModal = _b[0], setShowADModal = _b[1];
|
|
2179
2333
|
var register = useWebAuthn().register;
|
|
2180
|
-
var _c = useCredentialsHandler(function (state, data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2181
|
-
return __generator(this, function (_a) {
|
|
2334
|
+
var _c = useCredentialsHandler(function (state, data) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
2335
|
+
return __generator$1(this, function (_a) {
|
|
2182
2336
|
console.log(data);
|
|
2183
2337
|
if (state && data) {
|
|
2184
2338
|
context.isAuthenticated = true;
|
|
@@ -2204,9 +2358,9 @@ var DefaultLoginPage = function (_a) {
|
|
|
2204
2358
|
console.warn("Regular CAMS login requires configuration");
|
|
2205
2359
|
}
|
|
2206
2360
|
};
|
|
2207
|
-
var handleRegister = function (data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2361
|
+
var handleRegister = function (data) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
2208
2362
|
var options, attestationResponse, error_1;
|
|
2209
|
-
return __generator(this, function (_a) {
|
|
2363
|
+
return __generator$1(this, function (_a) {
|
|
2210
2364
|
switch (_a.label) {
|
|
2211
2365
|
case 0:
|
|
2212
2366
|
_a.trys.push([0, 4, , 5]);
|
|
@@ -2244,9 +2398,9 @@ var DefaultLoginPage = function (_a) {
|
|
|
2244
2398
|
// variant="outline"
|
|
2245
2399
|
className: "w-full flex items-center justify-center cursor-pointer bg-[#506f4a] hover:bg-[#506f4a] rounded-lg border border-transparent px-5 py-8 text-base font-medium transition-colors duration-250", onClick: handleMSALLogin, disabled: isLoading, children: [jsxRuntimeExports.jsx("img", { src: MicrosoftLogo, alt: "Microsoft Logo", width: 35, height: 35 }), jsxRuntimeExports.jsx("span", { className: "ml-2", children: isLoading ? "Logging in..." : "Sign in with Microsoft" })] }), useADLogin && (jsxRuntimeExports.jsxs(Button, { className: "w-full flex items-center justify-center cursor-pointer bg-[#506f4a] hover:bg-[#506f4a] rounded-lg border border-transparent px-5 py-8 text-base font-medium transition-colors duration-250", onClick: function () { return setShowADModal(true); }, disabled: isLoading, children: [jsxRuntimeExports.jsx(KeyIcon, { className: "text-[#506f4a]", size: 64 }), jsxRuntimeExports.jsx("span", { children: isLoading
|
|
2246
2400
|
? "Logging in..."
|
|
2247
|
-
: "Sign in with ActiveDirectory" })] })), usePassKey && (jsxRuntimeExports.jsxs(Button, { className: "w-full flex items-center justify-center cursor-pointer bg-[#506f4a] hover:bg-[#506f4a] rounded-lg border border-transparent px-5 py-8 text-base font-medium transition-colors duration-250", onClick: function () { return handleRegister(PassKeysRegisterProps); }, disabled: isLoading, children: [jsxRuntimeExports.jsx(KeyIcon, { className: "text-[#506f4a]", size: 64 }), jsxRuntimeExports.jsx("span", { children: "Create a Passkey" })] }))] }), jsxRuntimeExports.jsxs(CardFooter, { className: "flex items-center justify-center mt-6 space-x-2 text-gray-400 text-sm", children: [jsxRuntimeExports.jsx(ShieldCheck, { className: "w-4 h-4 text-[#506f4a] pulse-glow" }), jsxRuntimeExports.jsx("span", { children: "Powered By NIBSS" })] })] }) }) }, "landing"), jsxRuntimeExports.jsx(ADLoginModal, { open: showADModal, onOpenChange: setShowADModal, isLoading: isCredAuthLoading, setIsLoading: setIsCredAuthLoading, onLogin: function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
2401
|
+
: "Sign in with ActiveDirectory" })] })), usePassKey && (jsxRuntimeExports.jsxs(Button, { className: "w-full flex items-center justify-center cursor-pointer bg-[#506f4a] hover:bg-[#506f4a] rounded-lg border border-transparent px-5 py-8 text-base font-medium transition-colors duration-250", onClick: function () { return handleRegister(PassKeysRegisterProps); }, disabled: isLoading, children: [jsxRuntimeExports.jsx(KeyIcon, { className: "text-[#506f4a]", size: 64 }), jsxRuntimeExports.jsx("span", { children: "Create a Passkey" })] }))] }), jsxRuntimeExports.jsxs(CardFooter, { className: "flex items-center justify-center mt-6 space-x-2 text-gray-400 text-sm", children: [jsxRuntimeExports.jsx(ShieldCheck, { className: "w-4 h-4 text-[#506f4a] pulse-glow" }), jsxRuntimeExports.jsx("span", { children: "Powered By NIBSS" })] })] }) }) }, "landing"), jsxRuntimeExports.jsx(ADLoginModal, { open: showADModal, onOpenChange: setShowADModal, isLoading: isCredAuthLoading, setIsLoading: setIsCredAuthLoading, onLogin: function (_a) { return __awaiter$1(void 0, [_a], void 0, function (_b) {
|
|
2248
2402
|
var username = _b.username, password = _b.password, MFACode = _b.MFACode;
|
|
2249
|
-
return __generator(this, function (_c) {
|
|
2403
|
+
return __generator$1(this, function (_c) {
|
|
2250
2404
|
// Implement your AD login logic here
|
|
2251
2405
|
console.log("AD Login:", { username: username, password: password, MFACode: MFACode });
|
|
2252
2406
|
// Example: await adLoginService(username, password, mfaCode);
|
|
@@ -2287,8 +2441,8 @@ var MFAGate = function (_a) {
|
|
|
2287
2441
|
if (!success)
|
|
2288
2442
|
Logger.error("MFA authentication failed");
|
|
2289
2443
|
}, []);
|
|
2290
|
-
var handleAuthFailed = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
2291
|
-
return __generator(this, function (_a) {
|
|
2444
|
+
var handleAuthFailed = useCallback(function () { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
2445
|
+
return __generator$1(this, function (_a) {
|
|
2292
2446
|
switch (_a.label) {
|
|
2293
2447
|
case 0: return [4 /*yield*/, context.logout()];
|
|
2294
2448
|
case 1:
|