Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## 18.2.0

* Added: Realtime connections now send an `x-appwrite-jwt` header for authentication.
* Added: Forwarded `impersonateUserId` on `avatars` and `storage` file requests.
* Fixed: URL-encode path parameters in `databases` requests.

## 18.1.0

* Added: Email metadata fields to `User` (`emailCanonical`, `emailIsFree`, `emailIsDisposable`, `emailIsCorporate`, `emailIsCanonical`).
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Add the package to your `Package.swift` dependencies:

```swift
dependencies: [
.package(url: "git@github.com:appwrite/sdk-for-apple.git", from: "18.1.0"),
.package(url: "git@github.com:appwrite/sdk-for-apple.git", from: "18.2.0"),
],
```

Expand Down
14 changes: 7 additions & 7 deletions Sources/Appwrite/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ open class Client {
"x-sdk-name": "Apple",
"x-sdk-platform": "client",
"x-sdk-language": "apple",
"x-sdk-version": "18.1.0",
"x-sdk-version": "18.2.0",
"x-appwrite-response-format": "1.9.5"
]

Expand Down Expand Up @@ -187,7 +187,7 @@ open class Client {
///
/// Set ImpersonateUserId
///
/// Impersonate a user by ID on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.
/// Impersonate a user by ID
///
/// @param String value
///
Expand All @@ -202,7 +202,7 @@ open class Client {
///
/// Set ImpersonateUserEmail
///
/// Impersonate a user by email on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.
/// Impersonate a user by email
///
/// @param String value
///
Expand All @@ -217,7 +217,7 @@ open class Client {
///
/// Set ImpersonateUserPhone
///
/// Impersonate a user by phone on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.
/// Impersonate a user by phone
///
/// @param String value
///
Expand Down Expand Up @@ -374,7 +374,7 @@ open class Client {
}

///
/// Sends a "ping" request to Appwrite to verify connectivity.
/// Send a ping to project as part of onboarding.
///
/// @return String
/// @throws Exception
Expand All @@ -383,8 +383,8 @@ open class Client {
let apiPath: String = "/ping"

let apiHeaders: [String: String] = [
"content-type": "application/json",
"X-Appwrite-Project": config["project"] ?? ""
"X-Appwrite-Project": config["project"] ?? "",
"accept": "application/json",
]

return try await call(
Expand Down
24 changes: 16 additions & 8 deletions Sources/Appwrite/Services/Avatars.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ open class Avatars: Service {
"width": width,
"height": height,
"quality": quality,
"project": client.config["project"]
"project": client.config["project"],
"impersonateuserid": client.config["impersonateuserid"]
]

return try await client.call(
Expand Down Expand Up @@ -83,7 +84,8 @@ open class Avatars: Service {
"width": width,
"height": height,
"quality": quality,
"project": client.config["project"]
"project": client.config["project"],
"impersonateuserid": client.config["impersonateuserid"]
]

return try await client.call(
Expand Down Expand Up @@ -111,7 +113,8 @@ open class Avatars: Service {

let apiParams: [String: Any?] = [
"url": url,
"project": client.config["project"]
"project": client.config["project"],
"impersonateuserid": client.config["impersonateuserid"]
]

return try await client.call(
Expand Down Expand Up @@ -154,7 +157,8 @@ open class Avatars: Service {
"width": width,
"height": height,
"quality": quality,
"project": client.config["project"]
"project": client.config["project"],
"impersonateuserid": client.config["impersonateuserid"]
]

return try await client.call(
Expand Down Expand Up @@ -195,7 +199,8 @@ open class Avatars: Service {
"url": url,
"width": width,
"height": height,
"project": client.config["project"]
"project": client.config["project"],
"impersonateuserid": client.config["impersonateuserid"]
]

return try await client.call(
Expand Down Expand Up @@ -244,7 +249,8 @@ open class Avatars: Service {
"width": width,
"height": height,
"background": background,
"project": client.config["project"]
"project": client.config["project"],
"impersonateuserid": client.config["impersonateuserid"]
]

return try await client.call(
Expand Down Expand Up @@ -280,7 +286,8 @@ open class Avatars: Service {
"size": size,
"margin": margin,
"download": download,
"project": client.config["project"]
"project": client.config["project"],
"impersonateuserid": client.config["impersonateuserid"]
]

return try await client.call(
Expand Down Expand Up @@ -371,7 +378,8 @@ open class Avatars: Service {
"height": height,
"quality": quality,
"output": output?.rawValue,
"project": client.config["project"]
"project": client.config["project"],
"impersonateuserid": client.config["impersonateuserid"]
]

return try await client.call(
Expand Down
6 changes: 6 additions & 0 deletions Sources/Appwrite/Services/Databases.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ open class Databases: Service {
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.TransactionList
///
@available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.listTransactions` instead.")
open func listTransactions(
queries: [String]? = nil
) async throws -> AppwriteModels.TransactionList {
Expand Down Expand Up @@ -51,6 +52,7 @@ open class Databases: Service {
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.Transaction
///
@available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.createTransaction` instead.")
open func createTransaction(
ttl: Int? = nil
) async throws -> AppwriteModels.Transaction {
Expand Down Expand Up @@ -87,6 +89,7 @@ open class Databases: Service {
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.Transaction
///
@available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.getTransaction` instead.")
open func getTransaction(
transactionId: String
) async throws -> AppwriteModels.Transaction {
Expand Down Expand Up @@ -123,6 +126,7 @@ open class Databases: Service {
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.Transaction
///
@available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.updateTransaction` instead.")
open func updateTransaction(
transactionId: String,
commit: Bool? = nil,
Expand Down Expand Up @@ -163,6 +167,7 @@ open class Databases: Service {
/// - Throws: Exception if the request fails
/// - Returns: Any
///
@available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTransaction` instead.")
open func deleteTransaction(
transactionId: String
) async throws -> Any {
Expand Down Expand Up @@ -192,6 +197,7 @@ open class Databases: Service {
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.Transaction
///
@available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.createOperations` instead.")
open func createOperations(
transactionId: String,
operations: [Any]? = nil
Expand Down
6 changes: 6 additions & 0 deletions Sources/Appwrite/Services/Realtime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,15 @@ open class Realtime : Service {
return
}

var headers = HTTPHeaders()
if let jwt = client.config["jwt"], !jwt.isEmpty {
headers.add(name: "x-appwrite-jwt", value: jwt)
}

socketClient = WebSocketClient(
url,
tlsEnabled: !client.selfSigned,
headers: headers,
delegate: self
)

Expand Down
9 changes: 6 additions & 3 deletions Sources/Appwrite/Services/Storage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ open class Storage: Service {

let apiParams: [String: Any?] = [
"token": token,
"project": client.config["project"]
"project": client.config["project"],
"impersonateuserid": client.config["impersonateuserid"]
]

return try await client.call(
Expand Down Expand Up @@ -327,7 +328,8 @@ open class Storage: Service {
"background": background,
"output": output?.rawValue,
"token": token,
"project": client.config["project"]
"project": client.config["project"],
"impersonateuserid": client.config["impersonateuserid"]
]

return try await client.call(
Expand Down Expand Up @@ -360,7 +362,8 @@ open class Storage: Service {

let apiParams: [String: Any?] = [
"token": token,
"project": client.config["project"]
"project": client.config["project"],
"impersonateuserid": client.config["impersonateuserid"]
]

return try await client.call(
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let account = Account(client)
let user = try await account.create(
userId: "<USER_ID>",
email: "email@example.com",
password: "",
password: "password",
name: "<NAME>" // optional
)

Expand Down
4 changes: 2 additions & 2 deletions docs/examples/account/update-password.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ let client = Client()
let account = Account(client)

let user = try await account.updatePassword(
password: "",
oldPassword: "<OLD_PASSWORD>" // optional
password: "password",
oldPassword: "password" // optional
)

```
2 changes: 1 addition & 1 deletion docs/examples/account/update-recovery.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let account = Account(client)
let token = try await account.updateRecovery(
userId: "<USER_ID>",
secret: "<SECRET>",
password: ""
password: "password"
)

```
Loading