Socket
Socket
Sign inDemoInstall

asurso

Package Overview
Dependencies
83
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.11 to 0.2.0

lib/DocumentGenerationClass.js

2

lib/DiaryClass.js

@@ -1,1 +0,1 @@

import{format}from"date-fns";import{dateValidator,validateSchema}from"./utils.js";import*as yup from"yup";export default class DiaryClass{async getDiary(a,b,c,d=!1){await validateSchema([["yearId",a,yup.number().required()],["start",b,dateValidator],["end",c,dateValidator],["withLaAssigns",d,yup.bool()]]);const e=a=>format(a,"yyyy-MM-dd"),f={yearId:a,studentId:this.studentID,weekStart:e(b),weekEnd:e(c),withLaAssigns:d},g=await this.fetch(`https://asurso.ru/webapi/student/diary?${new URLSearchParams(f)}`);return g}async getAssignmentDetails(a){await validateSchema([["assignmentID",a,yup.number().required()]]);const b={studentId:this.studentID},c=await this.fetch(`https://asurso.ru/webapi/student/diary/assigns/${a}?${new URLSearchParams(b)}`);return c}}
import{format}from"date-fns";import{dateValidator,validateSchema}from"./utils.js";import*as yup from"yup";export default class DiaryClass{async getDiary(a,b,c=this.yearID,d=!1){await validateSchema([["yearId",c,yup.number().required()],["start",a,dateValidator],["end",b,dateValidator],["withLaAssigns",d,yup.bool()]]);const e=a=>format(a,"yyyy-MM-dd"),f={yearId:c,studentId:this.studentID,weekStart:e(a),weekEnd:e(b),withLaAssigns:d},g=await this.fetch(`https://asurso.ru/webapi/student/diary?${new URLSearchParams(f)}`);return g}async getAssignmentDetails(a){await validateSchema([["assignmentID",a,yup.number().required()]]);const b={studentId:this.studentID},c=await this.fetch(`https://asurso.ru/webapi/student/diary/assigns/${a}?${new URLSearchParams(b)}`);return c}}

@@ -1,1 +0,1 @@

import{aggregation}from"./utils.js";import Login from"./LoginClass.js";import Diary from"./DiaryClass.js";import Users from"./UsersClass.js";import Messages from"./MessagesClass.js";import Portfolio from"./PortfolioClass.js";import Announcements from"./AnnouncementsClass.js";import*as yup from"yup";import nodefetch from"node-fetch";import _ from"lodash";import cookie from"cookie";class BaseClass{constructor(a){const b=yup.object().shape({countryID:yup.number().required(),regionID:yup.number().required(),regionAreaID:yup.number().required(),cityID:yup.number().required(),schoolTypeID:yup.number().required(),schoolID:yup.number().required(),login:yup.string().required(),password:yup.string().required()});b.validateSync(a),this.loginDetails=a}async fetch(a,b={},c=!0){_.set(b,"headers.at",this.atKey);const d=b.cookie??[];_.set(b,"headers.Cookie",[cookie.serialize("ESRNSec",this.sessionToken),...d].join("; "));const e=await nodefetch(a,b);return c?await e.json():e}}export default class ASURSO extends aggregation(BaseClass,Login,Diary,Users,Messages,Portfolio,Announcements){}
import{aggregation}from"./utils.js";import Login from"./LoginClass.js";import Diary from"./DiaryClass.js";import Users from"./UsersClass.js";import Messages from"./MessagesClass.js";import Portfolio from"./PortfolioClass.js";import Announcements from"./AnnouncementsClass.js";import*as yup from"yup";import nodefetch from"node-fetch";import _ from"lodash";import cookie from"cookie";class BaseClass{constructor(a){const b=yup.object().shape({countryID:yup.number().required(),regionID:yup.number().required(),regionAreaID:yup.number().required(),cityID:yup.number().required(),schoolTypeID:yup.number().required(),schoolID:yup.number().required(),login:yup.string().required(),password:yup.string().required()});b.validateSync(a),this.loginDetails=a}async fetch(a,b={},c=!0){_.set(b,"headers.at",this.atKey);const d=b.cookie??[];_.set(b,"headers.Cookie",[cookie.serialize("ESRNSec",this.sessionToken,{encode:a=>a}),...d].join("; "));const e=await nodefetch(a,b);return c?await e.json():e}}export default class ASURSO extends aggregation(BaseClass,Login,Diary,Users,Messages,Portfolio,Announcements){}

@@ -1,1 +0,1 @@

import fetch from"node-fetch";import cookie from"cookie";import md5 from"md5";export default class Login{async login(a){if(a)this.atKey=a.atKey,this.sessionToken=a.sessionToken;else{const a=await fetch("https://asurso.ru/webapi/auth/getdata",{method:"POST"}),b=cookie.parse(a.headers.get("set-cookie")).NSSESSIONID,c=await a.json(),d=md5(c.salt+md5(this.loginDetails.password)),e={LoginType:1,cid:this.loginDetails.countryID,sid:this.loginDetails.regionID,pid:this.loginDetails.regionAreaID,cn:this.loginDetails.cityID,sft:this.loginDetails.schoolTypeID,scid:this.loginDetails.schoolID,UN:this.loginDetails.login,PW:d.substring(0,9),lt:c.lt,pw2:d,ver:c.ver},f=await fetch("https://asurso.ru/webapi/login",{method:"POST",body:new URLSearchParams(e),headers:{Cookie:cookie.serialize("NSSESSIONID",b),"X-Requested-With":"XMLHttpRequest"},referrer:"https://asurso.ru/about.html"}),g=await f.json();this.atKey=g.at,this.sessionToken=cookie.parse(f.headers.get("set-cookie")).ESRNSec}return this.studentID=await this.getStudentID(),{atKey:this.atKey,sessionToken:this.sessionToken}}async getStudentID(){const a=await this.fetch("https://asurso.ru/webapi/student/diary/init"),b=a.students[0].studentId;return b}}
import fetch from"node-fetch";import cookie from"cookie";import md5 from"md5";import{parse as htmlParser}from"node-html-parser";export default class Login{async login(a){if(a)this.atKey=a.atKey,this.sessionToken=a.sessionToken;else{const a=await fetch("https://asurso.ru/webapi/auth/getdata",{method:"POST"}),b=cookie.parse(a.headers.get("set-cookie")).NSSESSIONID,c=await a.json(),d=md5(c.salt+md5(this.loginDetails.password)),e={LoginType:1,cid:this.loginDetails.countryID,sid:this.loginDetails.regionID,pid:this.loginDetails.regionAreaID,cn:this.loginDetails.cityID,sft:this.loginDetails.schoolTypeID,scid:this.loginDetails.schoolID,UN:this.loginDetails.login,PW:d.substring(0,9),lt:c.lt,pw2:d,ver:c.ver},f=await fetch("https://asurso.ru/webapi/login",{method:"POST",body:new URLSearchParams(e),headers:{Cookie:cookie.serialize("NSSESSIONID",b),"X-Requested-With":"XMLHttpRequest"},referrer:"https://asurso.ru/about.html"}),g=await f.json();this.atKey=g.at,this.sessionToken=cookie.parse(f.headers.get("set-cookie")).ESRNSec}return this.studentID=await this.getStudentID(),this.yearID=await this.getYearID(),{atKey:this.atKey,sessionToken:this.sessionToken}}async getStudentID(){const a=await this.fetch("https://asurso.ru/webapi/student/diary/init"),b=a.students[0].studentId;return b}async getYearID(){const a=await this.fetch("https://asurso.ru/angular/school/main/",{method:"POST",body:new URLSearchParams({AT:this.atKey})},!1),b=await a.text(),c=htmlParser(b),d=c.querySelectorAll("head script[type=\"text/javascript\"]:not([src])").map(a=>a.innerHTML);for(let a of d){const b=a.match(/appContext\.yearId = "(\d+)"/)?.[1];if(b)return+b}}}

@@ -1,4 +0,1 @@

export default class PortfolioClass{async getPortfolio(a){const b={userId:a??this.studentID},c=await this.fetch(`https://asurso.ru/webapi/portfolios/personal/?${new URLSearchParams(b)}`);return c}// async downloadAnnouncementAttachment(attachmentID) {
// return this.fetch(`https://asurso.ru/webapi/attachments/${attachmentID}`, {}, false)
// }
}
export default class PortfolioClass{async getPortfolio(a){const b={userId:a??this.studentID},c=await this.fetch(`https://asurso.ru/webapi/portfolios/personal/?${new URLSearchParams(b)}`);return c}}
{
"name": "asurso",
"version": "0.1.11",
"version": "0.2.0",
"type": "module",

@@ -24,3 +24,5 @@ "description": "asurso.ru API wrapper [beta]",

"wrapper",
"student"
"api-wrapper",
"student",
"reverse-engineering"
],

@@ -45,2 +47,3 @@ "author": "vityaschel <hi@hloth.dev> (https://hloth.dev/)",

"node-fetch": "^3.1.0",
"node-html-parser": "^5.2.0",
"patch-package": "^6.4.7",

@@ -47,0 +50,0 @@ "yup": "^0.32.11"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc