@nibssplc/cams-sdk-react 1.0.0-rc.44 → 1.0.0-rc.45
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 +1 -0
- package/dist/index.cjs.js +184 -43
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +184 -43
- 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) {
|
|
@@ -432,8 +573,8 @@ function useCAMSMSALAuth(options) {
|
|
|
432
573
|
}
|
|
433
574
|
});
|
|
434
575
|
}); }, [instance, scopes, prompt, appCode, MFAEndpoint, onAuthSuccess, onAuthError, storageKey, inProgress]);
|
|
435
|
-
var completeMFA = useCallback(function (data) { return __awaiter(_this, void 0, void 0, function () {
|
|
436
|
-
return __generator(this, function (_a) {
|
|
576
|
+
var completeMFA = useCallback(function (data) { return __awaiter$1(_this, void 0, void 0, function () {
|
|
577
|
+
return __generator$1(this, function (_a) {
|
|
437
578
|
if (!mfaAuthenticator) {
|
|
438
579
|
throw new CAMSError(CAMSErrorType.API_VALIDATION_ERROR, "MFA Authenticator not initialized");
|
|
439
580
|
}
|
|
@@ -467,8 +608,8 @@ function useCAMSMSALAuth(options) {
|
|
|
467
608
|
return [2 /*return*/];
|
|
468
609
|
});
|
|
469
610
|
}); }, [mfaAuthenticator, accessToken, idToken, storageKey, activeCookiePeriod]);
|
|
470
|
-
var sendEmailOTP = useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
471
|
-
return __generator(this, function (_a) {
|
|
611
|
+
var sendEmailOTP = useCallback(function () { return __awaiter$1(_this, void 0, void 0, function () {
|
|
612
|
+
return __generator$1(this, function (_a) {
|
|
472
613
|
switch (_a.label) {
|
|
473
614
|
case 0:
|
|
474
615
|
if (!mfaAuthenticator) {
|
|
@@ -479,9 +620,9 @@ function useCAMSMSALAuth(options) {
|
|
|
479
620
|
}
|
|
480
621
|
});
|
|
481
622
|
}); }, [mfaAuthenticator]);
|
|
482
|
-
var logout = useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
623
|
+
var logout = useCallback(function () { return __awaiter$1(_this, void 0, void 0, function () {
|
|
483
624
|
var err_2, camsError;
|
|
484
|
-
return __generator(this, function (_a) {
|
|
625
|
+
return __generator$1(this, function (_a) {
|
|
485
626
|
switch (_a.label) {
|
|
486
627
|
case 0:
|
|
487
628
|
_a.trys.push([0, 2, , 3]);
|
|
@@ -566,10 +707,10 @@ function arrayBufferToBase64url(buffer) {
|
|
|
566
707
|
* @returns A promise that resolves to a JSON-serializable representation of the PublicKeyCredential.
|
|
567
708
|
*/
|
|
568
709
|
function register(options) {
|
|
569
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
710
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
570
711
|
var createOptions, credential, publicKeyCredential, attestationResponse, transports, err_1;
|
|
571
712
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
572
|
-
return __generator(this, function (_k) {
|
|
713
|
+
return __generator$1(this, function (_k) {
|
|
573
714
|
switch (_k.label) {
|
|
574
715
|
case 0:
|
|
575
716
|
_k.trys.push([0, 2, , 3]);
|
|
@@ -627,10 +768,10 @@ function register(options) {
|
|
|
627
768
|
* @returns A promise that resolves to a JSON-serializable representation of the PublicKeyCredential.
|
|
628
769
|
*/
|
|
629
770
|
function authenticate(options) {
|
|
630
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
771
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
631
772
|
var getOptions, credential, publicKeyCredential, assertionResponse;
|
|
632
773
|
var _a;
|
|
633
|
-
return __generator(this, function (_b) {
|
|
774
|
+
return __generator$1(this, function (_b) {
|
|
634
775
|
switch (_b.label) {
|
|
635
776
|
case 0:
|
|
636
777
|
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 +1321,8 @@ function CAMSMSALProviderInner(_a) {
|
|
|
1180
1321
|
}
|
|
1181
1322
|
}, [userProfile, profileStorageKey]);
|
|
1182
1323
|
// Enhanced logout that also clears profile
|
|
1183
|
-
var enhancedLogout = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1184
|
-
return __generator(this, function (_a) {
|
|
1324
|
+
var enhancedLogout = function () { return __awaiter$1(_this, void 0, void 0, function () {
|
|
1325
|
+
return __generator$1(this, function (_a) {
|
|
1185
1326
|
switch (_a.label) {
|
|
1186
1327
|
case 0: return [4 /*yield*/, auth.logout()];
|
|
1187
1328
|
case 1:
|
|
@@ -1282,8 +1423,8 @@ function CAMSProviderCore(props) {
|
|
|
1282
1423
|
}
|
|
1283
1424
|
}
|
|
1284
1425
|
}, [userProfile, profileStorageKey]);
|
|
1285
|
-
var enhancedLogout = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1286
|
-
return __generator(this, function (_a) {
|
|
1426
|
+
var enhancedLogout = function () { return __awaiter$1(_this, void 0, void 0, function () {
|
|
1427
|
+
return __generator$1(this, function (_a) {
|
|
1287
1428
|
switch (_a.label) {
|
|
1288
1429
|
case 0: return [4 /*yield*/, auth.logout()];
|
|
1289
1430
|
case 1:
|
|
@@ -1780,9 +1921,9 @@ var useOTPHandler = function (_a) {
|
|
|
1780
1921
|
var _b = useState(false), loading = _b[0], setLoading = _b[1];
|
|
1781
1922
|
var _c = useState(0), attemptCount = _c[0], setAttemptCount = _c[1];
|
|
1782
1923
|
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 () {
|
|
1924
|
+
var handleSubmitOTP = useMemo(function () { return function (authenticationValue) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
1784
1925
|
var currentAttempt, response, error_1, currentAttempt;
|
|
1785
|
-
return __generator(this, function (_a) {
|
|
1926
|
+
return __generator$1(this, function (_a) {
|
|
1786
1927
|
switch (_a.label) {
|
|
1787
1928
|
case 0:
|
|
1788
1929
|
if (isMaxAttemptsReached) {
|
|
@@ -1872,9 +2013,9 @@ var useCredentialsHandler = function (onAuthComplete) {
|
|
|
1872
2013
|
var _b = useState(0), attemptCount = _b[0], setAttemptCount = _b[1];
|
|
1873
2014
|
var _c = useState(false), isMaxAttemptsReached = _c[0], setIsMaxAttemptsReached = _c[1];
|
|
1874
2015
|
var handleSubmitCredentials = useMemo(function () {
|
|
1875
|
-
return function (CredAuthEndpoint, credentials, appCode) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2016
|
+
return function (CredAuthEndpoint, credentials, appCode) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
1876
2017
|
var currentAttempt, response, error_2, currentAttempt;
|
|
1877
|
-
return __generator(this, function (_a) {
|
|
2018
|
+
return __generator$1(this, function (_a) {
|
|
1878
2019
|
switch (_a.label) {
|
|
1879
2020
|
case 0:
|
|
1880
2021
|
_a.trys.push([0, 2, 3, 4]);
|
|
@@ -1946,15 +2087,15 @@ var MFAOptions = function (_a) {
|
|
|
1946
2087
|
var context = useCAMSContext();
|
|
1947
2088
|
var _f = context.authMode === "MSAL" && "sendEmailOTP" in context
|
|
1948
2089
|
? context
|
|
1949
|
-
: { sendEmailOTP: null, completeMFA: null, logout: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
2090
|
+
: { sendEmailOTP: null, completeMFA: null, logout: function () { return __awaiter$1(void 0, void 0, void 0, function () { return __generator$1(this, function (_a) {
|
|
1950
2091
|
return [2 /*return*/];
|
|
1951
2092
|
}); }); } }, sendEmailOTP = _f.sendEmailOTP, completeMFA = _f.completeMFA, logout = _f.logout;
|
|
1952
2093
|
var accessToken = context.authMode === "MSAL" ? context.accessToken : "";
|
|
1953
2094
|
var idToken = context.authMode === "MSAL" ? context.idToken : "";
|
|
1954
2095
|
var authenticate = useWebAuthn().authenticate;
|
|
1955
|
-
var handleFIDOLogin = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
2096
|
+
var handleFIDOLogin = function () { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
1956
2097
|
var options, assertionResponse, error_1;
|
|
1957
|
-
return __generator(this, function (_a) {
|
|
2098
|
+
return __generator$1(this, function (_a) {
|
|
1958
2099
|
switch (_a.label) {
|
|
1959
2100
|
case 0:
|
|
1960
2101
|
_a.trys.push([0, 4, , 5]);
|
|
@@ -2034,9 +2175,9 @@ var MFAOptions = function (_a) {
|
|
|
2034
2175
|
}
|
|
2035
2176
|
var content = jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {});
|
|
2036
2177
|
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 () {
|
|
2178
|
+
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
2179
|
var success;
|
|
2039
|
-
return __generator(this, function (_a) {
|
|
2180
|
+
return __generator$1(this, function (_a) {
|
|
2040
2181
|
switch (_a.label) {
|
|
2041
2182
|
case 0:
|
|
2042
2183
|
// resetAttempts();
|
|
@@ -2107,16 +2248,16 @@ var ADLoginModal = function (_a) {
|
|
|
2107
2248
|
resolver: a$1(credentialsSchema),
|
|
2108
2249
|
defaultValues: { username: "", password: "" },
|
|
2109
2250
|
});
|
|
2110
|
-
var handleCredentialsSubmit = function (values) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2111
|
-
return __generator(this, function (_a) {
|
|
2251
|
+
var handleCredentialsSubmit = function (values) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
2252
|
+
return __generator$1(this, function (_a) {
|
|
2112
2253
|
setCredentials(values);
|
|
2113
2254
|
setStep("mfa");
|
|
2114
2255
|
return [2 /*return*/];
|
|
2115
2256
|
});
|
|
2116
2257
|
}); };
|
|
2117
|
-
var handleMFASubmit = function (code) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2258
|
+
var handleMFASubmit = function (code) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
2118
2259
|
var error_1;
|
|
2119
|
-
return __generator(this, function (_a) {
|
|
2260
|
+
return __generator$1(this, function (_a) {
|
|
2120
2261
|
switch (_a.label) {
|
|
2121
2262
|
case 0:
|
|
2122
2263
|
setIsLoading(true);
|
|
@@ -2177,8 +2318,8 @@ var DefaultLoginPage = function (_a) {
|
|
|
2177
2318
|
var login = context.login, isLoading = context.isLoading, authMode = context.authMode;
|
|
2178
2319
|
var _b = useState(false), showADModal = _b[0], setShowADModal = _b[1];
|
|
2179
2320
|
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) {
|
|
2321
|
+
var _c = useCredentialsHandler(function (state, data) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
2322
|
+
return __generator$1(this, function (_a) {
|
|
2182
2323
|
console.log(data);
|
|
2183
2324
|
if (state && data) {
|
|
2184
2325
|
context.isAuthenticated = true;
|
|
@@ -2204,9 +2345,9 @@ var DefaultLoginPage = function (_a) {
|
|
|
2204
2345
|
console.warn("Regular CAMS login requires configuration");
|
|
2205
2346
|
}
|
|
2206
2347
|
};
|
|
2207
|
-
var handleRegister = function (data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2348
|
+
var handleRegister = function (data) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
2208
2349
|
var options, attestationResponse, error_1;
|
|
2209
|
-
return __generator(this, function (_a) {
|
|
2350
|
+
return __generator$1(this, function (_a) {
|
|
2210
2351
|
switch (_a.label) {
|
|
2211
2352
|
case 0:
|
|
2212
2353
|
_a.trys.push([0, 4, , 5]);
|
|
@@ -2244,9 +2385,9 @@ var DefaultLoginPage = function (_a) {
|
|
|
2244
2385
|
// variant="outline"
|
|
2245
2386
|
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
2387
|
? "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) {
|
|
2388
|
+
: "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
2389
|
var username = _b.username, password = _b.password, MFACode = _b.MFACode;
|
|
2249
|
-
return __generator(this, function (_c) {
|
|
2390
|
+
return __generator$1(this, function (_c) {
|
|
2250
2391
|
// Implement your AD login logic here
|
|
2251
2392
|
console.log("AD Login:", { username: username, password: password, MFACode: MFACode });
|
|
2252
2393
|
// Example: await adLoginService(username, password, mfaCode);
|
|
@@ -2287,8 +2428,8 @@ var MFAGate = function (_a) {
|
|
|
2287
2428
|
if (!success)
|
|
2288
2429
|
Logger.error("MFA authentication failed");
|
|
2289
2430
|
}, []);
|
|
2290
|
-
var handleAuthFailed = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
2291
|
-
return __generator(this, function (_a) {
|
|
2431
|
+
var handleAuthFailed = useCallback(function () { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
2432
|
+
return __generator$1(this, function (_a) {
|
|
2292
2433
|
switch (_a.label) {
|
|
2293
2434
|
case 0: return [4 /*yield*/, context.logout()];
|
|
2294
2435
|
case 1:
|