@nibssplc/cams-sdk-react 0.0.1-beta.94 → 0.0.1-beta.96
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/index.cjs.js +37 -13
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +37 -13
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1864,32 +1864,48 @@ var MFAOptions = function (_a) {
|
|
|
1864
1864
|
var idToken = context.authMode === "MSAL" ? context.idToken : "";
|
|
1865
1865
|
var authenticate = useWebAuthn().authenticate;
|
|
1866
1866
|
var handleFIDOLogin = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1867
|
-
var options, assertionResponse, error_1;
|
|
1868
|
-
|
|
1869
|
-
|
|
1867
|
+
var options, fixedOptions, assertionResponse, error_1;
|
|
1868
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1869
|
+
return __generator(this, function (_g) {
|
|
1870
|
+
switch (_g.label) {
|
|
1870
1871
|
case 0:
|
|
1871
|
-
|
|
1872
|
+
_g.trys.push([0, 4, , 5]);
|
|
1872
1873
|
// 1. Fetch authentication challenge from your server
|
|
1873
1874
|
console.log("Requesting authentication challenge from server...");
|
|
1874
|
-
return [4 /*yield*/, axios.post(MFAEndpoints.RetrieveAuthChallenge
|
|
1875
|
+
return [4 /*yield*/, axios.post(MFAEndpoints.RetrieveAuthChallenge, {}, {
|
|
1876
|
+
headers: {
|
|
1877
|
+
"X-DEVICE-ID": GenerateDeviceId(),
|
|
1878
|
+
"X-API-VERSION": "1.0",
|
|
1879
|
+
},
|
|
1880
|
+
})];
|
|
1875
1881
|
case 1:
|
|
1876
|
-
options = (
|
|
1882
|
+
options = (_g.sent()).data;
|
|
1877
1883
|
console.log("Received challenge:", options);
|
|
1884
|
+
fixedOptions = __assign(__assign({}, options), { pubKeyCredParams: (_a = options.pubKeyCredParams) === null || _a === void 0 ? void 0 : _a.map(function (param) { return ({
|
|
1885
|
+
type: "public-key",
|
|
1886
|
+
alg: param.alg
|
|
1887
|
+
}); }), attestation: ((_b = options.attestation) === null || _b === void 0 ? void 0 : _b.toLowerCase()) || "none", authenticatorSelection: __assign(__assign({}, options.authenticatorSelection), { residentKey: ((_d = (_c = options.authenticatorSelection) === null || _c === void 0 ? void 0 : _c.residentKey) === null || _d === void 0 ? void 0 : _d.toLowerCase()) || "discouraged", userVerification: ((_f = (_e = options.authenticatorSelection) === null || _e === void 0 ? void 0 : _e.userVerification) === null || _f === void 0 ? void 0 : _f.toLowerCase()) || "preferred" }) });
|
|
1878
1888
|
// 2. Call the SDK to trigger the browser's passkey authentication UI
|
|
1879
1889
|
console.log("Calling SDK authenticate function...");
|
|
1880
|
-
return [4 /*yield*/, authenticate(
|
|
1890
|
+
return [4 /*yield*/, authenticate(fixedOptions)];
|
|
1881
1891
|
case 2:
|
|
1882
|
-
assertionResponse =
|
|
1892
|
+
assertionResponse = _g.sent();
|
|
1883
1893
|
console.log("Authentication assertion received from client:", assertionResponse);
|
|
1884
1894
|
// 3. Send the assertion back to the server for verification
|
|
1885
1895
|
console.log("Sending assertion to server for verification...");
|
|
1886
|
-
return [4 /*yield*/, axios.post(MFAEndpoints.AuthChallengeVerify, assertionResponse
|
|
1896
|
+
return [4 /*yield*/, axios.post(MFAEndpoints.AuthChallengeVerify, assertionResponse, {
|
|
1897
|
+
headers: {
|
|
1898
|
+
"X-DEVICE-ID": GenerateDeviceId(),
|
|
1899
|
+
"X-API-VERSION": "1.0",
|
|
1900
|
+
},
|
|
1901
|
+
withCredentials: true, // credentials: 'include'
|
|
1902
|
+
})];
|
|
1887
1903
|
case 3:
|
|
1888
|
-
|
|
1904
|
+
_g.sent();
|
|
1889
1905
|
sonner.toast.success("🔑 Sign-in successful!");
|
|
1890
1906
|
return [3 /*break*/, 5];
|
|
1891
1907
|
case 4:
|
|
1892
|
-
error_1 =
|
|
1908
|
+
error_1 = _g.sent();
|
|
1893
1909
|
console.error("Authentication failed:", error_1);
|
|
1894
1910
|
sonner.toast.error("❌ Could not sign in.");
|
|
1895
1911
|
return [3 /*break*/, 5];
|
|
@@ -2107,7 +2123,12 @@ var DefaultLoginPage = function (_a) {
|
|
|
2107
2123
|
_a.trys.push([0, 4, , 5]);
|
|
2108
2124
|
// 1. Fetch challenge from your server
|
|
2109
2125
|
console.log("Requesting registration challenge from server...");
|
|
2110
|
-
return [4 /*yield*/, axios.post(MFAEndpoints.RegisterNewChallenge, __assign({}, data)
|
|
2126
|
+
return [4 /*yield*/, axios.post(MFAEndpoints.RegisterNewChallenge, __assign({}, data), {
|
|
2127
|
+
headers: {
|
|
2128
|
+
"X-DEVICE-ID": GenerateDeviceId(),
|
|
2129
|
+
"X-API-VERSION": "1.0",
|
|
2130
|
+
},
|
|
2131
|
+
})];
|
|
2111
2132
|
case 1:
|
|
2112
2133
|
options = (_a.sent()).data;
|
|
2113
2134
|
console.log("Received challenge:", options);
|
|
@@ -2120,7 +2141,10 @@ var DefaultLoginPage = function (_a) {
|
|
|
2120
2141
|
// 3. Send the response back to the server for verification
|
|
2121
2142
|
console.log("Sending attestation to server for verification...");
|
|
2122
2143
|
return [4 /*yield*/, axios.post(MFAEndpoints.RegisterVerify, attestationResponse, {
|
|
2123
|
-
headers: {
|
|
2144
|
+
headers: {
|
|
2145
|
+
"X-DEVICE-ID": GenerateDeviceId(),
|
|
2146
|
+
"X-API-VERSION": "1.0",
|
|
2147
|
+
},
|
|
2124
2148
|
withCredentials: true, // credentials: 'include'
|
|
2125
2149
|
})];
|
|
2126
2150
|
case 3:
|