From 0065875f122763a46c5210a69fc25299e6da5b40 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Mon, 8 Jun 2020 23:28:07 +0000 Subject: [PATCH 1/2] fix: ensure access token is null not undefined (#2981) --- .../admin/local/__snapshots__/initLocalState.spec.ts.snap | 4 ++++ .../auth/local/__snapshots__/initLocalState.spec.ts.snap | 4 ++++ src/core/client/framework/lib/relay/localState.ts | 6 +++--- .../stream/local/__snapshots__/initLocalState.spec.ts.snap | 3 +++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/core/client/admin/local/__snapshots__/initLocalState.spec.ts.snap b/src/core/client/admin/local/__snapshots__/initLocalState.spec.ts.snap index b60535cd6..38a0efe59 100644 --- a/src/core/client/admin/local/__snapshots__/initLocalState.spec.ts.snap +++ b/src/core/client/admin/local/__snapshots__/initLocalState.spec.ts.snap @@ -5,6 +5,7 @@ exports[`get access token from url 1`] = ` \\"__id\\": \\"client:root.local\\", \\"__typename\\": \\"Local\\", \\"accessToken\\": \\"eyJraWQiOiI5NmM4MDY2YS1kOTg3LTQyODItODNmOS1kYTUxNjc5N2Y5ZmMiLCJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIzMWIyNjU5MS00ZTlhLTQzODgtYTdmZi1lMWJkYzVkOTdjY2UifQ==.\\", + \\"accessTokenExp\\": null, \\"accessTokenJTI\\": \\"31b26591-4e9a-4388-a7ff-e1bdc5d97cce\\", \\"redirectPath\\": null, \\"authView\\": \\"SIGN_IN\\", @@ -24,6 +25,9 @@ exports[`init local state 1`] = ` \\"client:root.local\\": { \\"__id\\": \\"client:root.local\\", \\"__typename\\": \\"Local\\", + \\"accessToken\\": null, + \\"accessTokenExp\\": null, + \\"accessTokenJTI\\": null, \\"redirectPath\\": null, \\"authView\\": \\"SIGN_IN\\", \\"authError\\": null diff --git a/src/core/client/auth/local/__snapshots__/initLocalState.spec.ts.snap b/src/core/client/auth/local/__snapshots__/initLocalState.spec.ts.snap index b9ef8f03f..8a29dce6b 100644 --- a/src/core/client/auth/local/__snapshots__/initLocalState.spec.ts.snap +++ b/src/core/client/auth/local/__snapshots__/initLocalState.spec.ts.snap @@ -5,6 +5,7 @@ exports[`get access token from url 1`] = ` \\"__id\\": \\"client:root.local\\", \\"__typename\\": \\"Local\\", \\"accessToken\\": \\"eyJraWQiOiI5NmM4MDY2YS1kOTg3LTQyODItODNmOS1kYTUxNjc5N2Y5ZmMiLCJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIzMWIyNjU5MS00ZTlhLTQzODgtYTdmZi1lMWJkYzVkOTdjY2UifQ==.\\", + \\"accessTokenExp\\": null, \\"accessTokenJTI\\": \\"31b26591-4e9a-4388-a7ff-e1bdc5d97cce\\", \\"view\\": \\"SIGN_IN\\", \\"error\\": null @@ -23,6 +24,9 @@ exports[`init local state 1`] = ` \\"client:root.local\\": { \\"__id\\": \\"client:root.local\\", \\"__typename\\": \\"Local\\", + \\"accessToken\\": null, + \\"accessTokenExp\\": null, + \\"accessTokenJTI\\": null, \\"view\\": \\"SIGN_IN\\", \\"error\\": null } diff --git a/src/core/client/framework/lib/relay/localState.ts b/src/core/client/framework/lib/relay/localState.ts index 295e05858..199379815 100644 --- a/src/core/client/framework/lib/relay/localState.ts +++ b/src/core/client/framework/lib/relay/localState.ts @@ -38,10 +38,10 @@ export function initLocalBaseState( root.setLinkedRecord(local, "local"); // Update the access token properties. - local.setValue(auth?.accessToken, "accessToken"); + local.setValue(auth?.accessToken || null, "accessToken"); // Update the claims. - local.setValue(auth?.claims.exp, "accessTokenExp"); - local.setValue(auth?.claims.jti, "accessTokenJTI"); + local.setValue(auth?.claims.exp || null, "accessTokenExp"); + local.setValue(auth?.claims.jti || null, "accessTokenJTI"); }); } diff --git a/src/core/client/stream/local/__snapshots__/initLocalState.spec.ts.snap b/src/core/client/stream/local/__snapshots__/initLocalState.spec.ts.snap index c49db3c35..016c7ed25 100644 --- a/src/core/client/stream/local/__snapshots__/initLocalState.spec.ts.snap +++ b/src/core/client/stream/local/__snapshots__/initLocalState.spec.ts.snap @@ -12,6 +12,9 @@ exports[`init local state 1`] = ` \\"client:root.local\\": { \\"__id\\": \\"client:root.local\\", \\"__typename\\": \\"Local\\", + \\"accessToken\\": null, + \\"accessTokenExp\\": null, + \\"accessTokenJTI\\": null, \\"commentsOrderBy\\": \\"CREATED_AT_DESC\\", \\"authPopup\\": { \\"__ref\\": \\"client:root.local.authPopup\\" From 0fa27ae41b081e1f634466ee0086bd5194e4a45b Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Mon, 8 Jun 2020 17:30:39 -0600 Subject: [PATCH 2/2] chore: bump version --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 46e111859..3a6f92a29 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@coralproject/talk", - "version": "6.2.0", + "version": "6.2.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 924a4ab33..7356f8765 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@coralproject/talk", - "version": "6.2.0", + "version": "6.2.1", "author": "The Coral Project", "homepage": "https://coralproject.net/", "sideEffects": [