@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.cjs.js
CHANGED
|
@@ -81,7 +81,7 @@ function __rest(s, e) {
|
|
|
81
81
|
return t;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
84
|
+
function __awaiter$1(thisArg, _arguments, P, generator) {
|
|
85
85
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
86
86
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
87
87
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -91,7 +91,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
function __generator(thisArg, body) {
|
|
94
|
+
function __generator$1(thisArg, body) {
|
|
95
95
|
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);
|
|
96
96
|
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
97
97
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
@@ -188,10 +188,10 @@ function useCAMSAuth(options) {
|
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
}, [options.storageKey]);
|
|
191
|
-
var login = React.useCallback(function (config) { return __awaiter(_this, void 0, void 0, function () {
|
|
191
|
+
var login = React.useCallback(function (config) { return __awaiter$1(_this, void 0, void 0, function () {
|
|
192
192
|
var loginConfig, userProfile, err_1, e, isPopupClosedError, restoredToken, userProfile;
|
|
193
193
|
var _a, _b, _c;
|
|
194
|
-
return __generator(this, function (_d) {
|
|
194
|
+
return __generator$1(this, function (_d) {
|
|
195
195
|
switch (_d.label) {
|
|
196
196
|
case 0:
|
|
197
197
|
if (!sessionManagerRef.current)
|
|
@@ -239,8 +239,8 @@ function useCAMSAuth(options) {
|
|
|
239
239
|
}
|
|
240
240
|
});
|
|
241
241
|
}); }, [options.idleTimeout]);
|
|
242
|
-
var logout = React.useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
243
|
-
return __generator(this, function (_a) {
|
|
242
|
+
var logout = React.useCallback(function () { return __awaiter$1(_this, void 0, void 0, function () {
|
|
243
|
+
return __generator$1(this, function (_a) {
|
|
244
244
|
switch (_a.label) {
|
|
245
245
|
case 0:
|
|
246
246
|
if (!sessionManagerRef.current)
|
|
@@ -270,6 +270,147 @@ function useCAMSAuth(options) {
|
|
|
270
270
|
};
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
+
var _a;
|
|
274
|
+
// Crypto polyfill for MSAL browser compatibility
|
|
275
|
+
// Only apply if crypto.subtle is completely missing
|
|
276
|
+
if (typeof window !== "undefined" && !((_a = window.crypto) === null || _a === void 0 ? void 0 : _a.subtle)) {
|
|
277
|
+
// Ensure crypto object exists
|
|
278
|
+
if (!window.crypto) {
|
|
279
|
+
window.crypto = {};
|
|
280
|
+
}
|
|
281
|
+
// Polyfill getRandomValues
|
|
282
|
+
if (!window.crypto.getRandomValues) {
|
|
283
|
+
window.crypto.getRandomValues = function (array) {
|
|
284
|
+
var bytes = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
|
|
285
|
+
for (var i = 0; i < bytes.length; i++) {
|
|
286
|
+
bytes[i] = Math.floor(Math.random() * 256);
|
|
287
|
+
}
|
|
288
|
+
return array;
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
var sha256_1 = function (data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
292
|
+
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;
|
|
293
|
+
return __generator(this, function (_a) {
|
|
294
|
+
toUint8 = function (src) {
|
|
295
|
+
if (src instanceof ArrayBuffer)
|
|
296
|
+
return new Uint8Array(src);
|
|
297
|
+
if (ArrayBuffer.isView(src)) {
|
|
298
|
+
var view = src;
|
|
299
|
+
return new Uint8Array(view.buffer, view.byteOffset || 0, view.byteLength);
|
|
300
|
+
}
|
|
301
|
+
throw new TypeError("Unsupported BufferSource");
|
|
302
|
+
};
|
|
303
|
+
bytes = toUint8(data);
|
|
304
|
+
hash = new Uint32Array(8);
|
|
305
|
+
k = new Uint32Array([
|
|
306
|
+
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1,
|
|
307
|
+
0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
|
|
308
|
+
0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786,
|
|
309
|
+
0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
310
|
+
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,
|
|
311
|
+
0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
|
|
312
|
+
0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b,
|
|
313
|
+
0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
314
|
+
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a,
|
|
315
|
+
0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
|
|
316
|
+
0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
|
|
317
|
+
]);
|
|
318
|
+
hash[0] = 0x6a09e667;
|
|
319
|
+
hash[1] = 0xbb67ae85;
|
|
320
|
+
hash[2] = 0x3c6ef372;
|
|
321
|
+
hash[3] = 0xa54ff53a;
|
|
322
|
+
hash[4] = 0x510e527f;
|
|
323
|
+
hash[5] = 0x9b05688c;
|
|
324
|
+
hash[6] = 0x1f83d9ab;
|
|
325
|
+
hash[7] = 0x5be0cd19;
|
|
326
|
+
ml = bytes.length * 8;
|
|
327
|
+
msg = new Uint8Array(bytes.length + 64 + ((64 - ((bytes.length + 9) % 64)) % 64));
|
|
328
|
+
msg.set(bytes);
|
|
329
|
+
msg[bytes.length] = 0x80;
|
|
330
|
+
dv = new DataView(msg.buffer);
|
|
331
|
+
high = Math.floor(ml / 0x100000000);
|
|
332
|
+
low = ml >>> 0;
|
|
333
|
+
dv.setUint32(msg.length - 8, high, false);
|
|
334
|
+
dv.setUint32(msg.length - 4, low, false);
|
|
335
|
+
for (i = 0; i < msg.length; i += 64) {
|
|
336
|
+
w = new Uint32Array(64);
|
|
337
|
+
for (j = 0; j < 16; j++)
|
|
338
|
+
w[j] = new DataView(msg.buffer).getUint32(i + j * 4, false);
|
|
339
|
+
for (j = 16; j < 64; j++) {
|
|
340
|
+
s0 = ((w[j - 15] >>> 7) | (w[j - 15] << 25)) ^
|
|
341
|
+
((w[j - 15] >>> 18) | (w[j - 15] << 14)) ^
|
|
342
|
+
(w[j - 15] >>> 3);
|
|
343
|
+
s1 = ((w[j - 2] >>> 17) | (w[j - 2] << 15)) ^
|
|
344
|
+
((w[j - 2] >>> 19) | (w[j - 2] << 13)) ^
|
|
345
|
+
(w[j - 2] >>> 10);
|
|
346
|
+
w[j] = (w[j - 16] + s0 + w[j - 7] + s1) >>> 0;
|
|
347
|
+
}
|
|
348
|
+
a = hash[0], b = hash[1], c = hash[2], d = hash[3], e = hash[4], f = hash[5], g = hash[6], h = hash[7];
|
|
349
|
+
for (j = 0; j < 64; j++) {
|
|
350
|
+
S1 = ((e >>> 6) | (e << 26)) ^
|
|
351
|
+
((e >>> 11) | (e << 21)) ^
|
|
352
|
+
((e >>> 25) | (e << 7));
|
|
353
|
+
ch = (e & f) ^ (~e & g);
|
|
354
|
+
temp1 = (h + S1 + ch + k[j] + w[j]) >>> 0;
|
|
355
|
+
S0 = ((a >>> 2) | (a << 30)) ^
|
|
356
|
+
((a >>> 13) | (a << 19)) ^
|
|
357
|
+
((a >>> 22) | (a << 10));
|
|
358
|
+
maj = (a & b) ^ (a & c) ^ (b & c);
|
|
359
|
+
temp2 = (S0 + maj) >>> 0;
|
|
360
|
+
h = g;
|
|
361
|
+
g = f;
|
|
362
|
+
f = e;
|
|
363
|
+
e = (d + temp1) >>> 0;
|
|
364
|
+
d = c;
|
|
365
|
+
c = b;
|
|
366
|
+
b = a;
|
|
367
|
+
a = (temp1 + temp2) >>> 0;
|
|
368
|
+
}
|
|
369
|
+
hash[0] = (hash[0] + a) >>> 0;
|
|
370
|
+
hash[1] = (hash[1] + b) >>> 0;
|
|
371
|
+
hash[2] = (hash[2] + c) >>> 0;
|
|
372
|
+
hash[3] = (hash[3] + d) >>> 0;
|
|
373
|
+
hash[4] = (hash[4] + e) >>> 0;
|
|
374
|
+
hash[5] = (hash[5] + f) >>> 0;
|
|
375
|
+
hash[6] = (hash[6] + g) >>> 0;
|
|
376
|
+
hash[7] = (hash[7] + h) >>> 0;
|
|
377
|
+
}
|
|
378
|
+
result = new Uint8Array(32);
|
|
379
|
+
for (i = 0; i < 8; i++)
|
|
380
|
+
new DataView(result.buffer).setUint32(i * 4, hash[i], false);
|
|
381
|
+
return [2 /*return*/, result.buffer];
|
|
382
|
+
});
|
|
383
|
+
}); };
|
|
384
|
+
// Create the polyfilled subtle object
|
|
385
|
+
var polyfillSubtle = {
|
|
386
|
+
digest: function (algorithm, data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
387
|
+
var alg;
|
|
388
|
+
return __generator(this, function (_a) {
|
|
389
|
+
alg = typeof algorithm === "string"
|
|
390
|
+
? algorithm
|
|
391
|
+
: algorithm.name;
|
|
392
|
+
if (alg === "SHA-256")
|
|
393
|
+
return [2 /*return*/, sha256_1(data)];
|
|
394
|
+
throw new Error("Unsupported algorithm: ".concat(alg));
|
|
395
|
+
});
|
|
396
|
+
}); },
|
|
397
|
+
};
|
|
398
|
+
// Set the polyfilled subtle object
|
|
399
|
+
window.crypto.subtle = polyfillSubtle;
|
|
400
|
+
// Polyfill randomUUID
|
|
401
|
+
if (!window.crypto.randomUUID) {
|
|
402
|
+
window.crypto.randomUUID =
|
|
403
|
+
function () {
|
|
404
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
|
|
405
|
+
var r = (Math.random() * 16) | 0;
|
|
406
|
+
var v = c === "x" ? r : (r & 0x3) | 0x8;
|
|
407
|
+
return v.toString(16);
|
|
408
|
+
});
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
console.log("Crypto polyfill applied (native crypto.subtle not available)");
|
|
412
|
+
}
|
|
413
|
+
|
|
273
414
|
var setCookie = function (name, value, days) {
|
|
274
415
|
if (days === void 0) { days = 1; }
|
|
275
416
|
var expires = new Date(Date.now() + days * 24 * 60 * 60 * 1000).toUTCString();
|
|
@@ -377,10 +518,10 @@ function useCAMSMSALAuth(options) {
|
|
|
377
518
|
// };
|
|
378
519
|
// handleRedirect();
|
|
379
520
|
// }, []);
|
|
380
|
-
var login = React.useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
521
|
+
var login = React.useCallback(function () { return __awaiter$1(_this, void 0, void 0, function () {
|
|
381
522
|
var response, mfaConfig, authenticator, err_1, camsError_1, camsError;
|
|
382
523
|
var _a;
|
|
383
|
-
return __generator(this, function (_b) {
|
|
524
|
+
return __generator$1(this, function (_b) {
|
|
384
525
|
switch (_b.label) {
|
|
385
526
|
case 0:
|
|
386
527
|
if (inProgress !== msalBrowser.InteractionStatus.None) {
|
|
@@ -453,8 +594,8 @@ function useCAMSMSALAuth(options) {
|
|
|
453
594
|
}
|
|
454
595
|
});
|
|
455
596
|
}); }, [instance, scopes, prompt, appCode, MFAEndpoint, onAuthSuccess, onAuthError, storageKey, inProgress]);
|
|
456
|
-
var completeMFA = React.useCallback(function (data) { return __awaiter(_this, void 0, void 0, function () {
|
|
457
|
-
return __generator(this, function (_a) {
|
|
597
|
+
var completeMFA = React.useCallback(function (data) { return __awaiter$1(_this, void 0, void 0, function () {
|
|
598
|
+
return __generator$1(this, function (_a) {
|
|
458
599
|
if (!mfaAuthenticator) {
|
|
459
600
|
throw new camsSdk.CAMSError(camsSdk.CAMSErrorType.API_VALIDATION_ERROR, "MFA Authenticator not initialized");
|
|
460
601
|
}
|
|
@@ -488,8 +629,8 @@ function useCAMSMSALAuth(options) {
|
|
|
488
629
|
return [2 /*return*/];
|
|
489
630
|
});
|
|
490
631
|
}); }, [mfaAuthenticator, accessToken, idToken, storageKey, activeCookiePeriod]);
|
|
491
|
-
var sendEmailOTP = React.useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
492
|
-
return __generator(this, function (_a) {
|
|
632
|
+
var sendEmailOTP = React.useCallback(function () { return __awaiter$1(_this, void 0, void 0, function () {
|
|
633
|
+
return __generator$1(this, function (_a) {
|
|
493
634
|
switch (_a.label) {
|
|
494
635
|
case 0:
|
|
495
636
|
if (!mfaAuthenticator) {
|
|
@@ -500,9 +641,9 @@ function useCAMSMSALAuth(options) {
|
|
|
500
641
|
}
|
|
501
642
|
});
|
|
502
643
|
}); }, [mfaAuthenticator]);
|
|
503
|
-
var logout = React.useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
644
|
+
var logout = React.useCallback(function () { return __awaiter$1(_this, void 0, void 0, function () {
|
|
504
645
|
var err_2, camsError;
|
|
505
|
-
return __generator(this, function (_a) {
|
|
646
|
+
return __generator$1(this, function (_a) {
|
|
506
647
|
switch (_a.label) {
|
|
507
648
|
case 0:
|
|
508
649
|
_a.trys.push([0, 2, , 3]);
|
|
@@ -587,10 +728,10 @@ function arrayBufferToBase64url(buffer) {
|
|
|
587
728
|
* @returns A promise that resolves to a JSON-serializable representation of the PublicKeyCredential.
|
|
588
729
|
*/
|
|
589
730
|
function register(options) {
|
|
590
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
731
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
591
732
|
var createOptions, credential, publicKeyCredential, attestationResponse, transports, err_1;
|
|
592
733
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
593
|
-
return __generator(this, function (_k) {
|
|
734
|
+
return __generator$1(this, function (_k) {
|
|
594
735
|
switch (_k.label) {
|
|
595
736
|
case 0:
|
|
596
737
|
_k.trys.push([0, 2, , 3]);
|
|
@@ -648,10 +789,10 @@ function register(options) {
|
|
|
648
789
|
* @returns A promise that resolves to a JSON-serializable representation of the PublicKeyCredential.
|
|
649
790
|
*/
|
|
650
791
|
function authenticate(options) {
|
|
651
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
792
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
652
793
|
var getOptions, credential, publicKeyCredential, assertionResponse;
|
|
653
794
|
var _a;
|
|
654
|
-
return __generator(this, function (_b) {
|
|
795
|
+
return __generator$1(this, function (_b) {
|
|
655
796
|
switch (_b.label) {
|
|
656
797
|
case 0:
|
|
657
798
|
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) })); }) });
|
|
@@ -1201,8 +1342,8 @@ function CAMSMSALProviderInner(_a) {
|
|
|
1201
1342
|
}
|
|
1202
1343
|
}, [userProfile, profileStorageKey]);
|
|
1203
1344
|
// Enhanced logout that also clears profile
|
|
1204
|
-
var enhancedLogout = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1205
|
-
return __generator(this, function (_a) {
|
|
1345
|
+
var enhancedLogout = function () { return __awaiter$1(_this, void 0, void 0, function () {
|
|
1346
|
+
return __generator$1(this, function (_a) {
|
|
1206
1347
|
switch (_a.label) {
|
|
1207
1348
|
case 0: return [4 /*yield*/, auth.logout()];
|
|
1208
1349
|
case 1:
|
|
@@ -1303,8 +1444,8 @@ function CAMSProviderCore(props) {
|
|
|
1303
1444
|
}
|
|
1304
1445
|
}
|
|
1305
1446
|
}, [userProfile, profileStorageKey]);
|
|
1306
|
-
var enhancedLogout = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1307
|
-
return __generator(this, function (_a) {
|
|
1447
|
+
var enhancedLogout = function () { return __awaiter$1(_this, void 0, void 0, function () {
|
|
1448
|
+
return __generator$1(this, function (_a) {
|
|
1308
1449
|
switch (_a.label) {
|
|
1309
1450
|
case 0: return [4 /*yield*/, auth.logout()];
|
|
1310
1451
|
case 1:
|
|
@@ -1801,9 +1942,9 @@ var useOTPHandler = function (_a) {
|
|
|
1801
1942
|
var _b = React.useState(false), loading = _b[0], setLoading = _b[1];
|
|
1802
1943
|
var _c = React.useState(0), attemptCount = _c[0], setAttemptCount = _c[1];
|
|
1803
1944
|
var _d = React.useState(false), isMaxAttemptsReached = _d[0], setIsMaxAttemptsReached = _d[1];
|
|
1804
|
-
var handleSubmitOTP = React.useMemo(function () { return function (authenticationValue) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1945
|
+
var handleSubmitOTP = React.useMemo(function () { return function (authenticationValue) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
1805
1946
|
var currentAttempt, response, error_1, currentAttempt;
|
|
1806
|
-
return __generator(this, function (_a) {
|
|
1947
|
+
return __generator$1(this, function (_a) {
|
|
1807
1948
|
switch (_a.label) {
|
|
1808
1949
|
case 0:
|
|
1809
1950
|
if (isMaxAttemptsReached) {
|
|
@@ -1893,9 +2034,9 @@ var useCredentialsHandler = function (onAuthComplete) {
|
|
|
1893
2034
|
var _b = React.useState(0), attemptCount = _b[0], setAttemptCount = _b[1];
|
|
1894
2035
|
var _c = React.useState(false), isMaxAttemptsReached = _c[0], setIsMaxAttemptsReached = _c[1];
|
|
1895
2036
|
var handleSubmitCredentials = React.useMemo(function () {
|
|
1896
|
-
return function (CredAuthEndpoint, credentials, appCode) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2037
|
+
return function (CredAuthEndpoint, credentials, appCode) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
1897
2038
|
var currentAttempt, response, error_2, currentAttempt;
|
|
1898
|
-
return __generator(this, function (_a) {
|
|
2039
|
+
return __generator$1(this, function (_a) {
|
|
1899
2040
|
switch (_a.label) {
|
|
1900
2041
|
case 0:
|
|
1901
2042
|
_a.trys.push([0, 2, 3, 4]);
|
|
@@ -1967,15 +2108,15 @@ var MFAOptions = function (_a) {
|
|
|
1967
2108
|
var context = useCAMSContext();
|
|
1968
2109
|
var _f = context.authMode === "MSAL" && "sendEmailOTP" in context
|
|
1969
2110
|
? context
|
|
1970
|
-
: { sendEmailOTP: null, completeMFA: null, logout: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
2111
|
+
: { sendEmailOTP: null, completeMFA: null, logout: function () { return __awaiter$1(void 0, void 0, void 0, function () { return __generator$1(this, function (_a) {
|
|
1971
2112
|
return [2 /*return*/];
|
|
1972
2113
|
}); }); } }, sendEmailOTP = _f.sendEmailOTP, completeMFA = _f.completeMFA, logout = _f.logout;
|
|
1973
2114
|
var accessToken = context.authMode === "MSAL" ? context.accessToken : "";
|
|
1974
2115
|
var idToken = context.authMode === "MSAL" ? context.idToken : "";
|
|
1975
2116
|
var authenticate = useWebAuthn().authenticate;
|
|
1976
|
-
var handleFIDOLogin = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
2117
|
+
var handleFIDOLogin = function () { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
1977
2118
|
var options, assertionResponse, error_1;
|
|
1978
|
-
return __generator(this, function (_a) {
|
|
2119
|
+
return __generator$1(this, function (_a) {
|
|
1979
2120
|
switch (_a.label) {
|
|
1980
2121
|
case 0:
|
|
1981
2122
|
_a.trys.push([0, 4, , 5]);
|
|
@@ -2055,9 +2196,9 @@ var MFAOptions = function (_a) {
|
|
|
2055
2196
|
}
|
|
2056
2197
|
var content = jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {});
|
|
2057
2198
|
if (!authType) {
|
|
2058
|
-
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 () {
|
|
2199
|
+
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 () {
|
|
2059
2200
|
var success;
|
|
2060
|
-
return __generator(this, function (_a) {
|
|
2201
|
+
return __generator$1(this, function (_a) {
|
|
2061
2202
|
switch (_a.label) {
|
|
2062
2203
|
case 0:
|
|
2063
2204
|
// resetAttempts();
|
|
@@ -2128,16 +2269,16 @@ var ADLoginModal = function (_a) {
|
|
|
2128
2269
|
resolver: a$1(credentialsSchema),
|
|
2129
2270
|
defaultValues: { username: "", password: "" },
|
|
2130
2271
|
});
|
|
2131
|
-
var handleCredentialsSubmit = function (values) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2132
|
-
return __generator(this, function (_a) {
|
|
2272
|
+
var handleCredentialsSubmit = function (values) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
2273
|
+
return __generator$1(this, function (_a) {
|
|
2133
2274
|
setCredentials(values);
|
|
2134
2275
|
setStep("mfa");
|
|
2135
2276
|
return [2 /*return*/];
|
|
2136
2277
|
});
|
|
2137
2278
|
}); };
|
|
2138
|
-
var handleMFASubmit = function (code) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2279
|
+
var handleMFASubmit = function (code) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
2139
2280
|
var error_1;
|
|
2140
|
-
return __generator(this, function (_a) {
|
|
2281
|
+
return __generator$1(this, function (_a) {
|
|
2141
2282
|
switch (_a.label) {
|
|
2142
2283
|
case 0:
|
|
2143
2284
|
setIsLoading(true);
|
|
@@ -2198,8 +2339,8 @@ var DefaultLoginPage = function (_a) {
|
|
|
2198
2339
|
var login = context.login, isLoading = context.isLoading, authMode = context.authMode;
|
|
2199
2340
|
var _b = React.useState(false), showADModal = _b[0], setShowADModal = _b[1];
|
|
2200
2341
|
var register = useWebAuthn().register;
|
|
2201
|
-
var _c = useCredentialsHandler(function (state, data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2202
|
-
return __generator(this, function (_a) {
|
|
2342
|
+
var _c = useCredentialsHandler(function (state, data) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
2343
|
+
return __generator$1(this, function (_a) {
|
|
2203
2344
|
console.log(data);
|
|
2204
2345
|
if (state && data) {
|
|
2205
2346
|
context.isAuthenticated = true;
|
|
@@ -2225,9 +2366,9 @@ var DefaultLoginPage = function (_a) {
|
|
|
2225
2366
|
console.warn("Regular CAMS login requires configuration");
|
|
2226
2367
|
}
|
|
2227
2368
|
};
|
|
2228
|
-
var handleRegister = function (data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2369
|
+
var handleRegister = function (data) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
2229
2370
|
var options, attestationResponse, error_1;
|
|
2230
|
-
return __generator(this, function (_a) {
|
|
2371
|
+
return __generator$1(this, function (_a) {
|
|
2231
2372
|
switch (_a.label) {
|
|
2232
2373
|
case 0:
|
|
2233
2374
|
_a.trys.push([0, 4, , 5]);
|
|
@@ -2265,9 +2406,9 @@ var DefaultLoginPage = function (_a) {
|
|
|
2265
2406
|
// variant="outline"
|
|
2266
2407
|
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(lucideReact.KeyIcon, { className: "text-[#506f4a]", size: 64 }), jsxRuntimeExports.jsx("span", { children: isLoading
|
|
2267
2408
|
? "Logging in..."
|
|
2268
|
-
: "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(lucideReact.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(lucideReact.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) {
|
|
2409
|
+
: "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(lucideReact.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(lucideReact.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) {
|
|
2269
2410
|
var username = _b.username, password = _b.password, MFACode = _b.MFACode;
|
|
2270
|
-
return __generator(this, function (_c) {
|
|
2411
|
+
return __generator$1(this, function (_c) {
|
|
2271
2412
|
// Implement your AD login logic here
|
|
2272
2413
|
console.log("AD Login:", { username: username, password: password, MFACode: MFACode });
|
|
2273
2414
|
// Example: await adLoginService(username, password, mfaCode);
|
|
@@ -2308,8 +2449,8 @@ var MFAGate = function (_a) {
|
|
|
2308
2449
|
if (!success)
|
|
2309
2450
|
camsSdk.Logger.error("MFA authentication failed");
|
|
2310
2451
|
}, []);
|
|
2311
|
-
var handleAuthFailed = React.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
2312
|
-
return __generator(this, function (_a) {
|
|
2452
|
+
var handleAuthFailed = React.useCallback(function () { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
2453
|
+
return __generator$1(this, function (_a) {
|
|
2313
2454
|
switch (_a.label) {
|
|
2314
2455
|
case 0: return [4 /*yield*/, context.logout()];
|
|
2315
2456
|
case 1:
|