reddy-api-srm 1.0.8 → 1.0.9

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.
@@ -62,7 +62,7 @@ async function terminateSessions({ flowId, identifier, digest, csrfToken }) {
62
62
  ? { "x-zcsrf-token": `iamcsrcoo=${csrfToken}` }
63
63
  : {}),
64
64
  Referer:
65
- "https://academia.srmist.edu.in/accounts/p/10002227248/signin?hide_fp=true&servicename=ZohoCreator&service_language=en&dcc=true&serviceurl=https%3A%2F%2Facademia.srmist.edu.in%2Fportal%2Facademia-academic-services%2FredirectFromLogin",
65
+ "https://academia.srmist.edu.in/accounts/p/40-10002227248/signin?hide_fp=true&servicename=ZohoCreator&service_language=en&dcc=true&serviceurl=https%3A%2F%2Facademia.srmist.edu.in%2Fportal%2Facademia-academic-services%2FredirectFromLogin",
66
66
  "Referrer-Policy": "strict-origin-when-cross-origin",
67
67
  },
68
68
  body: body.toString(),
@@ -100,7 +100,7 @@ async function terminateSessions({ flowId, identifier, digest, csrfToken }) {
100
100
  },
101
101
  });
102
102
 
103
- if (res2.ok || res2.status === 200 || res2.status === 204) {
103
+ if (res2.ok || res2.status === 200 || res2.status === 202 || res2.status === 204) {
104
104
  let data = null;
105
105
  try { data = await res2.json(); } catch { /* 204 No Content is fine */ }
106
106
  return { success: true, status: res2.status, strategy: "webclient-delete", data };
@@ -12,9 +12,7 @@ async function validatePassword({ identifier, digest, password, }) {
12
12
  "sec-fetch-dest": "empty",
13
13
  "sec-fetch-mode": "cors",
14
14
  "sec-fetch-site": "same-origin",
15
- "x-zcsrf-token": "iamcsrcoo=fae2d8fa-e5a1-4cb0-a5ee-cc40af87e89f",
16
- cookie: "zalb_74c3a1eecc=4cad43ac9848cc7edd20d2313fcde774; zccpn=a6fa7bc8-11c7-44ad-8be8-0aa6b04fad8a; JSESSIONID=3BD0053672AF3D628D983A15AA469D07; cli_rgn=IN; _ga=GA1.3.2061081340.1748689001; _gid=GA1.3.1677956689.1748689001; _ga_HQWPLLNMKY=GS2.3.s1748689001$o1$g0$t1748689001$j60$l0$h0; zalb_f0e8db9d3d=7ad3232c36fdd9cc324fb86c2c0a58ad; iamcsr=fae2d8fa-e5a1-4cb0-a5ee-cc40af87e89f; _zcsr_tmp=fae2d8fa-e5a1-4cb0-a5ee-cc40af87e89f; stk=d6559e9a58e77dbea9e24adf3bb57941",
17
- Referer: "https://academia.srmist.edu.in/accounts/p/10002227248/signin?hide_fp=true&servicename=ZohoCreator&service_language=en&css_url=/49910842/academia-academic-services/downloadPortalCustomCss/login&dcc=true&serviceurl=https%3A%2F%2Facademia.srmist.edu.in%2Fportal%2Facademia-academic-services%2FredirectFromLogin",
15
+ Referer: "https://academia.srmist.edu.in/accounts/p/40-10002227248/signin?hide_fp=true&servicename=ZohoCreator&service_language=en&dcc=true&serviceurl=https%3A%2F%2Facademia.srmist.edu.in%2Fportal%2Facademia-academic-services%2FredirectFromLogin",
18
16
  "Referrer-Policy": "strict-origin-when-cross-origin",
19
17
  },
20
18
  body: `{"passwordauth":{"password":"${password}"}}`,
@@ -39,12 +37,14 @@ async function validatePassword({ identifier, digest, password, }) {
39
37
  return { error: "Internal Server Error", errorReason: new Error("Non-JSON response from login endpoint") };
40
38
  }
41
39
  if (response.status_code === 201) {
42
- // Use filterCookies to process set-cookie header
43
- const setCookieHeader = res.headers.get("set-cookie");
44
- if (!setCookieHeader)
40
+ const setCookieHeaders = (typeof res.headers.getSetCookie === "function"
41
+ ? res.headers.getSetCookie()
42
+ : [res.headers.get("set-cookie")].filter(Boolean));
43
+ if (!setCookieHeaders.length)
45
44
  throw new Error("Couldn't able to get cookie from response header ");
45
+ const combinedCookieHeader = setCookieHeaders.join("; ");
46
46
  const matches = [
47
- ...setCookieHeader.matchAll(/(_(?:iamadt|iambdt)_client_\d+|_z_identity)=[^;]+/g),
47
+ ...combinedCookieHeader.matchAll(/(_(?:iamadt|iambdt)_client_\d+|_z_identity)=[^;]+/g),
48
48
  ];
49
49
  const extractedCookies = matches.map((m) => m[0]).join("; ") + ";";
50
50
  const data = {
@@ -90,4 +90,4 @@ async function validatePassword({ identifier, digest, password, }) {
90
90
  return { error: "Internal Server Error", errorReason: e };
91
91
  }
92
92
  }
93
- //# sourceMappingURL=validatePassword.js.map
93
+ //# sourceMappingURL=validatePassword.js.map
@@ -8,15 +8,10 @@ async function validateUser(username) {
8
8
  accept: "*/*",
9
9
  "accept-language": "en-US,en;q=0.9",
10
10
  "content-type": "application/x-www-form-urlencoded;charset=UTF-8",
11
- "sec-ch-ua": '"Chromium";v="136", "Google Chrome";v="136", "Not.A/Brand";v="99"',
12
- "sec-ch-ua-mobile": "?1",
13
- "sec-ch-ua-platform": '"Android"',
14
11
  "sec-fetch-dest": "empty",
15
12
  "sec-fetch-mode": "cors",
16
13
  "sec-fetch-site": "same-origin",
17
- "x-zcsrf-token": "iamcsrcoo=3dea6395-0540-44ea-8de7-544256dd7549",
18
- cookie: "zalb_74c3a1eecc=50830239914cba1225506e915a665a91; zccpn=68703e7d-ccf0-42ba-92b2-9c87c7a0c8ae; JSESSIONID=739937C3826C1F58C37186170B4F4B36; cli_rgn=IN; _ga=GA1.3.1846200817.1748679237; _gid=GA1.3.734795940.1748679237; _gat=1; _ga_HQWPLLNMKY=GS2.3.s1748679237$o1$g0$t1748679237$j60$l0$h0; zalb_f0e8db9d3d=983d6a65b2f29022f18db52385bfc639; iamcsr=3dea6395-0540-44ea-8de7-544256dd7549; _zcsr_tmp=3dea6395-0540-44ea-8de7-544256dd7549; stk=4ec13d42454007681bd4337cf126baec",
19
- Referer: "https://academia.srmist.edu.in/accounts/p/10002227248/signin?hide_fp=true&servicename=ZohoCreator&service_language=en&css_url=/49910842/academia-academic-services/downloadPortalCustomCss/login&dcc=true&serviceurl=https%3A%2F%2Facademia.srmist.edu.in%2Fportal%2Facademia-academic-services%2FredirectFromLogin",
14
+ Referer: "https://academia.srmist.edu.in/accounts/p/40-10002227248/signin?hide_fp=true&servicename=ZohoCreator&service_language=en&dcc=true&serviceurl=https%3A%2F%2Facademia.srmist.edu.in%2Fportal%2Facademia-academic-services%2FredirectFromLogin",
20
15
  "Referrer-Policy": "strict-origin-when-cross-origin",
21
16
  },
22
17
  body: `mode=primary&cli_time=${Date.now()}&servicename=ZohoCreator&service_language=en&serviceurl=https%3A%2F%2Facademia.srmist.edu.in%2Fportal%2Facademia-academic-services%2FredirectFromLogin`,
@@ -39,4 +34,4 @@ async function validateUser(username) {
39
34
  };
40
35
  }
41
36
  }
42
- //# sourceMappingURL=validateUser.js.map
37
+ //# sourceMappingURL=validateUser.js.map
@@ -25,18 +25,14 @@ async function fetchAttendance(cookie) {
25
25
  return request.data;
26
26
  }
27
27
  catch (error) {
28
- if (error &&
29
- typeof error === "object" &&
30
- "status" in error &&
31
- error.status === 500) {
28
+ const statusCode = axios_1.default.isAxiosError(error) ? error.response?.status : undefined;
29
+ if (statusCode === 401 || statusCode === 403 || statusCode === 500) {
32
30
  return { error: "Unauthorized", status: 401 };
33
31
  }
34
32
  return {
35
33
  error: error instanceof Error ? error.message : "Failed to fetch attendance",
36
- status: error && typeof error === "object" && "status" in error
37
- ? error.status
38
- : 500,
34
+ status: statusCode ?? 500,
39
35
  };
40
36
  }
41
37
  }
42
- //# sourceMappingURL=fetchAttendance.js.map
38
+ //# sourceMappingURL=fetchAttendance.js.map
@@ -30,18 +30,14 @@ async function fetchCalendar(cookie) {
30
30
  return response.data;
31
31
  }
32
32
  catch (error) {
33
- if (error &&
34
- typeof error === "object" &&
35
- "status" in error &&
36
- error.status === 500) {
33
+ const statusCode = axios_1.default.isAxiosError(error) ? error.response?.status : undefined;
34
+ if (statusCode === 401 || statusCode === 403 || statusCode === 500) {
37
35
  return { error: "Unauthorized", status: 401 };
38
36
  }
39
37
  return {
40
38
  error: error instanceof Error ? error.message : "Failed to fetch calendar",
41
- status: error && typeof error === "object" && "status" in error
42
- ? error.status
43
- : 500,
39
+ status: statusCode ?? 500,
44
40
  };
45
41
  }
46
42
  }
47
- //# sourceMappingURL=fetchCalender.js.map
43
+ //# sourceMappingURL=fetchCalender.js.map
@@ -30,20 +30,16 @@ async function fetchCourseDetails(cookie) {
30
30
  return request.data;
31
31
  }
32
32
  catch (error) {
33
- if (error &&
34
- typeof error === "object" &&
35
- "status" in error &&
36
- error.status === 500) {
33
+ const statusCode = axios_1.default.isAxiosError(error) ? error.response?.status : undefined;
34
+ if (statusCode === 401 || statusCode === 403 || statusCode === 500) {
37
35
  return { error: "Unauthorized", status: 401 };
38
36
  }
39
37
  return {
40
38
  error: error instanceof Error
41
39
  ? error.message
42
40
  : "Failed to fetch course details",
43
- status: error && typeof error === "object" && "status" in error
44
- ? error.status
45
- : 500,
41
+ status: statusCode ?? 500,
46
42
  };
47
43
  }
48
44
  }
49
- //# sourceMappingURL=fetchCourseDetails.js.map
45
+ //# sourceMappingURL=fetchCourseDetails.js.map
@@ -25,18 +25,14 @@ async function fetchDayOrder(cookie) {
25
25
  return request.data;
26
26
  }
27
27
  catch (error) {
28
- if (error &&
29
- typeof error === "object" &&
30
- "status" in error &&
31
- error.status === 500) {
28
+ const statusCode = axios_1.default.isAxiosError(error) ? error.response?.status : undefined;
29
+ if (statusCode === 401 || statusCode === 403 || statusCode === 500) {
32
30
  return { error: "Unauthorized", status: 401 };
33
31
  }
34
32
  return {
35
33
  error: error instanceof Error ? error.message : "Failed to fetch attendance",
36
- status: error && typeof error === "object" && "status" in error
37
- ? error.status
38
- : 500,
34
+ status: statusCode ?? 500,
39
35
  };
40
36
  }
41
37
  }
42
- //# sourceMappingURL=fetchDayOrder.js.map
38
+ //# sourceMappingURL=fetchDayOrder.js.map
@@ -25,18 +25,14 @@ async function fetchMarks(cookie) {
25
25
  return request.data;
26
26
  }
27
27
  catch (error) {
28
- if (error &&
29
- typeof error === "object" &&
30
- "status" in error &&
31
- error.status === 500) {
28
+ const statusCode = axios_1.default.isAxiosError(error) ? error.response?.status : undefined;
29
+ if (statusCode === 401 || statusCode === 403 || statusCode === 500) {
32
30
  return { error: "Unauthorized", status: 401 };
33
31
  }
34
32
  return {
35
33
  error: error instanceof Error ? error.message : "Failed to fetch attendance",
36
- status: error && typeof error === "object" && "status" in error
37
- ? error.status
38
- : 500,
34
+ status: statusCode ?? 500,
39
35
  };
40
36
  }
41
37
  }
42
- //# sourceMappingURL=fetchMarks.js.map
38
+ //# sourceMappingURL=fetchMarks.js.map
@@ -30,20 +30,16 @@ async function fetchTimetable(cookie) {
30
30
  return request.data;
31
31
  }
32
32
  catch (error) {
33
- if (error &&
34
- typeof error === "object" &&
35
- "status" in error &&
36
- error.status === 500) {
33
+ const statusCode = axios_1.default.isAxiosError(error) ? error.response?.status : undefined;
34
+ if (statusCode === 401 || statusCode === 403 || statusCode === 500) {
37
35
  return { error: "Unauthorized", status: 401 };
38
36
  }
39
37
  return {
40
38
  error: error instanceof Error
41
39
  ? error.message
42
40
  : "Failed to fetch course details",
43
- status: error && typeof error === "object" && "status" in error
44
- ? error.status
45
- : 500,
41
+ status: statusCode ?? 500,
46
42
  };
47
43
  }
48
44
  }
49
- //# sourceMappingURL=fetchTimetable.js.map
45
+ //# sourceMappingURL=fetchTimetable.js.map
@@ -5,9 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.fetchUserInfo = fetchUserInfo;
7
7
  const axios_1 = __importDefault(require("axios"));
8
+ const dynamicUrl_1 = require("../../utils/dynamicUrl");
8
9
  async function fetchUserInfo(cookie) {
10
+ const url = await (0, dynamicUrl_1.courseDynamicUrl)();
9
11
  try {
10
- const request = await (0, axios_1.default)("https://academia.srmist.edu.in/srm_university/academia-academic-services/page/My_Time_Table_2023_24", {
12
+ const request = await (0, axios_1.default)(url, {
11
13
  headers: {
12
14
  accept: "*/*",
13
15
  "accept-language": "en-US,en;q=0.9",
@@ -25,19 +27,14 @@ async function fetchUserInfo(cookie) {
25
27
  return request.data;
26
28
  }
27
29
  catch (error) {
28
- if (error &&
29
- typeof error === "object" &&
30
- "status" in error &&
31
- error.status === 500) {
30
+ const statusCode = axios_1.default.isAxiosError(error) ? error.response?.status : undefined;
31
+ if (statusCode === 401 || statusCode === 403 || statusCode === 500) {
32
32
  return { error: "Unauthorized", status: 401 };
33
33
  }
34
- // Handle other errors
35
34
  return {
36
35
  error: error instanceof Error ? error.message : "Failed to fetch user info",
37
- status: error && typeof error === "object" && "status" in error
38
- ? error.status
39
- : 500,
36
+ status: statusCode ?? 500,
40
37
  };
41
38
  }
42
39
  }
43
- //# sourceMappingURL=fetchUserInfo.js.map
40
+ //# sourceMappingURL=fetchUserInfo.js.map
package/dist/src/index.js CHANGED
@@ -42,8 +42,8 @@ async function logoutUser(cookie) {
42
42
  return await (0, fetchLogout_1.fetchLogout)(cookie);
43
43
  }
44
44
  // Terminate concurrent sessions (2-device limit bypass)
45
- async function terminateSessions({ flowId, identifier, digest }) {
46
- return await (0, terminateSessions_1.terminateSessions)({ flowId, identifier, digest });
45
+ async function terminateSessions({ flowId, identifier, digest, csrfToken }) {
46
+ return await (0, terminateSessions_1.terminateSessions)({ flowId, identifier, digest, csrfToken });
47
47
  }
48
48
  // Get TimeTable
49
49
  async function getTimetable(cookie) {
@@ -115,4 +115,4 @@ async function getCourse(cookie) {
115
115
  return { error: parse.error, status: parse.status };
116
116
  return parse;
117
117
  }
118
- //# sourceMappingURL=index.js.map
118
+ //# sourceMappingURL=index.js.map
@@ -25,7 +25,12 @@ async function calendarDynamicUrl() {
25
25
  return dynamicUrl;
26
26
  }
27
27
  async function courseDynamicUrl() {
28
- const baseUrl = "https://academia.srmist.edu.in/srm_university/academia-academic-services/page/My_Time_Table_2023_24";
29
- return baseUrl;
28
+ const currentDate = new Date();
29
+ const currentYear = currentDate.getFullYear();
30
+ const currentMonth = currentDate.getMonth() + 1;
31
+ const academicYearString = currentMonth >= 1 && currentMonth <= 6
32
+ ? `${currentYear - 1}_${currentYear.toString().slice(-2)}`
33
+ : `${currentYear}_${(currentYear + 1).toString().slice(-2)}`;
34
+ return `https://academia.srmist.edu.in/srm_university/academia-academic-services/page/My_Time_Table_${academicYearString}`;
30
35
  }
31
- //# sourceMappingURL=dynamicUrl.js.map
36
+ //# sourceMappingURL=dynamicUrl.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "reddy-api-srm",
3
3
  "description": "SRMIST KTR Academia portal",
4
- "version": "1.0.8",
4
+ "version": "1.0.9",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
7
7
  "exports": {