@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
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import "../utils/crypto-polyfill";
|
|
1
2
|
import { CAMSError, CAMSMFAAuthenticator, MFAResponse } from "@nibssplc/cams-sdk";
|
|
2
3
|
export interface UseCAMSMSALAuthOptions {
|
|
3
|
-
onAuthSuccess?: (
|
|
4
|
+
onAuthSuccess?: (tokens: {
|
|
5
|
+
accessToken: string;
|
|
6
|
+
idToken: string;
|
|
7
|
+
}) => void;
|
|
4
8
|
onAuthError?: (error: CAMSError) => void;
|
|
5
9
|
onTokenExpired?: () => void;
|
|
6
10
|
scopes?: string[];
|
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) {
|
|
@@ -422,7 +563,10 @@ function useCAMSMSALAuth(options) {
|
|
|
422
563
|
idToken: response.idToken,
|
|
423
564
|
}));
|
|
424
565
|
}
|
|
425
|
-
onAuthSuccess === null || onAuthSuccess === void 0 ? void 0 : onAuthSuccess(
|
|
566
|
+
onAuthSuccess === null || onAuthSuccess === void 0 ? void 0 : onAuthSuccess({
|
|
567
|
+
accessToken: response.accessToken,
|
|
568
|
+
idToken: response.idToken,
|
|
569
|
+
});
|
|
426
570
|
return [3 /*break*/, 4];
|
|
427
571
|
case 3:
|
|
428
572
|
err_1 = _b.sent();
|
|
@@ -452,9 +596,19 @@ function useCAMSMSALAuth(options) {
|
|
|
452
596
|
case 4: return [2 /*return*/];
|
|
453
597
|
}
|
|
454
598
|
});
|
|
455
|
-
}); }, [
|
|
456
|
-
|
|
457
|
-
|
|
599
|
+
}); }, [
|
|
600
|
+
instance,
|
|
601
|
+
scopes,
|
|
602
|
+
prompt,
|
|
603
|
+
appCode,
|
|
604
|
+
MFAEndpoint,
|
|
605
|
+
onAuthSuccess,
|
|
606
|
+
onAuthError,
|
|
607
|
+
storageKey,
|
|
608
|
+
inProgress,
|
|
609
|
+
]);
|
|
610
|
+
var completeMFA = React.useCallback(function (data) { return __awaiter$1(_this, void 0, void 0, function () {
|
|
611
|
+
return __generator$1(this, function (_a) {
|
|
458
612
|
if (!mfaAuthenticator) {
|
|
459
613
|
throw new camsSdk.CAMSError(camsSdk.CAMSErrorType.API_VALIDATION_ERROR, "MFA Authenticator not initialized");
|
|
460
614
|
}
|
|
@@ -488,8 +642,8 @@ function useCAMSMSALAuth(options) {
|
|
|
488
642
|
return [2 /*return*/];
|
|
489
643
|
});
|
|
490
644
|
}); }, [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) {
|
|
645
|
+
var sendEmailOTP = React.useCallback(function () { return __awaiter$1(_this, void 0, void 0, function () {
|
|
646
|
+
return __generator$1(this, function (_a) {
|
|
493
647
|
switch (_a.label) {
|
|
494
648
|
case 0:
|
|
495
649
|
if (!mfaAuthenticator) {
|
|
@@ -500,9 +654,9 @@ function useCAMSMSALAuth(options) {
|
|
|
500
654
|
}
|
|
501
655
|
});
|
|
502
656
|
}); }, [mfaAuthenticator]);
|
|
503
|
-
var logout = React.useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
657
|
+
var logout = React.useCallback(function () { return __awaiter$1(_this, void 0, void 0, function () {
|
|
504
658
|
var err_2, camsError;
|
|
505
|
-
return __generator(this, function (_a) {
|
|
659
|
+
return __generator$1(this, function (_a) {
|
|
506
660
|
switch (_a.label) {
|
|
507
661
|
case 0:
|
|
508
662
|
_a.trys.push([0, 2, , 3]);
|
|
@@ -587,10 +741,10 @@ function arrayBufferToBase64url(buffer) {
|
|
|
587
741
|
* @returns A promise that resolves to a JSON-serializable representation of the PublicKeyCredential.
|
|
588
742
|
*/
|
|
589
743
|
function register(options) {
|
|
590
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
744
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
591
745
|
var createOptions, credential, publicKeyCredential, attestationResponse, transports, err_1;
|
|
592
746
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
593
|
-
return __generator(this, function (_k) {
|
|
747
|
+
return __generator$1(this, function (_k) {
|
|
594
748
|
switch (_k.label) {
|
|
595
749
|
case 0:
|
|
596
750
|
_k.trys.push([0, 2, , 3]);
|
|
@@ -648,10 +802,10 @@ function register(options) {
|
|
|
648
802
|
* @returns A promise that resolves to a JSON-serializable representation of the PublicKeyCredential.
|
|
649
803
|
*/
|
|
650
804
|
function authenticate(options) {
|
|
651
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
805
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
652
806
|
var getOptions, credential, publicKeyCredential, assertionResponse;
|
|
653
807
|
var _a;
|
|
654
|
-
return __generator(this, function (_b) {
|
|
808
|
+
return __generator$1(this, function (_b) {
|
|
655
809
|
switch (_b.label) {
|
|
656
810
|
case 0:
|
|
657
811
|
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 +1355,8 @@ function CAMSMSALProviderInner(_a) {
|
|
|
1201
1355
|
}
|
|
1202
1356
|
}, [userProfile, profileStorageKey]);
|
|
1203
1357
|
// Enhanced logout that also clears profile
|
|
1204
|
-
var enhancedLogout = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1205
|
-
return __generator(this, function (_a) {
|
|
1358
|
+
var enhancedLogout = function () { return __awaiter$1(_this, void 0, void 0, function () {
|
|
1359
|
+
return __generator$1(this, function (_a) {
|
|
1206
1360
|
switch (_a.label) {
|
|
1207
1361
|
case 0: return [4 /*yield*/, auth.logout()];
|
|
1208
1362
|
case 1:
|
|
@@ -1303,8 +1457,8 @@ function CAMSProviderCore(props) {
|
|
|
1303
1457
|
}
|
|
1304
1458
|
}
|
|
1305
1459
|
}, [userProfile, profileStorageKey]);
|
|
1306
|
-
var enhancedLogout = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1307
|
-
return __generator(this, function (_a) {
|
|
1460
|
+
var enhancedLogout = function () { return __awaiter$1(_this, void 0, void 0, function () {
|
|
1461
|
+
return __generator$1(this, function (_a) {
|
|
1308
1462
|
switch (_a.label) {
|
|
1309
1463
|
case 0: return [4 /*yield*/, auth.logout()];
|
|
1310
1464
|
case 1:
|
|
@@ -1801,9 +1955,9 @@ var useOTPHandler = function (_a) {
|
|
|
1801
1955
|
var _b = React.useState(false), loading = _b[0], setLoading = _b[1];
|
|
1802
1956
|
var _c = React.useState(0), attemptCount = _c[0], setAttemptCount = _c[1];
|
|
1803
1957
|
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 () {
|
|
1958
|
+
var handleSubmitOTP = React.useMemo(function () { return function (authenticationValue) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
1805
1959
|
var currentAttempt, response, error_1, currentAttempt;
|
|
1806
|
-
return __generator(this, function (_a) {
|
|
1960
|
+
return __generator$1(this, function (_a) {
|
|
1807
1961
|
switch (_a.label) {
|
|
1808
1962
|
case 0:
|
|
1809
1963
|
if (isMaxAttemptsReached) {
|
|
@@ -1893,9 +2047,9 @@ var useCredentialsHandler = function (onAuthComplete) {
|
|
|
1893
2047
|
var _b = React.useState(0), attemptCount = _b[0], setAttemptCount = _b[1];
|
|
1894
2048
|
var _c = React.useState(false), isMaxAttemptsReached = _c[0], setIsMaxAttemptsReached = _c[1];
|
|
1895
2049
|
var handleSubmitCredentials = React.useMemo(function () {
|
|
1896
|
-
return function (CredAuthEndpoint, credentials, appCode) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2050
|
+
return function (CredAuthEndpoint, credentials, appCode) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
1897
2051
|
var currentAttempt, response, error_2, currentAttempt;
|
|
1898
|
-
return __generator(this, function (_a) {
|
|
2052
|
+
return __generator$1(this, function (_a) {
|
|
1899
2053
|
switch (_a.label) {
|
|
1900
2054
|
case 0:
|
|
1901
2055
|
_a.trys.push([0, 2, 3, 4]);
|
|
@@ -1967,15 +2121,15 @@ var MFAOptions = function (_a) {
|
|
|
1967
2121
|
var context = useCAMSContext();
|
|
1968
2122
|
var _f = context.authMode === "MSAL" && "sendEmailOTP" in context
|
|
1969
2123
|
? context
|
|
1970
|
-
: { sendEmailOTP: null, completeMFA: null, logout: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
2124
|
+
: { sendEmailOTP: null, completeMFA: null, logout: function () { return __awaiter$1(void 0, void 0, void 0, function () { return __generator$1(this, function (_a) {
|
|
1971
2125
|
return [2 /*return*/];
|
|
1972
2126
|
}); }); } }, sendEmailOTP = _f.sendEmailOTP, completeMFA = _f.completeMFA, logout = _f.logout;
|
|
1973
2127
|
var accessToken = context.authMode === "MSAL" ? context.accessToken : "";
|
|
1974
2128
|
var idToken = context.authMode === "MSAL" ? context.idToken : "";
|
|
1975
2129
|
var authenticate = useWebAuthn().authenticate;
|
|
1976
|
-
var handleFIDOLogin = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
2130
|
+
var handleFIDOLogin = function () { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
1977
2131
|
var options, assertionResponse, error_1;
|
|
1978
|
-
return __generator(this, function (_a) {
|
|
2132
|
+
return __generator$1(this, function (_a) {
|
|
1979
2133
|
switch (_a.label) {
|
|
1980
2134
|
case 0:
|
|
1981
2135
|
_a.trys.push([0, 4, , 5]);
|
|
@@ -2055,9 +2209,9 @@ var MFAOptions = function (_a) {
|
|
|
2055
2209
|
}
|
|
2056
2210
|
var content = jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {});
|
|
2057
2211
|
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 () {
|
|
2212
|
+
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
2213
|
var success;
|
|
2060
|
-
return __generator(this, function (_a) {
|
|
2214
|
+
return __generator$1(this, function (_a) {
|
|
2061
2215
|
switch (_a.label) {
|
|
2062
2216
|
case 0:
|
|
2063
2217
|
// resetAttempts();
|
|
@@ -2128,16 +2282,16 @@ var ADLoginModal = function (_a) {
|
|
|
2128
2282
|
resolver: a$1(credentialsSchema),
|
|
2129
2283
|
defaultValues: { username: "", password: "" },
|
|
2130
2284
|
});
|
|
2131
|
-
var handleCredentialsSubmit = function (values) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2132
|
-
return __generator(this, function (_a) {
|
|
2285
|
+
var handleCredentialsSubmit = function (values) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
2286
|
+
return __generator$1(this, function (_a) {
|
|
2133
2287
|
setCredentials(values);
|
|
2134
2288
|
setStep("mfa");
|
|
2135
2289
|
return [2 /*return*/];
|
|
2136
2290
|
});
|
|
2137
2291
|
}); };
|
|
2138
|
-
var handleMFASubmit = function (code) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2292
|
+
var handleMFASubmit = function (code) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
2139
2293
|
var error_1;
|
|
2140
|
-
return __generator(this, function (_a) {
|
|
2294
|
+
return __generator$1(this, function (_a) {
|
|
2141
2295
|
switch (_a.label) {
|
|
2142
2296
|
case 0:
|
|
2143
2297
|
setIsLoading(true);
|
|
@@ -2198,8 +2352,8 @@ var DefaultLoginPage = function (_a) {
|
|
|
2198
2352
|
var login = context.login, isLoading = context.isLoading, authMode = context.authMode;
|
|
2199
2353
|
var _b = React.useState(false), showADModal = _b[0], setShowADModal = _b[1];
|
|
2200
2354
|
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) {
|
|
2355
|
+
var _c = useCredentialsHandler(function (state, data) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
2356
|
+
return __generator$1(this, function (_a) {
|
|
2203
2357
|
console.log(data);
|
|
2204
2358
|
if (state && data) {
|
|
2205
2359
|
context.isAuthenticated = true;
|
|
@@ -2225,9 +2379,9 @@ var DefaultLoginPage = function (_a) {
|
|
|
2225
2379
|
console.warn("Regular CAMS login requires configuration");
|
|
2226
2380
|
}
|
|
2227
2381
|
};
|
|
2228
|
-
var handleRegister = function (data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2382
|
+
var handleRegister = function (data) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
2229
2383
|
var options, attestationResponse, error_1;
|
|
2230
|
-
return __generator(this, function (_a) {
|
|
2384
|
+
return __generator$1(this, function (_a) {
|
|
2231
2385
|
switch (_a.label) {
|
|
2232
2386
|
case 0:
|
|
2233
2387
|
_a.trys.push([0, 4, , 5]);
|
|
@@ -2265,9 +2419,9 @@ var DefaultLoginPage = function (_a) {
|
|
|
2265
2419
|
// variant="outline"
|
|
2266
2420
|
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
2421
|
? "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) {
|
|
2422
|
+
: "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
2423
|
var username = _b.username, password = _b.password, MFACode = _b.MFACode;
|
|
2270
|
-
return __generator(this, function (_c) {
|
|
2424
|
+
return __generator$1(this, function (_c) {
|
|
2271
2425
|
// Implement your AD login logic here
|
|
2272
2426
|
console.log("AD Login:", { username: username, password: password, MFACode: MFACode });
|
|
2273
2427
|
// Example: await adLoginService(username, password, mfaCode);
|
|
@@ -2308,8 +2462,8 @@ var MFAGate = function (_a) {
|
|
|
2308
2462
|
if (!success)
|
|
2309
2463
|
camsSdk.Logger.error("MFA authentication failed");
|
|
2310
2464
|
}, []);
|
|
2311
|
-
var handleAuthFailed = React.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
2312
|
-
return __generator(this, function (_a) {
|
|
2465
|
+
var handleAuthFailed = React.useCallback(function () { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
2466
|
+
return __generator$1(this, function (_a) {
|
|
2313
2467
|
switch (_a.label) {
|
|
2314
2468
|
case 0: return [4 /*yield*/, context.logout()];
|
|
2315
2469
|
case 1:
|