From b821328e8680546c269f931dea0c21ebe132d47b Mon Sep 17 00:00:00 2001 From: root Date: Wed, 8 Oct 2025 04:14:10 +0000 Subject: [PATCH 1/2] chore: regen --- CHANGELOG.md | 5 + README.md | 2 +- Sources/Appwrite/Client.swift | 2 +- Sources/Appwrite/Services/Account.swift | 98 ++++++++++++++++++- Sources/Appwrite/Services/TablesDb.swift | 8 +- .../account/create-email-verification.md | 12 +++ .../account/update-email-verification.md | 13 +++ 7 files changed, 130 insertions(+), 10 deletions(-) create mode 100644 docs/examples/account/create-email-verification.md create mode 100644 docs/examples/account/update-email-verification.md diff --git a/CHANGELOG.md b/CHANGELOG.md index f62eb70..dc65637 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## 13.0.1 + +* Deprecate `createVerification` method in `Account` service +* Add `createEmailVerification` method in `Account` service + ## 10.2.0 * Update sdk to use swift-native doc comments instead of jsdoc styled comments as per [Swift Documentation Comments](https://github.com/swiftlang/swift/blob/main/docs/DocumentationComments.md) diff --git a/README.md b/README.md index d3844d8..1a61d0c 100644 --- a/README.md +++ b/README.md @@ -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: "13.0.0"), + .package(url: "git@github.com:appwrite/sdk-for-apple.git", from: "13.0.1"), ], ``` diff --git a/Sources/Appwrite/Client.swift b/Sources/Appwrite/Client.swift index 3459d57..3a9d9ca 100644 --- a/Sources/Appwrite/Client.swift +++ b/Sources/Appwrite/Client.swift @@ -23,7 +23,7 @@ open class Client { "x-sdk-name": "Apple", "x-sdk-platform": "client", "x-sdk-language": "apple", - "x-sdk-version": "13.0.0", + "x-sdk-version": "13.0.1", "x-appwrite-response-format": "1.8.0" ] diff --git a/Sources/Appwrite/Services/Account.swift b/Sources/Appwrite/Services/Account.swift index 9457229..289a70f 100644 --- a/Sources/Appwrite/Services/Account.swift +++ b/Sources/Appwrite/Services/Account.swift @@ -2210,10 +2210,59 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Token /// + open func createEmailVerification( + url: String + ) async throws -> AppwriteModels.Token { + let apiPath: String = "/account/verifications/email" + + let apiParams: [String: Any?] = [ + "url": url + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Token = { response in + return AppwriteModels.Token.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "POST", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Use this endpoint to send a verification message to your user email address + /// to confirm they are the valid owners of that address. Both the **userId** + /// and **secret** arguments will be passed as query parameters to the URL you + /// have provided to be attached to the verification email. The provided URL + /// should redirect the user back to your app and allow you to complete the + /// verification process by verifying both the **userId** and **secret** + /// parameters. Learn more about how to [complete the verification + /// process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). + /// The verification link sent to the user's email address is valid for 7 days. + /// + /// Please note that in order to avoid a [Redirect + /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), + /// the only valid redirect URLs are the ones from domains you have set when + /// adding your platforms in the console interface. + /// + /// + /// - Parameters: + /// - url: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Token + /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.") open func createVerification( url: String ) async throws -> AppwriteModels.Token { - let apiPath: String = "/account/verification" + let apiPath: String = "/account/verifications/email" let apiParams: [String: Any?] = [ "url": url @@ -2248,11 +2297,52 @@ open class Account: Service { /// - Throws: Exception if the request fails /// - Returns: AppwriteModels.Token /// + open func updateEmailVerification( + userId: String, + secret: String + ) async throws -> AppwriteModels.Token { + let apiPath: String = "/account/verifications/email" + + let apiParams: [String: Any?] = [ + "userId": userId, + "secret": secret + ] + + let apiHeaders: [String: String] = [ + "content-type": "application/json" + ] + + let converter: (Any) -> AppwriteModels.Token = { response in + return AppwriteModels.Token.from(map: response as! [String: Any]) + } + + return try await client.call( + method: "PUT", + path: apiPath, + headers: apiHeaders, + params: apiParams, + converter: converter + ) + } + + /// + /// Use this endpoint to complete the user email verification process. Use both + /// the **userId** and **secret** parameters that were attached to your app URL + /// to verify the user email ownership. If confirmed this route will return a + /// 200 status code. + /// + /// - Parameters: + /// - userId: String + /// - secret: String + /// - Throws: Exception if the request fails + /// - Returns: AppwriteModels.Token + /// + @available(*, deprecated, message: "This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.") open func updateVerification( userId: String, secret: String ) async throws -> AppwriteModels.Token { - let apiPath: String = "/account/verification" + let apiPath: String = "/account/verifications/email" let apiParams: [String: Any?] = [ "userId": userId, @@ -2291,7 +2381,7 @@ open class Account: Service { /// open func createPhoneVerification( ) async throws -> AppwriteModels.Token { - let apiPath: String = "/account/verification/phone" + let apiPath: String = "/account/verifications/phone" let apiParams: [String: Any] = [:] @@ -2328,7 +2418,7 @@ open class Account: Service { userId: String, secret: String ) async throws -> AppwriteModels.Token { - let apiPath: String = "/account/verification/phone" + let apiPath: String = "/account/verifications/phone" let apiParams: [String: Any?] = [ "userId": userId, diff --git a/Sources/Appwrite/Services/TablesDb.swift b/Sources/Appwrite/Services/TablesDb.swift index cbc2abb..3445d0e 100644 --- a/Sources/Appwrite/Services/TablesDb.swift +++ b/Sources/Appwrite/Services/TablesDb.swift @@ -75,7 +75,7 @@ open class TablesDB: Service { /// /// Create a new Row. Before using this route, you should create a new table /// resource using either a [server - /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) + /// integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) /// API or directly from your database console. /// /// - Parameters: @@ -125,7 +125,7 @@ open class TablesDB: Service { /// /// Create a new Row. Before using this route, you should create a new table /// resource using either a [server - /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) + /// integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) /// API or directly from your database console. /// /// - Parameters: @@ -227,7 +227,7 @@ open class TablesDB: Service { /// /// Create or update a Row. Before using this route, you should create a new /// table resource using either a [server - /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) + /// integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) /// API or directly from your database console. /// /// - Parameters: @@ -277,7 +277,7 @@ open class TablesDB: Service { /// /// Create or update a Row. Before using this route, you should create a new /// table resource using either a [server - /// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) + /// integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) /// API or directly from your database console. /// /// - Parameters: diff --git a/docs/examples/account/create-email-verification.md b/docs/examples/account/create-email-verification.md new file mode 100644 index 0000000..378558e --- /dev/null +++ b/docs/examples/account/create-email-verification.md @@ -0,0 +1,12 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let account = Account(client) + +let token = try await account.createEmailVerification( + url: "https://example.com" +) + diff --git a/docs/examples/account/update-email-verification.md b/docs/examples/account/update-email-verification.md new file mode 100644 index 0000000..77ef28e --- /dev/null +++ b/docs/examples/account/update-email-verification.md @@ -0,0 +1,13 @@ +import Appwrite + +let client = Client() + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let account = Account(client) + +let token = try await account.updateEmailVerification( + userId: "", + secret: "" +) + From baf0d2209aefd87a905211b0cb96ef6209ccf91d Mon Sep 17 00:00:00 2001 From: root Date: Wed, 8 Oct 2025 04:54:24 +0000 Subject: [PATCH 2/2] fix version --- CHANGELOG.md | 2 +- README.md | 2 +- Sources/Appwrite/Client.swift | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc65637..dce2df1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change Log -## 13.0.1 +## 13.1.0 * Deprecate `createVerification` method in `Account` service * Add `createEmailVerification` method in `Account` service diff --git a/README.md b/README.md index 1a61d0c..56b12e2 100644 --- a/README.md +++ b/README.md @@ -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: "13.0.1"), + .package(url: "git@github.com:appwrite/sdk-for-apple.git", from: "13.1.0"), ], ``` diff --git a/Sources/Appwrite/Client.swift b/Sources/Appwrite/Client.swift index 3a9d9ca..0bb8ef7 100644 --- a/Sources/Appwrite/Client.swift +++ b/Sources/Appwrite/Client.swift @@ -23,7 +23,7 @@ open class Client { "x-sdk-name": "Apple", "x-sdk-platform": "client", "x-sdk-language": "apple", - "x-sdk-version": "13.0.1", + "x-sdk-version": "13.1.0", "x-appwrite-response-format": "1.8.0" ]