Skip to content

Commit 20a109f

Browse files
authored
Merge pull request #52 from appwrite/dev
Fix okttp with AGP 8.2+
2 parents 4826572 + 8ef821b commit 20a109f

File tree

7 files changed

+55
-42
lines changed

7 files changed

+55
-42
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
![Maven Central](https://img.shields.io/maven-central/v/io.appwrite/sdk-for-android.svg?color=green&style=flat-square)
44
![License](https://img.shields.io/github/license/appwrite/sdk-for-android.svg?style=flat-square)
5-
![Version](https://img.shields.io/badge/api%20version-1.5.1-blue.svg?style=flat-square)
5+
![Version](https://img.shields.io/badge/api%20version-1.5.4-blue.svg?style=flat-square)
66
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
77
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
88
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
@@ -38,7 +38,7 @@ repositories {
3838
Next, add the dependency to your project's `build.gradle(.kts)` file:
3939

4040
```groovy
41-
implementation("io.appwrite:sdk-for-android:5.0.0")
41+
implementation("io.appwrite:sdk-for-android:5.1.0")
4242
```
4343

4444
### Maven
@@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file:
4949
<dependency>
5050
<groupId>io.appwrite</groupId>
5151
<artifactId>sdk-for-android</artifactId>
52-
<version>5.0.0</version>
52+
<version>5.1.0</version>
5353
</dependency>
5454
</dependencies>
5555
```

library/build.gradle

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,7 @@ dependencies {
5959
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1")
6060
api("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1")
6161

62-
api(platform("com.squareup.okhttp3:okhttp-bom:4.12.0"))
63-
api("com.squareup.okhttp3:okhttp")
64-
implementation("com.squareup.okhttp3:okhttp-urlconnection")
65-
implementation("com.squareup.okhttp3:logging-interceptor")
62+
implementation("com.squareup.okhttp3:okhttp:4.12.0")
6663
implementation("com.google.code.gson:gson:2.10.1")
6764

6865
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")

library/src/main/java/io/appwrite/Client.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class Client @JvmOverloads constructor(
8383
"x-sdk-name" to "Android",
8484
"x-sdk-platform" to "client",
8585
"x-sdk-language" to "android",
86-
"x-sdk-version" to "5.0.0",
86+
"x-sdk-version" to "5.1.0",
8787
"x-appwrite-response-format" to "1.5.0"
8888
)
8989
config = mutableMapOf()
Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,34 @@
11
package io.appwrite
22

3+
import java.time.Instant
4+
import kotlin.math.floor
5+
import kotlin.random.Random
6+
37
class ID {
48
companion object {
9+
// Generate an hex ID based on timestamp
10+
// Recreated from https://www.php.net/manual/en/function.uniqid.php
11+
private fun hexTimestamp(): String {
12+
val now = Instant.now()
13+
val sec = now.epochSecond
14+
val usec = (System.nanoTime() / 1000) % 1000
15+
16+
val hexTimestamp = "%08x%05x".format(sec, usec)
17+
18+
return hexTimestamp
19+
}
20+
521
fun custom(id: String): String
622
= id
7-
fun unique(): String
8-
= "unique()"
23+
24+
// Generate a unique ID with padding to have a longer ID
25+
fun unique(padding: Int = 7): String {
26+
val baseId = hexTimestamp()
27+
val randomPadding = (1..padding)
28+
.map { Random.nextInt(0, 16).toString(16) }
29+
.joinToString("")
30+
31+
return baseId + randomPadding
32+
}
933
}
10-
}
34+
}

library/src/main/java/io/appwrite/models/MfaFactors.kt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,35 @@ import io.appwrite.extensions.jsonCast
88
*/
99
data class MfaFactors(
1010
/**
11-
* TOTP
11+
* Can TOTP be used for MFA challenge for this account.
1212
*/
1313
@SerializedName("totp")
1414
val totp: Boolean,
1515

1616
/**
17-
* Phone
17+
* Can phone (SMS) be used for MFA challenge for this account.
1818
*/
1919
@SerializedName("phone")
2020
val phone: Boolean,
2121

2222
/**
23-
* Email
23+
* Can email be used for MFA challenge for this account.
2424
*/
2525
@SerializedName("email")
2626
val email: Boolean,
2727

28+
/**
29+
* Can recovery code be used for MFA challenge for this account.
30+
*/
31+
@SerializedName("recoveryCode")
32+
val recoveryCode: Boolean,
33+
2834
) {
2935
fun toMap(): Map<String, Any> = mapOf(
3036
"totp" to totp as Any,
3137
"phone" to phone as Any,
3238
"email" to email as Any,
39+
"recoveryCode" to recoveryCode as Any,
3340
)
3441

3542
companion object {
@@ -41,6 +48,7 @@ data class MfaFactors(
4148
totp = map["totp"] as Boolean,
4249
phone = map["phone"] as Boolean,
4350
email = map["email"] as Boolean,
51+
recoveryCode = map["recoveryCode"] as Boolean,
4452
)
4553
}
4654
}

library/src/main/java/io/appwrite/models/Session.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ data class Session(
1919
@SerializedName("\$createdAt")
2020
val createdAt: String,
2121

22+
/**
23+
* Session update date in ISO 8601 format.
24+
*/
25+
@SerializedName("\$updatedAt")
26+
val updatedAt: String,
27+
2228
/**
2329
* User ID.
2430
*/
@@ -179,6 +185,7 @@ data class Session(
179185
fun toMap(): Map<String, Any> = mapOf(
180186
"\$id" to id as Any,
181187
"\$createdAt" to createdAt as Any,
188+
"\$updatedAt" to updatedAt as Any,
182189
"userId" to userId as Any,
183190
"expire" to expire as Any,
184191
"provider" to provider as Any,
@@ -215,6 +222,7 @@ data class Session(
215222
) = Session(
216223
id = map["\$id"] as String,
217224
createdAt = map["\$createdAt"] as String,
225+
updatedAt = map["\$updatedAt"] as String,
218226
userId = map["userId"] as String,
219227
expire = map["expire"] as String,
220228
provider = map["provider"] as String,

library/src/main/java/io/appwrite/services/Account.kt

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -466,13 +466,12 @@ class Account(client: Client) : Service(client) {
466466
*
467467
* @param type Type of authenticator.
468468
* @param otp Valid verification token.
469-
* @return [io.appwrite.models.User<T>]
469+
* @return [Any]
470470
*/
471-
suspend fun <T> deleteMfaAuthenticator(
471+
suspend fun deleteMfaAuthenticator(
472472
type: io.appwrite.enums.AuthenticatorType,
473473
otp: String,
474-
nestedType: Class<T>,
475-
): io.appwrite.models.User<T> {
474+
): Any {
476475
val apiPath = "/account/mfa/authenticators/{type}"
477476
.replace("{type}", type.value)
478477

@@ -482,38 +481,15 @@ class Account(client: Client) : Service(client) {
482481
val apiHeaders = mutableMapOf(
483482
"content-type" to "application/json",
484483
)
485-
val converter: (Any) -> io.appwrite.models.User<T> = {
486-
@Suppress("UNCHECKED_CAST")
487-
io.appwrite.models.User.from(map = it as Map<String, Any>, nestedType)
488-
}
489484
return client.call(
490485
"DELETE",
491486
apiPath,
492487
apiHeaders,
493488
apiParams,
494-
responseType = classOf(),
495-
converter,
489+
responseType = Any::class.java,
496490
)
497491
}
498492

499-
/**
500-
* Delete Authenticator
501-
*
502-
* Delete an authenticator for a user by ID.
503-
*
504-
* @param type Type of authenticator.
505-
* @param otp Valid verification token.
506-
* @return [io.appwrite.models.User<T>]
507-
*/
508-
@Throws(AppwriteException::class)
509-
suspend fun deleteMfaAuthenticator(
510-
type: io.appwrite.enums.AuthenticatorType,
511-
otp: String,
512-
): io.appwrite.models.User<Map<String, Any>> = deleteMfaAuthenticator(
513-
type,
514-
otp,
515-
nestedType = classOf(),
516-
)
517493

518494
/**
519495
* Create 2FA Challenge

0 commit comments

Comments
 (0)