@btc-vision/bitcoin 7.0.0-alpha.4 → 7.0.0-alpha.6
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/browser/chunks/index.browser-CEpt3zCD.js +10742 -0
- package/browser/index.d.ts +1 -1
- package/browser/index.d.ts.map +1 -1
- package/browser/index.js +1886 -12608
- package/browser/workers/index.browser.d.ts +16 -0
- package/browser/workers/index.browser.d.ts.map +1 -0
- package/browser/workers/index.d.ts +3 -16
- package/browser/workers/index.d.ts.map +1 -1
- package/browser/workers/index.js +21 -0
- package/browser/workers/index.node.d.ts +12 -19
- package/browser/workers/index.node.d.ts.map +1 -1
- package/browser/workers/index.shared.d.ts +15 -0
- package/browser/workers/index.shared.d.ts.map +1 -0
- package/browser/workers/types.d.ts +5 -0
- package/browser/workers/types.d.ts.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/build/workers/index.browser.d.ts +24 -0
- package/build/workers/index.browser.d.ts.map +1 -0
- package/build/workers/index.browser.js +30 -0
- package/build/workers/index.browser.js.map +1 -0
- package/build/workers/index.d.ts +5 -17
- package/build/workers/index.d.ts.map +1 -1
- package/build/workers/index.js +3 -11
- package/build/workers/index.js.map +1 -1
- package/build/workers/index.node.d.ts +17 -3
- package/build/workers/index.node.d.ts.map +1 -1
- package/build/workers/index.node.js +23 -4
- package/build/workers/index.node.js.map +1 -1
- package/build/workers/index.shared.d.ts +15 -0
- package/build/workers/index.shared.d.ts.map +1 -0
- package/build/workers/index.shared.js +20 -0
- package/build/workers/index.shared.js.map +1 -0
- package/build/workers/types.d.ts +5 -0
- package/build/workers/types.d.ts.map +1 -1
- package/package.json +10 -1
- package/src/index.ts +2 -0
- package/src/workers/index.browser.ts +34 -0
- package/src/workers/index.node.ts +28 -5
- package/src/workers/index.shared.ts +58 -0
- package/src/workers/index.ts +6 -64
- package/src/workers/types.ts +5 -0
- package/vite.config.browser.ts +31 -6
- package/browser/chunks/WorkerSigningPool.sequential-DHha7j0b.js +0 -113
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Node.js worker pool entry point.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Uses worker_threads for parallel signing. Provides direct access to
|
|
5
|
+
* NodeWorkerSigningPool without runtime detection overhead.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```typescript
|
|
@@ -19,8 +19,27 @@
|
|
|
19
19
|
*
|
|
20
20
|
* @packageDocumentation
|
|
21
21
|
*/
|
|
22
|
-
|
|
23
|
-
export * from './index.js';
|
|
22
|
+
export * from './index.shared.js';
|
|
24
23
|
// Node.js specific exports
|
|
25
24
|
export { NodeWorkerSigningPool } from './WorkerSigningPool.node.js';
|
|
25
|
+
/**
|
|
26
|
+
* Detects the runtime environment.
|
|
27
|
+
*
|
|
28
|
+
* @returns Always 'node' in this entry point.
|
|
29
|
+
*/
|
|
30
|
+
export function detectRuntime() {
|
|
31
|
+
return 'node';
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Creates a signing pool for the Node.js runtime using worker_threads.
|
|
35
|
+
*
|
|
36
|
+
* @param config - Optional pool configuration
|
|
37
|
+
* @returns A promise resolving to the initialized signing pool
|
|
38
|
+
*/
|
|
39
|
+
export async function createSigningPool(config) {
|
|
40
|
+
const { NodeWorkerSigningPool } = await import('./WorkerSigningPool.node.js');
|
|
41
|
+
const pool = NodeWorkerSigningPool.getInstance(config);
|
|
42
|
+
await pool.initialize();
|
|
43
|
+
return pool;
|
|
44
|
+
}
|
|
26
45
|
//# sourceMappingURL=index.node.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.node.js","sourceRoot":"","sources":["../../src/workers/index.node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;
|
|
1
|
+
{"version":3,"file":"index.node.js","sourceRoot":"","sources":["../../src/workers/index.node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,cAAc,mBAAmB,CAAC;AAElC,2BAA2B;AAC3B,OAAO,EAAE,qBAAqB,EAA6B,MAAM,6BAA6B,CAAC;AAE/F;;;;GAIG;AACH,MAAM,UAAU,aAAa;IACzB,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,MAAyB;IAC7D,MAAM,EAAE,qBAAqB,EAAE,GAAG,MAAM,MAAM,CAAC,6BAA6B,CAAC,CAAC;IAC9E,MAAM,IAAI,GAAG,qBAAqB,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACvD,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;IACxB,OAAO,IAAI,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared worker module exports.
|
|
3
|
+
*
|
|
4
|
+
* Contains all platform-agnostic exports used by browser, Node.js, and generic
|
|
5
|
+
* entry points. Platform-specific entry points re-export from this module and
|
|
6
|
+
* add their own `detectRuntime` and `createSigningPool` implementations.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
export { SignatureType, type SigningTaskMessage, type BatchSigningMessage, type BatchSigningTask, type BatchSigningResultMessage, type BatchSigningTaskResult, type BatchSigningTaskError, type WorkerInitMessage, type WorkerShutdownMessage, type WorkerMessage, type SigningResultMessage, type SigningErrorMessage, type WorkerReadyMessage, type WorkerShutdownAckMessage, type WorkerResponse, isSigningError, isSigningResult, isBatchResult, isWorkerReady, type WorkerEccLib, type WorkerPoolConfig, type SigningTask, type ParallelSignerKeyPair, type ParallelSigningResult, type SigningPoolLike, WorkerState, type PooledWorker, } from './types.js';
|
|
11
|
+
export { WorkerSigningPool, getSigningPool } from './WorkerSigningPool.js';
|
|
12
|
+
export { generateWorkerCode, createWorkerBlobUrl, revokeWorkerBlobUrl } from './signing-worker.js';
|
|
13
|
+
export { ECC_BUNDLE, ECC_BUNDLE_SIZE } from './ecc-bundle.js';
|
|
14
|
+
export { signPsbtParallel, prepareSigningTasks, applySignaturesToPsbt, type ParallelSignOptions, type PsbtParallelKeyPair, } from './psbt-parallel.js';
|
|
15
|
+
//# sourceMappingURL=index.shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.shared.d.ts","sourceRoot":"","sources":["../../src/workers/index.shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EACH,aAAa,EACb,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,yBAAyB,EAC9B,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,cAAc,EACnB,cAAc,EACd,eAAe,EACf,aAAa,EACb,aAAa,EACb,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,WAAW,EACX,KAAK,YAAY,GACpB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAG3E,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAGnG,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAG9D,OAAO,EACH,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,GAC3B,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared worker module exports.
|
|
3
|
+
*
|
|
4
|
+
* Contains all platform-agnostic exports used by browser, Node.js, and generic
|
|
5
|
+
* entry points. Platform-specific entry points re-export from this module and
|
|
6
|
+
* add their own `detectRuntime` and `createSigningPool` implementations.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
// Type exports
|
|
11
|
+
export { SignatureType, isSigningError, isSigningResult, isBatchResult, isWorkerReady, WorkerState, } from './types.js';
|
|
12
|
+
// Browser worker pool
|
|
13
|
+
export { WorkerSigningPool, getSigningPool } from './WorkerSigningPool.js';
|
|
14
|
+
// Worker code generation (for custom implementations)
|
|
15
|
+
export { generateWorkerCode, createWorkerBlobUrl, revokeWorkerBlobUrl } from './signing-worker.js';
|
|
16
|
+
// ECC bundle (for embedding in custom workers)
|
|
17
|
+
export { ECC_BUNDLE, ECC_BUNDLE_SIZE } from './ecc-bundle.js';
|
|
18
|
+
// PSBT parallel signing integration
|
|
19
|
+
export { signPsbtParallel, prepareSigningTasks, applySignaturesToPsbt, } from './psbt-parallel.js';
|
|
20
|
+
//# sourceMappingURL=index.shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.shared.js","sourceRoot":"","sources":["../../src/workers/index.shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,eAAe;AACf,OAAO,EACH,aAAa,EAeb,cAAc,EACd,eAAe,EACf,aAAa,EACb,aAAa,EAOb,WAAW,GAEd,MAAM,YAAY,CAAC;AAEpB,sBAAsB;AACtB,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE3E,sDAAsD;AACtD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAEnG,+CAA+C;AAC/C,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE9D,oCAAoC;AACpC,OAAO,EACH,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,GAGxB,MAAM,oBAAoB,CAAC"}
|
package/build/workers/types.d.ts
CHANGED
|
@@ -355,8 +355,13 @@ export type WorkerState = (typeof WorkerState)[keyof typeof WorkerState];
|
|
|
355
355
|
*/
|
|
356
356
|
export interface SigningPoolLike {
|
|
357
357
|
signBatch(tasks: readonly SigningTask[], keyPair: ParallelSignerKeyPair): Promise<ParallelSigningResult>;
|
|
358
|
+
preserveWorkers(): void;
|
|
359
|
+
releaseWorkers(): void;
|
|
358
360
|
initialize(): Promise<void>;
|
|
359
361
|
shutdown(): Promise<void>;
|
|
362
|
+
readonly workerCount: number;
|
|
363
|
+
readonly idleWorkerCount: number;
|
|
364
|
+
readonly busyWorkerCount: number;
|
|
360
365
|
readonly isPreservingWorkers: boolean;
|
|
361
366
|
}
|
|
362
367
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/workers/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;GAEG;AACH,eAAO,MAAM,aAAa;IACtB,kCAAkC;;IAElC,iCAAiC;;CAE3B,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAE/E;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IAC/B,iCAAiC;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,sCAAsC;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,8BAA8B;IAC9B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,wDAAwD;IACxD,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,mDAAmD;IAC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AE,MAAM,CAAC;IACjC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,2BAA2B;IAC3B,KAAK,EAAE,WAAW,CAAC;IACnB,iCAAiC;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,gCAAgC;IAChC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,0CAA0C;IAC1C,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@btc-vision/bitcoin",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.0.0-alpha.
|
|
4
|
+
"version": "7.0.0-alpha.6",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "Client-side Bitcoin JavaScript library",
|
|
7
7
|
"engines": {
|
|
@@ -201,6 +201,14 @@
|
|
|
201
201
|
"vite-plugin-wasm": "^3.5.0",
|
|
202
202
|
"vitest": "^4.0.18"
|
|
203
203
|
},
|
|
204
|
+
"peerDependencies": {
|
|
205
|
+
"react-native-worklets": ">=0.7.0"
|
|
206
|
+
},
|
|
207
|
+
"peerDependenciesMeta": {
|
|
208
|
+
"react-native-worklets": {
|
|
209
|
+
"optional": true
|
|
210
|
+
}
|
|
211
|
+
},
|
|
204
212
|
"dependencies": {
|
|
205
213
|
"@btc-vision/bip32": "^7.0.2",
|
|
206
214
|
"@btc-vision/ecpair": "^4.0.2",
|
|
@@ -213,6 +221,7 @@
|
|
|
213
221
|
"browserify-zlib": "^0.2.0",
|
|
214
222
|
"bs58check": "^4.0.0",
|
|
215
223
|
"buffer": "^6.0.3",
|
|
224
|
+
"esbuild": "^0.27.2",
|
|
216
225
|
"process": "^0.11.10",
|
|
217
226
|
"varuint-bitcoin": "^2.0.0"
|
|
218
227
|
}
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser worker pool entry point.
|
|
3
|
+
*
|
|
4
|
+
* Uses Web Workers for parallel signing. Never references Node.js modules
|
|
5
|
+
* (worker_threads, os, etc.), so it is safe for browser bundlers.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { WorkerPoolConfig, SigningPoolLike } from './types.js';
|
|
11
|
+
|
|
12
|
+
export * from './index.shared.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Detects the runtime environment.
|
|
16
|
+
*
|
|
17
|
+
* @returns Always 'browser' in this entry point.
|
|
18
|
+
*/
|
|
19
|
+
export function detectRuntime(): 'node' | 'browser' | 'react-native' | 'unknown' {
|
|
20
|
+
return 'browser';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Creates a signing pool for the browser runtime using Web Workers.
|
|
25
|
+
*
|
|
26
|
+
* @param config - Optional pool configuration
|
|
27
|
+
* @returns A promise resolving to the initialized signing pool
|
|
28
|
+
*/
|
|
29
|
+
export async function createSigningPool(config?: WorkerPoolConfig): Promise<SigningPoolLike> {
|
|
30
|
+
const { WorkerSigningPool } = await import('./WorkerSigningPool.js');
|
|
31
|
+
const pool = WorkerSigningPool.getInstance(config);
|
|
32
|
+
await pool.initialize();
|
|
33
|
+
return pool;
|
|
34
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Node.js worker pool entry point.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Uses worker_threads for parallel signing. Provides direct access to
|
|
5
|
+
* NodeWorkerSigningPool without runtime detection overhead.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```typescript
|
|
@@ -20,8 +20,31 @@
|
|
|
20
20
|
* @packageDocumentation
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
import type { WorkerPoolConfig, SigningPoolLike } from './types.js';
|
|
24
|
+
|
|
25
|
+
export * from './index.shared.js';
|
|
25
26
|
|
|
26
27
|
// Node.js specific exports
|
|
27
|
-
export { NodeWorkerSigningPool, type NodeWorkerPoolConfig } from './WorkerSigningPool.node.js';
|
|
28
|
+
export { NodeWorkerSigningPool, type NodeWorkerPoolConfig } from './WorkerSigningPool.node.js';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Detects the runtime environment.
|
|
32
|
+
*
|
|
33
|
+
* @returns Always 'node' in this entry point.
|
|
34
|
+
*/
|
|
35
|
+
export function detectRuntime(): 'node' | 'browser' | 'react-native' | 'unknown' {
|
|
36
|
+
return 'node';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Creates a signing pool for the Node.js runtime using worker_threads.
|
|
41
|
+
*
|
|
42
|
+
* @param config - Optional pool configuration
|
|
43
|
+
* @returns A promise resolving to the initialized signing pool
|
|
44
|
+
*/
|
|
45
|
+
export async function createSigningPool(config?: WorkerPoolConfig): Promise<SigningPoolLike> {
|
|
46
|
+
const { NodeWorkerSigningPool } = await import('./WorkerSigningPool.node.js');
|
|
47
|
+
const pool = NodeWorkerSigningPool.getInstance(config);
|
|
48
|
+
await pool.initialize();
|
|
49
|
+
return pool;
|
|
50
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared worker module exports.
|
|
3
|
+
*
|
|
4
|
+
* Contains all platform-agnostic exports used by browser, Node.js, and generic
|
|
5
|
+
* entry points. Platform-specific entry points re-export from this module and
|
|
6
|
+
* add their own `detectRuntime` and `createSigningPool` implementations.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// Type exports
|
|
12
|
+
export {
|
|
13
|
+
SignatureType,
|
|
14
|
+
type SigningTaskMessage,
|
|
15
|
+
type BatchSigningMessage,
|
|
16
|
+
type BatchSigningTask,
|
|
17
|
+
type BatchSigningResultMessage,
|
|
18
|
+
type BatchSigningTaskResult,
|
|
19
|
+
type BatchSigningTaskError,
|
|
20
|
+
type WorkerInitMessage,
|
|
21
|
+
type WorkerShutdownMessage,
|
|
22
|
+
type WorkerMessage,
|
|
23
|
+
type SigningResultMessage,
|
|
24
|
+
type SigningErrorMessage,
|
|
25
|
+
type WorkerReadyMessage,
|
|
26
|
+
type WorkerShutdownAckMessage,
|
|
27
|
+
type WorkerResponse,
|
|
28
|
+
isSigningError,
|
|
29
|
+
isSigningResult,
|
|
30
|
+
isBatchResult,
|
|
31
|
+
isWorkerReady,
|
|
32
|
+
type WorkerEccLib,
|
|
33
|
+
type WorkerPoolConfig,
|
|
34
|
+
type SigningTask,
|
|
35
|
+
type ParallelSignerKeyPair,
|
|
36
|
+
type ParallelSigningResult,
|
|
37
|
+
type SigningPoolLike,
|
|
38
|
+
WorkerState,
|
|
39
|
+
type PooledWorker,
|
|
40
|
+
} from './types.js';
|
|
41
|
+
|
|
42
|
+
// Browser worker pool
|
|
43
|
+
export { WorkerSigningPool, getSigningPool } from './WorkerSigningPool.js';
|
|
44
|
+
|
|
45
|
+
// Worker code generation (for custom implementations)
|
|
46
|
+
export { generateWorkerCode, createWorkerBlobUrl, revokeWorkerBlobUrl } from './signing-worker.js';
|
|
47
|
+
|
|
48
|
+
// ECC bundle (for embedding in custom workers)
|
|
49
|
+
export { ECC_BUNDLE, ECC_BUNDLE_SIZE } from './ecc-bundle.js';
|
|
50
|
+
|
|
51
|
+
// PSBT parallel signing integration
|
|
52
|
+
export {
|
|
53
|
+
signPsbtParallel,
|
|
54
|
+
prepareSigningTasks,
|
|
55
|
+
applySignaturesToPsbt,
|
|
56
|
+
type ParallelSignOptions,
|
|
57
|
+
type PsbtParallelKeyPair,
|
|
58
|
+
} from './psbt-parallel.js';
|
package/src/workers/index.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Worker-based parallel signing module.
|
|
2
|
+
* Worker-based parallel signing module (generic entry point).
|
|
3
3
|
*
|
|
4
4
|
* Provides secure parallel signature computation using worker threads.
|
|
5
5
|
* Works in both Node.js (worker_threads) and browsers (Web Workers).
|
|
6
|
+
* Uses runtime detection to select the appropriate pool implementation.
|
|
6
7
|
*
|
|
7
8
|
* @example
|
|
8
9
|
* ```typescript
|
|
@@ -46,56 +47,9 @@
|
|
|
46
47
|
* @packageDocumentation
|
|
47
48
|
*/
|
|
48
49
|
|
|
49
|
-
import type { WorkerPoolConfig,
|
|
50
|
+
import type { WorkerPoolConfig, SigningPoolLike } from './types.js';
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
export {
|
|
53
|
-
SignatureType,
|
|
54
|
-
type SigningTaskMessage,
|
|
55
|
-
type BatchSigningMessage,
|
|
56
|
-
type BatchSigningTask,
|
|
57
|
-
type BatchSigningResultMessage,
|
|
58
|
-
type BatchSigningTaskResult,
|
|
59
|
-
type BatchSigningTaskError,
|
|
60
|
-
type WorkerInitMessage,
|
|
61
|
-
type WorkerShutdownMessage,
|
|
62
|
-
type WorkerMessage,
|
|
63
|
-
type SigningResultMessage,
|
|
64
|
-
type SigningErrorMessage,
|
|
65
|
-
type WorkerReadyMessage,
|
|
66
|
-
type WorkerShutdownAckMessage,
|
|
67
|
-
type WorkerResponse,
|
|
68
|
-
isSigningError,
|
|
69
|
-
isSigningResult,
|
|
70
|
-
isBatchResult,
|
|
71
|
-
isWorkerReady,
|
|
72
|
-
type WorkerEccLib,
|
|
73
|
-
type WorkerPoolConfig,
|
|
74
|
-
type SigningTask,
|
|
75
|
-
type ParallelSignerKeyPair,
|
|
76
|
-
type ParallelSigningResult,
|
|
77
|
-
type SigningPoolLike,
|
|
78
|
-
WorkerState,
|
|
79
|
-
type PooledWorker,
|
|
80
|
-
} from './types.js';
|
|
81
|
-
|
|
82
|
-
// Browser worker pool
|
|
83
|
-
export { WorkerSigningPool, getSigningPool } from './WorkerSigningPool.js';
|
|
84
|
-
|
|
85
|
-
// Worker code generation (for custom implementations)
|
|
86
|
-
export { generateWorkerCode, createWorkerBlobUrl, revokeWorkerBlobUrl } from './signing-worker.js';
|
|
87
|
-
|
|
88
|
-
// ECC bundle (for embedding in custom workers)
|
|
89
|
-
export { ECC_BUNDLE, ECC_BUNDLE_SIZE } from './ecc-bundle.js';
|
|
90
|
-
|
|
91
|
-
// PSBT parallel signing integration
|
|
92
|
-
export {
|
|
93
|
-
signPsbtParallel,
|
|
94
|
-
prepareSigningTasks,
|
|
95
|
-
applySignaturesToPsbt,
|
|
96
|
-
type ParallelSignOptions,
|
|
97
|
-
type PsbtParallelKeyPair,
|
|
98
|
-
} from './psbt-parallel.js';
|
|
52
|
+
export * from './index.shared.js';
|
|
99
53
|
|
|
100
54
|
/**
|
|
101
55
|
* Detects the runtime environment and returns the appropriate signing pool.
|
|
@@ -136,19 +90,7 @@ export function detectRuntime(): 'node' | 'browser' | 'react-native' | 'unknown'
|
|
|
136
90
|
* await pool.shutdown();
|
|
137
91
|
* ```
|
|
138
92
|
*/
|
|
139
|
-
export async function createSigningPool(config?: WorkerPoolConfig): Promise<{
|
|
140
|
-
signBatch: (
|
|
141
|
-
tasks: readonly SigningTask[],
|
|
142
|
-
keyPair: ParallelSignerKeyPair,
|
|
143
|
-
) => Promise<ParallelSigningResult>;
|
|
144
|
-
preserveWorkers: () => void;
|
|
145
|
-
releaseWorkers: () => void;
|
|
146
|
-
shutdown: () => Promise<void>;
|
|
147
|
-
workerCount: number;
|
|
148
|
-
idleWorkerCount: number;
|
|
149
|
-
busyWorkerCount: number;
|
|
150
|
-
isPreservingWorkers: boolean;
|
|
151
|
-
}> {
|
|
93
|
+
export async function createSigningPool(config?: WorkerPoolConfig): Promise<SigningPoolLike> {
|
|
152
94
|
const runtime = detectRuntime();
|
|
153
95
|
|
|
154
96
|
if (runtime === 'node') {
|
|
@@ -169,4 +111,4 @@ export async function createSigningPool(config?: WorkerPoolConfig): Promise<{
|
|
|
169
111
|
} else {
|
|
170
112
|
throw new Error('Unsupported runtime for worker signing pool');
|
|
171
113
|
}
|
|
172
|
-
}
|
|
114
|
+
}
|
package/src/workers/types.ts
CHANGED
|
@@ -411,8 +411,13 @@ export interface SigningPoolLike {
|
|
|
411
411
|
tasks: readonly SigningTask[],
|
|
412
412
|
keyPair: ParallelSignerKeyPair,
|
|
413
413
|
): Promise<ParallelSigningResult>;
|
|
414
|
+
preserveWorkers(): void;
|
|
415
|
+
releaseWorkers(): void;
|
|
414
416
|
initialize(): Promise<void>;
|
|
415
417
|
shutdown(): Promise<void>;
|
|
418
|
+
readonly workerCount: number;
|
|
419
|
+
readonly idleWorkerCount: number;
|
|
420
|
+
readonly busyWorkerCount: number;
|
|
416
421
|
readonly isPreservingWorkers: boolean;
|
|
417
422
|
}
|
|
418
423
|
|
package/vite.config.browser.ts
CHANGED
|
@@ -1,8 +1,32 @@
|
|
|
1
1
|
import { resolve } from 'path';
|
|
2
|
-
import { defineConfig } from 'vite';
|
|
2
|
+
import { defineConfig, type Plugin } from 'vite';
|
|
3
3
|
import { nodePolyfills } from 'vite-plugin-node-polyfills';
|
|
4
4
|
import dts from 'vite-plugin-dts';
|
|
5
5
|
|
|
6
|
+
const BROWSER_WORKERS_INDEX = resolve(__dirname, 'src/workers/index.browser.ts');
|
|
7
|
+
|
|
8
|
+
// Redirect all imports of workers/index to the browser-specific entry
|
|
9
|
+
// which never references Node.js modules (worker_threads, os, etc.)
|
|
10
|
+
function browserWorkersRedirect(): Plugin {
|
|
11
|
+
const workersIndex = resolve(__dirname, 'src/workers/index.ts');
|
|
12
|
+
return {
|
|
13
|
+
name: 'browser-workers-redirect',
|
|
14
|
+
enforce: 'pre',
|
|
15
|
+
resolveId(source, importer) {
|
|
16
|
+
if (!importer) return null;
|
|
17
|
+
// Match resolved path to workers/index.ts (from relative ./workers/index.js imports)
|
|
18
|
+
if (source === './workers/index.js' || source === './workers/index.ts') {
|
|
19
|
+
const resolvedDir = resolve(importer, '..');
|
|
20
|
+
const resolved = resolve(resolvedDir, 'workers/index.ts');
|
|
21
|
+
if (resolved === workersIndex) {
|
|
22
|
+
return BROWSER_WORKERS_INDEX;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
6
30
|
export default defineConfig({
|
|
7
31
|
build: {
|
|
8
32
|
outDir: 'browser',
|
|
@@ -10,16 +34,16 @@ export default defineConfig({
|
|
|
10
34
|
target: 'esnext',
|
|
11
35
|
minify: 'esbuild',
|
|
12
36
|
lib: {
|
|
13
|
-
entry:
|
|
37
|
+
entry: {
|
|
38
|
+
index: resolve(__dirname, 'src/index.ts'),
|
|
39
|
+
'workers/index': BROWSER_WORKERS_INDEX,
|
|
40
|
+
},
|
|
14
41
|
formats: ['es'],
|
|
15
|
-
fileName: () =>
|
|
42
|
+
fileName: (_format, entryName) => `${entryName}.js`,
|
|
16
43
|
},
|
|
17
44
|
rollupOptions: {
|
|
18
|
-
external: [/WorkerSigningPool\.node/],
|
|
19
45
|
output: {
|
|
20
46
|
chunkFileNames: 'chunks/[name]-[hash].js',
|
|
21
|
-
// Tree-shaking enabled - no manual chunks needed
|
|
22
|
-
// This allows bundlers to only include what's actually used
|
|
23
47
|
},
|
|
24
48
|
},
|
|
25
49
|
},
|
|
@@ -36,6 +60,7 @@ export default defineConfig({
|
|
|
36
60
|
global: 'globalThis',
|
|
37
61
|
},
|
|
38
62
|
plugins: [
|
|
63
|
+
browserWorkersRedirect(),
|
|
39
64
|
nodePolyfills({
|
|
40
65
|
globals: {
|
|
41
66
|
Buffer: true,
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { EccContext as f, SignatureType as g } from "../index.js";
|
|
2
|
-
class r {
|
|
3
|
-
static #e = null;
|
|
4
|
-
constructor(t = {}) {
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Number of workers — always 0 for sequential pool.
|
|
8
|
-
*/
|
|
9
|
-
get workerCount() {
|
|
10
|
-
return 0;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Idle workers — always 0.
|
|
14
|
-
*/
|
|
15
|
-
get idleWorkerCount() {
|
|
16
|
-
return 0;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Busy workers — always 0.
|
|
20
|
-
*/
|
|
21
|
-
get busyWorkerCount() {
|
|
22
|
-
return 0;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Whether workers are preserved — always false (no workers to preserve).
|
|
26
|
-
*/
|
|
27
|
-
get isPreservingWorkers() {
|
|
28
|
-
return !1;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Gets the singleton instance.
|
|
32
|
-
*/
|
|
33
|
-
static getInstance(t) {
|
|
34
|
-
return r.#e || (r.#e = new r(t)), r.#e;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Resets the singleton instance (for testing).
|
|
38
|
-
*/
|
|
39
|
-
static resetInstance() {
|
|
40
|
-
r.#e = null;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* No-op — no workers to preserve.
|
|
44
|
-
*/
|
|
45
|
-
preserveWorkers() {
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* No-op — no workers to release.
|
|
49
|
-
*/
|
|
50
|
-
releaseWorkers() {
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* No-op — no initialization required.
|
|
54
|
-
*/
|
|
55
|
-
async initialize() {
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Signs tasks sequentially on the main thread.
|
|
59
|
-
*/
|
|
60
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
61
|
-
async signBatch(t, c) {
|
|
62
|
-
const o = performance.now();
|
|
63
|
-
if (t.length === 0)
|
|
64
|
-
return {
|
|
65
|
-
success: !0,
|
|
66
|
-
signatures: /* @__PURE__ */ new Map(),
|
|
67
|
-
errors: /* @__PURE__ */ new Map(),
|
|
68
|
-
durationMs: performance.now() - o
|
|
69
|
-
};
|
|
70
|
-
const i = f.get().lib, u = c.getPrivateKey(), p = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
|
|
71
|
-
try {
|
|
72
|
-
for (const e of t)
|
|
73
|
-
try {
|
|
74
|
-
let s;
|
|
75
|
-
const n = e.hash, y = u;
|
|
76
|
-
e.signatureType === g.Schnorr ? s = i.signSchnorr(n, y) : s = i.sign(n, y), p.set(e.inputIndex, {
|
|
77
|
-
type: "result",
|
|
78
|
-
taskId: e.taskId,
|
|
79
|
-
signature: s,
|
|
80
|
-
inputIndex: e.inputIndex,
|
|
81
|
-
publicKey: c.publicKey,
|
|
82
|
-
signatureType: e.signatureType,
|
|
83
|
-
leafHash: e.leafHash
|
|
84
|
-
});
|
|
85
|
-
} catch (s) {
|
|
86
|
-
const n = s instanceof Error ? s.message : "Signing failed";
|
|
87
|
-
a.set(e.inputIndex, n);
|
|
88
|
-
}
|
|
89
|
-
} finally {
|
|
90
|
-
u.fill(0);
|
|
91
|
-
}
|
|
92
|
-
return {
|
|
93
|
-
success: a.size === 0,
|
|
94
|
-
signatures: p,
|
|
95
|
-
errors: a,
|
|
96
|
-
durationMs: performance.now() - o
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* No-op — no workers to shut down.
|
|
101
|
-
*/
|
|
102
|
-
async shutdown() {
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Enables `await using pool = ...` syntax.
|
|
106
|
-
*/
|
|
107
|
-
async [Symbol.asyncDispose]() {
|
|
108
|
-
await this.shutdown();
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
export {
|
|
112
|
-
r as SequentialSigningPool
|
|
113
|
-
};
|