Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
isSessionExpired,
setStoredStoreAppSession,
} from './session.js'
import {STORE_AUTH_APP_CLIENT_ID} from './auth-config.js'
import {prepareAdminStoreGraphQLContext} from './admin-graphql-context.js'

vi.mock('./session.js')
Expand All @@ -24,7 +25,7 @@ describe('prepareAdminStoreGraphQLContext', () => {
const store = 'shop.myshopify.com'
const storedSession = {
store,
clientId: 'b16de5d7ba3e2e22279a38c22ef025a0',
clientId: STORE_AUTH_APP_CLIENT_ID,
userId: '42',
accessToken: 'token',
refreshToken: 'refresh-token',
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/cli/services/store/auth-config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const STORE_AUTH_APP_CLIENT_ID = 'b16de5d7ba3e2e22279a38c22ef025a0'
export const STORE_AUTH_APP_CLIENT_ID = '7e9cb568cfd431c538f36d1ad3f2b4f6'
Comment thread
dmerand marked this conversation as resolved.
Comment thread
dmerand marked this conversation as resolved.
export const DEFAULT_STORE_AUTH_PORT = 13387
export const STORE_AUTH_CALLBACK_PATH = '/auth/callback'

Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/cli/services/store/execute.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {describe, test, expect, vi, beforeEach, afterEach} from 'vitest'
import {executeStoreOperation} from './execute.js'
import {getStoredStoreAppSession} from './session.js'
import {STORE_AUTH_APP_CLIENT_ID} from './auth-config.js'
import {fetchApiVersions, adminUrl} from '@shopify/cli-kit/node/api/admin'
import {graphqlRequest} from '@shopify/cli-kit/node/api/graphql'
import {renderSingleTask, renderSuccess} from '@shopify/cli-kit/node/ui'
Expand All @@ -25,7 +26,7 @@ describe('executeStoreOperation', () => {
const session = {token: 'token', storeFqdn: store}
const storedSession = {
store,
clientId: 'b16de5d7ba3e2e22279a38c22ef025a0',
clientId: STORE_AUTH_APP_CLIENT_ID,
userId: '42',
accessToken: 'token',
scopes: ['read_products'],
Expand Down
11 changes: 6 additions & 5 deletions packages/cli/src/cli/services/store/session.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {describe, test, expect} from 'vitest'
import {LocalStorage} from '@shopify/cli-kit/node/local-storage'
import {STORE_AUTH_APP_CLIENT_ID, storeAuthSessionKey} from './auth-config.js'
import {
clearStoredStoreAppSession,
getStoredStoreAppSession,
Expand Down Expand Up @@ -27,7 +28,7 @@ function inMemoryStorage() {
function buildSession(overrides: Partial<StoredStoreAppSession> = {}): StoredStoreAppSession {
return {
store: 'shop.myshopify.com',
clientId: 'b16de5d7ba3e2e22279a38c22ef025a0',
clientId: STORE_AUTH_APP_CLIENT_ID,
userId: '42',
accessToken: 'token-1',
scopes: ['read_products'],
Expand Down Expand Up @@ -79,26 +80,26 @@ describe('store session storage', () => {

test('returns undefined and clears the bucket when the current user session is missing', () => {
const storage = inMemoryStorage()
storage.set('b16de5d7ba3e2e22279a38c22ef025a0::shop.myshopify.com', {
storage.set(storeAuthSessionKey('shop.myshopify.com'), {
currentUserId: '999',
sessionsByUserId: {
'42': buildSession(),
},
})

expect(getStoredStoreAppSession('shop.myshopify.com', storage as any)).toBeUndefined()
expect(storage.get('b16de5d7ba3e2e22279a38c22ef025a0::shop.myshopify.com')).toBeUndefined()
expect(storage.get(storeAuthSessionKey('shop.myshopify.com'))).toBeUndefined()
})

test('returns undefined and clears corrupted stored buckets', () => {
const storage = inMemoryStorage()
storage.set('b16de5d7ba3e2e22279a38c22ef025a0::shop.myshopify.com', {
storage.set(storeAuthSessionKey('shop.myshopify.com'), {
currentUserId: 42,
sessionsByUserId: null,
})

expect(getStoredStoreAppSession('shop.myshopify.com', storage as any)).toBeUndefined()
expect(storage.get('b16de5d7ba3e2e22279a38c22ef025a0::shop.myshopify.com')).toBeUndefined()
expect(storage.get(storeAuthSessionKey('shop.myshopify.com'))).toBeUndefined()
})
})

Expand Down
Loading