@spirobel/monero-wallet-api 0.6.15 → 0.6.16
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.
package/dist/tools/content.d.ts
CHANGED
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
type
|
|
2
|
-
sendMessage: (msg: unknown) => Promise<unknown>;
|
|
3
|
-
connect: (info: {
|
|
4
|
-
name: string;
|
|
5
|
-
}) => {
|
|
6
|
-
onMessage: {
|
|
7
|
-
addListener: (cb: (msg: unknown) => void) => void;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
type ExtensionBrowser = {
|
|
12
|
-
runtime: ExtensionRuntime;
|
|
13
|
-
};
|
|
1
|
+
import type { ExtensionBrowser } from "./globals";
|
|
14
2
|
declare global {
|
|
15
3
|
var browser: ExtensionBrowser;
|
|
16
4
|
var chrome: ExtensionBrowser;
|
|
@@ -18,4 +6,3 @@ declare global {
|
|
|
18
6
|
export declare function interceptToolLinkCallback(e: Event): void;
|
|
19
7
|
export declare function deliverToolUrl(url: string): boolean;
|
|
20
8
|
export declare function installToolLinkEventInterception(): void;
|
|
21
|
-
export {};
|
package/dist/tools/globals.d.ts
CHANGED
|
@@ -120,6 +120,7 @@ export type ExtensionRuntime = {
|
|
|
120
120
|
connect: (info: {
|
|
121
121
|
name: string;
|
|
122
122
|
}) => ExtensionPort;
|
|
123
|
+
getURL: (path: string) => string;
|
|
123
124
|
onMessage: {
|
|
124
125
|
addListener: (cb: (msg: unknown, sender: unknown) => void) => void;
|
|
125
126
|
};
|
|
@@ -127,6 +128,21 @@ export type ExtensionRuntime = {
|
|
|
127
128
|
addListener: (cb: (port: ExtensionPort) => void) => void;
|
|
128
129
|
};
|
|
129
130
|
};
|
|
131
|
+
export type ExtensionBrowser = {
|
|
132
|
+
runtime: ExtensionRuntime;
|
|
133
|
+
tabs: {
|
|
134
|
+
query: (query: {
|
|
135
|
+
url?: string;
|
|
136
|
+
}) => Promise<{
|
|
137
|
+
id?: number;
|
|
138
|
+
}[]>;
|
|
139
|
+
remove: (ids: number[]) => Promise<void>;
|
|
140
|
+
update: (id: number, update: {
|
|
141
|
+
url?: string;
|
|
142
|
+
active?: boolean;
|
|
143
|
+
}) => Promise<unknown>;
|
|
144
|
+
};
|
|
145
|
+
};
|
|
130
146
|
export declare function getExtensionRuntime(): ExtensionRuntime | null;
|
|
131
147
|
export declare function sendToBackground<K extends ExtensionMessageKind>(kind: K, payload: ExtensionMessageByKind[K]): Promise<unknown>;
|
|
132
148
|
export type PortMessageByKind = {
|
|
@@ -2,6 +2,7 @@ import { TOOL_MAGIC_STRING, type ToolArm, type ToolInvocationValidity, type Tool
|
|
|
2
2
|
export { TOOL_MAGIC_STRING, type ToolInvocationValidity };
|
|
3
3
|
export type { ToolArm, ToolContentZone, ToolCounterpartyZone, ToolInvocationForValidate, ToolWorkerZone, } from "./globals";
|
|
4
4
|
export type { ToolUiCopy, ToolNotice, ToolPermission, } from "./globals";
|
|
5
|
+
export type { ExtensionRuntime, ExtensionBrowser } from "./globals";
|
|
5
6
|
export declare const tools: {
|
|
6
7
|
readonly "001": ToolArm<import("./calls/001").SendTransactionToolPayload, {
|
|
7
8
|
validate_route: (deps: {
|
|
@@ -28,6 +28,34 @@ function isToolId(id) {
|
|
|
28
28
|
return id in tools;
|
|
29
29
|
}
|
|
30
30
|
export function parseToolLink(link) {
|
|
31
|
+
// the browser can wrap a pasted monero: uri in the search url it built, escaped or plain
|
|
32
|
+
const lower = link.toLowerCase();
|
|
33
|
+
const plain_at = lower.indexOf("monero:");
|
|
34
|
+
const escaped_at = lower.indexOf("monero%3a");
|
|
35
|
+
const legacy_at = plain_at !== -1 ? plain_at : escaped_at;
|
|
36
|
+
if (legacy_at !== -1) {
|
|
37
|
+
try {
|
|
38
|
+
// an escaped uri sits inside one parameter, so the next raw & ends it
|
|
39
|
+
//...?q=monero%3AADDR&source=desktop
|
|
40
|
+
// the pasted uri, ends at &
|
|
41
|
+
const tail = link.slice(legacy_at);
|
|
42
|
+
const uri = new URL(decodeURIComponent(plain_at !== -1 ? tail : tail.split("&")[0] ?? ""));
|
|
43
|
+
const address = uri.pathname;
|
|
44
|
+
const amount = uri.searchParams.get("tx_amount") ?? "";
|
|
45
|
+
if (!/^([1-9A-HJ-NP-Za-km-z]{95}|[1-9A-HJ-NP-Za-km-z]{106})$/.test(address))
|
|
46
|
+
return null;
|
|
47
|
+
if (amount && !/^\d+(?:\.\d{1,12})?$/.test(amount))
|
|
48
|
+
return null;
|
|
49
|
+
// separate payment ids are not supported. do not drop one or choose between amounts.
|
|
50
|
+
if (uri.searchParams.has("tx_payment_id") || uri.searchParams.getAll("tx_amount").length > 1)
|
|
51
|
+
return null;
|
|
52
|
+
return { tool_id: "001", payload: { address, amount, no_check: true } };
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
// a broken monero uri is not a tool call. do not fall through to the marker scan.
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
31
59
|
const magic_str_index = link.lastIndexOf(TOOL_MAGIC_STRING);
|
|
32
60
|
if (magic_str_index === -1)
|
|
33
61
|
return null;
|