Skip to content

Commit

Permalink
Merge pull request #61 from appwrite/1.6.x
Browse files Browse the repository at this point in the history
1.6.x
  • Loading branch information
christyjacob4 authored Aug 27, 2024
2 parents 469a7a4 + f110d17 commit 3231f9b
Show file tree
Hide file tree
Showing 148 changed files with 398 additions and 140 deletions.
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ let package = Package(
),
],
dependencies: [
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.17.0"),
.package(url: "https://github.com/apple/swift-nio.git", from: "2.32.0"),
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.19.0"),
.package(url: "https://github.com/apple/swift-nio.git", from: "2.58.0"),
],
targets: [
.target(
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

![Swift Package Manager](https://img.shields.io/github/v/release/appwrite/sdk-for-apple.svg?color=green&style=flat-square)
![License](https://img.shields.io/github/license/appwrite/sdk-for-apple.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.5.6-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.6.0-blue.svg?style=flat-square)
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)

**This SDK is compatible with Appwrite server version 1.5.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-apple/releases).**
**This SDK is compatible with Appwrite server version 1.6.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-apple/releases).**

Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Apple SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)

Expand All @@ -31,7 +31,7 @@ Add the package to your `Package.swift` dependencies:

```swift
dependencies: [
.package(url: "[email protected]:appwrite/sdk-for-apple.git", from: "6.0.0"),
.package(url: "[email protected]:appwrite/sdk-for-apple.git", from: "7.0.0"),
],
```

Expand Down
10 changes: 8 additions & 2 deletions Sources/Appwrite/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ open class Client {
"x-sdk-name": "Apple",
"x-sdk-platform": "client",
"x-sdk-language": "apple",
"x-sdk-version": "6.0.0",
"x-appwrite-response-format": "1.5.0"
"x-sdk-version": "7.0.0",
"x-appwrite-response-format": "1.6.0"
]

internal var config: [String: String] = [:]
Expand Down Expand Up @@ -313,6 +313,12 @@ open class Client {
timeout: .seconds(30)
)

if let warning = response.headers["x-appwrite-warning"].first {
warning.split(separator: ";").forEach { warning in
print("Warning: \(warning)")
}
}

switch response.status.code {
case 0..<400:
if response.headers["Set-Cookie"].count > 0 {
Expand Down
24 changes: 14 additions & 10 deletions Sources/Appwrite/OAuth/WebAuthComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,24 @@ public class WebAuthComponent {
/// - url: The URL containing the cookie
///
public static func handleIncomingCookie(from url: URL) {
let components = URLComponents(string: url.absoluteString)!

let cookieParts = [String: String](uniqueKeysWithValues: components.queryItems!.map {
($0.name, $0.value!)
guard let components = URLComponents(string: url.absoluteString),
let queryItems = components.queryItems else {
return
}

let cookieParts = [String: String](uniqueKeysWithValues: queryItems.compactMap { item in
item.value.map { (item.name, $0) }
})

var domain = cookieParts["domain"]!
guard var domain = cookieParts["domain"],
let key = cookieParts["key"],
let secret = cookieParts["secret"] else {
return
}

domain.remove(at: domain.startIndex)

let key: String = cookieParts["key"]!
let secret: String = cookieParts["secret"]!
let path: String? = cookieParts["path"]
let expires: String? = cookieParts["expires"]
let maxAge: String? = cookieParts["maxAge"]
Expand Down Expand Up @@ -92,10 +99,7 @@ public class WebAuthComponent {
cookie += "; secure"
}

let existing = UserDefaults.standard.stringArray(forKey: domain)
let new = [cookie]

UserDefaults.standard.set(new, forKey: domain)
UserDefaults.standard.set([cookie], forKey: domain)

WebAuthComponent.onCallback(
scheme: components.scheme!,
Expand Down
20 changes: 8 additions & 12 deletions Sources/Appwrite/Services/Account.swift
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ open class Account: Service {
///
open func createJWT(
) async throws -> AppwriteModels.Jwt {
let apiPath: String = "/account/jwt"
let apiPath: String = "/account/jwts"

let apiParams: [String: Any] = [:]

Expand Down Expand Up @@ -402,7 +402,7 @@ open class Account: Service {
}

///
/// Add Authenticator
/// Create Authenticator
///
/// Add an authenticator app to be used as an MFA factor. Verify the
/// authenticator using the [verify
Expand Down Expand Up @@ -443,7 +443,7 @@ open class Account: Service {
///
/// Verify an authenticator app after adding it using the [add
/// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator)
/// method. add
/// method.
///
/// @param AppwriteEnums.AuthenticatorType type
/// @param String otp
Expand Down Expand Up @@ -484,7 +484,7 @@ open class Account: Service {
///
/// Verify an authenticator app after adding it using the [add
/// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator)
/// method. add
/// method.
///
/// @param AppwriteEnums.AuthenticatorType type
/// @param String otp
Expand All @@ -508,20 +508,16 @@ open class Account: Service {
/// Delete an authenticator for a user by ID.
///
/// @param AppwriteEnums.AuthenticatorType type
/// @param String otp
/// @throws Exception
/// @return array
///
open func deleteMfaAuthenticator(
type: AppwriteEnums.AuthenticatorType,
otp: String
type: AppwriteEnums.AuthenticatorType
) async throws -> Any {
let apiPath: String = "/account/mfa/authenticators/{type}"
.replacingOccurrences(of: "{type}", with: type.rawValue)

let apiParams: [String: Any?] = [
"otp": otp
]
let apiParams: [String: Any] = [:]

let apiHeaders: [String: String] = [
"content-type": "application/json"
Expand All @@ -535,7 +531,7 @@ open class Account: Service {
}

///
/// Create 2FA Challenge
/// Create MFA Challenge
///
/// Begin the process of MFA verification after sign-in. Finish the flow with
/// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge)
Expand Down Expand Up @@ -2037,7 +2033,7 @@ open class Account: Service {
}

///
/// Create phone verification (confirmation)
/// Update phone verification (confirmation)
///
/// Use this endpoint to complete the user phone verification process. Use the
/// **userId** and **secret** that were sent to your user's phone number to
Expand Down
2 changes: 2 additions & 0 deletions Sources/Appwrite/Services/Avatars.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ open class Avatars: Service {
/// Use this endpoint to fetch the favorite icon (AKA favicon) of any remote
/// website URL.
///
/// This endpoint does not follow HTTP redirects.
///
/// @param String url
/// @throws Exception
Expand Down Expand Up @@ -180,6 +181,7 @@ open class Avatars: Service {
/// image at source quality. If dimensions are not specified, the default size
/// of image returned is 400x400px.
///
/// This endpoint does not follow HTTP redirects.
///
/// @param String url
/// @param Int width
Expand Down
7 changes: 5 additions & 2 deletions Sources/Appwrite/Services/Functions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ open class Functions: Service {
/// @param String path
/// @param AppwriteEnums.ExecutionMethod method
/// @param Any headers
/// @param String scheduledAt
/// @throws Exception
/// @return array
///
Expand All @@ -73,7 +74,8 @@ open class Functions: Service {
async: Bool? = nil,
path: String? = nil,
method: AppwriteEnums.ExecutionMethod? = nil,
headers: Any? = nil
headers: Any? = nil,
scheduledAt: String? = nil
) async throws -> AppwriteModels.Execution {
let apiPath: String = "/functions/{functionId}/executions"
.replacingOccurrences(of: "{functionId}", with: functionId)
Expand All @@ -83,7 +85,8 @@ open class Functions: Service {
"async": async,
"path": path,
"method": method,
"headers": headers
"headers": headers,
"scheduledAt": scheduledAt
]

let apiHeaders: [String: String] = [
Expand Down
4 changes: 4 additions & 0 deletions Sources/AppwriteModels/AlgoArgon2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@ public class AlgoArgon2 {
/// Algo type.
public let type: String


/// Memory used to compute hash.
public let memoryCost: Int


/// Amount of time consumed to compute hash
public let timeCost: Int


/// Number of threads used to compute hash.
public let threads: Int



init(
type: String,
memoryCost: Int,
Expand Down
1 change: 1 addition & 0 deletions Sources/AppwriteModels/AlgoBcrypt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class AlgoBcrypt {
public let type: String



init(
type: String
) {
Expand Down
1 change: 1 addition & 0 deletions Sources/AppwriteModels/AlgoMd5.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class AlgoMd5 {
public let type: String



init(
type: String
) {
Expand Down
1 change: 1 addition & 0 deletions Sources/AppwriteModels/AlgoPhpass.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class AlgoPhpass {
public let type: String



init(
type: String
) {
Expand Down
5 changes: 5 additions & 0 deletions Sources/AppwriteModels/AlgoScrypt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,24 @@ public class AlgoScrypt {
/// Algo type.
public let type: String


/// CPU complexity of computed hash.
public let costCpu: Int


/// Memory complexity of computed hash.
public let costMemory: Int


/// Parallelization of computed hash.
public let costParallel: Int


/// Length used to compute hash.
public let length: Int



init(
type: String,
costCpu: Int,
Expand Down
4 changes: 4 additions & 0 deletions Sources/AppwriteModels/AlgoScryptModified.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@ public class AlgoScryptModified {
/// Algo type.
public let type: String


/// Salt used to compute hash.
public let salt: String


/// Separator used to compute hash.
public let saltSeparator: String


/// Key used to compute hash.
public let signerKey: String



init(
type: String,
salt: String,
Expand Down
1 change: 1 addition & 0 deletions Sources/AppwriteModels/AlgoSha.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class AlgoSha {
public let type: String



init(
type: String
) {
Expand Down
2 changes: 2 additions & 0 deletions Sources/AppwriteModels/Continent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ public class Continent {
/// Continent name.
public let name: String


/// Continent two letter code.
public let code: String



init(
name: String,
code: String
Expand Down
2 changes: 2 additions & 0 deletions Sources/AppwriteModels/ContinentList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ public class ContinentList {
/// Total number of continents documents that matched your query.
public let total: Int


/// List of continents.
public let continents: [Continent]



init(
total: Int,
continents: [Continent]
Expand Down
2 changes: 2 additions & 0 deletions Sources/AppwriteModels/Country.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ public class Country {
/// Country name.
public let name: String


/// Country two-character ISO 3166-1 alpha code.
public let code: String



init(
name: String,
code: String
Expand Down
2 changes: 2 additions & 0 deletions Sources/AppwriteModels/CountryList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ public class CountryList {
/// Total number of countries documents that matched your query.
public let total: Int


/// List of countries.
public let countries: [Country]



init(
total: Int,
countries: [Country]
Expand Down
Loading

0 comments on commit 3231f9b

Please sign in to comment.