Repository navigation
Add selected account details to auth login - #8794
isaacroldan wants to merge 1 commit into
Conversation
|
/snapit |
|
🫰✨ Thanks @isaacroldan! Your snapshot has been published to npm. Built from Test the snapshot by installing your package globally: pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20261006115510Caution After installing, validate the version by running |
fdab1a6 to
08495a7
Compare
|
/snapit |
|
🫰✨ Thanks @isaacroldan! Your snapshot has been published to npm. Built from Test the snapshot by installing your package globally: pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20261006121130Caution After installing, validate the version by running |
08495a7 to
1f386df
Compare
|
/snapit |
1f386df to
99a3d98
Compare
|
/snapit |
|
🫰✨ Thanks @isaacroldan! Your snapshot has been published to npm. Built from Test the snapshot by installing your package globally: pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20261006165742Caution After installing, validate the version by running |
99a3d98 to
4b5a8ab
Compare
|
/snapit |
|
🫰✨ Thanks @isaacroldan! Your snapshot has been published to npm. Built from Test the snapshot by installing your package globally: pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20261007091213Caution After installing, validate the version by running |
4b5a8ab to
3329861
Compare
|
/snapit |
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 declarationsWe found no new type declarations in this PR Existing type declarationspackages/cli-kit/dist/public/node/session-prompt.d.ts@@ -1,3 +1,12 @@
+/** Public account details for a selected Shopify identity session. */
+export interface SelectedSession {
+ /** The identity provider user ID. */
+ userId: string;
+ /** The alias or display label used to select the account. */
+ alias: string;
+ /** The email returned by authentication, or null when it is not stored. */
+ email: string | null;
+}
/**
* Prompts the user to select from existing sessions or log in with a different account.
*
@@ -7,4 +16,11 @@
* @param alias - Optional alias of the account to switch to.
* @returns Promise with the alias of the chosen session.
*/
-export declare function promptSessionSelect(alias?: string): Promise<string>;
\ No newline at end of file
+export declare function promptSessionSelect(alias?: string): Promise<string>;
+/**
+ * Selects an existing session or authenticates a new account and returns its public details.
+ *
+ * @param alias - Optional alias or user ID of an account to select.
+ * @returns The selected user ID, display alias, and stored email without credentials.
+ */
+export declare function promptSessionSelectWithDetails(alias?: string): Promise<SelectedSession>;
\ No newline at end of file
packages/cli-kit/dist/private/node/session/schema.d.ts@@ -9,6 +9,7 @@ declare const IdentityTokenSchema: zod.ZodObject<{
scopes: zod.ZodArray<zod.ZodString, "many">;
userId: zod.ZodString;
alias: zod.ZodOptional<zod.ZodString>;
+ email: zod.ZodOptional<zod.ZodString>;
}, "strip", zod.ZodTypeAny, {
accessToken: string;
refreshToken: string;
@@ -16,6 +17,7 @@ declare const IdentityTokenSchema: zod.ZodObject<{
expiresAt: Date;
userId: string;
alias?: string | undefined;
+ email?: string | undefined;
}, {
accessToken: string;
refreshToken: string;
@@ -23,6 +25,7 @@ declare const IdentityTokenSchema: zod.ZodObject<{
userId: string;
expiresAt?: unknown;
alias?: string | undefined;
+ email?: string | undefined;
}>;
/**
* The schema represents an application token.
@@ -51,6 +54,7 @@ declare const SessionSchema: zod.ZodObject<{
scopes: zod.ZodArray<zod.ZodString, "many">;
userId: zod.ZodString;
alias: zod.ZodOptional<zod.ZodString>;
+ email: zod.ZodOptional<zod.ZodString>;
}, "strip", zod.ZodTypeAny, {
accessToken: string;
refreshToken: string;
@@ -58,6 +62,7 @@ declare const SessionSchema: zod.ZodObject<{
expiresAt: Date;
userId: string;
alias?: string | undefined;
+ email?: string | undefined;
}, {
accessToken: string;
refreshToken: string;
@@ -65,6 +70,7 @@ declare const SessionSchema: zod.ZodObject<{
userId: string;
expiresAt?: unknown;
alias?: string | undefined;
+ email?: string | undefined;
}>;
applications: zod.ZodObject<{}, "strip", zod.ZodObject<{
accessToken: zod.ZodString;
@@ -120,6 +126,7 @@ declare const SessionSchema: zod.ZodObject<{
expiresAt: Date;
userId: string;
alias?: string | undefined;
+ email?: string | undefined;
};
applications: {} & {
[k: string]: {
@@ -137,6 +144,7 @@ declare const SessionSchema: zod.ZodObject<{
userId: string;
expiresAt?: unknown;
alias?: string | undefined;
+ email?: string | undefined;
};
applications: {} & {
[k: string]: {
@@ -183,6 +191,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
scopes: zod.ZodArray<zod.ZodString, "many">;
userId: zod.ZodString;
alias: zod.ZodOptional<zod.ZodString>;
+ email: zod.ZodOptional<zod.ZodString>;
}, "strip", zod.ZodTypeAny, {
accessToken: string;
refreshToken: string;
@@ -190,6 +199,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
expiresAt: Date;
userId: string;
alias?: string | undefined;
+ email?: string | undefined;
}, {
accessToken: string;
refreshToken: string;
@@ -197,6 +207,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
userId: string;
expiresAt?: unknown;
alias?: string | undefined;
+ email?: string | undefined;
}>;
applications: zod.ZodObject<{}, "strip", zod.ZodObject<{
accessToken: zod.ZodString;
@@ -252,6 +263,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
expiresAt: Date;
userId: string;
alias?: string | undefined;
+ email?: string | undefined;
};
applications: {} & {
[k: string]: {
@@ -269,6 +281,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
userId: string;
expiresAt?: unknown;
alias?: string | undefined;
+ email?: string | undefined;
};
applications: {} & {
[k: string]: {
@@ -286,6 +299,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
scopes: zod.ZodArray<zod.ZodString, "many">;
userId: zod.ZodString;
alias: zod.ZodOptional<zod.ZodString>;
+ email: zod.ZodOptional<zod.ZodString>;
}, "strip", zod.ZodTypeAny, {
accessToken: string;
refreshToken: string;
@@ -293,6 +307,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
expiresAt: Date;
userId: string;
alias?: string | undefined;
+ email?: string | undefined;
}, {
accessToken: string;
refreshToken: string;
@@ -300,6 +315,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
userId: string;
expiresAt?: unknown;
alias?: string | undefined;
+ email?: string | undefined;
}>;
applications: zod.ZodObject<{}, "strip", zod.ZodObject<{
accessToken: zod.ZodString;
@@ -355,6 +371,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
expiresAt: Date;
userId: string;
alias?: string | undefined;
+ email?: string | undefined;
};
applications: {} & {
[k: string]: {
@@ -372,6 +389,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
userId: string;
expiresAt?: unknown;
alias?: string | undefined;
+ email?: string | undefined;
};
applications: {} & {
[k: string]: {
@@ -389,6 +407,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
scopes: zod.ZodArray<zod.ZodString, "many">;
userId: zod.ZodString;
alias: zod.ZodOptional<zod.ZodString>;
+ email: zod.ZodOptional<zod.ZodString>;
}, "strip", zod.ZodTypeAny, {
accessToken: string;
refreshToken: string;
@@ -396,6 +415,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
expiresAt: Date;
userId: string;
alias?: string | undefined;
+ email?: string | undefined;
}, {
accessToken: string;
refreshToken: string;
@@ -403,6 +423,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
userId: string;
expiresAt?: unknown;
alias?: string | undefined;
+ email?: string | undefined;
}>;
applications: zod.ZodObject<{}, "strip", zod.ZodObject<{
accessToken: zod.ZodString;
@@ -458,6 +479,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
expiresAt: Date;
userId: string;
alias?: string | undefined;
+ email?: string | undefined;
};
applications: {} & {
[k: string]: {
@@ -475,6 +497,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
userId: string;
expiresAt?: unknown;
alias?: string | undefined;
+ email?: string | undefined;
};
applications: {} & {
[k: string]: {
@@ -492,6 +515,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
scopes: zod.ZodArray<zod.ZodString, "many">;
userId: zod.ZodString;
alias: zod.ZodOptional<zod.ZodString>;
+ email: zod.ZodOptional<zod.ZodString>;
}, "strip", zod.ZodTypeAny, {
accessToken: string;
refreshToken: string;
@@ -499,6 +523,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
expiresAt: Date;
userId: string;
alias?: string | undefined;
+ email?: string | undefined;
}, {
accessToken: string;
refreshToken: string;
@@ -506,6 +531,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
userId: string;
expiresAt?: unknown;
alias?: string | undefined;
+ email?: string | undefined;
}>;
applications: zod.ZodObject<{}, "strip", zod.ZodObject<{
accessToken: zod.ZodString;
@@ -561,6 +587,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
expiresAt: Date;
userId: string;
alias?: string | undefined;
+ email?: string | undefined;
};
applications: {} & {
[k: string]: {
@@ -578,6 +605,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
userId: string;
expiresAt?: unknown;
alias?: string | undefined;
+ email?: string | undefined;
};
applications: {} & {
[k: string]: {
@@ -595,6 +623,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
scopes: zod.ZodArray<zod.ZodString, "many">;
userId: zod.ZodString;
alias: zod.ZodOptional<zod.ZodString>;
+ email: zod.ZodOptional<zod.ZodString>;
}, "strip", zod.ZodTypeAny, {
accessToken: string;
refreshToken: string;
@@ -602,6 +631,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
expiresAt: Date;
userId: string;
alias?: string | undefined;
+ email?: string | undefined;
}, {
accessToken: string;
refreshToken: string;
@@ -609,6 +639,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
userId: string;
expiresAt?: unknown;
alias?: string | undefined;
+ email?: string | undefined;
}>;
applications: zod.ZodObject<{}, "strip", zod.ZodObject<{
accessToken: zod.ZodString;
@@ -664,6 +695,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
expiresAt: Date;
userId: string;
alias?: string | undefined;
+ email?: string | undefined;
};
applications: {} & {
[k: string]: {
@@ -681,6 +713,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
userId: string;
expiresAt?: unknown;
alias?: string | undefined;
+ email?: string | undefined;
};
applications: {} & {
[k: string]: {
@@ -698,6 +731,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
scopes: zod.ZodArray<zod.ZodString, "many">;
userId: zod.ZodString;
alias: zod.ZodOptional<zod.ZodString>;
+ email: zod.ZodOptional<zod.ZodString>;
}, "strip", zod.ZodTypeAny, {
accessToken: string;
refreshToken: string;
@@ -705,6 +739,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
expiresAt: Date;
userId: string;
alias?: string | undefined;
+ email?: string | undefined;
}, {
accessToken: string;
refreshToken: string;
@@ -712,6 +747,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
userId: string;
expiresAt?: unknown;
alias?: string | undefined;
+ email?: string | undefined;
}>;
applications: zod.ZodObject<{}, "strip", zod.ZodObject<{
accessToken: zod.ZodString;
@@ -767,6 +803,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
expiresAt: Date;
userId: string;
alias?: string | undefined;
+ email?: string | undefined;
};
applications: {} & {
[k: string]: {
@@ -784,6 +821,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
userId: string;
expiresAt?: unknown;
alias?: string | undefined;
+ email?: string | undefined;
};
applications: {} & {
[k: string]: {
@@ -801,6 +839,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
scopes: zod.ZodArray<zod.ZodString, "many">;
userId: zod.ZodString;
alias: zod.ZodOptional<zod.ZodString>;
+ email: zod.ZodOptional<zod.ZodString>;
}, "strip", zod.ZodTypeAny, {
accessToken: string;
refreshToken: string;
@@ -808,6 +847,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
expiresAt: Date;
userId: string;
alias?: string | undefined;
+ email?: string | undefined;
}, {
accessToken: string;
refreshToken: string;
@@ -815,6 +855,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
userId: string;
expiresAt?: unknown;
alias?: string | undefined;
+ email?: string | undefined;
}>;
applications: zod.ZodObject<{}, "strip", zod.ZodObject<{
accessToken: zod.ZodString;
@@ -870,6 +911,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
expiresAt: Date;
userId: string;
alias?: string | undefined;
+ email?: string | undefined;
};
applications: {} & {
[k: string]: {
@@ -887,6 +929,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
userId: string;
expiresAt?: unknown;
alias?: string | undefined;
+ email?: string | undefined;
};
applications: {} & {
[k: string]: {
@@ -904,6 +947,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
scopes: zod.ZodArray<zod.ZodString, "many">;
userId: zod.ZodString;
alias: zod.ZodOptional<zod.ZodString>;
+ email: zod.ZodOptional<zod.ZodString>;
}, "strip", zod.ZodTypeAny, {
accessToken: string;
refreshToken: string;
@@ -911,6 +955,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
expiresAt: Date;
userId: string;
alias?: string | undefined;
+ email?: string | undefined;
}, {
accessToken: string;
refreshToken: string;
@@ -918,6 +963,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
userId: string;
expiresAt?: unknown;
alias?: string | undefined;
+ email?: string | undefined;
}>;
applications: zod.ZodObject<{}, "strip", zod.ZodObject<{
accessToken: zod.ZodString;
@@ -973,6 +1019,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
expiresAt: Date;
userId: string;
alias?: string | undefined;
+ email?: string | undefined;
};
applications: {} & {
[k: string]: {
@@ -990,6 +1037,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
userId: string;
expiresAt?: unknown;
alias?: string | undefined;
+ email?: string | undefined;
};
applications: {} & {
[k: string]: {
@@ -1007,6 +1055,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
scopes: zod.ZodArray<zod.ZodString, "many">;
userId: zod.ZodString;
alias: zod.ZodOptional<zod.ZodString>;
+ email: zod.ZodOptional<zod.ZodString>;
}, "strip", zod.ZodTypeAny, {
accessToken: string;
refreshToken: string;
@@ -1014,6 +1063,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
expiresAt: Date;
userId: string;
alias?: string | undefined;
+ email?: string | undefined;
}, {
accessToken: string;
refreshToken: string;
@@ -1021,6 +1071,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
userId: string;
expiresAt?: unknown;
alias?: string | undefined;
+ email?: string | undefined;
}>;
applications: zod.ZodObject<{}, "strip", zod.ZodObject<{
accessToken: zod.ZodString;
@@ -1076,6 +1127,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
expiresAt: Date;
userId: string;
alias?: string | undefined;
+ email?: string | undefined;
};
applications: {} & {
[k: string]: {
@@ -1093,6 +1145,7 @@ export declare const SessionsSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{}
userId: string;
expiresAt?: unknown;
alias?: string | undefined;
+ email?: string | undefined;
};
applications: {} & {
[k: string]: {
packages/cli-kit/dist/private/node/session/store.d.ts@@ -1,4 +1,5 @@
-import type { Sessions } from './schema.js';
+import type { IdentityToken, Sessions } from './schema.js';
+type SessionAccount = Pick<IdentityToken, 'userId' | 'alias' | 'email'>;
/**
* Serializes the session as a JSON and stores it in the system.
* @param session - the session to store.
@@ -15,12 +16,12 @@ export declare function fetch(): Promise<Sessions | undefined>;
*/
export declare function remove(): Promise<void>;
/**
- * Gets the session alias for a given user ID.
+ * Gets public account details for a stored user ID.
*
- * @param userId - The user ID of the session to get the alias for.
- * @returns The alias for the session if it exists, otherwise undefined.
+ * @param userId - The stored user ID whose account details are requested.
+ * @returns The account details if the session exists, otherwise undefined.
*/
-export declare function getSessionAlias(userId: string): Promise<string | undefined>;
+export declare function getSessionAccount(userId: string): Promise<SessionAccount | undefined>;
/**
* Sets the alias for a given user's session and persists it.
*
@@ -34,4 +35,6 @@ export declare function setSessionAlias(userId: string, alias: string): Promise<
* @param alias - The alias to search for
* @returns The user ID if found, otherwise undefined
*/
-export declare function findSessionByAlias(alias: string): Promise<string | undefined>;
\ No newline at end of file
+export declare function findSessionByAlias(alias: string): Promise<string | undefined>;
+export declare function findSessionAccountByAlias(alias: string): Promise<SessionAccount | undefined>;
+export {};
\ No newline at end of file
|
|
🫰✨ Thanks @isaacroldan! Your snapshot has been published to npm. Built from Test the snapshot by installing your package globally: pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20261007094639Caution After installing, validate the version by running |
WHY are these changes introduced?
An account alias alone does not identify the Shopify user or their email.
WHAT is this pull request doing?
Add
SelectedSessionand a details API while keeping the alias-only API. Store email from existing authentication requests and retain it for the correct user during refresh and reauthentication. Extend the login JSON result from #8791 withuserIdandemail; unknown email isnull.Validation: 41 auth tests, 112 session tests, lint, types and build pass. Prompt stream handling is excluded from this stack.
If #8791 is released separately first, the added JSON fields require a major CLI changeset for consumers with the old strict schema.
How to manually test your changes?
Use this PR's CLI or snapshot. Replace
<account-alias>with a stored alias.shopify auth login --alias "<account-alias>" --json --no-inputExpect
status,userId,aliasandemailfor the selected account. Older sessions can returnemail: null. Runshopify auth loginwithout JSON to complete a fresh sign-in, then repeat the alias-based JSON command in a new process. The email must be returned when available and remain stored.Select by a stored user ID to check that the email belongs to that account. Without JSON, the account message and selection behavior must stay the same.
Checklist
Stack: #8790: logout JSON → #8791: login JSON → #8794: account details. Merge in this order.