This repository has been archived by the owner on Aug 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d1276a9
commit 86f313e
Showing
12 changed files
with
197 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
lib/src/main/kotlin/mikataneko/interfaces/TokenCacheAspect.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package mikataneko.interfaces | ||
|
||
import com.microsoft.aad.msal4j.ITokenCacheAccessAspect | ||
import com.microsoft.aad.msal4j.ITokenCacheAccessContext | ||
|
||
abstract class TokenCacheAspect : ITokenCacheAccessAspect { | ||
override fun beforeCacheAccess(iTokenCacheAccessContext: ITokenCacheAccessContext?) { | ||
val data = loadCacheData() | ||
iTokenCacheAccessContext?.tokenCache()?.deserialize(data) | ||
} | ||
|
||
override fun afterCacheAccess(iTokenCacheAccessContext: ITokenCacheAccessContext?) { | ||
val data = iTokenCacheAccessContext?.tokenCache()?.serialize() | ||
data?.let { saveCacheData(it) } | ||
} | ||
|
||
abstract fun loadCacheData(): String | ||
abstract fun saveCacheData(data: String) | ||
} |
16 changes: 16 additions & 0 deletions
16
lib/src/main/kotlin/mikataneko/models/minecraft/GameItems.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package mikataneko.models.minecraft | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class GameItems( | ||
val items: List<GameItem>, | ||
val signature: String, | ||
val keyId: String, | ||
) | ||
|
||
@Serializable | ||
data class GameItem( | ||
val name: String, | ||
val signature: String, | ||
) |
27 changes: 27 additions & 0 deletions
27
lib/src/main/kotlin/mikataneko/models/minecraft/MinecraftAuthenticate.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package mikataneko.models.minecraft | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.json.JsonElement | ||
import kotlinx.serialization.json.JsonObject | ||
|
||
|
||
sealed class MinecraftAuthenticate | ||
|
||
@Serializable | ||
data class XboxMinecraftAuthenticate( | ||
val identityToken: String, | ||
) : MinecraftAuthenticate() | ||
|
||
@Serializable | ||
data class MinecraftAuthenticateResponse( | ||
val username: String, | ||
val roles: JsonElement, | ||
val metadata: JsonObject, | ||
@SerialName("access_token") | ||
val accessToken: String, | ||
@SerialName("token_type") | ||
val tokenType: String, | ||
@SerialName("expires_in") | ||
val expiresIn: Int, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package mikataneko.models.xbox | ||
|
||
data class DeviceCodeFlow( | ||
val clientId: String, | ||
val tenantId: String = "consumers", | ||
val scopes: List<String> = listOf("XboxLive.signin", "offline_access", "openid", "profile", "email"), | ||
) |
22 changes: 22 additions & 0 deletions
22
lib/src/main/kotlin/mikataneko/models/xbox/XSTSAuthorize.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package mikataneko.models.xbox | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class XSTSAuthorize( | ||
@SerialName("Properties") | ||
val xstsProperties: XSTSProperties, | ||
@SerialName("RelyingParty") | ||
val relyingParty: String = "rp://api.minecraftservices.com/", | ||
@SerialName("TokenType") | ||
val tokenType: String = "JWT", | ||
) | ||
|
||
@Serializable | ||
data class XSTSProperties( | ||
@SerialName("UserTokens") | ||
val userTokens: List<String>, | ||
@SerialName("SandboxId") | ||
val sandboxId: String = "RETAIL", | ||
) |
33 changes: 33 additions & 0 deletions
33
lib/src/main/kotlin/mikataneko/models/xbox/XSTSAuthorizeResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package mikataneko.models.xbox | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import java.time.Instant | ||
|
||
sealed class XSTSAuthorizeResponse | ||
|
||
@Serializable | ||
data class XSTSError( | ||
@SerialName("Identity") | ||
val identity: String, | ||
@SerialName("XErr") | ||
val xErr: Int, | ||
@SerialName("Message") | ||
val message: String, | ||
@SerialName("Redirect") | ||
val redirect: String, | ||
) : XSTSAuthorizeResponse() | ||
|
||
@Serializable | ||
data class XSTSSuccess( | ||
@SerialName("IssueInstant") | ||
@Serializable(with = InstantSerializer::class) | ||
val issueInstant: Instant, | ||
@SerialName("NotAfter") | ||
@Serializable(with = InstantSerializer::class) | ||
val notAfter: Instant, | ||
@SerialName("Token") | ||
val token: String, | ||
@SerialName("DisplayClaims") | ||
val displayClaims: DisplayClaims, | ||
) : XSTSAuthorizeResponse() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters