Implement clear auth for gift card mints#958
Implement clear auth for gift card mints#958jbojcic1 wants to merge 1 commit intosupport-clear-auth-with-shared-secretfrom
Conversation
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Not ready for review yet. I am not happy with some stuff here so will iterate |
de5f2da to
262e6f1
Compare
262e6f1 to
7ec10a1
Compare
| quotes: pendingMeltQuotes, | ||
| getWallet: (mintUrl) => { | ||
| const sourceAccount = getCashuAccountByMintUrl(mintUrl); | ||
| const authProvider = getMintAuthProvider(sourceAccount?.purpose); |
There was a problem hiding this comment.
at the moment we have to check if there is existing account for mint url and if yes what is the purpose to decide which (if any) auth provider is needed
I don't see another way to do it. unless we want to:
a) make getCashuWallet async and call mint info first to get purpose from there
b) make list of gift card accounts somewhere static so getCashuWallet can read it
| blocklist: mintBlocklist, | ||
| }); | ||
|
|
||
| type MintPurpose = 'gift-card' | 'transactional'; |
There was a problem hiding this comment.
i don't want to import purpose from accounts folder becaue shared feature shouldn't import non shared one. I was thinking to import it from /lib/cash protocol extensions but it's not there. @gudnuf didn't we change how we expose that stuff in mint info to include purpose?
There was a problem hiding this comment.
Yea, but that's in my open PRs for offers. In the agicash PR to support offer mints I exported MintPurpose here. Then here I reexported it as AccountPurpose because spark accounts have a purpose of transactional
There was a problem hiding this comment.
we can update this then once that gets merged
7ec10a1 to
bb72ec7
Compare
0610474 to
1de1aac
Compare
bb72ec7 to
66e951c
Compare
| blocklist: mintBlocklist, | ||
| }); | ||
|
|
||
| type MintPurpose = 'gift-card' | 'transactional'; |
There was a problem hiding this comment.
Yea, but that's in my open PRs for offers. In the agicash PR to support offer mints I exported MintPurpose here. Then here I reexported it as AccountPurpose because spark accounts have a purpose of transactional
| const sourceAccount = getCashuAccountByMintUrl(sourceMintUrl); | ||
|
|
||
| const sourceWallet = getCashuWallet(sourceMintUrl, { | ||
| unit: cashuUnit, |
There was a problem hiding this comment.
The account should have the wallet on it already, why use getCashuWallet here instead of just sourceAccount.wallet?
There was a problem hiding this comment.
good point. I forgot that
There was a problem hiding this comment.
i changed it so that it uses that wallet and calls getCashuWallet only if there is no account for that mint url
| } | ||
|
|
||
| /** | ||
| * Hook to get the method which returns the first cashu account matching a mint URL, or null if not found. |
There was a problem hiding this comment.
What if you have a USD and BTC account with same mint URL?
| @@ -39,6 +40,7 @@ import { type Currency, type CurrencyUnit, Money } from '~/lib/money'; | |||
| import { measureOperation } from '~/lib/performance'; | |||
| import { computeSHA256 } from '~/lib/sha256'; | |||
| import { getSeedPhraseDerivationPath } from '../accounts/account-cryptography'; | |||
There was a problem hiding this comment.
to your comment on importing to shared from non-shared, just btw this does that.
There was a problem hiding this comment.
i know. I noticed that too but didn't want to make unrelated changes now. we need to clean that up and possibly reorganize some other stuff too (e.g. perhaps bunch of stuff from accounts need to go to shared etc)
66e951c to
a5330bd
Compare
Add NUT-21 Clear Auth support so gift card mints can protect endpoints. - Add getAgicashMintAuthProvider in features/shared/agicash-mint-auth-provider.ts with React Query caching (shared across all gift card mints) - Add getMintAuthProvider(purpose) in features/shared/cashu.ts to map account purpose to the appropriate auth provider - Add useGetCashuAccountByMintUrlAndCurrency hook for looking up accounts - Pass auth provider to getCashuWallet for gift card accounts in: account-repository, user-repository, receive hooks, send hooks - Add getWallet callback to useOnMeltQuoteStateChange so callers control wallet construction with auth - Change getInitializedCashuWallet to use named params object - Extract isLoggedIn to features/shared/auth.ts - Delete implementation plan doc Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1a8c5c2 to
839bfb3
Compare
Implements #957