-
Notifications
You must be signed in to change notification settings - Fork 387
Pass required params to Session constructor. Allow undefined
in AuthScopes
#169
Pass required params to Session constructor. Allow undefined
in AuthScopes
#169
Conversation
679dd92
to
2444034
Compare
undefined
in AuthScopes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, just had a couple of nits!
let scopesArray: string[] = []; | ||
if (typeof scopes === 'string') { | ||
scopesArray = scopes.split(new RegExp(`${AuthScopes.SCOPE_DELIMITER}\\s*`)); | ||
} else { | ||
} else if (scopes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be extra sure that we only process accepted types?
} else if (scopes) { | |
} else if (scopes !== undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point. Should there be an exception/error at that point if scopes
is not a string, array or undefined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, typescript would fail in that case, but javascript wouldn't. Then again, we don't check for that sort of thing in a lot of other places (and is that an excuse for not doing it here? 😅 ).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'm unsure what the right move is here 😅
This needs a good rebase and probably a bit of refactoring since we've merged #153. I'll get that taken care of so this should be in a good place soon. |
2444034
to
8bf068e
Compare
88bf9c8
to
b772364
Compare
CHANGELOG.md
Outdated
## [1.2.1] - 2021-03-26 | ||
### Added | ||
- Added `April21` to `ApiVersion` [#149](https://github.com/Shopify/shopify-node-api/pull/149) | ||
- Sessions no longer default to `false` for `isOnline` [#169](https://github.com/Shopify/shopify-node-api/pull/169) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little confused - is this part of v1.2.1?
Also, I think this might be a breaking change, right? It will essentially break any apps that build sessions (which might be the case for custom session storages made prior to the change to allow objects).
Update: I actually don't think it's breaking! It's OK to not get those values in the constructor (if we make the params optional), and since the properties are all public, they can continue to be set as they were.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ope, sorry. My changelog got all weird after I rebased. Will fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also yes, this would be breaking. I don't think these values can be optional? They need to be there for other parts of the code that handle the Session
to work, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but if you call the constructor and then set the fields, that's OK too, as long as the right fields continue to be set - i.e. apps that did it 'the old way' would continue to work if the constructor doesn't break because of missing params.
753a7e8
to
65226ed
Compare
Any updates on this one? |
Any update or a workaround for now? |
@thecodepixi Any chance you can resolve those conflicts? |
Will this be merged in soon? Really critical |
Hi folks! Sorry for the delay on this one. We're currently working on a few breaking changes that are going to make up v2 of the library. Since this is also a breaking change (because of the Stay tuned, and thanks for your patience! |
WHY are these changes introduced?
The parameters required by
Session
were previously not being passed to the constructor, and we were instantiating instances ofSession
with just theirid
. This caused some issues due to potentially missing required params.An issue with
scopes
potentially beingundefined
and causing errors in theAuthScopes
class is also fixed in this PR. This initially seemed like aSession
issue but was able to be resolved in theAuthScope
class itself by allowingundefined
scopes in the constructor, which then translates to an empty array of scopes.The change to
AuthScopes
should potentially fix #159 and similar issues.WHAT is this pull request doing?
Session
params into the constructor.Session
new Session
to pass the required params.AuthScopes
to allow forundefined
in the constructor, and then check for the presence ofscope
.important to note that a large portion of this PR is updates to test files
Type of change
Checklist