From 4c3d7fd947a3c3a517a5ac2729fa44cc551dcb94 Mon Sep 17 00:00:00 2001 From: Rahul Date: Tue, 5 Sep 2023 12:52:21 +0530 Subject: [PATCH 1/4] redirection path support for binding added --- express/routes.js | 6 ++++++ express/session/session.js | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/express/routes.js b/express/routes.js index 1cbf0ca3..d4f99130 100644 --- a/express/routes.js +++ b/express/routes.js @@ -21,6 +21,7 @@ function setupRoutes(ext) { let companyId = parseInt(req.query.company_id); let platformConfig = ext.getPlatformConfig(companyId); let session; + let redirectPath = req.query.redirect_path; session = new Session(Session.generateSessionId(true)); @@ -32,6 +33,7 @@ function setupRoutes(ext) { session.expires = sessionExpires; session.access_mode = 'online'; // Always generate online mode token for extension launch session.extension_id = ext.api_key; + session.redirect_path = redirectPath; } else { if (session.expires) { session.expires = new Date(session.expires); @@ -145,6 +147,10 @@ function setupRoutes(ext) { }); } let redirectUrl = await ext.callbacks.auth(req); + if(req.fdkSession.redirect_path){ + redirectUrl = new URL(redirectUrl).origin; + redirectUrl += req.fdkSession.redirect_path + } logger.debug(`Redirecting after auth callback to url: ${redirectUrl}`); res.redirect(redirectUrl); } catch (error) { diff --git a/express/session/session.js b/express/session/session.js index 24f9255a..9a880755 100644 --- a/express/session/session.js +++ b/express/session/session.js @@ -17,6 +17,7 @@ class Session { this.refresh_token = null; this.isNew = isNew; this.extension_id = null; + this.redirect_path = null; } static cloneSession(id, session, isNew=true) { @@ -37,7 +38,8 @@ class Session { refresh_token: this.refresh_token, expires_in: this.expires_in, extension_id: this.extension_id, - access_token_validity: this.access_token_validity + access_token_validity: this.access_token_validity, + redirect_path: this.redirect_path }; } From e7cf5d18cb4c4af9dbf062acb5f0bf04a2928db3 Mon Sep 17 00:00:00 2001 From: Rahul Date: Mon, 16 Oct 2023 16:29:20 +0530 Subject: [PATCH 2/4] redirect path updated in install routes --- express/routes.js | 3 +-- package-lock.json | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/express/routes.js b/express/routes.js index d4f99130..fe723c10 100644 --- a/express/routes.js +++ b/express/routes.js @@ -148,8 +148,7 @@ function setupRoutes(ext) { } let redirectUrl = await ext.callbacks.auth(req); if(req.fdkSession.redirect_path){ - redirectUrl = new URL(redirectUrl).origin; - redirectUrl += req.fdkSession.redirect_path + redirectUrl = req.fdkSession.redirect_path; } logger.debug(`Redirecting after auth callback to url: ${redirectUrl}`); res.redirect(redirectUrl); diff --git a/package-lock.json b/package-lock.json index 0a80b0bd..d17970f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "fdk-extension-javascript", - "version": "0.6.0", + "version": "0.7.0", "lockfileVersion": 3, "requires": true, "packages": { From 4eafb7045fe7877f8af8fef872ec948c8d5e2bc5 Mon Sep 17 00:00:00 2001 From: Brijesh Mahidhariya Date: Fri, 19 Jul 2024 03:15:30 +0530 Subject: [PATCH 3/4] Bugfix: Handle refresh token not working on expiry is set to null --- CHANGELOG.md | 5 ++++- express/extension.js | 4 ++-- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cb9bf18..ef7a1fdc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v0.7.7] - 2024-07-19 +### Changed +- Handle refresh token not working for token which has expiry as `null`. +--- ## [v0.7.6] - 2024-07-11 ### Changed - Exported `apiRoutes` as `platformApiRoutes`. The `apiRoutes` export will be deprecated in the next major release. - Optimized webhook subscription by reducing unnecessary API calls. - --- ## [v0.7.5] - 2024-06-19 ### Changed diff --git a/express/extension.js b/express/extension.js index 0f05e48a..8fe8aabe 100644 --- a/express/extension.js +++ b/express/extension.js @@ -130,8 +130,8 @@ class Extension { platformConfig.oauthClient.setToken(session); platformConfig.oauthClient.token_expires_at = session.access_token_validity; - if (session.access_token_validity && session.refresh_token) { - let ac_nr_expired = ((session.access_token_validity - new Date().getTime()) / 1000) <= 120; + if (!session.access_token_validity || session.refresh_token) { + let ac_nr_expired = !session.access_token_validity? true: ((session.access_token_validity - new Date().getTime()) / 1000) <= 120; if (ac_nr_expired) { logger.debug(`Renewing access token for company ${companyId} with platform config ${logger.safeStringify(platformConfig)}`); const renewTokenRes = await platformConfig.oauthClient.renewAccessToken(session.access_mode === 'offline'); diff --git a/package-lock.json b/package-lock.json index f63d3f85..d6ec1877 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@gofynd/fdk-extension-javascript", - "version": "0.7.6", + "version": "0.7.7", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@gofynd/fdk-extension-javascript", - "version": "0.7.6", + "version": "0.7.7", "license": "ISC", "dependencies": { "axios": "^1.6.4", diff --git a/package.json b/package.json index 8d9b62a1..665da130 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ }, "name": "@gofynd/fdk-extension-javascript", "description": "FDK Extension Helper Library", - "version": "0.7.6", + "version": "0.7.7", "main": "index.js", "directories": { "example": "examples" From ccabd651a6d69ddecee509d0302f4e1707130228 Mon Sep 17 00:00:00 2001 From: Jigar Dafda Date: Thu, 25 Jul 2024 15:23:32 +0530 Subject: [PATCH 4/4] changelog updated --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef7a1fdc..891b07cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [v0.7.7] - 2024-07-19 ### Changed - Handle refresh token not working for token which has expiry as `null`. +- Added support for passing `redirect_path` as a query paramater to the launch url of the extension. --- ## [v0.7.6] - 2024-07-11 ### Changed