Skip to content

Commit

Permalink
Merge pull request #76 from doubletapp/dev
Browse files Browse the repository at this point in the history
Add secure webhooks
  • Loading branch information
rsedykh authored Sep 12, 2023
2 parents d329ba1 + 23a3f20 commit c21581d
Show file tree
Hide file tree
Showing 23 changed files with 194 additions and 155 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

# History

## 3.3.0
- Library:
- Added support for [signing your webhooks](https://uploadcare.com/docs/webhooks/#signed-webhooks) using the `signingSecret` parameter.
- Fixed an issue with `datetime` filtering.
- Improved the handling of large file uploads.
- Dependencies:
- Update the target SDK version to 34.
- Update AGP (Android Gradle Plugin) version to 8.1.1.
- Update dependencies.

## 3.2.0
- Widget:
- The methods `UploadcareWidget.selectFile()` and `Fragment.startActivityForResult` have been deprecated.
Expand Down
26 changes: 8 additions & 18 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

buildscript {
def versions = [:]
versions.kotlin_version = '1.8.21'
versions.kotlin_version = '1.9.10'
versions.kotlin_coroutines = '1.7.3'
versions.min_sdk = 22
versions.target_sdk = 33
versions.compile_sdk = 33
versions.target_sdk = 34
versions.compile_sdk = 34
versions.jdk = JavaVersion.VERSION_17

versions.gradle_version = '8.1.0'
versions.gradle_version = '8.1.1'

versions.androidx_core = "1.10.1"
versions.androidx_core = "1.12.0"
versions.material = "1.9.0"
versions.navigation = "2.6.0"
versions.lifecycle = "2.6.1"
versions.navigation = "2.7.2"
versions.lifecycle = "2.6.2"
versions.constraintlayout = "2.1.4"
versions.annotation = '1.6.0'
versions.annotation = '1.7.0'
versions.appcompat = "1.6.1"
versions.fragment = "1.6.1"
versions.work = "2.8.1"
Expand All @@ -33,8 +33,6 @@ buildscript {
versions.test_runner = "1.5.2"
versions.espresso_core = "3.5.1"

versions.dokka = "1.8.20"

ext.versions = versions

repositories {
Expand All @@ -46,7 +44,6 @@ buildscript {
classpath "com.android.tools.build:gradle:$versions.gradle_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin_version"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$versions.navigation"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$versions.dokka"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand All @@ -64,13 +61,6 @@ allprojects {
google()
mavenCentral()
}
// TODO: justkarleone 8.08.2023 remove after deleting deprecated code
gradle.projectsEvaluated {
tasks.withType(JavaCompile){
options.encoding = "UTF-8"
options.compilerArgs << "-Xlint:deprecation"
}
}
}

subprojects {
Expand Down
18 changes: 13 additions & 5 deletions documentation/LIBRARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,7 @@ uploadcare.createWebhookAsync(
context, // Context
URI.create("YOUR_WEBHOOK_URL"),
"YOUR_WEBHOOK_EVENT",
signingSecret = "YOUR_WEBHOOK_SIGNING_SECRET",
callback = object : UploadcareWebhookCallback {
override fun onFailure(e: UploadcareApiException) {
// Handle errors.
Expand All @@ -642,6 +643,7 @@ uploadcare.createWebhookAsync(
URI.create("YOUR_WEBHOOK_URL"),
"YOUR_WEBHOOK_EVENT",
true, // is webhook active or not.
"YOUR_WEBHOOK_SIGNING_SECRET",
new UploadcareWebhookCallback() {
@Override
public void onFailure(@NotNull UploadcareApiException e) {
Expand All @@ -662,15 +664,17 @@ Kotlin
val webhook = uploadcare.createWebhook(
URI.create("YOUR_WEBHOOK_URL"),
"YOUR_WEBHOOK_EVENT",
true // is webhook active or not.
true, // is webhook active or not.
"YOUR_WEBHOOK_SIGNING_SECRET"
)
```
Java
```java
UploadcareWebhook webhook = uploadcare.createWebhook(
URI.create("YOUR_WEBHOOK_URL"),
"YOUR_WEBHOOK_EVENT",
true // is webhook active or not.
true, // is webhook active or not.
"YOUR_WEBHOOK_SIGNING_SECRET"
);
```

Expand All @@ -685,6 +689,7 @@ uploadcare.updateWebhookAsync(
"YOUR_WEBHOOK_UUID",
URI.create("YOUR_WEBHOOK_URL"),
"YOUR_WEBHOOK_EVENT",
signingSecret = "YOUR_WEBHOOK_SIGNING_SECRET",
callback = object : UploadcareWebhookCallback {
override fun onFailure(e: UploadcareApiException) {
// Handle errors.
Expand All @@ -703,6 +708,7 @@ uploadcare.updateWebhookAsync(
URI.create("YOUR_WEBHOOK_URL"),
"YOUR_WEBHOOK_EVENT",
true, // is webhook active or not.
"YOUR_WEBHOOK_SIGNING_SECRET",
new UploadcareWebhookCallback() {
@Override
public void onFailure(@NotNull UploadcareApiException e) {
Expand All @@ -724,7 +730,8 @@ val webhook = uploadcare.updateWebhook(
"YOUR_WEBHOOK_UUID",
URI.create("YOUR_WEBHOOK_URL"),
"YOUR_WEBHOOK_EVENT",
true // is webhook active or not.
true, // is webhook active or not.
"YOUR_WEBHOOK_SIGNING_SECRET"
)
```
Java
Expand All @@ -733,7 +740,8 @@ UploadcareWebhook webhook = uploadcare.updateWebhook(
"YOUR_WEBHOOK_UUID",
URI.create("YOUR_WEBHOOK_URL"),
"YOUR_WEBHOOK_EVENT",
true // is webhook active or not.
true, // is webhook active or not.
"YOUR_WEBHOOK_SIGNING_SECRET"
);
```

Expand Down Expand Up @@ -1266,4 +1274,4 @@ Java
List<String> fileIds = ... // list of file UUID's

UploadcareGroup uploadcareGroup = uploadcare.createGroup(fileIds, null);
```
```
2 changes: 1 addition & 1 deletion example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ android {
applicationId "com.uploadcare.android.example"
minSdkVersion versions.min_sdk
targetSdkVersion versions.target_sdk
versionCode 8
versionCode 9
versionName "${version}"
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Project-wide Gradle settings.
version=3.2.0
version=3.3.0-SNAPSHOT

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
Expand Down
5 changes: 3 additions & 2 deletions library/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Supported features:
- File uploading from a file, byte array, URL, and URI.
- Document and Video Conversion.
- Secure Delivery.
- Secure Webhooks.
- Synchronous and asynchronous operation modes.

[Documentation](https://github.com/uploadcare/uploadcare-android/blob/master/documentation/LIBRARY.md)
Expand All @@ -24,6 +25,6 @@ The latest stable version is available at jCenter.
To include it in your Android project, add this line to the 'gradle.build' file:

```
implementation 'com.uploadcare.android.library:uploadcare-android:3.1.0'
implementation 'com.uploadcare.android.library:uploadcare-android:3.3.0'
```
```
16 changes: 1 addition & 15 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ plugins {
id 'kotlin-parcelize'
id 'kotlin-kapt'
id 'maven-publish'
id 'org.jetbrains.dokka'
}

group = "com.uploadcare.android.library"
Expand All @@ -16,7 +15,7 @@ android {
defaultConfig {
minSdkVersion versions.min_sdk
targetSdkVersion versions.target_sdk
versionCode 12
versionCode 13
versionName "${version}"
buildConfigField 'String', 'VERSION_NAME', "\"${version}\""
}
Expand Down Expand Up @@ -51,19 +50,6 @@ android {
kotlinOptions {
jvmTarget = versions.jdk
}

dokkaHtml.configure {
dokkaSourceSets {
named("main") {
outputDirectory.set(buildDir.resolve("javadoc"))
sourceRoots.setFrom(file("src/main/java"))
noAndroidSdkLink.set(false)
skipEmptyPackages.set(true)
includeNonPublic.set(false)
}
}
}

}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class FilesQueryBuilder(private val client: UploadcareClient)
*/
fun ordering(order: Order): FilesQueryBuilder {
parameters["ordering"] = FilesOrderParameter(order)
parameters.remove("from")
return this
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import java.net.URI
/**
* Result of the file copy operation
*/
@Parcelize @Suppress("unused")
@Parcelize
@Suppress("unused")
data class UploadcareCopyFile(private val type: String,
@AsString private val result: String) : Parcelable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import kotlinx.parcelize.Parcelize
import java.net.URI
import java.util.*

@Parcelize @Suppress("unused") @SuppressWarnings("WeakerAccess")
@Parcelize
@Suppress("unused") @SuppressWarnings("WeakerAccess")
data class UploadcareFile(val uuid: String,
val url: URI? = null,
val size: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import kotlinx.parcelize.Parcelize
import java.net.URI
import java.util.*

@Parcelize @Suppress("unused")
@Parcelize
@Suppress("unused")
data class UploadcareGroup(val id: String,
val url: URI,
val files: List<UploadcareFile>? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ import java.util.*
* The resource for Webhook.
*/
@Parcelize
data class UploadcareWebhook(val id: Int,
val event: String,
@Json(name = "target_url") val targetUrl: URI,
@Json(name = "is_active") val isActive: Boolean,
val project: Int,
val created: Date? = null,
val updated: Date? = null) : Parcelable
data class UploadcareWebhook(
val id: Int,
val event: String,
@Json(name = "target_url") val targetUrl: URI,
@Json(name = "is_active") val isActive: Boolean,
val project: Int,
val created: Date? = null,
val updated: Date? = null,
@Json(name = "signing_secret") val signingSecret: String? = null
) : Parcelable
Loading

0 comments on commit c21581d

Please sign in to comment.