Use store auth sessions for theme commands#7783
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
f0160e7 to
72f8f19
Compare
9bae25d to
58a57dd
Compare
72f8f19 to
b504c98
Compare
56a026b to
ab54f9c
Compare
b504c98 to
c3f7626
Compare
ab54f9c to
3764131
Compare
07d1745 to
f4ec45d
Compare
3764131 to
d2b96d9
Compare
d2b96d9 to
2ad7d1f
Compare
2ad7d1f to
5000127
Compare
dmerand
left a comment
There was a problem hiding this comment.
'bot found one concern worth looking into.
7ba8de4 to
d0a2320
Compare
5000127 to
ded68ab
Compare
d0a2320 to
be4217a
Compare
ded68ab to
2999eeb
Compare
716a05c to
77cfe9f
Compare
77cfe9f to
f44e9de
Compare
@alfonso-noriega I don't think this is the same thing. @nickwesselman what do you think? |
bdd4ac8 to
c2fe1bc
Compare
|
/snapit |
|
🫰✨ Thanks @alfonso-noriega! Your snapshot has been published to npm. Test the snapshot by installing your package globally: pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20260622103617Caution After installing, validate the version by running |
What is the error message and why wouldn't it trigger the agent to
The goal is to have a solution here that works for |
4b9f711 to
6e8b6b5
Compare
42b992a to
3d69dd4
Compare
3d69dd4 to
c31a07d
Compare
Assisted-By: devx/2de967b4-f860-4a71-a205-2e8334cf528c
c31a07d to
551bccc
Compare
Differences in type declarationsWe detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:
New type declarationspackages/cli-kit/dist/public/node/constants.d.tsexport declare const STORE_AUTH_APP_CLIENT_ID = "7e9cb568cfd431c538f36d1ad3f2b4f6";
packages/cli-kit/dist/public/node/store-auth-session.d.tsimport { LocalStorage } from './local-storage.js';
import type { AdminSession } from './session.js';
/**
* Discriminator for a stored store auth session.
*
* - 'standard': created via `shopify store auth`.
* - 'preview': created via `shopify store create preview`; backed by a server-issued Admin API token.
*
* Stored sessions written before this discriminator existed have no `kind` field and are
* read back as 'standard'.
*/
export type StoredStoreSessionKind = 'standard' | 'preview';
export interface StoredPreviewStoreMetadata {
/** Placeholder account UUID returned by the preview-store backend when available. */
placeholderAccountUuid?: string;
/** Numeric shop id returned by the preview-store backend. */
shopId: string;
/** Store name returned by the preview-store backend. */
name: string;
/** ISO country code requested for the store, when provided by the caller. */
country?: string;
/** ISO timestamp for when the preview store was created locally. */
createdAt: string;
/** Access URL returned by the preview-store backend. */
accessUrl?: string;
}
export interface StoredStoreAppSession {
store: string;
clientId: string;
userId: string;
accessToken: string;
refreshToken?: string;
scopes: string[];
acquiredAt: string;
expiresAt?: string;
refreshTokenExpiresAt?: string;
associatedUser?: {
id: number;
email?: string;
firstName?: string;
lastName?: string;
accountOwner?: boolean;
};
/**
* Discriminator. Optional in storage for back-compat with sessions written before the
* field existed; `sessionKind()` resolves missing values to 'standard'.
*/
kind?: StoredStoreSessionKind;
/** Preview-store-only metadata. Set iff `kind === 'preview'`. */
preview?: StoredPreviewStoreMetadata;
}
interface StoredStoreAppSessionBucket {
currentUserId: string;
sessionsByUserId: {
[userId: string]: StoredStoreAppSession;
};
}
interface StoreAuthSessionSchema {
[key: string]: StoredStoreAppSessionBucket;
}
/**
* Build the local-storage key used for store-auth sessions.
*
* @param store - The normalized store FQDN.
* @returns The store-auth session storage key.
*/
export declare function storeAuthSessionKey(store: string): string;
/**
* Project the current session for every store that has locally stored store auth.
*
* @param storage - Optional storage override for tests.
* @returns Current stored store auth sessions.
*/
export declare function listCurrentStoredStoreAppSessions(storage?: LocalStorage<StoreAuthSessionSchema>): StoredStoreAppSession[];
/**
* Get the current stored store auth session for a store.
*
* @param store - The store FQDN or URL to load a store-auth session for.
* @param storage - Optional storage override for tests.
* @returns The current stored store auth session, or undefined when missing or malformed.
*/
export declare function getCurrentStoredStoreAppSession(store: string, storage?: LocalStorage<StoreAuthSessionSchema>): StoredStoreAppSession | undefined;
/**
* Persist a store auth session and mark it as current for its store.
*
* @param session - The store auth session to persist.
* @param storage - Optional storage override for tests.
*/
export declare function setStoredStoreAppSession(session: StoredStoreAppSession, storage?: LocalStorage<StoreAuthSessionSchema>): void;
/**
* Clear stored store auth sessions for a store.
*
* @param store - The store FQDN or URL to clear sessions for.
* @param userIdOrStorage - Optional user ID to clear, or storage override when clearing all users.
* @param maybeStorage - Optional storage override when clearing one user.
*/
export declare function clearStoredStoreAppSession(store: string, userIdOrStorage?: string | LocalStorage<StoreAuthSessionSchema>, maybeStorage?: LocalStorage<StoreAuthSessionSchema>): void;
/**
* Load an Admin API session from the local store-auth cache when one is currently usable.
*
* @param store - The store FQDN or URL to load a store-auth session for.
* @param storage - Optional storage override for tests.
* @returns An Admin session, or undefined when no usable session is cached.
*/
export declare function getStoreAuthAdminSession(store: string, storage?: LocalStorage<StoreAuthSessionSchema>): AdminSession | undefined;
/**
* Check whether a stored store auth session is expired, including the refresh margin.
*
* @param session - The stored store auth session.
* @returns True when the session is expired or has an invalid expiry timestamp.
*/
export declare function isSessionExpired(session: StoredStoreAppSession): boolean;
export {};
Existing type declarationsWe found no diffs with existing type declarations |

WHY are these changes introduced?
Fixes https://github.com/shop/issues-develop/issues/22916.
Preview stores created by
shopify store create previewpersist an Admin API token in the store-auth cache.theme pullandtheme pushshould be able to use that cached token when the user does not provide a Theme Access/Admin token via--password.WHAT is this pull request doing?
@shopify/cli-kit/node/store-auth-session.packages/store's oldauth/session-storemodule; store and theme now use the cli-kit boundary directly.@shopify/theme→@shopify/storepackage dependency.--passwordstill wins, but missing--passwordcan fall back to a matching cached store-auth Admin API token before normal theme authentication.passwordwhen the matching store-auth cache session satisfies auth.How to test your changes?
Post-release steps
None.
Checklist