This repository was archived by the owner on Apr 11, 2024. It is now read-only.
Make scopes optional for mangaged install token exchange apps#1333
Draft
Make scopes optional for mangaged install token exchange apps#1333
Conversation
alvaro-shopify
previously approved these changes
Apr 9, 2024
Comment on lines
+72
to
+75
| throwIfScopesUndefined( | ||
| config.scopes, | ||
| 'Apps that use OAuth must define the required scopes in the config', | ||
| ); |
There was a problem hiding this comment.
Suggested change
| throwIfScopesUndefined( | |
| config.scopes, | |
| 'Apps that use OAuth must define the required scopes in the config', | |
| ); | |
| if (!config.scopes) { | |
| throw new ShopifyErrors.MissingRequiredArgument('Apps that use OAuth must define the required scopes in the config',); | |
| } |
I'd rather check the config.scopes nullability here (the throwIfScopesUndefined is not used elsewhere) to avoid using config.scopes!.toString() and rely on TS type checking
| * scopes if checkScopes is true. | ||
| */ | ||
| public isActive(scopes: AuthScopes | string | string[]): boolean { | ||
| const usingScopes = |
There was a problem hiding this comment.
I think that you need to add an additional check if scopes is instance of AuthScopes
scopes instanceofAuthScopes ? scopes.toArray().length > 0 : scopes !== '' && typeof scopes !== 'undefined' && scopes !== nullyou could extract it to a different method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WHY are these changes introduced?
Assumptions
SCOPESenvironment variable, or the scopes config setting, Shopify will manage redirecting to the authorization page if necessary.WHAT is this pull request doing?
scopesfield on the API config object optional.Type of change
Checklist
yarn changesetto create a draft changelog entry (do NOT update theCHANGELOG.mdfile manually)