@spirobel/monero-wallet-api 0.5.4 → 0.6.0

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.
Files changed (91) hide show
  1. package/dist/actionlog/actionLogOpened.d.ts +96 -1
  2. package/dist/actionlog/actionLogOpened.js +386 -1
  3. package/dist/actionlog/actionLogTypes.d.ts +114 -0
  4. package/dist/actionlog/actionLogTypes.js +198 -0
  5. package/dist/actionlog/backend/idbBackend.d.ts +13 -0
  6. package/dist/actionlog/backend/idbBackend.js +109 -0
  7. package/dist/actionlog/backend/jsonlBackend.d.ts +19 -0
  8. package/dist/actionlog/backend/jsonlBackend.js +110 -0
  9. package/dist/actionlog/backend/memoryBackend.d.ts +11 -0
  10. package/dist/actionlog/backend/memoryBackend.js +31 -0
  11. package/dist/actionlog/backend/sqliteBackend.d.ts +14 -0
  12. package/dist/actionlog/backend/sqliteBackend.js +96 -0
  13. package/dist/actionlog/backend.d.ts +12 -0
  14. package/dist/actionlog/backend.js +1 -0
  15. package/dist/actionlog/idbBackend.d.ts +19 -0
  16. package/dist/actionlog/idbBackend.js +98 -0
  17. package/dist/actionlog/jsonlBackend.d.ts +19 -0
  18. package/dist/actionlog/jsonlBackend.js +75 -0
  19. package/dist/actionlog/memoryBackend.d.ts +14 -0
  20. package/dist/actionlog/memoryBackend.js +38 -0
  21. package/dist/actionlog/openMaps.d.ts +11 -0
  22. package/dist/actionlog/openMaps.js +32 -0
  23. package/dist/actionlog/sqliteBackend.d.ts +18 -0
  24. package/dist/actionlog/sqliteBackend.js +105 -0
  25. package/dist/actionlog/toolContext.d.ts +36 -0
  26. package/dist/actionlog/toolContext.js +1 -0
  27. package/dist/actionlog/types.d.ts +62 -0
  28. package/dist/actionlog/types.js +62 -0
  29. package/dist/api.d.ts +4 -0
  30. package/dist/api.js +3 -0
  31. package/dist/io/sleep.d.ts +1 -1
  32. package/dist/io/sleep.js +16 -1
  33. package/dist/scanning-syncing/backgroundWorker.d.ts +2 -0
  34. package/dist/scanning-syncing/backgroundWorker.js +92 -10
  35. package/dist/scanning-syncing/blocksbuffer/blocksBufferFetchLoop.js +33 -2
  36. package/dist/scanning-syncing/blocksbuffer/blocksbufferCoordination.js +2 -2
  37. package/dist/scanning-syncing/connectionStatus.d.ts +8 -0
  38. package/dist/scanning-syncing/connectionStatus.js +50 -0
  39. package/dist/scanning-syncing/connectionStatusOpened.d.ts +3 -1
  40. package/dist/scanning-syncing/connectionStatusOpened.js +22 -14
  41. package/dist/scanning-syncing/openWallet.d.ts +4 -1
  42. package/dist/scanning-syncing/openWallet.js +3 -0
  43. package/dist/scanning-syncing/scanresult/scanCache.d.ts +5 -1
  44. package/dist/scanning-syncing/scanresult/scanCache.js +11 -2
  45. package/dist/scanning-syncing/scanresult/scanCacheOpened.d.ts +56 -5
  46. package/dist/scanning-syncing/scanresult/scanCacheOpened.js +422 -83
  47. package/dist/scanning-syncing/scanresult/scanCoordination.d.ts +7 -3
  48. package/dist/scanning-syncing/scanresult/scanCoordination.js +126 -28
  49. package/dist/scanning-syncing/scanresult/scanLoop.d.ts +1 -2
  50. package/dist/scanning-syncing/scanresult/scanLoop.js +0 -13
  51. package/dist/scanning-syncing/scanresult/scanResult.js +17 -12
  52. package/dist/scanning-syncing/scanresult/scanStats.js +8 -5
  53. package/dist/scanning-syncing/worker-entrypoints/worker.js +1 -1
  54. package/dist/scanning-syncing/worker-mains/coordinator-main.d.ts +1 -0
  55. package/dist/scanning-syncing/worker-mains/coordinator-main.js +16 -1
  56. package/dist/scanning-syncing/worker-mains/cpubound-main.js +3 -2
  57. package/dist/scanning-syncing/worker-mains/worker.js +45 -2
  58. package/dist/tools/calls/001.d.ts +20 -0
  59. package/dist/tools/calls/001.js +236 -0
  60. package/dist/tools/calls/002-content.d.ts +46 -0
  61. package/dist/tools/calls/002-content.js +135 -0
  62. package/dist/tools/calls/002-fail-cleanup.d.ts +27 -0
  63. package/dist/tools/calls/002-fail-cleanup.js +60 -0
  64. package/dist/tools/calls/002.d.ts +64 -0
  65. package/dist/tools/calls/002.js +353 -0
  66. package/dist/tools/content.d.ts +22 -0
  67. package/dist/tools/content.js +41 -0
  68. package/dist/tools/counterparty.d.ts +3 -0
  69. package/dist/tools/counterparty.js +1 -0
  70. package/dist/tools/download-public-suffix.d.ts +1 -0
  71. package/dist/tools/download-public-suffix.js +20 -0
  72. package/dist/tools/globals.d.ts +196 -0
  73. package/dist/tools/globals.js +14 -0
  74. package/dist/tools/monero-tools-content.d.ts +29 -0
  75. package/dist/tools/monero-tools-content.js +80 -0
  76. package/dist/tools/monero-tools.d.ts +27 -52
  77. package/dist/tools/monero-tools.js +127 -222
  78. package/dist/tools/public-suffix-list.d.ts +1 -0
  79. package/dist/tools/public-suffix-list.js +10336 -0
  80. package/dist/tools/runtimeMessages.d.ts +4 -0
  81. package/dist/tools/runtimeMessages.js +18 -0
  82. package/dist/tools/toolActionLogContext.d.ts +33 -0
  83. package/dist/tools/toolActionLogContext.js +1 -0
  84. package/dist/tools/toolArm.d.ts +47 -0
  85. package/dist/tools/toolArm.js +1 -0
  86. package/dist/tools/ui.d.ts +2 -0
  87. package/dist/tools/ui.js +1 -0
  88. package/dist/tools/worker.d.ts +1 -0
  89. package/dist/tools/worker.js +1 -0
  90. package/dist/wasm-processing/wasmFile.js +2 -2
  91. package/package.json +8 -1
@@ -0,0 +1,98 @@
1
+ import { OpenInvocationMaps } from "./openMaps";
2
+ const DB_NAME_DEFAULT = "monero-actionlog";
3
+ const STORE_EVENTS = "events";
4
+ export class ActionLogIdbBackend {
5
+ db;
6
+ open = new OpenInvocationMaps();
7
+ constructor(db) {
8
+ this.db = db;
9
+ }
10
+ static async open(dbName = DB_NAME_DEFAULT) {
11
+ if (typeof indexedDB === "undefined") {
12
+ throw new Error("IndexedDB not available");
13
+ }
14
+ const db = await openDb(dbName);
15
+ const backend = new ActionLogIdbBackend(db);
16
+ await backend.rebuildOpenMaps();
17
+ return backend;
18
+ }
19
+ async rebuildOpenMaps() {
20
+ this.open.clear();
21
+ const events = await this.getAllEventsOrdered();
22
+ for (const event of events)
23
+ this.open.apply(event);
24
+ }
25
+ getAllEventsOrdered() {
26
+ return new Promise((resolve, reject) => {
27
+ const tx = this.db.transaction(STORE_EVENTS, "readonly");
28
+ const store = tx.objectStore(STORE_EVENTS);
29
+ const req = store.getAll();
30
+ req.onerror = () => reject(req.error);
31
+ req.onsuccess = () => {
32
+ const rows = req.result ?? [];
33
+ rows.sort((a, b) => a.timestamp.localeCompare(b.timestamp));
34
+ resolve(rows);
35
+ };
36
+ });
37
+ }
38
+ async append(event) {
39
+ await new Promise((resolve, reject) => {
40
+ const tx = this.db.transaction(STORE_EVENTS, "readwrite");
41
+ const store = tx.objectStore(STORE_EVENTS);
42
+ const req = store.put(event);
43
+ req.onerror = () => reject(req.error);
44
+ req.onsuccess = () => resolve();
45
+ });
46
+ this.open.apply(event);
47
+ }
48
+ async getBranch(invocationId) {
49
+ return new Promise((resolve, reject) => {
50
+ const tx = this.db.transaction(STORE_EVENTS, "readonly");
51
+ const store = tx.objectStore(STORE_EVENTS);
52
+ const index = store.index("invocationId");
53
+ const req = index.getAll(invocationId);
54
+ req.onerror = () => reject(req.error);
55
+ req.onsuccess = () => {
56
+ const rows = req.result ?? [];
57
+ rows.sort((a, b) => a.timestamp.localeCompare(b.timestamp));
58
+ resolve(rows);
59
+ };
60
+ });
61
+ }
62
+ async getTip(invocationId) {
63
+ const branch = await this.getBranch(invocationId);
64
+ return branch.length ? branch[branch.length - 1] : null;
65
+ }
66
+ async getOpenByToolId(toolId) {
67
+ return this.open.getOpenByToolId(toolId);
68
+ }
69
+ async getOpenInvocations() {
70
+ return this.open.getOpenInvocations();
71
+ }
72
+ async feed(events) {
73
+ for (const event of events)
74
+ await this.append(event);
75
+ }
76
+ async reload() {
77
+ await this.rebuildOpenMaps();
78
+ }
79
+ async close() {
80
+ this.db.close();
81
+ }
82
+ }
83
+ function openDb(name) {
84
+ return new Promise((resolve, reject) => {
85
+ const req = indexedDB.open(name, 1);
86
+ req.onerror = () => reject(req.error);
87
+ req.onupgradeneeded = () => {
88
+ const db = req.result;
89
+ if (!db.objectStoreNames.contains(STORE_EVENTS)) {
90
+ const store = db.createObjectStore(STORE_EVENTS, { keyPath: "id" });
91
+ store.createIndex("invocationId", "invocationId", { unique: false });
92
+ store.createIndex("toolId", "toolId", { unique: false });
93
+ store.createIndex("timestamp", "timestamp", { unique: false });
94
+ }
95
+ };
96
+ req.onsuccess = () => resolve(req.result);
97
+ });
98
+ }
@@ -0,0 +1,19 @@
1
+ import type { ActionLogBackend } from "./backend";
2
+ import type { ActionLogEvent, OpenInvocationState } from "./types";
3
+ import type { ToolId } from "../tools/monero-tools";
4
+ export declare class ActionLogJsonlBackend implements ActionLogBackend {
5
+ private readonly path;
6
+ private events;
7
+ private open;
8
+ constructor(path: string);
9
+ static open(path: string): Promise<ActionLogJsonlBackend>;
10
+ private load;
11
+ private persist;
12
+ append(event: ActionLogEvent): Promise<void>;
13
+ getBranch(invocationId: string): Promise<ActionLogEvent[]>;
14
+ getTip(invocationId: string): Promise<ActionLogEvent | null>;
15
+ getOpenByToolId(toolId: ToolId): Promise<OpenInvocationState | null>;
16
+ getOpenInvocations(): Promise<OpenInvocationState[]>;
17
+ feed(events: ActionLogEvent[]): Promise<void>;
18
+ reload(): Promise<void>;
19
+ }
@@ -0,0 +1,75 @@
1
+ import { atomicWrite } from "../io/atomicWrite";
2
+ import { OpenInvocationMaps } from "./openMaps";
3
+ export class ActionLogJsonlBackend {
4
+ path;
5
+ events = [];
6
+ open = new OpenInvocationMaps();
7
+ constructor(path) {
8
+ this.path = path;
9
+ }
10
+ static async open(path) {
11
+ const backend = new ActionLogJsonlBackend(path);
12
+ await backend.load();
13
+ return backend;
14
+ }
15
+ async load() {
16
+ const text = await Bun.file(this.path)
17
+ .text()
18
+ .catch(() => "");
19
+ this.events = [];
20
+ this.open.clear();
21
+ if (!text.trim())
22
+ return;
23
+ for (const line of text.split("\n")) {
24
+ const t = line.trim();
25
+ if (!t)
26
+ continue;
27
+ try {
28
+ const event = JSON.parse(t);
29
+ this.events.push(event);
30
+ this.open.apply(event);
31
+ }
32
+ catch {
33
+ // skip bad line
34
+ }
35
+ }
36
+ }
37
+ async persist() {
38
+ const body = this.events.map((e) => JSON.stringify(e)).join("\n") +
39
+ (this.events.length ? "\n" : "");
40
+ await atomicWrite(this.path, body);
41
+ }
42
+ async append(event) {
43
+ this.events.push(event);
44
+ this.open.apply(event);
45
+ await this.persist();
46
+ }
47
+ async getBranch(invocationId) {
48
+ return this.events.filter((e) => e.invocationId === invocationId);
49
+ }
50
+ async getTip(invocationId) {
51
+ for (let i = this.events.length - 1; i >= 0; i--) {
52
+ if (this.events[i].invocationId === invocationId)
53
+ return this.events[i];
54
+ }
55
+ return null;
56
+ }
57
+ async getOpenByToolId(toolId) {
58
+ return this.open.getOpenByToolId(toolId);
59
+ }
60
+ async getOpenInvocations() {
61
+ return this.open.getOpenInvocations();
62
+ }
63
+ async feed(events) {
64
+ for (const event of events) {
65
+ if (this.events.some((e) => e.id === event.id))
66
+ continue;
67
+ this.events.push(event);
68
+ this.open.apply(event);
69
+ }
70
+ await this.persist();
71
+ }
72
+ async reload() {
73
+ await this.load();
74
+ }
75
+ }
@@ -0,0 +1,14 @@
1
+ import type { ActionLogBackend } from "./backend";
2
+ import type { ActionLogEvent, OpenInvocationState } from "./types";
3
+ import type { ToolId } from "../tools/monero-tools";
4
+ export declare class ActionLogMemoryBackend implements ActionLogBackend {
5
+ private events;
6
+ private open;
7
+ append(event: ActionLogEvent): Promise<void>;
8
+ getBranch(invocationId: string): Promise<ActionLogEvent[]>;
9
+ getTip(invocationId: string): Promise<ActionLogEvent | null>;
10
+ getOpenByToolId(toolId: ToolId): Promise<OpenInvocationState | null>;
11
+ getOpenInvocations(): Promise<OpenInvocationState[]>;
12
+ feed(events: ActionLogEvent[]): Promise<void>;
13
+ reload(): Promise<void>;
14
+ }
@@ -0,0 +1,38 @@
1
+ import { OpenInvocationMaps } from "./openMaps";
2
+ export class ActionLogMemoryBackend {
3
+ events = [];
4
+ open = new OpenInvocationMaps();
5
+ async append(event) {
6
+ this.events.push(event);
7
+ this.open.apply(event);
8
+ }
9
+ async getBranch(invocationId) {
10
+ return this.events.filter((e) => e.invocationId === invocationId);
11
+ }
12
+ async getTip(invocationId) {
13
+ for (let i = this.events.length - 1; i >= 0; i--) {
14
+ if (this.events[i].invocationId === invocationId)
15
+ return this.events[i];
16
+ }
17
+ return null;
18
+ }
19
+ async getOpenByToolId(toolId) {
20
+ return this.open.getOpenByToolId(toolId);
21
+ }
22
+ async getOpenInvocations() {
23
+ return this.open.getOpenInvocations();
24
+ }
25
+ async feed(events) {
26
+ for (const event of events) {
27
+ if (this.events.some((e) => e.id === event.id))
28
+ continue;
29
+ this.events.push(event);
30
+ this.open.apply(event);
31
+ }
32
+ }
33
+ async reload() {
34
+ this.open.clear();
35
+ for (const event of this.events)
36
+ this.open.apply(event);
37
+ }
38
+ }
@@ -0,0 +1,11 @@
1
+ import type { ToolId } from "../tools/monero-tools";
2
+ import { type ActionLogEvent, type OpenInvocationState } from "./types";
3
+ /** shared open-invocation maps for backends without a native secondary index */
4
+ export declare class OpenInvocationMaps {
5
+ byInvocation: Map<string, OpenInvocationState>;
6
+ byTool: Map<"001" | "002", string>;
7
+ apply(event: ActionLogEvent): void;
8
+ clear(): void;
9
+ getOpenByToolId(toolId: ToolId): OpenInvocationState | null;
10
+ getOpenInvocations(): OpenInvocationState[];
11
+ }
@@ -0,0 +1,32 @@
1
+ import { applyEventToState, isTerminalEventType, } from "./types";
2
+ /** shared open-invocation maps for backends without a native secondary index */
3
+ export class OpenInvocationMaps {
4
+ byInvocation = new Map();
5
+ byTool = new Map();
6
+ apply(event) {
7
+ const prev = this.byInvocation.get(event.invocationId) ?? null;
8
+ const next = applyEventToState(prev, event);
9
+ if (isTerminalEventType(event.type)) {
10
+ this.byInvocation.delete(event.invocationId);
11
+ if (this.byTool.get(event.toolId) === event.invocationId) {
12
+ this.byTool.delete(event.toolId);
13
+ }
14
+ return;
15
+ }
16
+ this.byInvocation.set(event.invocationId, next);
17
+ this.byTool.set(event.toolId, event.invocationId);
18
+ }
19
+ clear() {
20
+ this.byInvocation.clear();
21
+ this.byTool.clear();
22
+ }
23
+ getOpenByToolId(toolId) {
24
+ const id = this.byTool.get(toolId);
25
+ if (!id)
26
+ return null;
27
+ return this.byInvocation.get(id) ?? null;
28
+ }
29
+ getOpenInvocations() {
30
+ return [...this.byInvocation.values()];
31
+ }
32
+ }
@@ -0,0 +1,18 @@
1
+ import type { ActionLogBackend } from "./backend";
2
+ import type { ActionLogEvent, OpenInvocationState } from "./types";
3
+ import type { ToolId } from "../tools/monero-tools";
4
+ /** bun-only sqlite backend. do not import from browser worker graphs. */
5
+ export declare class ActionLogSqliteBackend implements ActionLogBackend {
6
+ private open;
7
+ private sql;
8
+ private constructor();
9
+ static open(filename: string): Promise<ActionLogSqliteBackend>;
10
+ private rebuildOpenMaps;
11
+ append(event: ActionLogEvent): Promise<void>;
12
+ getBranch(invocationId: string): Promise<ActionLogEvent[]>;
13
+ getTip(invocationId: string): Promise<ActionLogEvent | null>;
14
+ getOpenByToolId(toolId: ToolId): Promise<OpenInvocationState | null>;
15
+ getOpenInvocations(): Promise<OpenInvocationState[]>;
16
+ feed(events: ActionLogEvent[]): Promise<void>;
17
+ reload(): Promise<void>;
18
+ }
@@ -0,0 +1,105 @@
1
+ import { OpenInvocationMaps } from "./openMaps";
2
+ /** bun-only sqlite backend. do not import from browser worker graphs. */
3
+ export class ActionLogSqliteBackend {
4
+ open = new OpenInvocationMaps();
5
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
+ sql;
7
+ constructor(sql) {
8
+ this.sql = sql;
9
+ }
10
+ static async open(filename) {
11
+ const { SQL } = await import("bun");
12
+ const sql = new SQL({
13
+ adapter: "sqlite",
14
+ filename,
15
+ create: true,
16
+ });
17
+ await sql `PRAGMA journal_mode = WAL`;
18
+ await sql `
19
+ CREATE TABLE IF NOT EXISTS actionlog_events (
20
+ id TEXT PRIMARY KEY,
21
+ timestamp TEXT NOT NULL,
22
+ invocationId TEXT NOT NULL,
23
+ stage TEXT NOT NULL,
24
+ type TEXT NOT NULL,
25
+ toolId TEXT NOT NULL,
26
+ body TEXT NOT NULL
27
+ )
28
+ `;
29
+ await sql `
30
+ CREATE INDEX IF NOT EXISTS idx_actionlog_invocation
31
+ ON actionlog_events (invocationId)
32
+ `;
33
+ await sql `
34
+ CREATE INDEX IF NOT EXISTS idx_actionlog_tool
35
+ ON actionlog_events (toolId)
36
+ `;
37
+ await sql `
38
+ CREATE INDEX IF NOT EXISTS idx_actionlog_invocation_ts
39
+ ON actionlog_events (invocationId, timestamp)
40
+ `;
41
+ const backend = new ActionLogSqliteBackend(sql);
42
+ await backend.rebuildOpenMaps();
43
+ return backend;
44
+ }
45
+ async rebuildOpenMaps() {
46
+ this.open.clear();
47
+ const rows = (await this.sql `
48
+ SELECT body FROM actionlog_events ORDER BY rowid ASC
49
+ `);
50
+ if (!Array.isArray(rows))
51
+ return;
52
+ for (const row of rows) {
53
+ this.open.apply(JSON.parse(row.body));
54
+ }
55
+ }
56
+ async append(event) {
57
+ const body = JSON.stringify(event);
58
+ await this.sql `
59
+ INSERT INTO actionlog_events (id, timestamp, invocationId, stage, type, toolId, body)
60
+ VALUES (
61
+ ${event.id},
62
+ ${event.timestamp},
63
+ ${event.invocationId},
64
+ ${event.stage},
65
+ ${event.type},
66
+ ${event.toolId},
67
+ ${body}
68
+ )
69
+ `;
70
+ this.open.apply(event);
71
+ }
72
+ async getBranch(invocationId) {
73
+ const rows = (await this.sql `
74
+ SELECT body FROM actionlog_events
75
+ WHERE invocationId = ${invocationId}
76
+ ORDER BY rowid ASC
77
+ `);
78
+ if (!Array.isArray(rows))
79
+ return [];
80
+ return rows.map((r) => JSON.parse(r.body));
81
+ }
82
+ async getTip(invocationId) {
83
+ const branch = await this.getBranch(invocationId);
84
+ return branch.length ? branch[branch.length - 1] : null;
85
+ }
86
+ async getOpenByToolId(toolId) {
87
+ return this.open.getOpenByToolId(toolId);
88
+ }
89
+ async getOpenInvocations() {
90
+ return this.open.getOpenInvocations();
91
+ }
92
+ async feed(events) {
93
+ for (const event of events) {
94
+ try {
95
+ await this.append(event);
96
+ }
97
+ catch {
98
+ // skip duplicate
99
+ }
100
+ }
101
+ }
102
+ async reload() {
103
+ await this.rebuildOpenMaps();
104
+ }
105
+ }
@@ -0,0 +1,36 @@
1
+ import type { ActionLogEvent, ActionLogOpened } from "./actionLogOpened";
2
+ import type { ToolPermission } from "./types";
3
+ /** durable plate notice — title/message are tool-owned STE text */
4
+ export type ToolNotice = {
5
+ id: string;
6
+ permission: ToolPermission;
7
+ /** short STE title for the notice plate hole */
8
+ title: string;
9
+ /** full STE body for the notice plate hole */
10
+ message: string;
11
+ context_domain?: string;
12
+ context_href?: string;
13
+ wallet_slot?: number;
14
+ timestamp?: number | string;
15
+ };
16
+ /** static STE strings for open-invocation plate holes */
17
+ export type ToolUiCopy = {
18
+ openTitle: string;
19
+ acceptLabel?: string;
20
+ dismissLabel?: string;
21
+ };
22
+ /**
23
+ * context ActionLog passes into per-tool actionlog writers.
24
+ * lives next to ActionLog — tools import this, not the other way around for placement.
25
+ */
26
+ export type ToolActionLogContext = {
27
+ log: ActionLogOpened;
28
+ getWallets?: () => unknown;
29
+ /** host reopens wallets after tool changes scan settings */
30
+ reloadWallets?: () => void | Promise<void>;
31
+ getPort: (invocationId: string) => {
32
+ postMessage: (msg: unknown) => void;
33
+ } | undefined;
34
+ postToPort: (invocationId: string, msg: unknown) => void;
35
+ broadcast: (events: ActionLogEvent[]) => void;
36
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,62 @@
1
+ import type { ToolId } from "../tools/monero-tools";
2
+ import type { ExtensionPort, ToolInvocationValidity, ToolPermission } from "../tools/globals";
3
+ import type { ActionLogOpened } from "./actionLogOpened";
4
+ export type { ToolPermission };
5
+ export type ActionLogEventType = "session_start" | "validate_start" | "validate_result" | "accept" | "dismiss" | "execute_start" | "execute_error" | "execute_result" | "aborted";
6
+ export type ActionLogStage = "recognized" | "invoked" | "validated" | "accepted" | "executed";
7
+ export type ActionLogEvent = {
8
+ type: ActionLogEventType;
9
+ id: string;
10
+ timestamp: string;
11
+ invocationId: string;
12
+ stage: ActionLogStage;
13
+ toolId: ToolId;
14
+ valid?: ToolInvocationValidity;
15
+ amount?: string;
16
+ address?: string;
17
+ no_check?: boolean;
18
+ wallet_slot?: number;
19
+ context_domain?: string;
20
+ destination_domain?: string;
21
+ context_href?: string;
22
+ found_in?: "link" | "linkText";
23
+ link?: string;
24
+ linkText?: string;
25
+ wallet_to_send_from_pa?: string;
26
+ ok?: boolean;
27
+ error?: string;
28
+ [key: string]: unknown;
29
+ };
30
+ export type OpenInvocationState = {
31
+ invocationId: string;
32
+ toolId: ToolId;
33
+ stage: ActionLogStage;
34
+ lastType: ActionLogEventType;
35
+ valid?: ToolInvocationValidity;
36
+ amount?: string;
37
+ address?: string;
38
+ no_check?: boolean;
39
+ wallet_slot?: number;
40
+ context_domain?: string;
41
+ destination_domain?: string;
42
+ context_href?: string;
43
+ found_in?: "link" | "linkText";
44
+ link?: string;
45
+ linkText?: string;
46
+ timestamp?: string;
47
+ wallet_to_send_from_pa?: string;
48
+ ok?: boolean;
49
+ error?: string;
50
+ };
51
+ export declare const TERMINAL_EVENT_TYPES: ReadonlySet<ActionLogEventType>;
52
+ export declare function isTerminalEventType(type: ActionLogEventType): boolean;
53
+ export declare function newEventId(): string;
54
+ export declare function nowTimestamp(): string;
55
+ export type ToolWorkerContext = {
56
+ log: ActionLogOpened;
57
+ getWallets?: () => unknown;
58
+ reloadWallets?: () => void | Promise<void>;
59
+ getPort: (invocationId: string) => ExtensionPort | undefined;
60
+ };
61
+ export declare function applyEventToState(prev: OpenInvocationState | null, event: ActionLogEvent): OpenInvocationState;
62
+ export declare function isOpenState(state: OpenInvocationState): boolean;
@@ -0,0 +1,62 @@
1
+ export const TERMINAL_EVENT_TYPES = new Set([
2
+ "dismiss",
3
+ "execute_result",
4
+ "aborted",
5
+ ]);
6
+ export function isTerminalEventType(type) {
7
+ return TERMINAL_EVENT_TYPES.has(type);
8
+ }
9
+ export function newEventId() {
10
+ return crypto.randomUUID();
11
+ }
12
+ export function nowTimestamp() {
13
+ return new Date().toISOString();
14
+ }
15
+ export function applyEventToState(prev, event) {
16
+ const base = prev ?? {
17
+ invocationId: event.invocationId,
18
+ toolId: event.toolId,
19
+ stage: event.stage,
20
+ lastType: event.type,
21
+ };
22
+ const next = {
23
+ ...base,
24
+ invocationId: event.invocationId,
25
+ toolId: event.toolId,
26
+ stage: event.stage,
27
+ lastType: event.type,
28
+ timestamp: event.timestamp,
29
+ };
30
+ if (event.valid !== undefined)
31
+ next.valid = event.valid;
32
+ if (event.amount !== undefined)
33
+ next.amount = event.amount;
34
+ if (event.address !== undefined)
35
+ next.address = event.address;
36
+ if (event.no_check !== undefined)
37
+ next.no_check = event.no_check;
38
+ if (event.wallet_slot !== undefined)
39
+ next.wallet_slot = event.wallet_slot;
40
+ if (event.context_domain !== undefined)
41
+ next.context_domain = event.context_domain;
42
+ if (event.destination_domain !== undefined)
43
+ next.destination_domain = event.destination_domain;
44
+ if (event.context_href !== undefined)
45
+ next.context_href = event.context_href;
46
+ if (event.found_in !== undefined)
47
+ next.found_in = event.found_in;
48
+ if (event.link !== undefined)
49
+ next.link = event.link;
50
+ if (event.linkText !== undefined)
51
+ next.linkText = event.linkText;
52
+ if (event.wallet_to_send_from_pa !== undefined)
53
+ next.wallet_to_send_from_pa = event.wallet_to_send_from_pa;
54
+ if (event.ok !== undefined)
55
+ next.ok = event.ok;
56
+ if (event.error !== undefined)
57
+ next.error = event.error;
58
+ return next;
59
+ }
60
+ export function isOpenState(state) {
61
+ return !isTerminalEventType(state.lastType);
62
+ }
package/dist/api.d.ts CHANGED
@@ -8,6 +8,7 @@ export * from "./node-interaction/jsonEndpoints";
8
8
  export * from "./io/readDir";
9
9
  export * from "./io/atomicWrite";
10
10
  export * from "./io/sleep";
11
+ export { LOGGING_FUNCTIONS, type PossibleLogs, type LogSetting, } from "./io/logging";
11
12
  export { signTransaction, parseAddress, type ParsedAddress, type ParseAddressError, } from "./send-functionality/transactionBuilding";
12
13
  export { computeKeyImage } from "./scanning-syncing/scanresult/computeKeyImage";
13
14
  export * from "./multisig/multisig";
@@ -21,6 +22,7 @@ export * from "./scanning-syncing/blocksbuffer/blocksBufferFetchLoop";
21
22
  export * from "./scanning-syncing/blocksbuffer/blocksbufferCoordination";
22
23
  export * from "./scanning-syncing/connectionStatus";
23
24
  export { ConnectionStatusOpened } from "./scanning-syncing/connectionStatusOpened";
25
+ export { ActionLogOpened, type ActionLogOpenedCreateOptions, type ActionLogBackendKind, type ActionLogEvent, type ActionLogEventType, type ActionLogStage, Invocation, type InvocationDisplayStatus, type InvocationState, type ToolPermission, type ToolNotice, type ToolUiCopy, type ToolWorkerContext, } from "./actionlog/actionLogOpened";
24
26
  export * from "./scansettings/scanSettings";
25
27
  export { ScanSettingsOpened } from "./scansettings/scanSettingsOpened";
26
28
  export * from "./scanning-syncing/scanresult/scanResult";
@@ -33,3 +35,5 @@ export * from "./keypairs-seeds/keypairs";
33
35
  export * from "./send-functionality/conversion";
34
36
  export * from "./send-functionality/inputSelection";
35
37
  export * from "./tools/monero-tools";
38
+ export type { ToolArm, ToolContentZone, ToolCounterpartyZone, ToolWorkerZone, ToolInvocationForValidate, } from "./tools/globals";
39
+ export { sendToBackground } from "./tools/globals";
package/dist/api.js CHANGED
@@ -7,6 +7,7 @@ export * from "./node-interaction/jsonEndpoints";
7
7
  export * from "./io/readDir";
8
8
  export * from "./io/atomicWrite";
9
9
  export * from "./io/sleep";
10
+ export { LOGGING_FUNCTIONS, } from "./io/logging";
10
11
  export { signTransaction, parseAddress, } from "./send-functionality/transactionBuilding";
11
12
  export { computeKeyImage } from "./scanning-syncing/scanresult/computeKeyImage";
12
13
  export * from "./multisig/multisig";
@@ -20,6 +21,7 @@ export * from "./scanning-syncing/blocksbuffer/blocksBufferFetchLoop";
20
21
  export * from "./scanning-syncing/blocksbuffer/blocksbufferCoordination";
21
22
  export * from "./scanning-syncing/connectionStatus";
22
23
  export { ConnectionStatusOpened } from "./scanning-syncing/connectionStatusOpened";
24
+ export { ActionLogOpened, Invocation, } from "./actionlog/actionLogOpened";
23
25
  export * from "./scansettings/scanSettings";
24
26
  export { ScanSettingsOpened } from "./scansettings/scanSettingsOpened";
25
27
  export * from "./scanning-syncing/scanresult/scanResult";
@@ -32,3 +34,4 @@ export * from "./keypairs-seeds/keypairs";
32
34
  export * from "./send-functionality/conversion";
33
35
  export * from "./send-functionality/inputSelection";
34
36
  export * from "./tools/monero-tools";
37
+ export { sendToBackground } from "./tools/globals";
@@ -1 +1 @@
1
- export declare const sleep: (ms: number) => Promise<unknown>;
1
+ export declare const sleep: (ms: number, signal?: AbortSignal) => Promise<void>;
package/dist/io/sleep.js CHANGED
@@ -1 +1,16 @@
1
- export const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
1
+ export const sleep = (ms, signal) => new Promise((resolve, reject) => {
2
+ if (signal?.aborted) {
3
+ reject(signal.reason ?? new DOMException("aborted", "AbortError"));
4
+ return;
5
+ }
6
+ const onAbort = () => {
7
+ clearTimeout(timer);
8
+ signal?.removeEventListener("abort", onAbort);
9
+ reject(signal?.reason ?? new DOMException("aborted", "AbortError"));
10
+ };
11
+ const timer = setTimeout(() => {
12
+ signal?.removeEventListener("abort", onAbort);
13
+ resolve();
14
+ }, ms);
15
+ signal?.addEventListener("abort", onAbort, { once: true });
16
+ });
@@ -3,7 +3,9 @@ export declare const CPU_POOL_SIZE = 4;
3
3
  export type WorkerSet = {
4
4
  fetchWorker: Worker;
5
5
  cpuWorkers: Worker[];
6
+ shutdown: (timeoutMs?: number) => Promise<void>;
6
7
  terminate: () => void;
8
+ dumpHeaps: (dir?: string) => Promise<string[]>;
7
9
  };
8
10
  export declare function createWebworker(handle_result?: (result: CacheChangedCallbackParameters) => void, scan_settings_path?: string, pathPrefix?: string, handle_error?: (error: unknown) => void): Promise<WorkerSet | undefined>;
9
11
  export declare function makeWebworkerScript(): string;