From 45749752a6f7bbc57bfd11dafdadb3e9304c73fc Mon Sep 17 00:00:00 2001 From: hogpilot Date: Thu, 13 May 2021 09:05:40 -0600 Subject: [PATCH 1/3] fix(840): fixes a bug where token duration was not honored in oauth flow due to improper \`duration\` AFFECTS PACKAGES: @esri/arcgis-rest-auth ISSUES CLOSED: #840 --- packages/arcgis-rest-auth/src/UserSession.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/arcgis-rest-auth/src/UserSession.ts b/packages/arcgis-rest-auth/src/UserSession.ts index 7e45ccafdb..945995bf35 100644 --- a/packages/arcgis-rest-auth/src/UserSession.ts +++ b/packages/arcgis-rest-auth/src/UserSession.ts @@ -344,7 +344,7 @@ export class UserSession implements IAuthenticationManager { const session = defer(); - win[`__ESRI_REST_AUTH_HANDLER_${clientId}`] = function( + win[`__ESRI_REST_AUTH_HANDLER_${clientId}`] = function ( errorString: any, oauthInfoString: string ) { @@ -534,7 +534,7 @@ export class UserSession implements IAuthenticationManager { }; response.writeHead(301, { - Location: `${portal}/oauth2/authorize?client_id=${clientId}&duration=${duration}&response_type=code&redirect_uri=${encodeURIComponent( + Location: `${portal}/oauth2/authorize?client_id=${clientId}&expiration=${duration}&response_type=code&redirect_uri=${encodeURIComponent( redirectUri )}`, }); From 108c4b301fdfe65c240c9c608c96054a69fb497a Mon Sep 17 00:00:00 2001 From: hogpilot Date: Thu, 13 May 2021 09:39:33 -0600 Subject: [PATCH 2/3] removing an unintentional formatting fix in previous commit --- packages/arcgis-rest-auth/src/UserSession.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/arcgis-rest-auth/src/UserSession.ts b/packages/arcgis-rest-auth/src/UserSession.ts index 945995bf35..2ce722a12b 100644 --- a/packages/arcgis-rest-auth/src/UserSession.ts +++ b/packages/arcgis-rest-auth/src/UserSession.ts @@ -344,7 +344,7 @@ export class UserSession implements IAuthenticationManager { const session = defer(); - win[`__ESRI_REST_AUTH_HANDLER_${clientId}`] = function ( + win[`__ESRI_REST_AUTH_HANDLER_${clientId}`] = function( errorString: any, oauthInfoString: string ) { From efaf6cc558143a25d1b1cb8cfe1928ef79e0c255 Mon Sep 17 00:00:00 2001 From: hogpilot Date: Thu, 13 May 2021 09:48:03 -0600 Subject: [PATCH 3/3] updated UserSession.test.ts --- packages/arcgis-rest-auth/test/UserSession.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/arcgis-rest-auth/test/UserSession.test.ts b/packages/arcgis-rest-auth/test/UserSession.test.ts index 9348708caf..78c3237c19 100644 --- a/packages/arcgis-rest-auth/test/UserSession.test.ts +++ b/packages/arcgis-rest-auth/test/UserSession.test.ts @@ -1474,7 +1474,7 @@ describe("UserSession", () => { end() { expect(spy.calls.mostRecent().args[0]).toBe(301); expect(spy.calls.mostRecent().args[1].Location).toBe( - "https://arcgis.com/sharing/rest/oauth2/authorize?client_id=clientId&duration=20160&response_type=code&redirect_uri=https%3A%2F%2Fexample-app.com%2Fredirect-uri" + "https://arcgis.com/sharing/rest/oauth2/authorize?client_id=clientId&expiration=20160&response_type=code&redirect_uri=https%3A%2F%2Fexample-app.com%2Fredirect-uri" ); done(); },