diff --git a/packages/cli/src/cli/services/store/auth/scopes.test.ts b/packages/cli/src/cli/services/store/auth/scopes.test.ts index 5dbb0dba04f..25674f54cb6 100644 --- a/packages/cli/src/cli/services/store/auth/scopes.test.ts +++ b/packages/cli/src/cli/services/store/auth/scopes.test.ts @@ -17,6 +17,26 @@ describe('store auth scope helpers', () => { expect(mergeRequestedAndStoredScopes(['read_products'], ['read_orders'])).toEqual(['read_orders', 'read_products']) }) + test('parseStoreAuthScopes splits space-separated scopes (PowerShell transforms commas to spaces)', () => { + expect(parseStoreAuthScopes('read_products read_inventory')).toEqual(['read_products', 'read_inventory']) + }) + + test('parseStoreAuthScopes splits mixed comma-and-space delimiters', () => { + expect(parseStoreAuthScopes('read_products, read_inventory')).toEqual(['read_products', 'read_inventory']) + }) + + test('resolveGrantedScopes succeeds when requested scopes were space-separated (PowerShell bug scenario)', () => { + expect( + resolveGrantedScopes( + { + access_token: 'token', + scope: 'read_products,read_inventory', + }, + ['read_products', 'read_inventory'], + ), + ).toEqual(['read_products', 'read_inventory']) + }) + test('resolveGrantedScopes accepts compressed write scopes that imply requested reads', () => { expect( resolveGrantedScopes( diff --git a/packages/cli/src/cli/services/store/auth/scopes.ts b/packages/cli/src/cli/services/store/auth/scopes.ts index efe8a2b5913..1b5b286c156 100644 --- a/packages/cli/src/cli/services/store/auth/scopes.ts +++ b/packages/cli/src/cli/services/store/auth/scopes.ts @@ -4,7 +4,7 @@ import type {StoreTokenResponse} from './token-client.js' export function parseStoreAuthScopes(input: string): string[] { const scopes = input - .split(',') + .split(/[\s,]+/) .map((scope) => scope.trim()) .filter(Boolean)