@spirobel/monero-wallet-api 0.3.11 → 0.3.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ScanSettingOpened } from "../api";
|
|
1
2
|
export declare const TOOL_MAGIC_STRING = "monerochan";
|
|
2
3
|
export declare function parseToolLink(link: string): MoneroTool | null;
|
|
3
4
|
export type ToolInvocationValidity = "valid" | "invalid" | "unverified";
|
|
@@ -60,7 +61,7 @@ export declare function shareViewKey002(payload: ShareViewkeyPayload): Promise<S
|
|
|
60
61
|
export type ShareViewkey002Pruned = {
|
|
61
62
|
viewkey: string;
|
|
62
63
|
primary_address: string;
|
|
63
|
-
wallet_slot:
|
|
64
|
+
wallet_slot: number;
|
|
64
65
|
};
|
|
65
66
|
export declare function potentialSuccessRedirect002(payload: ShareViewkeyPayload): Promise<void>;
|
|
66
|
-
export declare function handle002ShareRequest(req: Request, parsed_cb: (parsed_body: ShareViewkey002Pruned) => Promise<void>, successUrl?: string): Promise<ShareViewkeyResult>;
|
|
67
|
+
export declare function handle002ShareRequest(req: Request, wallets: ScanSettingOpened[], parsed_cb: (parsed_body: ShareViewkey002Pruned) => Promise<void>, successUrl?: string): Promise<ShareViewkeyResult>;
|
|
@@ -223,19 +223,26 @@ export async function potentialSuccessRedirect002(payload) {
|
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
// backend response
|
|
226
|
-
export async function handle002ShareRequest(req, parsed_cb, successUrl) {
|
|
226
|
+
export async function handle002ShareRequest(req, wallets, parsed_cb, successUrl) {
|
|
227
227
|
try {
|
|
228
228
|
const json_body = await req.json();
|
|
229
229
|
const { viewkey, primary_address, wallet_slot } = json_body;
|
|
230
|
-
if (Number.isNaN(parseInt(wallet_slot))) {
|
|
231
|
-
return { ok: false, successUrl: null };
|
|
232
|
-
}
|
|
233
230
|
if (typeof viewkey !== "string" ||
|
|
234
231
|
viewkey.trim().length === 0 ||
|
|
235
232
|
typeof primary_address !== "string" ||
|
|
236
|
-
primary_address.trim().length === 0
|
|
233
|
+
primary_address.trim().length === 0 ||
|
|
234
|
+
typeof wallet_slot !== "number") {
|
|
237
235
|
return { ok: false, successUrl: null };
|
|
238
236
|
}
|
|
237
|
+
const foundSlot = wallets.find((wallet) => wallet.wallet_slot === wallet_slot);
|
|
238
|
+
if (foundSlot) {
|
|
239
|
+
if (foundSlot.primary_address !== primary_address) {
|
|
240
|
+
return { ok: false, successUrl: null };
|
|
241
|
+
}
|
|
242
|
+
if (foundSlot.secret_view_key !== viewkey) {
|
|
243
|
+
return { ok: false, successUrl: null };
|
|
244
|
+
}
|
|
245
|
+
}
|
|
239
246
|
await parsed_cb({ viewkey, primary_address, wallet_slot });
|
|
240
247
|
return {
|
|
241
248
|
ok: true,
|