From 2d27edfab067c5aef3428b0c2a99d776260a1a43 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Tue, 6 Oct 2026 15:54:00 +0100 Subject: [PATCH] feat: SDK update for version 29.1.0 Adds the optional state parameter to createOAuth2Token (appwrite/appwrite#14157). --- CHANGELOG.md | 4 ++++ docs/examples/account/create-o-auth-2-token.md | 1 + package-lock.json | 4 ++-- package.json | 2 +- src/client.ts | 4 ++-- src/services/account.ts | 17 +++++++++++++++-- 6 files changed, 25 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 658b743..86ee3d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 29.1.0 + +* Added: optional `state` parameter on `createOAuth2Token`, returned unchanged on the success and failure URLs + ## 29.0.0 * Stable release of the dedicated database APIs: `mysql`, `postgresql`, `mongo`, `documentsDB`, and `vectorsDB` services, previously released as release candidates diff --git a/docs/examples/account/create-o-auth-2-token.md b/docs/examples/account/create-o-auth-2-token.md index 40e1d1f..fa54473 100644 --- a/docs/examples/account/create-o-auth-2-token.md +++ b/docs/examples/account/create-o-auth-2-token.md @@ -13,5 +13,6 @@ const result = await account.createOAuth2Token({ success: 'https://example.com', // optional failure: 'https://example.com', // optional scopes: [], // optional + state: '', // optional }); ``` diff --git a/package-lock.json b/package-lock.json index 6c386f6..dec85fe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "node-appwrite", - "version": "29.0.0", + "version": "29.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "node-appwrite", - "version": "29.0.0", + "version": "29.1.0", "license": "BSD-3-Clause", "dependencies": { "json-bigint": "1.0.0", diff --git a/package.json b/package.json index 1fd513c..f8580da 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "node-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API", - "version": "29.0.0", + "version": "29.1.0", "license": "BSD-3-Clause", "main": "dist/index.js", "type": "commonjs", diff --git a/src/client.ts b/src/client.ts index 10ff729..9883e59 100644 --- a/src/client.ts +++ b/src/client.ts @@ -80,7 +80,7 @@ class AppwriteException extends Error { } function getUserAgent() { - let ua = 'AppwriteNodeJSSDK/29.0.0'; + let ua = 'AppwriteNodeJSSDK/29.1.0'; // `process` is a global in Node.js, but not fully available in all runtimes. const platform: string[] = []; @@ -142,7 +142,7 @@ class Client { 'x-sdk-name': 'Node.js', 'x-sdk-platform': 'server', 'x-sdk-language': 'nodejs', - 'x-sdk-version': '29.0.0', + 'x-sdk-version': '29.1.0', 'user-agent': getUserAgent(), 'X-Appwrite-Response-Format': '2.0.0', }; diff --git a/src/services/account.ts b/src/services/account.ts index 02085be..bd68990 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -2905,6 +2905,7 @@ export class Account { * @param {string} params.success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's 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. * @param {string} params.failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's 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. * @param {string[]} params.scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. + * @param {string} params.state - An opaque value your app generates and keeps, for example in a cookie. It is returned unchanged as the `state` query parameter on the success and failure URLs, so your app can check that the sign-in it receives is one it started. Printable ASCII only (RFC 6749 Appendix A.5). Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise} */ @@ -2913,6 +2914,7 @@ export class Account { success?: string; failure?: string; scopes?: string[]; + state?: string; }): Promise; /** * Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed. @@ -2925,6 +2927,7 @@ export class Account { * @param {string} success - URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's 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. * @param {string} failure - URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's 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. * @param {string[]} scopes - A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. + * @param {string} state - An opaque value your app generates and keeps, for example in a cookie. It is returned unchanged as the `state` query parameter on the success and failure URLs, so your app can check that the sign-in it receives is one it started. Printable ASCII only (RFC 6749 Appendix A.5). Max length: 256 chars. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. @@ -2934,6 +2937,7 @@ export class Account { success?: string, failure?: string, scopes?: string[], + state?: string, ): Promise; createOAuth2Token( paramsOrFirst: @@ -2942,15 +2946,17 @@ export class Account { success?: string; failure?: string; scopes?: string[]; + state?: string; } | OAuthProvider, - ...rest: [string?, string?, string[]?] + ...rest: [string?, string?, string[]?, string?] ): Promise { let params: { provider: OAuthProvider; success?: string; failure?: string; scopes?: string[]; + state?: string; }; if ( @@ -2960,13 +2966,15 @@ export class Account { ('provider' in paramsOrFirst || 'success' in paramsOrFirst || 'failure' in paramsOrFirst || - 'scopes' in paramsOrFirst) + 'scopes' in paramsOrFirst || + 'state' in paramsOrFirst) ) { params = (paramsOrFirst || {}) as { provider: OAuthProvider; success?: string; failure?: string; scopes?: string[]; + state?: string; }; } else { params = { @@ -2974,6 +2982,7 @@ export class Account { success: rest[0] as string, failure: rest[1] as string, scopes: rest[2] as string[], + state: rest[3] as string, }; } @@ -2981,6 +2990,7 @@ export class Account { const success = params.success; const failure = params.failure; const scopes = params.scopes; + const state = params.state; if (typeof provider === 'undefined') { throw new AppwriteException( 'Missing required parameter: "provider"', @@ -3000,6 +3010,9 @@ export class Account { if (typeof scopes !== 'undefined') { apiPayload['scopes'] = scopes; } + if (typeof state !== 'undefined') { + apiPayload['state'] = state; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = {