@spirobel/monero-wallet-api 0.3.12 → 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";
@@ -63,4 +64,4 @@ export type ShareViewkey002Pruned = {
63
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,7 +223,7 @@ 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;
@@ -234,6 +234,15 @@ export async function handle002ShareRequest(req, parsed_cb, successUrl) {
234
234
  typeof wallet_slot !== "number") {
235
235
  return { ok: false, successUrl: null };
236
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
+ }
237
246
  await parsed_cb({ viewkey, primary_address, wallet_slot });
238
247
  return {
239
248
  ok: true,
package/package.json CHANGED
@@ -40,7 +40,7 @@
40
40
  "clean": "rm -rf ./dist"
41
41
  },
42
42
  "files": ["dist"],
43
- "version": "0.3.12",
43
+ "version": "0.3.13",
44
44
  "devDependencies": {
45
45
  "@types/bun": "latest"
46
46
  },