fix(pos-app): rename partner API key to customer API key#396
fix(pos-app): rename partner API key to customer API key#396ignaciosantise wants to merge 4 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Claude finished @ignaciosantise's task in 3m 1s —— View job Code Review
Found 5 issue(s)Issue 1: URL query parameter renamed without fallbackID: brk-use-url-credentials-url-param-rename-b7c4 Context:
Recommendation: Add temporary fallback during transition: const rawCustomerApiKey = params.get("customerApiKey") ?? params.get("partnerApiKey");Issue 2: Env variable renamed without backward compatID: brk-env-example-partner-to-customer-env-var-a3f2 Context:
Recommendation: Add a dev-mode guard in Issue 3: Hardcoded key string instead of constant in migrationID: secure-storage-hardcoded-key-constant-f3a1 Context:
Recommendation: const NEW_KEY = KEYS.CUSTOMER_API_KEY; // was hardcoded "customer_api_key"Issue 4: API key transmitted via URL query parameterID: dcl-use-url-credentials-apikey-url-exposure-c2d9 Context:
Recommendation: Use a short-lived signed token or server-side session handoff instead of embedding the raw key in the URL. If URL delivery is required, use a one-time code that is exchanged server-side for the actual key. Issue 5: Error message text change breaks monitoring rulesID: brk-payment-error-message-text-rename-d1e8 Context:
Recommendation: Update any Sentry/monitoring alert rules that reference the old message text before or immediately after deploying. |
Review Response — All 5 issues discardedIssue 1 (URL param no fallback): Discarded — user explicitly chose a clean break during planning. No backward compatibility for the old Issue 2 (Env var no fallback): Discarded — fallback not needed in this case. Environments using the old var name will update as part of this rename. Issue 3 (Hardcoded key in migration): Discarded — intentional pattern. Migration functions should use hardcoded strings to remain stable regardless of future constant changes. If Issue 4 (API key in URL): Discarded — pre-existing design introduced in commit Issue 5 (Error message monitoring): Discarded — standard consequence of the rename with low risk. No monitoring rules reference the old message text. |
Adds window.postMessage as the primary method for receiving merchantId and customerApiKey on web, keeping URL query params as fallback. postMessage values are plain text (no base64 needed since data stays in JS memory). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
partnerAPI key terminology tocustomeracross settings UI, hooks, store API, payment services, web URL params, env defaults, docs, and tests.isPartnerApiKeySettoisCustomerApiKeySetand secure-storage key migration from legacy keys tocustomer_api_key.merchant_api_key,partner_api_key) so stale credentials cannot be re-imported during migration.postMessageas the primary credential injection method on web, keeping URL query params as fallback.versionCodeindapps/pos-app/app.jsonfrom 17 to 18.postMessage Protocol
Parent/opener sends credentials to the POS app window via plain text (no base64 needed):
?merchantId=<base64>&customerApiKey=<base64>)Flow
flowchart TD A[App Rehydrate] --> B[clearStaleSecureStorage] B --> C[Delete customer_api_key + legacy keys] A --> D[migrateCustomerApiKey] D --> E{customer_api_key exists?} E -- No --> F[Copy first legacy key to customer_api_key] E -- Yes --> G[Keep existing customer_api_key] F --> H[Delete legacy keys] G --> HValidation
npm test -- --runInBand __tests__/hooks/use-url-credentials.test.ts __tests__/services/payment.test.ts __tests__/store/useSettingsStore.test.ts __tests__/utils/secure-storage.test.tsnpx tsc --noEmit