Conversation
🦋 Changeset detectedLatest commit: 2f6644b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
7de9bc2 to
1d0aa0f
Compare
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds a new authenticated GET /wallet endpoint that loads a credential's ACTIVE|FROZEN card, calls Panda for processor details, returns processorCardId/timeBasedSecret, adds a Panda utility, tests covering success and error mappings, and adds a changeset for a patch release. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Client
participant API as GET /wallet
participant DB as Database
participant Panda as Panda API
Client->>API: GET /wallet (credentialId cookie)
API->>DB: Load credential (pandaId, first ACTIVE|FROZEN card)
alt no credential
DB-->>API: not found
API-->>Client: 500 { code: "no credential" }
else credential missing pandaId
DB-->>API: credential (no pandaId)
API-->>Client: 403 { code: "no panda" }
else no eligible card
DB-->>API: credential (no eligible card)
API-->>Client: 404 { code: "no card" }
else credential + card found
DB-->>API: credential + cardId
API->>Panda: GET /issuing/cards/{cardId}/processorDetails
alt processor details found
Panda-->>API: { processorCardId, timeBasedSecret }
API-->>Client: 200 { cardId, cardSecret }
else processor 404
Panda-->>API: 404
API-->>Client: 404 { code: "no card" }
else other error
Panda-->>API: error
API-->>Client: 500 (error)
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
❌ 1 Tests Failed:
View the full list of 1 ❄️ flaky test(s)
To view more test analytics, go to the Prevent Tests Dashboard |
af7c987 to
9495bf1
Compare
9495bf1 to
0975d4d
Compare
0975d4d to
0ed88f7
Compare
0ed88f7 to
ba4376c
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (1)
server/test/api/card.test.ts (1)
867-869:⚠️ Potential issue | 🟡 MinorUse
Pandain the mockedServiceErrorfor consistency.
"Rain"works, but using the real provider label keeps test fixtures closer to production behavior.Suggested fix
- vi.spyOn(panda, "getProcessorDetails").mockRejectedValueOnce(new ServiceError("Rain", 500, "internal error")); + vi.spyOn(panda, "getProcessorDetails").mockRejectedValueOnce(new ServiceError("Panda", 500, "internal error"));
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 7e528c82-bb28-42c9-8cd9-b0f075ed5b87
📒 Files selected for processing (4)
.changeset/chilly-suns-dress.mdserver/api/card.tsserver/test/api/card.test.tsserver/utils/panda.ts
ba4376c to
2f6644b
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 36b39f7e-467b-4910-bcf5-d80b1c4e08e9
📒 Files selected for processing (4)
.changeset/chilly-suns-dress.mdserver/api/card.tsserver/test/api/card.test.tsserver/utils/panda.ts
| try { | ||
| const provisioning = await getProcessorDetails(credential.cards[0].id); | ||
| return c.json( | ||
| { cardId: provisioning.processorCardId, cardSecret: provisioning.timeBasedSecret } satisfies InferOutput< | ||
| typeof WalletResponse | ||
| >, | ||
| 200, | ||
| ); |
There was a problem hiding this comment.
Prevent caching of wallet provisioning secrets.
This success path returns raw provisioning material on a GET, but it does not set Cache-Control: no-store. With cookie auth, browser/private caches can persist cardSecret, which materially weakens the protection around these credentials.
🔒 Proposed fix
try {
const provisioning = await getProcessorDetails(credential.cards[0].id);
+ c.header("Cache-Control", "no-store");
+ c.header("Pragma", "no-cache");
return c.json(
{ cardId: provisioning.processorCardId, cardSecret: provisioning.timeBasedSecret } satisfies InferOutput<
typeof WalletResponse
>,
200,
Closes #440
Summary by CodeRabbit
New Features
Tests
Chores
This is part 1 of 2 in a stack made with GitButler: