From 8b7b84b8980be81e97c0dd220af6b2c9d03bb89b Mon Sep 17 00:00:00 2001 From: root Date: Wed, 8 Oct 2025 04:14:56 +0000 Subject: [PATCH 1/2] chore: regen --- CHANGELOG.md | 5 + .../account/create-email-verification.md | 13 ++ .../account/update-email-verification.md | 14 ++ package.json | 2 +- src/client.ts | 2 +- src/services/account.ts | 127 +++++++++++++++++- src/services/tables-db.ts | 24 ++-- 7 files changed, 169 insertions(+), 18 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 eda0bca2..fa077f06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change log +## 0.15.1 + +* Deprecate `createVerification` method in `Account` service +* Add `createEmailVerification` method in `Account` service + ## 0.11.0 * Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service diff --git a/docs/examples/account/create-email-verification.md b/docs/examples/account/create-email-verification.md new file mode 100644 index 00000000..42260501 --- /dev/null +++ b/docs/examples/account/create-email-verification.md @@ -0,0 +1,13 @@ +import { Client, Account } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const account = new Account(client); + +const result = await account.createEmailVerification({ + url: 'https://example.com' +}); + +console.log(result); diff --git a/docs/examples/account/update-email-verification.md b/docs/examples/account/update-email-verification.md new file mode 100644 index 00000000..4270380d --- /dev/null +++ b/docs/examples/account/update-email-verification.md @@ -0,0 +1,14 @@ +import { Client, Account } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const account = new Account(client); + +const result = await account.updateEmailVerification({ + userId: '', + secret: '' +}); + +console.log(result); diff --git a/package.json b/package.json index 168aaf1b..c046785e 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "react-native-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", - "version": "0.15.0", + "version": "0.15.1", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index 9561d822..644f3c34 100644 --- a/src/client.ts +++ b/src/client.ts @@ -115,7 +115,7 @@ class Client { 'x-sdk-name': 'React Native', 'x-sdk-platform': 'client', 'x-sdk-language': 'reactnative', - 'x-sdk-version': '0.15.0', + 'x-sdk-version': '0.15.1', 'X-Appwrite-Response-Format': '1.8.0', }; diff --git a/src/services/account.ts b/src/services/account.ts index 4f143646..f3c1f512 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -2427,6 +2427,62 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ + createEmailVerification(params: { url: string }): Promise; + /** + * 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. + * + * + * @param {string} url - URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createEmailVerification(url: string): Promise; + createEmailVerification( + paramsOrFirst: { url: string } | string + ): Promise { + let params: { url: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { url: string }; + } else { + params = { + url: paramsOrFirst as string + }; + } + + const url = params.url; + + if (typeof url === 'undefined') { + throw new AppwriteException('Missing required parameter: "url"'); + } + + const apiPath = '/account/verifications/email'; + const payload: Payload = {}; + + if (typeof url !== 'undefined') { + payload['url'] = url; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('post', uri, { + 'content-type': 'application/json', + }, payload); + } + + /** + * 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. + * + * + * @param {string} params.url - URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead. + */ createVerification(params: { url: string }): Promise; /** * 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. @@ -2459,7 +2515,7 @@ export class Account extends Service { throw new AppwriteException('Missing required parameter: "url"'); } - const apiPath = '/account/verification'; + const apiPath = '/account/verifications/email'; const payload: Payload = {}; if (typeof url !== 'undefined') { @@ -2480,6 +2536,69 @@ export class Account extends Service { * @throws {AppwriteException} * @returns {Promise} */ + updateEmailVerification(params: { userId: string, secret: string }): Promise; + /** + * 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. + * + * @param {string} userId - User ID. + * @param {string} secret - Valid verification token. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateEmailVerification(userId: string, secret: string): Promise; + updateEmailVerification( + paramsOrFirst: { userId: string, secret: string } | string, + ...rest: [(string)?] + ): Promise { + let params: { userId: string, secret: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, secret: string }; + } else { + params = { + userId: paramsOrFirst as string, + secret: rest[0] as string + }; + } + + const userId = params.userId; + const secret = params.secret; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + if (typeof secret === 'undefined') { + throw new AppwriteException('Missing required parameter: "secret"'); + } + + const apiPath = '/account/verifications/email'; + const payload: Payload = {}; + + if (typeof userId !== 'undefined') { + payload['userId'] = userId; + } + + if (typeof secret !== 'undefined') { + payload['secret'] = secret; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('put', uri, { + 'content-type': 'application/json', + }, payload); + } + + /** + * 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. + * + * @param {string} params.userId - User ID. + * @param {string} params.secret - Valid verification token. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead. + */ updateVerification(params: { userId: string, secret: string }): Promise; /** * 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. @@ -2517,7 +2636,7 @@ export class Account extends Service { throw new AppwriteException('Missing required parameter: "secret"'); } - const apiPath = '/account/verification'; + const apiPath = '/account/verifications/email'; const payload: Payload = {}; if (typeof userId !== 'undefined') { @@ -2541,7 +2660,7 @@ export class Account extends Service { * @returns {Promise} */ createPhoneVerification(): Promise { - const apiPath = '/account/verification/phone'; + const apiPath = '/account/verifications/phone'; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -2595,7 +2714,7 @@ export class Account extends Service { throw new AppwriteException('Missing required parameter: "secret"'); } - const apiPath = '/account/verification/phone'; + const apiPath = '/account/verifications/phone'; const payload: Payload = {}; if (typeof userId !== 'undefined') { diff --git a/src/services/tables-db.ts b/src/services/tables-db.ts index b3b12b9e..d4636080 100644 --- a/src/services/tables-db.ts +++ b/src/services/tables-db.ts @@ -17,7 +17,7 @@ export class TablesDB extends Service { * Get a list of all the user's rows in a given table. You can use the query params to filter your results. * * @param {string} params.databaseId - Database ID. - * @param {string} params.tableId - Table ID. You can create a new table using the TableDB service [server integration](https://appwrite.io/docs/server/tablesdbdb#tablesdbCreate). + * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/products/databases/tables#create-table). * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @throws {AppwriteException} * @returns {Promise} @@ -27,7 +27,7 @@ export class TablesDB extends Service { * Get a list of all the user's rows in a given table. You can use the query params to filter your results. * * @param {string} databaseId - Database ID. - * @param {string} tableId - Table ID. You can create a new table using the TableDB service [server integration](https://appwrite.io/docs/server/tablesdbdb#tablesdbCreate). + * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/products/databases/tables#create-table). * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @throws {AppwriteException} * @returns {Promise>} @@ -75,10 +75,10 @@ export class TablesDB extends 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) API or directly from your database console. + * Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. * * @param {string} params.databaseId - Database ID. - * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). Make sure to define columns before creating rows. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). Make sure to define columns before creating rows. * @param {string} params.rowId - Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {Row extends Models.DefaultRow ? Partial & Record : Partial & Omit} params.data - Row data as JSON object. * @param {string[]} params.permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). @@ -87,10 +87,10 @@ export class TablesDB extends Service { */ createRow(params: { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial & Record : Partial & Omit, permissions?: string[] }): Promise; /** - * 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) API or directly from your database console. + * Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. * * @param {string} databaseId - Database ID. - * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). Make sure to define columns before creating rows. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). Make sure to define columns before creating rows. * @param {string} rowId - Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {Row extends Models.DefaultRow ? Partial & Record : Partial & Omit} data - Row data as JSON object. * @param {string[]} permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). @@ -164,7 +164,7 @@ export class TablesDB extends Service { * Get a row by its unique ID. This endpoint response returns a JSON object with the row data. * * @param {string} params.databaseId - Database ID. - * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.rowId - Row ID. * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @throws {AppwriteException} @@ -175,7 +175,7 @@ export class TablesDB extends Service { * Get a row by its unique ID. This endpoint response returns a JSON object with the row data. * * @param {string} databaseId - Database ID. - * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} rowId - Row ID. * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @throws {AppwriteException} @@ -230,7 +230,7 @@ export class TablesDB extends 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) API or directly from your database console. + * 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/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. * * @param {string} params.databaseId - Database ID. * @param {string} params.tableId - Table ID. @@ -242,7 +242,7 @@ export class TablesDB extends Service { */ upsertRow(params: { databaseId: string, tableId: string, rowId: string, data?: Row extends Models.DefaultRow ? Partial & Record : Partial & Partial>, permissions?: string[] }): Promise; /** - * 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) API or directly from your database console. + * 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/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. * * @param {string} databaseId - Database ID. * @param {string} tableId - Table ID. @@ -389,7 +389,7 @@ export class TablesDB extends Service { * Delete a row by its unique ID. * * @param {string} params.databaseId - Database ID. - * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} params.rowId - Row ID. * @throws {AppwriteException} * @returns {Promise} @@ -399,7 +399,7 @@ export class TablesDB extends Service { * Delete a row by its unique ID. * * @param {string} databaseId - Database ID. - * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param {string} rowId - Row ID. * @throws {AppwriteException} * @returns {Promise<{}>} From 1e79e943bae2a4b091a302aed223c18916b2f50c Mon Sep 17 00:00:00 2001 From: root Date: Wed, 8 Oct 2025 04:55:15 +0000 Subject: [PATCH 2/2] fix version --- CHANGELOG.md | 2 +- package.json | 2 +- src/client.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa077f06..79ade8cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change log -## 0.15.1 +## 0.16.0 * Deprecate `createVerification` method in `Account` service * Add `createEmailVerification` method in `Account` service diff --git a/package.json b/package.json index c046785e..9e3b94c8 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "react-native-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", - "version": "0.15.1", + "version": "0.16.0", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index 644f3c34..47611eb0 100644 --- a/src/client.ts +++ b/src/client.ts @@ -115,7 +115,7 @@ class Client { 'x-sdk-name': 'React Native', 'x-sdk-platform': 'client', 'x-sdk-language': 'reactnative', - 'x-sdk-version': '0.15.1', + 'x-sdk-version': '0.16.0', 'X-Appwrite-Response-Format': '1.8.0', };