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
49 changes: 38 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# JavaSteam

[![Java CI/CD](https://github.com/Longi94/JavaSteam/actions/workflows/javasteam-build-push.yml/badge.svg)](https://github.com/Longi94/JavaSteam/actions/workflows/javasteam-build.yml)
[![Maven Central](https://img.shields.io/maven-central/v/in.dragonbra/javasteam)](https://mvnrepository.com/artifact/in.dragonbra/javasteam)
[![Discord](https://img.shields.io/discord/420907597906968586.svg)](https://discord.gg/8F2JuTu)
Expand All @@ -9,34 +10,47 @@ Java port of [SteamKit2](https://github.com/SteamRE/SteamKit). JavaSteam targets

Latest version is available through [Maven](https://mvnrepository.com/artifact/in.dragonbra/javasteam)

If you get a `java.security.InvalidKeyException: Illegal key size or default parameters` exception when trying to encrypt a message you need to download the [Unlimited Strength Jurisdiction Policy Files](http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html) and place them under `${java.home}/jre/lib/security/`. See [this stackoverflow question](https://stackoverflow.com/questions/6481627/java-security-illegal-key-size-or-default-parameters).
Snapshots may be available through [Maven central repository](https://central.sonatype.com/service/rest/repository/browse/maven-snapshots/in/dragonbra/)

If you get a `java.security.InvalidKeyException: Illegal key size or default parameters` exception when trying to
encrypt a message you need to download
the [Unlimited Strength Jurisdiction Policy Files](http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html)
and place them under `${java.home}/jre/lib/security/`.

See [this stackoverflow question](https://stackoverflow.com/questions/6481627/java-security-illegal-key-size-or-default-parameters).

**1. Add the repository to your build.**

Gradle

```groovy
repositories {
mavenCentral()
}
```

Maven

```xml

<repository>
<id>central</id>
<url>https://repo.maven.apache.org/maven2</url>
<id>central</id>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
```

**2. Add the JavaSteam dependency to your project.**

Gradle

```groovy
implementation 'in.dragonbra:javasteam:x.y.z'
```

Maven

```xml

<dependency>
<groupId>in.dragonbra</groupId>
<artifactId>javasteam</artifactId>
Expand All @@ -50,17 +64,28 @@ Maven

[Android and Non-Android | Bouncy Castle](https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk18on)

**4. (Optional) Working with protobufs.**

If you plan on working with protobuf builders directly to perform actions a handler doesn't support, you will need to add the protobuf-java dependency.
**4. Optional dependencies.**

Note: To eliminate any errors or warnings, you should try and match the same version JavaSteam uses.<br>You can find the latest version being used [here](https://github.com/Longi94/JavaSteam/blob/master/gradle/libs.versions.toml).
* Protobufs:
* If you plan on working with protobuf builders directly to perform actions a handler doesn't support, you will need
to add the [protobuf-java](https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java) dependency.
* Note: To eliminate any errors or warnings, you should try and match the same version JavaSteam uses.
<br><br>
* Content Downloading:
* If you plan on working with Content Downloading, Depot files may be compressed with Zstd *(Zstandard)*.
* You will need to implement the correct type
of [ztd implementation](https://mvnrepository.com/artifact/com.github.luben/zstd-jni) if using JVM or Android.
* Android uses `aar` for the library type.

[Protobuf Java](https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java)
You can find the latest version of these dependencies JavaSteam
supports [here](https://github.com/Longi94/JavaSteam/blob/master/gradle/libs.versions.toml).

## Getting Started

You can head to the very short [Getting Started](https://github.com/Longi94/JavaSteam/wiki/Getting-started) page or take a look at the [samples](https://github.com/Longi94/JavaSteam/tree/master/javasteam-samples/src/main/java/in/dragonbra/javasteamsamples) to get you started with using this library.
You can head to the very short [Getting Started](https://github.com/Longi94/JavaSteam/wiki/Getting-started) page or take
a look at
the [samples](https://github.com/Longi94/JavaSteam/tree/master/javasteam-samples/src/main/java/in/dragonbra/javasteamsamples)
to get you started with using this library.

There some [open-source projects](https://github.com/Longi94/JavaSteam/wiki/Samples) too you can check out.

Expand All @@ -78,11 +103,13 @@ Generated classes:<br>

## Contributing

Contributions to the repository are always welcome! Checkout the [contribution guidelines](CONTRIBUTING.md) to get started.
Contributions to the repository are always welcome! Checkout the [contribution guidelines](CONTRIBUTING.md) to get
started.

## Other

Join the [discord server](https://discord.gg/8F2JuTu) if you have any questions related or unrelated to this repo or just want to chat!
Join the [discord server](https://discord.gg/8F2JuTu) if you have any questions related or unrelated to this repo or
just want to chat!

## License

Expand Down
5 changes: 3 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,17 @@ tasks.withType<FormatTask> {
}

dependencies {
implementation(libs.bundles.ktor)
implementation(libs.commons.io)
implementation(libs.commons.lang3)
implementation(libs.commons.validator)
implementation(libs.gson)
implementation(libs.kotlin.coroutines)
implementation(libs.kotlin.stdib)
implementation(libs.okHttp)
implementation(libs.xz)
implementation(libs.protobuf.java)
implementation(libs.bundles.ktor)
implementation(libs.xz)
compileOnly(libs.zstd)

testImplementation(libs.bundles.testing)
}
Expand Down
9 changes: 6 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ protobuf-gradle = "0.9.5" # https://mvnrepository.com/artifact/com.google.protob
publishPlugin = "2.0.0" # https://mvnrepository.com/artifact/io.github.gradle-nexus/publish-plugin
qrCode = "1.0.1" # https://mvnrepository.com/artifact/pro.leaco.qrcode/console-qrcode
xz = "1.10" # https://mvnrepository.com/artifact/org.tukaani/xz
zstd = "1.5.7-3" # https://search.maven.org/artifact/com.github.luben/zstd-jni

# Testing Lib versions
commonsCodec = "1.18.0" # https://mvnrepository.com/artifact/commons-codec/commons-codec
Expand All @@ -39,14 +40,15 @@ commons-validator = { module = "commons-validator:commons-validator", version.re
gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
kotlin-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlin-coroutines" }
kotlin-stdib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version = "3.0.3" }
ktor-client-core = { module = "io.ktor:ktor-client-core", version = "3.0.3" }
ktor-client-websocket = { module = "io.ktor:ktor-client-websockets", version = "3.0.3" }
okHttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okHttp" }
protobuf-java = { module = "com.google.protobuf:protobuf-java", version.ref = "protobuf" }
protobuf-protoc = { module = "com.google.protobuf:protoc", version.ref = "protobuf" }
qrCode = { module = "pro.leaco.qrcode:console-qrcode", version.ref = "qrCode" }
xz = { module = "org.tukaani:xz", version.ref = "xz" }
ktor-client-core = { module = "io.ktor:ktor-client-core", version = "3.0.3" }
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version = "3.0.3" }
ktor-client-websocket = { module = "io.ktor:ktor-client-websockets", version = "3.0.3" }
zstd = { module = "com.github.luben:zstd-jni", version.ref = "zstd" }

test-commons-codec = { module = "commons-codec:commons-codec", version.ref = "commonsCodec" }
test-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit5" }
Expand All @@ -73,6 +75,7 @@ testing = [
"test-mock-webserver3",
"test-mockito-core",
"test-mockito-jupiter",
"zstd"
]

ktor = [
Expand Down
3 changes: 2 additions & 1 deletion javasteam-samples/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ java {
dependencies {
implementation(rootProject)

implementation(libs.okHttp)
implementation(libs.bouncyCastle)
implementation(libs.gson)
implementation(libs.kotlin.coroutines)
implementation(libs.okHttp)
implementation(libs.protobuf.java) // To access protobufs directly as shown in Sample #2
implementation(libs.qrCode)
implementation(libs.zstd) // Content Downloading.
}
4 changes: 2 additions & 2 deletions src/main/java/in/dragonbra/javasteam/steam/cdn/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class Client(steamClient: SteamClient) : Closeable {
proxyServer: Server? = null,
cdnAuthToken: String? = null,
): CompletableFuture<DepotManifest> = defaultScope.future {
downloadManifest(
return@future downloadManifest(
depotId = depotId,
manifestId = manifestId,
manifestRequestCode = manifestRequestCode.toULong(),
Expand Down Expand Up @@ -372,7 +372,7 @@ class Client(steamClient: SteamClient) : Closeable {
proxyServer: Server? = null,
cdnAuthToken: String? = null,
): CompletableFuture<Int> = defaultScope.future {
downloadDepotChunk(
return@future downloadDepotChunk(
depotId = depotId,
chunk = chunk,
server = server,
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/in/dragonbra/javasteam/steam/cdn/DepotChunk.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import `in`.dragonbra.javasteam.types.ChunkData
import `in`.dragonbra.javasteam.util.Strings
import `in`.dragonbra.javasteam.util.Utils
import `in`.dragonbra.javasteam.util.VZipUtil
import `in`.dragonbra.javasteam.util.VZstdUtil
import `in`.dragonbra.javasteam.util.ZipUtil
import `in`.dragonbra.javasteam.util.crypto.CryptoHelper
import `in`.dragonbra.javasteam.util.stream.MemoryStream
Expand Down Expand Up @@ -73,7 +74,11 @@ object DepotChunk {
buffer[3] == 'a'.code.toByte()
) {
// Zstd
throw RuntimeException("Zstd compressed chunks are not yet implemented in JavaSteam.")
writtenDecompressed = VZstdUtil.decompress(
buffer = buffer.copyOfRange(0, written),
destination = destination,
verifyChecksum = false,
)
} else if (buffer[0] == 'V'.code.toByte() &&
buffer[1] == 'Z'.code.toByte() &&
buffer[2] == 'a'.code.toByte()
Expand Down
Loading