Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wombat fallback fix #41

Merged
merged 2 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@wharfkit/wallet-plugin-anchor",
"description": "An Anchor plugin for use with @wharfkit/session.",
"version": "1.2.1",
"version": "1.2.2-rc1",
"homepage": "https://github.com/wharfkit/wallet-plugin-anchor",
"license": "BSD-3-Clause",
"main": "lib/wallet-plugin-anchor.js",
Expand Down
36 changes: 12 additions & 24 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,13 @@ export class WalletPluginAnchor extends AbstractWalletPlugin {

// Await a promise race to wait for either the wallet response or the cancel
const callbackResponse: CallbackPayload = await waitForCallback(callback, this.buoyWs, t)
verifyLoginCallbackResponse(callbackResponse, context)

if (
callbackResponse.link_ch &&
callbackResponse.link_key &&
callbackResponse.link_name &&
callbackResponse.cid
) {
verifyLoginCallbackResponse(callbackResponse, context)
if (!callbackResponse.cid || !callbackResponse.sa || !callbackResponse.sp) {
throw new Error('Invalid callback response')
}

if (callbackResponse.link_ch && callbackResponse.link_key && callbackResponse.link_name) {
this.data.requestKey = requestKey
this.data.privateKey = privateKey
this.data.signerKey =
Expand All @@ -178,24 +176,14 @@ export class WalletPluginAnchor extends AbstractWalletPlugin {
} catch (e) {
// console.log('Error processing link_meta', e)
}
}

return {
chain: Checksum256.from(callbackResponse.cid),
permissionLevel: PermissionLevel.from({
actor: callbackResponse.sa,
permission: callbackResponse.sp,
}),
}
} else {
// Close the prompt
promptResponse.cancel('Invalid response from Anchor.')

throw new Error(
t('error.invalid_response', {
default:
'Invalid response from Anchor, must contain link_ch, link_key, link_name and cid flags.',
})
)
return {
chain: Checksum256.from(callbackResponse.cid),
permissionLevel: PermissionLevel.from({
actor: callbackResponse.sa,
permission: callbackResponse.sp,
}),
}
}

Expand Down
Loading