feat(passkey-crypto): add removePasskeyFromWallet function#8646
Open
feat(passkey-crypto): add removePasskeyFromWallet function#8646
Conversation
895e229 to
f01d766
Compare
f01d766 to
834fe16
Compare
9877398 to
4c6a78f
Compare
Contributor
Author
|
@claude review this PR |
mohammadalfaiyazbitgo
requested changes
May 4, 2026
Contributor
mohammadalfaiyazbitgo
left a comment
There was a problem hiding this comment.
can we move this to passkey module?
e6d52f4 to
ebd4c33
Compare
mohammadalfaiyazbitgo
requested changes
May 4, 2026
Comment on lines
+16
to
+36
| // Fetch wallet to infer coin and keychainId | ||
| const walletData = await bitgo.get(bitgo.url(`/wallet/${walletId}`, 2)).result(); | ||
|
|
||
| const coin = walletData.coin; | ||
| if (!coin || typeof coin !== 'string') { | ||
| throw new Error(`Wallet ${walletId} has no coin type. Cannot remove passkey.`); | ||
| } | ||
|
|
||
| const keys = walletData.keys as string[] | undefined; | ||
| if (!keys || keys.length === 0) { | ||
| throw new Error(`Wallet ${walletId} has no keys. Cannot remove passkey.`); | ||
| } | ||
| const keychainId = keys[0]; | ||
|
|
||
| // Fetch user keychain | ||
| const keychain = await bitgo.get(bitgo.url(`/${coin}/key/${keychainId}`, 2)).result(); | ||
|
|
||
| if (!keychain.encryptedPrv) { | ||
| throw new Error(`Keychain ${keychainId} has no encryptedPrv. Cannot verify passphrase before passkey removal.`); | ||
| } | ||
|
|
Contributor
There was a problem hiding this comment.
simplify using the sdk-core methods.
ebd4c33 to
c493bd2
Compare
Removes a WebAuthn passkey credential from a wallet's user keychain. Uses idiomatic sdk-core methods (wallets().get(), keychains().get(), decryptKeychainPrivateKey) instead of raw HTTP calls. Verifies the wallet passphrase before issuing the DELETE to prevent accidental lockout. Validates device.id before proceeding. TICKET: WCN-190
c493bd2 to
18f301a
Compare
mohammadalfaiyazbitgo
requested changes
May 6, 2026
Comment on lines
+43
to
+44
| "@types/proxyquire": "^1.3.31", | ||
| "proxyquire": "^2.1.3" |
Contributor
There was a problem hiding this comment.
you shouldn't need this, you should be able to mock responses via sinon and the other testing utilities we have.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@bitgo/public-typesto 6.1.0 to import canonicalWebAuthnOtpDevicetype (replaces local stub)removePasskeyFromWallet()tomodules/sdk-core/src/bitgo/passkey/device.id, walletcoin, and walletkeysbefore proceedingdecrypt()before issuing any DELETE — wrong passphrase aborts cleanly with no side effects/api/v2/key/{keychainId}/webauthndevice/{device.id}using MongoDB ObjectId (not credentialId)Test plan
device.idencryptedPrv— verifies descriptive error thrown, no decrypt or DELETE calleddevice.id— verifies error thrown, no API calls madeTICKET: WCN-190