Fetch preview store claim URL#7788
Conversation
|
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.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
| }, | ||
| nextSteps: [ | ||
| `Open ${response.accessUrl} to view and access your preview store.`, | ||
| `Claim ${claim.claimUrl} to save your preview store and continue editing later.`, |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
'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` |
There was a problem hiding this comment.
🔒 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.
| const url = `https://${fqdn}/services/preview-stores/${request.shopId}/claim` | |
| const url = `https://${fqdn}/services/preview-stores/${encodeURIComponent(request.shopId)}/claim` |

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 previewto request the claim URL after a successful create so the command output includes both access and claim links.Backend endpoint contract:
Headers:
Request:
{ "email": "optional recipient email" }Response:
{ "claim_url": "https://admin.shopify.com/store-transfer/accept/:claim_token" }WHAT is this pull request doing?
POST /services/preview-stores/:shop_id/claim.claim_urlinstore create previewJSON output.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.tspnpm nx run store:lint --skip-nx-cache --output-style=streampnpm --filter @shopify/store run type-check/usr/bin/git diff --checkPost-release steps
None.
Checklist
@shopify/store