Skip to content

Commit 4c61839

Browse files
Merge pull request #120 from appwrite/dev
feat: SDK update for version 18.2.0
2 parents 8749341 + 5df92c5 commit 4c61839

10 files changed

Lines changed: 51 additions & 23 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change Log
22

3+
## 18.2.0
4+
5+
* Added: Realtime connections now send an `x-appwrite-jwt` header for authentication.
6+
* Added: Forwarded `impersonateUserId` on `avatars` and `storage` file requests.
7+
38
## 18.1.0
49

510
* Added: Email metadata fields to `User` (`emailCanonical`, `emailIsFree`, `emailIsDisposable`, `emailIsCorporate`, `emailIsCanonical`).

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Add the package to your `Package.swift` dependencies:
3131

3232
```swift
3333
dependencies: [
34-
.package(url: "git@github.com:appwrite/sdk-for-apple.git", from: "18.1.0"),
34+
.package(url: "git@github.com:appwrite/sdk-for-apple.git", from: "18.2.0"),
3535
],
3636
```
3737

Sources/Appwrite/Client.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ open class Client {
2727
"x-sdk-name": "Apple",
2828
"x-sdk-platform": "client",
2929
"x-sdk-language": "apple",
30-
"x-sdk-version": "18.1.0",
30+
"x-sdk-version": "18.2.0",
3131
"x-appwrite-response-format": "1.9.5"
3232
]
3333

@@ -187,7 +187,7 @@ open class Client {
187187
///
188188
/// Set ImpersonateUserId
189189
///
190-
/// 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.
190+
/// Impersonate a user by ID
191191
///
192192
/// @param String value
193193
///
@@ -202,7 +202,7 @@ open class Client {
202202
///
203203
/// Set ImpersonateUserEmail
204204
///
205-
/// 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.
205+
/// Impersonate a user by email
206206
///
207207
/// @param String value
208208
///
@@ -217,7 +217,7 @@ open class Client {
217217
///
218218
/// Set ImpersonateUserPhone
219219
///
220-
/// 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.
220+
/// Impersonate a user by phone
221221
///
222222
/// @param String value
223223
///
@@ -374,7 +374,7 @@ open class Client {
374374
}
375375

376376
///
377-
/// Sends a "ping" request to Appwrite to verify connectivity.
377+
/// Send a ping to project as part of onboarding.
378378
///
379379
/// @return String
380380
/// @throws Exception
@@ -383,8 +383,8 @@ open class Client {
383383
let apiPath: String = "/ping"
384384

385385
let apiHeaders: [String: String] = [
386-
"content-type": "application/json",
387-
"X-Appwrite-Project": config["project"] ?? ""
386+
"X-Appwrite-Project": config["project"] ?? "",
387+
"accept": "application/json",
388388
]
389389

390390
return try await call(

Sources/Appwrite/Services/Avatars.swift

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ open class Avatars: Service {
4141
"width": width,
4242
"height": height,
4343
"quality": quality,
44-
"project": client.config["project"]
44+
"project": client.config["project"],
45+
"impersonateuserid": client.config["impersonateuserid"]
4546
]
4647

4748
return try await client.call(
@@ -83,7 +84,8 @@ open class Avatars: Service {
8384
"width": width,
8485
"height": height,
8586
"quality": quality,
86-
"project": client.config["project"]
87+
"project": client.config["project"],
88+
"impersonateuserid": client.config["impersonateuserid"]
8789
]
8890

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

112114
let apiParams: [String: Any?] = [
113115
"url": url,
114-
"project": client.config["project"]
116+
"project": client.config["project"],
117+
"impersonateuserid": client.config["impersonateuserid"]
115118
]
116119

117120
return try await client.call(
@@ -154,7 +157,8 @@ open class Avatars: Service {
154157
"width": width,
155158
"height": height,
156159
"quality": quality,
157-
"project": client.config["project"]
160+
"project": client.config["project"],
161+
"impersonateuserid": client.config["impersonateuserid"]
158162
]
159163

160164
return try await client.call(
@@ -195,7 +199,8 @@ open class Avatars: Service {
195199
"url": url,
196200
"width": width,
197201
"height": height,
198-
"project": client.config["project"]
202+
"project": client.config["project"],
203+
"impersonateuserid": client.config["impersonateuserid"]
199204
]
200205

201206
return try await client.call(
@@ -244,7 +249,8 @@ open class Avatars: Service {
244249
"width": width,
245250
"height": height,
246251
"background": background,
247-
"project": client.config["project"]
252+
"project": client.config["project"],
253+
"impersonateuserid": client.config["impersonateuserid"]
248254
]
249255

250256
return try await client.call(
@@ -280,7 +286,8 @@ open class Avatars: Service {
280286
"size": size,
281287
"margin": margin,
282288
"download": download,
283-
"project": client.config["project"]
289+
"project": client.config["project"],
290+
"impersonateuserid": client.config["impersonateuserid"]
284291
]
285292

286293
return try await client.call(
@@ -371,7 +378,8 @@ open class Avatars: Service {
371378
"height": height,
372379
"quality": quality,
373380
"output": output?.rawValue,
374-
"project": client.config["project"]
381+
"project": client.config["project"],
382+
"impersonateuserid": client.config["impersonateuserid"]
375383
]
376384

377385
return try await client.call(

Sources/Appwrite/Services/Databases.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ open class Databases: Service {
1616
/// - Throws: Exception if the request fails
1717
/// - Returns: AppwriteModels.TransactionList
1818
///
19+
@available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.listTransactions` instead.")
1920
open func listTransactions(
2021
queries: [String]? = nil
2122
) async throws -> AppwriteModels.TransactionList {
@@ -51,6 +52,7 @@ open class Databases: Service {
5152
/// - Throws: Exception if the request fails
5253
/// - Returns: AppwriteModels.Transaction
5354
///
55+
@available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.createTransaction` instead.")
5456
open func createTransaction(
5557
ttl: Int? = nil
5658
) async throws -> AppwriteModels.Transaction {
@@ -87,6 +89,7 @@ open class Databases: Service {
8789
/// - Throws: Exception if the request fails
8890
/// - Returns: AppwriteModels.Transaction
8991
///
92+
@available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.getTransaction` instead.")
9093
open func getTransaction(
9194
transactionId: String
9295
) async throws -> AppwriteModels.Transaction {
@@ -123,6 +126,7 @@ open class Databases: Service {
123126
/// - Throws: Exception if the request fails
124127
/// - Returns: AppwriteModels.Transaction
125128
///
129+
@available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.updateTransaction` instead.")
126130
open func updateTransaction(
127131
transactionId: String,
128132
commit: Bool? = nil,
@@ -163,6 +167,7 @@ open class Databases: Service {
163167
/// - Throws: Exception if the request fails
164168
/// - Returns: Any
165169
///
170+
@available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTransaction` instead.")
166171
open func deleteTransaction(
167172
transactionId: String
168173
) async throws -> Any {
@@ -192,6 +197,7 @@ open class Databases: Service {
192197
/// - Throws: Exception if the request fails
193198
/// - Returns: AppwriteModels.Transaction
194199
///
200+
@available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `TablesDB.createOperations` instead.")
195201
open func createOperations(
196202
transactionId: String,
197203
operations: [Any]? = nil

Sources/Appwrite/Services/Realtime.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,15 @@ open class Realtime : Service {
135135
return
136136
}
137137

138+
var headers = HTTPHeaders()
139+
if let jwt = client.config["jwt"], !jwt.isEmpty {
140+
headers.add(name: "x-appwrite-jwt", value: jwt)
141+
}
142+
138143
socketClient = WebSocketClient(
139144
url,
140145
tlsEnabled: !client.selfSigned,
146+
headers: headers,
141147
delegate: self
142148
)
143149

Sources/Appwrite/Services/Storage.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ open class Storage: Service {
259259

260260
let apiParams: [String: Any?] = [
261261
"token": token,
262-
"project": client.config["project"]
262+
"project": client.config["project"],
263+
"impersonateuserid": client.config["impersonateuserid"]
263264
]
264265

265266
return try await client.call(
@@ -327,7 +328,8 @@ open class Storage: Service {
327328
"background": background,
328329
"output": output?.rawValue,
329330
"token": token,
330-
"project": client.config["project"]
331+
"project": client.config["project"],
332+
"impersonateuserid": client.config["impersonateuserid"]
331333
]
332334

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

361363
let apiParams: [String: Any?] = [
362364
"token": token,
363-
"project": client.config["project"]
365+
"project": client.config["project"],
366+
"impersonateuserid": client.config["impersonateuserid"]
364367
]
365368

366369
return try await client.call(

docs/examples/account/create.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ let account = Account(client)
1010
let user = try await account.create(
1111
userId: "<USER_ID>",
1212
email: "email@example.com",
13-
password: "",
13+
password: "password",
1414
name: "<NAME>" // optional
1515
)
1616

docs/examples/account/update-password.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ let client = Client()
88
let account = Account(client)
99

1010
let user = try await account.updatePassword(
11-
password: "",
12-
oldPassword: "<OLD_PASSWORD>" // optional
11+
password: "password",
12+
oldPassword: "password" // optional
1313
)
1414

1515
```

docs/examples/account/update-recovery.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ let account = Account(client)
1010
let token = try await account.updateRecovery(
1111
userId: "<USER_ID>",
1212
secret: "<SECRET>",
13-
password: ""
13+
password: "password"
1414
)
1515

1616
```

0 commit comments

Comments
 (0)