Skip to content

Fetch preview store claim URL#7788

Open
alfonso-noriega wants to merge 2 commits into
productionize-preview-store-create-mainfrom
preview-store-claim-url
Open

Fetch preview store claim URL#7788
alfonso-noriega wants to merge 2 commits into
productionize-preview-store-create-mainfrom
preview-store-claim-url

Conversation

@alfonso-noriega

@alfonso-noriega alfonso-noriega commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

Preview store creation now returns an access URL for immediately opening the store, but saving/claiming the preview store is a separate backend step. This PR extends shopify store create preview to request the claim URL after a successful create so the command output includes both access and claim links.

Backend endpoint contract:

POST /services/preview-stores/:shop_id/claim

Headers:

  • Requires the preview store Admin API token returned by create.

Request:

{
  "email": "optional recipient email"
}

Response:

{
  "claim_url": "https://admin.shopify.com/store-transfer/accept/:claim_token"
}

WHAT is this pull request doing?

  • Adds a preview-store claim client for POST /services/preview-stores/:shop_id/claim.
  • Sends the returned Admin API token in the claim request headers.
  • Calls the claim endpoint after preview store creation and local auth persistence.
  • Includes the returned claim_url in store create preview JSON output.
  • Displays the claim URL in text output and next steps.
  • Redacts tokenized claim URLs from malformed-response diagnostics.

How to test your changes?

  • pnpm --filter @shopify/store exec vitest run src/cli/commands/store/create/preview.test.ts src/cli/services/store/create/preview/client.test.ts src/cli/services/store/create/preview/index.test.ts src/cli/services/store/create/preview/result.test.ts
  • pnpm nx run store:lint --skip-nx-cache --output-style=stream
  • pnpm --filter @shopify/store run type-check
  • /usr/bin/git diff --check

Post-release steps

None.

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've considered analytics changes to measure impact
  • The change is user-facing — changeset added for @shopify/store

alfonso-noriega commented Jun 12, 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.

@github-actions github-actions Bot added the Area: @shopify/cli @shopify/cli package issues label Jun 12, 2026
@alfonso-noriega alfonso-noriega marked this pull request as ready for review June 12, 2026 15:06
@alfonso-noriega alfonso-noriega requested review from a team as code owners June 12, 2026 15:07
},
nextSteps: [
`Open ${response.accessUrl} to view and access your preview store.`,
`Claim ${claim.claimUrl} to save your preview store and continue editing later.`,

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.

I think this language needs updating from the doc -- currently it reads "Create an account (https://x12y45z.myshopify.com/?foo=bar) for free to save progress."

@dmerand dmerand left a comment

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.

'bot had a good point on this one.

options: PreviewStoreRequestOptions = {},
): Promise<PreviewStoreClaimResponse> {
const fqdn = await appManagementFqdn()
const url = `https://${fqdn}/services/preview-stores/${request.shopId}/claim`

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.

🔒 Security: Worth reviewing the claim URL construction because shopId is interpolated directly into a path segment. In this file, shopId ultimately comes from response narrowing that accepts any string or number, so a value containing /, ?, #, or traversal-like characters could change the requested path on the same host while still sending the Admin API token headers.

Suggestion: Encode the path segment before interpolation.

Suggested change
const url = `https://${fqdn}/services/preview-stores/${request.shopId}/claim`
const url = `https://${fqdn}/services/preview-stores/${encodeURIComponent(request.shopId)}/claim`

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

Labels

Area: @shopify/cli @shopify/cli package issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants