Skip to content

Add local store auth summary API#7709

Draft
dmerand wants to merge 3 commits into
donald/store-list-business-platformfrom
donald/store-list-local-auth-seam
Draft

Add local store auth summary API#7709
dmerand wants to merge 3 commits into
donald/store-list-business-platformfrom
donald/store-list-local-auth-seam

Conversation

@dmerand

@dmerand dmerand commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Introduce a local store-auth summary API without changing command behavior yet.

Scope

  • add StoredStoreAuthSummary
  • add listStoredStoreAuthSummaries() under services/store/auth
  • keep token-bearing session buckets as the current persistence source of truth
  • keep conf traversal and bucket cleanup in session-store.ts
  • re-export the summary API from services/store/auth/index.ts
  • sort summaries newest-auth-first for the “return to the store I was working on” use case

Why this split exists

The next PR needs one narrow question answered first:

  • what directly authenticated store auth exists on this machine?

This PR answers that without taking on product behavior:

  • no auth-listing command yet
  • no persistence migration
  • no access-token exposure

That keeps the behavior PR focused on command policy and output, not on storage traversal.

Boundary this PR is trying to establish

  • persistence details stay in session-store.ts
  • callers see StoredStoreAuthSummary[]
  • callers do not need token-bearing session buckets or conf layout knowledge

Not changed / deferred

  • Did not add the shopify auth list command in this PR. This PR is only the storage projection; command behavior lands upstack.
  • Did not expose access tokens or refresh tokens. The summary API is deliberately safe for display/automation consumers.
  • Did not migrate the persisted store-auth schema or add an index key for known stores. This keeps existing auth sessions compatible and avoids making a storage migration part of this stack.
  • Did not add a public LocalStorage.entries() / enumeration API in cli-kit. Follow-through review correctly noted that session-store.ts still relies on the underlying conf layout to discover existing buckets; fixing that should be a focused storage follow-up before adding more local-auth inventory features.

@github-actions github-actions Bot added the no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users. label Jun 3, 2026
@dmerand dmerand changed the title Introduce local store auth summary seam Introduce local store auth summary API Jun 4, 2026
@dmerand dmerand force-pushed the donald/store-list-business-platform branch from 92fffc1 to c7e152d Compare June 5, 2026 13:41
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch 2 times, most recently from 619636c to 7c049c1 Compare June 5, 2026 14:10
@dmerand dmerand force-pushed the donald/store-list-business-platform branch from 3ac3560 to 6fbe857 Compare June 5, 2026 14:24
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch from 7c049c1 to 52daf1c Compare June 5, 2026 14:24

dmerand commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@dmerand dmerand force-pushed the donald/store-list-business-platform branch from 6fbe857 to 87919a9 Compare June 5, 2026 18:12
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch 2 times, most recently from 00dce2a to 22e4f4a Compare June 5, 2026 18:31
@dmerand dmerand force-pushed the donald/store-list-business-platform branch 2 times, most recently from f516bbe to 79dbfa7 Compare June 5, 2026 19:06
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch from 22e4f4a to 31a07f1 Compare June 5, 2026 19:06
@dmerand dmerand force-pushed the donald/store-list-business-platform branch from 79dbfa7 to 9e07ceb Compare June 8, 2026 18:41
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch 2 times, most recently from c128517 to 9343914 Compare June 8, 2026 19:06
@dmerand dmerand force-pushed the donald/store-list-business-platform branch from 5986997 to b4c7faa Compare June 8, 2026 19:10
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch from 9343914 to 81229e4 Compare June 8, 2026 19:10
@dmerand dmerand marked this pull request as ready for review June 8, 2026 20:56
@dmerand dmerand requested a review from a team as a code owner June 8, 2026 20:56
@dmerand dmerand force-pushed the donald/store-list-business-platform branch from b4c7faa to cb1e68e Compare June 8, 2026 21:08
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch from 81229e4 to 04b87d7 Compare June 8, 2026 21:08
@dmerand dmerand force-pushed the donald/store-list-business-platform branch from cb1e68e to 4a2c0dd Compare June 10, 2026 14:34
@dmerand dmerand requested a review from a team as a code owner June 10, 2026 14:34
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch from 04b87d7 to b3f03fe Compare June 10, 2026 14:34
@dmerand dmerand force-pushed the donald/store-list-business-platform branch from 4a2c0dd to 0974dfd Compare June 10, 2026 15:00
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch from b3f03fe to 6246aef Compare June 10, 2026 15:00
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch 4 times, most recently from 8d4afd4 to a2cf41b Compare June 11, 2026 13:23
@dmerand dmerand force-pushed the donald/store-list-business-platform branch from 5cc2126 to 4075110 Compare June 11, 2026 13:31
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch from a2cf41b to 541a4a4 Compare June 11, 2026 13:31
@dmerand dmerand force-pushed the donald/store-list-business-platform branch from 4075110 to cd562c1 Compare June 11, 2026 15:28
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch from 541a4a4 to a053144 Compare June 11, 2026 15:37
@dmerand dmerand force-pushed the donald/store-list-business-platform branch from cd562c1 to 8dd1001 Compare June 11, 2026 15:40
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch 3 times, most recently from 9f582a7 to 9649fc5 Compare June 11, 2026 17:23
@dmerand dmerand force-pushed the donald/store-list-business-platform branch from 6e10c3a to 000cd81 Compare June 11, 2026 18:45
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch from 9649fc5 to a151039 Compare June 11, 2026 18:45
@dmerand dmerand force-pushed the donald/store-list-business-platform branch from 000cd81 to 8a8afc2 Compare June 11, 2026 19:42
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch from a151039 to 3755b76 Compare June 11, 2026 19:42
...(sanitizeAssociatedUser(session.associatedUser)
? {associatedUser: sanitizeAssociatedUser(session.associatedUser)}
: {}),
...(associatedUser ? {associatedUser} : {}),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice drive-by refactor 👍

// `conf` persists dotted keys as nested objects. Store-auth callers should not
// learn that layout directly; this helper keeps the current traversal private to
// the persistence seam while higher-level code projects summaries instead.
function readRawStoreSessionStorage(storage: LocalStorage<StoreSessionSchema>): Record<string, unknown> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these need to be unknowns? Would a union type be possible?

return (storage as unknown as {config: {store: Record<string, unknown>}}).config.store ?? {}
}

function collectCurrentStoredStoreAppSessions(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is kind of an abomination. I would strongly prefer that we have a background task that fixes the storage once (e.g. foo.myshopify.com => foo-myshopify-com) and then we can avoid this complexity going forward.

By the way, we don't really test this crawling logic anywhere if I am understanding correctly.

@dmerand dmerand marked this pull request as draft June 15, 2026 14:16
@dmerand dmerand force-pushed the donald/store-list-business-platform branch from 8a8afc2 to 67cfc8b Compare June 15, 2026 14:18
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch 2 times, most recently from 538642c to a94504a Compare June 15, 2026 14:30
@dmerand dmerand changed the title Introduce local store auth summary API Add local store auth summary API Jun 15, 2026
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch from a94504a to 0c53a33 Compare June 15, 2026 14:39
@dmerand dmerand force-pushed the donald/store-list-local-auth-seam branch from 0c53a33 to b61793b Compare June 15, 2026 14:58
@github-actions

Copy link
Copy Markdown
Contributor

Differences in type declarations

We 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:

  • Some seemingly private modules might be re-exported through public modules.
  • If the branch is behind main you might see odd diffs, rebase main into this branch.

New type declarations

We found no new type declarations in this PR

Existing type declarations

packages/cli-kit/dist/public/common/string.d.ts
@@ -102,6 +102,16 @@ export declare function formatDate(date: Date): string;
  * @returns The transformed string in local system time.
  */
 export declare function formatLocalDate(dateString: string): string;
+/**
+ * Formats a date as a short calendar date like "May 22, 2026" () in UTC.
+ *
+ * UTC keeps the output deterministic regardless of the machine timezone. Returns an empty string
+ * when the value cannot be parsed into a valid date.
+ *
+ * @param value - A Date, epoch milliseconds, or a date string such as an ISO 8601 timestamp.
+ * @returns The formatted date, or an empty string when the value is invalid.
+ */
+export declare function formatShortDate(value: Date | number | string): string;
 /**
  * Given a list of items, it returns a string with the items joined by commas and the last item joined by "and".
  * All items are wrapped in double quotes.
packages/cli-kit/dist/public/common/url.d.ts
@@ -28,4 +28,13 @@ export declare function extractHost(value: string | null | undefined): string |
  * @param value - A URL or host string, possibly null/undefined.
  * @returns The myshopify subdomain handle, or undefined when the input isn't a  URL.
  */
-export declare function extractMyshopifyHandle(value: string | null | undefined): string | undefined;
\ No newline at end of file
+export declare function extractMyshopifyHandle(value: string | null | undefined): string | undefined;
+/**
+ * Extracts the leading subdomain label from a URL or host, across environments — e.g.
+ * , , or local development hosts — rather than assuming a
+ *  domain.
+ *
+ * @param value - A URL or host string, possibly null/undefined.
+ * @returns The first DNS label, or undefined when no host can be extracted.
+ */
+export declare function extractSubdomain(value: string | null | undefined): string | undefined;
\ No newline at end of file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants