Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[POC] feat: add support for session refresh for safari #266

Merged
merged 17 commits into from
Apr 10, 2024

Conversation

hunger-programmer
Copy link
Collaborator

ref: UUI-683

Copy link

codecov bot commented Jan 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (b0d1b74) to head (b17a705).

❗ Current head b17a705 differs from pull request most recent head cc2844b. Consider uploading reports for the commit cc2844b to get more accurate results

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #266   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           14        14           
  Lines          626       641   +15     
  Branches       162       170    +8     
=========================================
+ Hits           626       641   +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@bogdan-niculescu-sch bogdan-niculescu-sch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

package.json Outdated Show resolved Hide resolved
src/identity.js Outdated
const client_sdrn = `sdrn:${NAMESPACE[this.env]}:client:${this.clientId}`;
const redirectBackUrl = this.redirectUri.substring(0 , this.redirectUri.lastIndexOf('/'));
const params = { redirect_uri: redirectBackUrl, client_sdrn: client_sdrn};
this.emit('redirectToSessionService');
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, this event has no sense in this place because we are redirected right after the event is triggered.
For PoC it can stay, but not for final solution

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this event allow the brands to save any progress on critical flows to i.e. localStorage before the redirect happens?

Copy link
Collaborator

@bogdan-niculescu-sch bogdan-niculescu-sch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changing to request changes to not merge by mistake since this needs to be a feature😁

@hunger-programmer hunger-programmer changed the title feat: add support for session refresh for safari [POC] feat: add support for session refresh for safari Jan 25, 2024
@hunger-programmer hunger-programmer force-pushed the feat/UUI-683/add-support-for-page-refresh branch 5 times, most recently from 3499cfb to 9f50c25 Compare January 25, 2024 14:45
@hunger-programmer hunger-programmer force-pushed the feat/UUI-683/add-support-for-page-refresh branch from 9f50c25 to 8b513b0 Compare January 25, 2024 14:48
@@ -38,6 +38,6 @@ jobs:
- name: Build application
run: npm run build
- name: Publish to npm
run: npm publish --access=public
run: npm publish --access=public --tag beta #TODO: To be removed, for PoC purposes only
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beta tag should be removed for final release

src/identity.js Outdated
// for expiring session and safari browser do full page redirect to gain new session
if(_checkRedirectionNeed(sessionData)){
if (this._enableSessionCaching) {
const expiresIn = 1000 * (sessionData.expiresIn || 300);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, sessionData is an object with one key "redirectURL".
We should consider creating a separate field for this.

src/identity.js Outdated
if (sessionData){
// for expiring session and safari browser do full page redirect to gain new session
if(_checkRedirectionNeed(sessionData)){
if (this._enableSessionCaching) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this "semaphore" logic be extracted into separate methods?
hasSession does a lot already.

src/identity.js Outdated
return _postProcess(sessionData);
};
this._hasSessionInProgress = _getSession()
.then(
sessionData => {
this._hasSessionInProgress = false;

if (typeof sessionData === 'string' && isUrl(sessionData)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typeof sessionData === 'string' can be removed.
If sessionData is not a stringified URL isUrl will safely fail to parse it and return false

src/identity.js Outdated
@@ -480,9 +491,16 @@ export class Identity extends EventEmitter {
* @return {Promise<HasSessionSuccessResponse|HasSessionFailureResponse>}
*/
hasSession() {
const checkIfSessionOngoing = this.cache.get("sessionFlowOngoing");
if (checkIfSessionOngoing)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove newline before '{'

@bogdan-niculescu-sch bogdan-niculescu-sch merged commit 6617d02 into master Apr 10, 2024
4 checks passed
@bogdan-niculescu-sch bogdan-niculescu-sch deleted the feat/UUI-683/add-support-for-page-refresh branch April 10, 2024 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants