@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.esm.js CHANGED
@@ -1843,32 +1843,48 @@ var MFAOptions = function (_a) {
1843
1843
  var idToken = context.authMode === "MSAL" ? context.idToken : "";
1844
1844
  var authenticate = useWebAuthn().authenticate;
1845
1845
  var handleFIDOLogin = function () { return __awaiter(void 0, void 0, void 0, function () {
1846
- var options, assertionResponse, error_1;
1847
- return __generator(this, function (_a) {
1848
- switch (_a.label) {
1846
+ var options, fixedOptions, assertionResponse, error_1;
1847
+ var _a, _b, _c, _d, _e, _f;
1848
+ return __generator(this, function (_g) {
1849
+ switch (_g.label) {
1849
1850
  case 0:
1850
- _a.trys.push([0, 4, , 5]);
1851
+ _g.trys.push([0, 4, , 5]);
1851
1852
  // 1. Fetch authentication challenge from your server
1852
1853
  console.log("Requesting authentication challenge from server...");
1853
- return [4 /*yield*/, axios.post(MFAEndpoints.RetrieveAuthChallenge)];
1854
+ return [4 /*yield*/, axios.post(MFAEndpoints.RetrieveAuthChallenge, {}, {
1855
+ headers: {
1856
+ "X-DEVICE-ID": GenerateDeviceId(),
1857
+ "X-API-VERSION": "1.0",
1858
+ },
1859
+ })];
1854
1860
  case 1:
1855
- options = (_a.sent()).data;
1861
+ options = (_g.sent()).data;
1856
1862
  console.log("Received challenge:", options);
1863
+ fixedOptions = __assign(__assign({}, options), { pubKeyCredParams: (_a = options.pubKeyCredParams) === null || _a === void 0 ? void 0 : _a.map(function (param) { return ({
1864
+ type: "public-key",
1865
+ alg: param.alg
1866
+ }); }), 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" }) });
1857
1867
  // 2. Call the SDK to trigger the browser's passkey authentication UI
1858
1868
  console.log("Calling SDK authenticate function...");
1859
- return [4 /*yield*/, authenticate(options)];
1869
+ return [4 /*yield*/, authenticate(fixedOptions)];
1860
1870
  case 2:
1861
- assertionResponse = _a.sent();
1871
+ assertionResponse = _g.sent();
1862
1872
  console.log("Authentication assertion received from client:", assertionResponse);
1863
1873
  // 3. Send the assertion back to the server for verification
1864
1874
  console.log("Sending assertion to server for verification...");
1865
- return [4 /*yield*/, axios.post(MFAEndpoints.AuthChallengeVerify, assertionResponse)];
1875
+ return [4 /*yield*/, axios.post(MFAEndpoints.AuthChallengeVerify, assertionResponse, {
1876
+ headers: {
1877
+ "X-DEVICE-ID": GenerateDeviceId(),
1878
+ "X-API-VERSION": "1.0",
1879
+ },
1880
+ withCredentials: true, // credentials: 'include'
1881
+ })];
1866
1882
  case 3:
1867
- _a.sent();
1883
+ _g.sent();
1868
1884
  toast.success("🔑 Sign-in successful!");
1869
1885
  return [3 /*break*/, 5];
1870
1886
  case 4:
1871
- error_1 = _a.sent();
1887
+ error_1 = _g.sent();
1872
1888
  console.error("Authentication failed:", error_1);
1873
1889
  toast.error("❌ Could not sign in.");
1874
1890
  return [3 /*break*/, 5];
@@ -2086,7 +2102,12 @@ var DefaultLoginPage = function (_a) {
2086
2102
  _a.trys.push([0, 4, , 5]);
2087
2103
  // 1. Fetch challenge from your server
2088
2104
  console.log("Requesting registration challenge from server...");
2089
- return [4 /*yield*/, axios.post(MFAEndpoints.RegisterNewChallenge, __assign({}, data))];
2105
+ return [4 /*yield*/, axios.post(MFAEndpoints.RegisterNewChallenge, __assign({}, data), {
2106
+ headers: {
2107
+ "X-DEVICE-ID": GenerateDeviceId(),
2108
+ "X-API-VERSION": "1.0",
2109
+ },
2110
+ })];
2090
2111
  case 1:
2091
2112
  options = (_a.sent()).data;
2092
2113
  console.log("Received challenge:", options);
@@ -2099,7 +2120,10 @@ var DefaultLoginPage = function (_a) {
2099
2120
  // 3. Send the response back to the server for verification
2100
2121
  console.log("Sending attestation to server for verification...");
2101
2122
  return [4 /*yield*/, axios.post(MFAEndpoints.RegisterVerify, attestationResponse, {
2102
- headers: { "Content-Type": "application/json" },
2123
+ headers: {
2124
+ "X-DEVICE-ID": GenerateDeviceId(),
2125
+ "X-API-VERSION": "1.0",
2126
+ },
2103
2127
  withCredentials: true, // credentials: 'include'
2104
2128
  })];
2105
2129
  case 3: