Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "com.librusek.dev"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 134
versionName "1.3.4"
versionCode 135
versionName "1.3.5"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
Expand Down
4 changes: 2 additions & 2 deletions ios/App/App/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.3.4</string>
<string>1.3.5</string>
<key>CFBundleVersion</key>
<string>134</string>
<string>135</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand Down
52 changes: 46 additions & 6 deletions lib/auth.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { apiUrl } from "./core";

const authUrls = {
init: "https://api.librus.pl/OAuth/Authorization?client_id=46&response_type=code&scope=mydata",
final: "https://api.librus.pl/OAuth/Authorization?client_id=46",
init: "https://synergia.librus.pl/loguj/portalRodzina?v=",
auth: "https://api.librus.pl/OAuth/Authorization?client_id=46",
mfa: "https://api.librus.pl/OAuth/Authorization/PerformLogin?client_id=46",
perform: "https://api.librus.pl/OAuth/Authorization/PerformLogin?client_id=46",
grant: "https://api.librus.pl/OAuth/Authorization/Grant?client_id=46",
};

Expand All @@ -23,20 +25,54 @@ const activate = async () => {
}
};

const getBaner = () => {
const turnips = Date.now()
.toString()
.split("")
.map(function (l) {
return String.fromCharCode(l.charCodeAt(0) + 20);
})
.join("")
const preTurnips = Math.random()
.toString()
.split("")
.map(function (l) {
return String.fromCharCode(l.charCodeAt(0) + 20);
})
.join("")
return preTurnips + String.fromCharCode(95) + turnips;
}

const authenticate = async (login, password) => {
try {
const initRequest = await fetch(authUrls.init, {
const initRequest = await fetch(authUrls.init + Date.now() / 1000, {
connectTimeout: 5000,
headers: {
"Referer": "https://portal.librus.pl/"
}
});
if (!initRequest.ok) return { error: "unknown" };
const prep = initRequest.headers.get("location");
await fetch(prep, {
headers: {
"Referer": "https://portal.librus.pl/"
}
})
await fetch(authUrls.auth)
const formData = new FormData();
formData.append("action", "login");
formData.append("login", login);
formData.append("pass", password);
const authorization = await fetch(authUrls.final, {
const authorization = await fetch(authUrls.auth, {
method: "POST",
body: formData,
credentials: "include",
headers: {
"Accept": "application/json",
"X-Requested-With": "XMLHttpRequest",
"X-Baner": getBaner(),
"Referer": authUrls.auth
}
});
if (authorization.status !== 200) {
const errorBody = await authorization.json();
Expand All @@ -52,12 +88,16 @@ const authenticate = async (login, password) => {
}
return { error: "unknown" };
}
const mfa = await fetch(authUrls.mfa);
if (!mfa.ok) return { error: "unknown" };
const perform = await fetch(authUrls.perform);
if (!perform.ok) return { error: "unknown" };
const grant = await fetch(authUrls.grant);
if (!grant.ok) return false;
if (!grant.ok) return { error: "unknown" };
return await activate();
} catch (error) {
console.error(error);
return false;
return { error: "unknown" };
}
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "librusek",
"version": "1.3.4",
"version": "1.3.5",
"private": true,
"scripts": {
"base:dev": "next dev -H 0.0.0.0",
Expand Down
Loading