diff --git a/build.gradle.kts b/build.gradle.kts index a403bfd..8e72611 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,4 @@ plugins { - alias(libs.plugins.androidLibrary).apply(false) - alias(libs.plugins.kotlinMultiplatform).apply(false) + alias(libs.plugins.androidLibrary).apply(false) + alias(libs.plugins.kotlinMultiplatform).apply(false) } diff --git a/library/build.gradle.kts b/library/build.gradle.kts index 3741454..9821c19 100644 --- a/library/build.gradle.kts +++ b/library/build.gradle.kts @@ -1,102 +1,94 @@ +import com.vanniktech.maven.publish.SonatypeHost import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.dsl.JvmTarget -import com.vanniktech.maven.publish.SonatypeHost val libraryName = "Pawnote" + version = "0.0.0" plugins { - alias(libs.plugins.kotlinMultiplatform) - alias(libs.plugins.androidLibrary) - id("com.vanniktech.maven.publish") version "0.29.0" + alias(libs.plugins.kotlinMultiplatform) + alias(libs.plugins.androidLibrary) + id("com.vanniktech.maven.publish") version "0.29.0" } kotlin { - jvm() - androidTarget { - publishLibraryVariants("release") - @OptIn(ExperimentalKotlinGradlePluginApi::class) - compilerOptions { - jvmTarget.set(JvmTarget.JVM_1_8) - } + jvm() + androidTarget { + publishLibraryVariants("release") + @OptIn(ExperimentalKotlinGradlePluginApi::class) + compilerOptions { jvmTarget.set(JvmTarget.JVM_1_8) } + } + + sourceSets { + val commonMain by getting { + dependencies { + implementation(libs.ktor.client.core) + implementation(libs.ktor.client.okhttp) + + implementation(libs.kotlinx.serialization.json) + implementation(libs.kotlinx.serialization.core) + + implementation(libs.kotlinx.datetime) + } } - - sourceSets { - val commonMain by getting { - dependencies { - implementation(libs.ktor.client.core) - implementation(libs.ktor.client.okhttp) - - implementation(libs.kotlinx.serialization.json) - implementation(libs.kotlinx.serialization.core) - - implementation(libs.kotlinx.datetime) - } - } - val commonTest by getting { - dependencies { - implementation(libs.kotlin.test) - } - } - val jvmMain by getting { - dependencies { - implementation(libs.ktor.client.okhttp) - implementation(libs.kotlin.test) - } - } - val androidMain by getting { - dependencies { - implementation(libs.ktor.client.okhttp) - } - } + val commonTest by getting { dependencies { implementation(libs.kotlin.test) } } + val jvmMain by getting { + dependencies { + implementation(libs.ktor.client.okhttp) + implementation(libs.kotlin.test) + } } + val androidMain by getting { + dependsOn(jvmMain) + dependencies { implementation(libs.ktor.client.okhttp) } + } + } } val groupName = "ink.literate" val idLibraryName = libraryName.lowercase() + group = groupName android { - namespace = groupName - compileSdk = libs.versions.android.compileSdk.get().toInt() - defaultConfig { - minSdk = libs.versions.android.minSdk.get().toInt() - } + namespace = groupName + compileSdk = libs.versions.android.compileSdk.get().toInt() + defaultConfig { minSdk = libs.versions.android.minSdk.get().toInt() } } - mavenPublishing { - coordinates(groupName, idLibraryName, version.toString()) - - pom { - name = libraryName - description = "A purrfect API wrapper for PRONOTE." - inceptionYear = "2024" - - url = "https://docs.literate.ink/$idLibraryName" - - licenses { - license { - name.set("GPL-3.0-or-later") - url.set("https://www.gnu.org/licenses/gpl-3.0.txt") - distribution.set("https://www.gnu.org/licenses/gpl-3.0.txt") - } - } - - developers { - developer { - organization = "LiterateInk" - organizationUrl = "https://literate.ink" - } - } - - scm { - url = "https://github.com/LiterateInk/$libraryName" - connection = "scm:git:https://github.com/LiterateInk/$libraryName.git" - developerConnection = "scm:git:https://github.com/LiterateInk/$libraryName.git" - } + coordinates(groupName, idLibraryName, version.toString()) + + pom { + name = libraryName + description = "A purrfect API wrapper for PRONOTE." + inceptionYear = "2024" + + url = "https://docs.literate.ink/$idLibraryName" + + licenses { + license { + name.set("GPL-3.0-or-later") + url.set("https://www.gnu.org/licenses/gpl-3.0.txt") + distribution.set("https://www.gnu.org/licenses/gpl-3.0.txt") + } + } + + developers { + developer { + organization = "LiterateInk" + organizationUrl = "https://literate.ink" + } + } + + scm { + url = "https://github.com/LiterateInk/$libraryName" + connection = "scm:git:https://github.com/LiterateInk/$libraryName.git" + developerConnection = "scm:git:https://github.com/LiterateInk/$libraryName.git" } + } - publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, automaticRelease = true) - signAllPublications() + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, automaticRelease = true) + signAllPublications() } diff --git a/library/src/commonMain/kotlin/ink/literate/pawnote/api/geolocation.kt b/library/src/commonMain/kotlin/ink/literate/pawnote/api/geolocation.kt index c95e36c..c29d52d 100644 --- a/library/src/commonMain/kotlin/ink/literate/pawnote/api/geolocation.kt +++ b/library/src/commonMain/kotlin/ink/literate/pawnote/api/geolocation.kt @@ -12,8 +12,8 @@ import kotlinx.serialization.json.jsonArray import kotlinx.serialization.json.jsonObject suspend fun geolocation( - position: Position, - httpClient: HttpClient = HttpClient() + position: Position, + httpClient: HttpClient = HttpClient() ): List { val res = httpClient.submitForm( diff --git a/library/src/commonMain/kotlin/ink/literate/pawnote/api/session-information.kt b/library/src/commonMain/kotlin/ink/literate/pawnote/api/session-information.kt index 6b446c1..45df6a1 100644 --- a/library/src/commonMain/kotlin/ink/literate/pawnote/api/session-information.kt +++ b/library/src/commonMain/kotlin/ink/literate/pawnote/api/session-information.kt @@ -22,8 +22,8 @@ data class SessionInfoParams( ) suspend fun sessionInformation( - options: SessionInfoParams, - httpClient: HttpClient = HttpClient { followRedirects = false } + options: SessionInfoParams, + httpClient: HttpClient = HttpClient { followRedirects = false } ): SessionInformation { val url = Url(options.base + "/" + encodeAccountKindToPath(options.kind)) diff --git a/library/src/commonMain/kotlin/ink/literate/pawnote/decoders/Instance.kt b/library/src/commonMain/kotlin/ink/literate/pawnote/decoders/Instance.kt index 58b36e1..b09750f 100644 --- a/library/src/commonMain/kotlin/ink/literate/pawnote/decoders/Instance.kt +++ b/library/src/commonMain/kotlin/ink/literate/pawnote/decoders/Instance.kt @@ -17,7 +17,7 @@ fun decodeInstance(instance: JsonObject): Instance { return Instance( name = instance["nomEtab"]!!.jsonPrimitive.content, version = instance["version"]!!.jsonArray.map { version -> version.jsonPrimitive.int }, - date = LocalDateTime.parse(instance["date"]!!.jsonPrimitive.content), + date = LocalDateTime.parse(instance["date"]!!.jsonPrimitive.content.dropLast(1)), accounts = instance["espaces"]!!.jsonArray.map { account -> InstanceAccount( diff --git a/library/src/commonTest/kotlin/ink/literate/pawnote/GeolocationTest.kt b/library/src/commonTest/kotlin/ink/literate/pawnote/GeolocationTest.kt deleted file mode 100644 index 75af7f1..0000000 --- a/library/src/commonTest/kotlin/ink/literate/pawnote/GeolocationTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -package ink.literate.pawnote - -import ink.literate.pawnote.api.geolocation -import ink.literate.pawnote.models.Position -import kotlin.test.Test -import kotlin.test.assertTrue -import kotlinx.coroutines.runBlocking - -class GeolocationTest { - - @Test - fun `test geolocation`() { - runBlocking { - val position = Position(latitude = 50.614843, longitude = 3.0784157) - - val instances = geolocation(position) - - println(instances) - - assertTrue { true } - } - } -} diff --git a/library/src/commonTest/kotlin/ink/literate/pawnote/api/Instance.kt b/library/src/commonTest/kotlin/ink/literate/pawnote/api/Instance.kt deleted file mode 100644 index c206af8..0000000 --- a/library/src/commonTest/kotlin/ink/literate/pawnote/api/Instance.kt +++ /dev/null @@ -1,18 +0,0 @@ -package ink.literate.pawnote.api - -import kotlin.test.Test -import kotlin.test.assertTrue -import kotlinx.coroutines.runBlocking - -class InstanceTest { - @Test - fun `test instance`() { - runBlocking { - val instance = instance("https://demo.index-education.net/pronote/eleve.html") - - println(instance) - - assertTrue { true } - } - } -} diff --git a/library/src/commonTest/kotlin/ink/literate/pawnote/api/identify.kt b/library/src/commonTest/kotlin/ink/literate/pawnote/api/identify.kt deleted file mode 100644 index 83db78c..0000000 --- a/library/src/commonTest/kotlin/ink/literate/pawnote/api/identify.kt +++ /dev/null @@ -1,46 +0,0 @@ -package ink.literate.pawnote.api - -import ink.literate.pawnote.api.private.IdentifyParameters -import ink.literate.pawnote.api.private.identify -import ink.literate.pawnote.models.* -import kotlin.test.Test -import kotlinx.coroutines.runBlocking - -class IdentifyTest { - val sessionBase = "https://demo.index-education.net/pronote" - val sessionId = 1235678 - - val sessionInfo = - SessionInformation( - order = 0, - url = sessionBase, - id = sessionId, - accountKind = AccountKind.STUDENT, - aesIV = "\tfmýÝ[½¬È»Dmøu0010", - aesKey = "", - skipCompression = false, - skipEncryption = false, - demo = true, - accessKind = SessionAccessKind.ACCOUNT, - rsaModulus = "", - rsaExponent = "", - rsaFromConstants = true, - http = false, - poll = false) - - @Test - fun `simple identify`() { - runBlocking { - println( - identify( - sessionInfo, - IdentifyParameters( - requestFirstMobileAuthentication = true, - reuseMobileAuthentication = false, - requestFromQRCode = false, - useCAS = false, - username = "demo", - deviceUUID = "coucou"))) - } - } -} diff --git a/library/src/commonTest/kotlin/ink/literate/pawnote/api/private/instance-parameters.kt b/library/src/commonTest/kotlin/ink/literate/pawnote/api/private/instance-parameters.kt deleted file mode 100644 index 5401af5..0000000 --- a/library/src/commonTest/kotlin/ink/literate/pawnote/api/private/instance-parameters.kt +++ /dev/null @@ -1,30 +0,0 @@ -package ink.literate.pawnote.api.private - -import ink.literate.pawnote.api.SessionInfoParams -import ink.literate.pawnote.api.sessionInformation -import ink.literate.pawnote.models.AccountKind -import kotlin.test.Test -import kotlinx.coroutines.runBlocking - -class InstanceParametersTest { - val sessionBase = "https://demo.index-education.net/pronote" - val sessionId = 1235678 - - @Test - fun `simple request test`() { - runBlocking { - println( - instanceParameters( - sessionInformation( - SessionInfoParams( - base = sessionBase, - kind = AccountKind.STUDENT, - params = - mapOf( - "fd" to "1", - "login" to "true", - "bydlg" to "A6ABB224-12DD-4E31-AD3E-8A39A1C2C335"), - cookies = listOf())))) - } - } -} diff --git a/library/src/commonTest/kotlin/ink/literate/pawnote/api/session-information.kt b/library/src/commonTest/kotlin/ink/literate/pawnote/api/session-information.kt deleted file mode 100644 index 98721f5..0000000 --- a/library/src/commonTest/kotlin/ink/literate/pawnote/api/session-information.kt +++ /dev/null @@ -1,25 +0,0 @@ -package ink.literate.pawnote.api - -import ink.literate.pawnote.models.AccountKind -import kotlin.test.Test -import kotlinx.coroutines.runBlocking - -class SessionInformationTest { - val sessionBase = "https://demo.index-education.net/pronote" - - @Test - fun `simple request test`() { - runBlocking { - sessionInformation( - SessionInfoParams( - base = sessionBase, - kind = AccountKind.STUDENT, - params = - mapOf( - "fd" to "1", - "login" to "true", - "bydlg" to "A6ABB224-12DD-4E31-AD3E-8A39A1C2C335"), - cookies = listOf())) - } - } -} diff --git a/library/src/commonTest/kotlin/ink/literate/pawnote/core/ResponseFNTest.kt b/library/src/commonTest/kotlin/ink/literate/pawnote/core/ResponseFNTest.kt index d33a709..a65ced6 100644 --- a/library/src/commonTest/kotlin/ink/literate/pawnote/core/ResponseFNTest.kt +++ b/library/src/commonTest/kotlin/ink/literate/pawnote/core/ResponseFNTest.kt @@ -18,7 +18,7 @@ class ResponseFNTest { id = sessionId, accountKind = AccountKind.STUDENT, aesIV = "09666dfddd5bbdacc8bb446df87530303130", - aesKey = "09666dfddd5bbdacc8bb446df87530303130", + aesKey = "", skipCompression = true, skipEncryption = true, demo = true, diff --git a/library/src/commonTest/kotlin/ink/literate/pawnote/login.kt b/library/src/commonTest/kotlin/ink/literate/pawnote/login.kt deleted file mode 100644 index 51f4288..0000000 --- a/library/src/commonTest/kotlin/ink/literate/pawnote/login.kt +++ /dev/null @@ -1,28 +0,0 @@ -package ink.literate.pawnote - -import ink.literate.pawnote.api.helpers.loginCredentials -import ink.literate.pawnote.models.AccountKind -import ink.literate.pawnote.models.CredentialsAuth -import kotlin.test.Test -import kotlinx.coroutines.runBlocking - -class LoginTest { - @Test - fun `credentials login`() { - // val sessionBase = "https://demo.index-education.net/pronote" - - val sessionBase = "https://dev-instance-pron.papillon.bzh/pronote" - - runBlocking { - println( - loginCredentials( - CredentialsAuth( - url = sessionBase, - username = "demonstration", - password = "12345678", - kind = AccountKind.STUDENT, - deviceUUID = "uuidRandom", - ))) - } - } -} diff --git a/settings.gradle.kts b/settings.gradle.kts index cdb0ccd..d73182c 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,17 +1,18 @@ pluginManagement { - repositories { - google() - mavenCentral() - gradlePluginPortal() - } + repositories { + google() + mavenCentral() + gradlePluginPortal() + } } dependencyResolutionManagement { - repositories { - google() - mavenCentral() - } + repositories { + google() + mavenCentral() + } } rootProject.name = "pawnote" + include(":library")