@fedimint/core-web 0.0.0-20250617190659
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/LICENSE +21 -0
- package/README.md +16 -0
- package/dist/dts/FedimintWallet.d.ts +114 -0
- package/dist/dts/FedimintWallet.d.ts.map +1 -0
- package/dist/dts/index.d.ts +3 -0
- package/dist/dts/index.d.ts.map +1 -0
- package/dist/dts/services/BalanceService.d.ts +15 -0
- package/dist/dts/services/BalanceService.d.ts.map +1 -0
- package/dist/dts/services/FederationService.d.ts +11 -0
- package/dist/dts/services/FederationService.d.ts.map +1 -0
- package/dist/dts/services/LightningService.d.ts +47 -0
- package/dist/dts/services/LightningService.d.ts.map +1 -0
- package/dist/dts/services/MintService.d.ts +23 -0
- package/dist/dts/services/MintService.d.ts.map +1 -0
- package/dist/dts/services/RecoveryService.d.ts +13 -0
- package/dist/dts/services/RecoveryService.d.ts.map +1 -0
- package/dist/dts/services/WalletService.d.ts +8 -0
- package/dist/dts/services/WalletService.d.ts.map +1 -0
- package/dist/dts/services/index.d.ts +7 -0
- package/dist/dts/services/index.d.ts.map +1 -0
- package/dist/dts/types/index.d.ts +4 -0
- package/dist/dts/types/index.d.ts.map +1 -0
- package/dist/dts/types/utils.d.ts +23 -0
- package/dist/dts/types/utils.d.ts.map +1 -0
- package/dist/dts/types/wallet.d.ts +102 -0
- package/dist/dts/types/wallet.d.ts.map +1 -0
- package/dist/dts/types/worker.d.ts +4 -0
- package/dist/dts/types/worker.d.ts.map +1 -0
- package/dist/dts/utils/logger.d.ts +17 -0
- package/dist/dts/utils/logger.d.ts.map +1 -0
- package/dist/dts/worker/WorkerClient.d.ts +44 -0
- package/dist/dts/worker/WorkerClient.d.ts.map +1 -0
- package/dist/dts/worker/index.d.ts +2 -0
- package/dist/dts/worker/index.d.ts.map +1 -0
- package/dist/index.d.ts +392 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/worker.js +2 -0
- package/dist/worker.js.map +1 -0
- package/package.json +43 -0
- package/src/FedimintWallet.test.ts +73 -0
- package/src/FedimintWallet.ts +215 -0
- package/src/index.ts +2 -0
- package/src/services/BalanceService.test.ts +50 -0
- package/src/services/BalanceService.ts +29 -0
- package/src/services/FederationService.test.ts +58 -0
- package/src/services/FederationService.ts +24 -0
- package/src/services/LightningService.test.ts +208 -0
- package/src/services/LightningService.ts +274 -0
- package/src/services/MintService.test.ts +74 -0
- package/src/services/MintService.ts +129 -0
- package/src/services/RecoveryService.ts +28 -0
- package/src/services/WalletService.test.ts +24 -0
- package/src/services/WalletService.ts +10 -0
- package/src/services/index.ts +6 -0
- package/src/test/TestFedimintWallet.ts +26 -0
- package/src/test/TestingService.ts +79 -0
- package/src/test/crypto.ts +44 -0
- package/src/test/fixtures.test.ts +18 -0
- package/src/test/fixtures.ts +70 -0
- package/src/types/index.ts +3 -0
- package/src/types/utils.ts +29 -0
- package/src/types/wallet.ts +141 -0
- package/src/types/worker.ts +16 -0
- package/src/utils/logger.ts +61 -0
- package/src/worker/WorkerClient.test.ts +6 -0
- package/src/worker/WorkerClient.ts +236 -0
- package/src/worker/index.ts +1 -0
- package/src/worker/worker.js +167 -0
- package/src/worker/worker.test.ts +90 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 fedimint
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# @fedimint/core-web
|
|
2
|
+
|
|
3
|
+
### This is early software. Use with caution. Report Bugs.
|
|
4
|
+
|
|
5
|
+
Check out the [Getting Started Guide](https://web.fedimint.org/core/getting-started.html) for more information.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
Also check out the examples for working code
|
|
10
|
+
|
|
11
|
+
- [Vite + React](https://web.fedimint.org/examples/vite-react)
|
|
12
|
+
- [Bare JS](https://web.fedimint.org/examples/bare-js)
|
|
13
|
+
|
|
14
|
+
### Resources
|
|
15
|
+
|
|
16
|
+
- [Bitcoin Mints](https://bitcoinmints.com/?tab=mints&showFedimint=true) - list of public federations with invite codes
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { BalanceService, MintService, LightningService, FederationService, RecoveryService, WalletService } from './services';
|
|
2
|
+
import { type LogLevel } from './utils/logger';
|
|
3
|
+
import { FederationConfig, JSONValue } from './types';
|
|
4
|
+
export declare class FedimintWallet {
|
|
5
|
+
private _client;
|
|
6
|
+
balance: BalanceService;
|
|
7
|
+
mint: MintService;
|
|
8
|
+
lightning: LightningService;
|
|
9
|
+
federation: FederationService;
|
|
10
|
+
recovery: RecoveryService;
|
|
11
|
+
wallet: WalletService;
|
|
12
|
+
private _openPromise;
|
|
13
|
+
private _resolveOpen;
|
|
14
|
+
private _isOpen;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new instance of FedimintWallet.
|
|
17
|
+
*
|
|
18
|
+
* This constructor initializes a FedimintWallet instance, which manages communication
|
|
19
|
+
* with a Web Worker. The Web Worker is responsible for running WebAssembly code that
|
|
20
|
+
* handles the core Fedimint Client operations.
|
|
21
|
+
*
|
|
22
|
+
* (default) When not in lazy mode, the constructor immediately initializes the
|
|
23
|
+
* Web Worker and begins loading the WebAssembly module in the background. This
|
|
24
|
+
* allows for faster subsequent operations but may increase initial load time.
|
|
25
|
+
*
|
|
26
|
+
* In lazy mode, the Web Worker and WebAssembly initialization are deferred until
|
|
27
|
+
* the first operation that requires them, reducing initial overhead at the cost
|
|
28
|
+
* of a slight delay on the first operation.
|
|
29
|
+
*
|
|
30
|
+
* @param {boolean} lazy - If true, delays Web Worker and WebAssembly initialization
|
|
31
|
+
* until needed. Default is false.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* // Create a wallet with immediate initialization
|
|
35
|
+
* const wallet = new FedimintWallet();
|
|
36
|
+
* wallet.open();
|
|
37
|
+
*
|
|
38
|
+
* // Create a wallet with lazy initialization
|
|
39
|
+
* const lazyWallet = new FedimintWallet(true);
|
|
40
|
+
* // Some time later...
|
|
41
|
+
* lazyWallet.initialize();
|
|
42
|
+
* lazyWallet.open();
|
|
43
|
+
*/
|
|
44
|
+
constructor(lazy?: boolean);
|
|
45
|
+
initialize(): Promise<void>;
|
|
46
|
+
waitForOpen(): Promise<void>;
|
|
47
|
+
open(clientName?: string): Promise<boolean>;
|
|
48
|
+
joinFederation(inviteCode: string, clientName?: string): Promise<boolean>;
|
|
49
|
+
/**
|
|
50
|
+
* This should ONLY be called when UNLOADING the wallet client.
|
|
51
|
+
* After this call, the FedimintWallet instance should be discarded.
|
|
52
|
+
*/
|
|
53
|
+
cleanup(): Promise<void>;
|
|
54
|
+
isOpen(): boolean;
|
|
55
|
+
previewFederation(inviteCode: string): Promise<{
|
|
56
|
+
config: FederationConfig;
|
|
57
|
+
federation_id: string;
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* Sets the log level for the library.
|
|
61
|
+
* @param level The desired log level ('DEBUG', 'INFO', 'WARN', 'ERROR', 'NONE').
|
|
62
|
+
*/
|
|
63
|
+
setLogLevel(level: LogLevel): void;
|
|
64
|
+
/**
|
|
65
|
+
* Parses a federation invite code and retrieves its details.
|
|
66
|
+
*
|
|
67
|
+
* This method sends the provided invite code to the WorkerClient for parsing.
|
|
68
|
+
* The response includes the federation_id and url.
|
|
69
|
+
*
|
|
70
|
+
* @param {string} inviteCode - The invite code to be parsed.
|
|
71
|
+
* @returns {Promise<{ federation_id: string, url: string}>}
|
|
72
|
+
* A promise that resolves to an object containing:
|
|
73
|
+
* - `federation_id`: The id of the feder.
|
|
74
|
+
* - `url`: One of the apipoints to connect to the federation
|
|
75
|
+
*
|
|
76
|
+
* @throws {Error} If the WorkerClient encounters an issue during the parsing process.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* const inviteCode = "example-invite-code";
|
|
80
|
+
* const parsedCode = await wallet.parseInviteCode(inviteCode);
|
|
81
|
+
* console.log(parsedCode.federation_id, parsedCode.url);
|
|
82
|
+
*/
|
|
83
|
+
parseInviteCode(inviteCode: string): Promise<{
|
|
84
|
+
type: string;
|
|
85
|
+
data: JSONValue;
|
|
86
|
+
requestId: number;
|
|
87
|
+
}>;
|
|
88
|
+
/**
|
|
89
|
+
* Parses a BOLT11 Lightning invoice and retrieves its details.
|
|
90
|
+
*
|
|
91
|
+
* This method sends the provided invoice string to the WorkerClient for parsing.
|
|
92
|
+
* The response includes details such as the amount, expiry, and memo.
|
|
93
|
+
*
|
|
94
|
+
* @param {string} invoiceStr - The BOLT11 invoice string to be parsed.
|
|
95
|
+
* @returns {Promise<{ amount: string, expiry: number, memo: string }>}
|
|
96
|
+
* A promise that resolves to an object containing:
|
|
97
|
+
* - `amount`: The amount specified in the invoice.
|
|
98
|
+
* - `expiry`: The expiry time of the invoice in seconds.
|
|
99
|
+
* - `memo`: A description or memo attached to the invoice.
|
|
100
|
+
*
|
|
101
|
+
* @throws {Error} If the WorkerClient encounters an issue during the parsing process.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* const invoiceStr = "lnbc1...";
|
|
105
|
+
* const parsedInvoice = await wallet.parseBolt11Invoice(invoiceStr);
|
|
106
|
+
* console.log(parsedInvoice.amount, parsedInvoice.expiry, parsedInvoice.memo);
|
|
107
|
+
*/
|
|
108
|
+
parseBolt11Invoice(invoiceStr: string): Promise<{
|
|
109
|
+
type: string;
|
|
110
|
+
data: JSONValue;
|
|
111
|
+
requestId: number;
|
|
112
|
+
}>;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=FedimintWallet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FedimintWallet.d.ts","sourceRoot":"","sources":["../../src/FedimintWallet.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,aAAa,EACd,MAAM,YAAY,CAAA;AACnB,OAAO,EAAU,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAIrD,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAc;IAEtB,OAAO,EAAE,cAAc,CAAA;IACvB,IAAI,EAAE,WAAW,CAAA;IACjB,SAAS,EAAE,gBAAgB,CAAA;IAC3B,UAAU,EAAE,iBAAiB,CAAA;IAC7B,QAAQ,EAAE,eAAe,CAAA;IACzB,MAAM,EAAE,aAAa,CAAA;IAE5B,OAAO,CAAC,YAAY,CAAuC;IAC3D,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,OAAO,CAAiB;IAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;gBACS,IAAI,GAAE,OAAe;IAmB3B,UAAU;IAMV,WAAW;IAKX,IAAI,CAAC,UAAU,GAAE,MAA4B;IAc7C,cAAc,CAClB,UAAU,EAAE,MAAM,EAClB,UAAU,GAAE,MAA4B;IAwB1C;;;OAGG;IACG,OAAO;IAMb,MAAM;IAIA,iBAAiB,CAAC,UAAU,EAAE,MAAM;gBAE9B,gBAAgB;uBACT,MAAM;;IAKzB;;;OAGG;IACH,WAAW,CAAC,KAAK,EAAE,QAAQ;IAK3B;;;;;;;;;;;;;;;;;;OAkBG;IACG,eAAe,CAAC,UAAU,EAAE,MAAM;cAE9B,MAAM;cACN,SAAS;mBACJ,MAAM;;IAKrB;;;;;;;;;;;;;;;;;;;OAmBG;IACG,kBAAkB,CAAC,UAAU,EAAE,MAAM;cAEjC,MAAM;cACN,SAAS;mBACJ,MAAM;;CAItB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,mBAAmB,SAAS,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { WorkerClient } from '../worker';
|
|
2
|
+
/**
|
|
3
|
+
* Balance Service
|
|
4
|
+
*
|
|
5
|
+
* The Balance Service provides methods to interact with the balance of a Fedimint wallet.
|
|
6
|
+
*/
|
|
7
|
+
export declare class BalanceService {
|
|
8
|
+
private client;
|
|
9
|
+
constructor(client: WorkerClient);
|
|
10
|
+
/** https://web.fedimint.org/core/FedimintWallet/BalanceService/getBalance */
|
|
11
|
+
getBalance(): Promise<number>;
|
|
12
|
+
/** https://web.fedimint.org/core/FedimintWallet/BalanceService/subscribeBalance */
|
|
13
|
+
subscribeBalance(onSuccess?: (balanceMsats: number) => void, onError?: (error: string) => void): import("..").CancelFunction;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=BalanceService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BalanceService.d.ts","sourceRoot":"","sources":["../../../src/services/BalanceService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC;;;;GAIG;AACH,qBAAa,cAAc;IACb,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;IAExC,6EAA6E;IACvE,UAAU;IAIhB,mFAAmF;IACnF,gBAAgB,CACd,SAAS,GAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAe,EACpD,OAAO,GAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAe;CAU9C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { JSONValue } from '../types';
|
|
2
|
+
import { WorkerClient } from '../worker';
|
|
3
|
+
export declare class FederationService {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: WorkerClient);
|
|
6
|
+
getConfig(): Promise<JSONValue>;
|
|
7
|
+
getFederationId(): Promise<string>;
|
|
8
|
+
getInviteCode(peer?: number): Promise<string | null>;
|
|
9
|
+
listOperations(): Promise<JSONValue[]>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=FederationService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FederationService.d.ts","sourceRoot":"","sources":["../../../src/services/FederationService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,qBAAa,iBAAiB;IAChB,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;IAElC,SAAS;IAIT,eAAe;IAIf,aAAa,CAAC,IAAI,GAAE,MAAU;IAM9B,cAAc;CAGrB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { WorkerClient } from '../worker';
|
|
2
|
+
import type { CreateBolt11Response, GatewayInfo, JSONObject, LightningGateway, LnPayState, LnReceiveState, OutgoingLightningPayment } from '../types';
|
|
3
|
+
export declare class LightningService {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: WorkerClient);
|
|
6
|
+
/** https://web.fedimint.org/core/FedimintWallet/LightningService/createInvoice#lightning-createinvoice */
|
|
7
|
+
createInvoice(amountMsats: number, description: string, expiryTime?: number, // in seconds
|
|
8
|
+
gatewayInfo?: GatewayInfo, extraMeta?: JSONObject): Promise<CreateBolt11Response>;
|
|
9
|
+
createInvoiceTweaked(amountMsats: number, description: string, tweakKey: string, index: number, expiryTime?: number, // in seconds
|
|
10
|
+
gatewayInfo?: GatewayInfo, extraMeta?: JSONObject): Promise<CreateBolt11Response>;
|
|
11
|
+
scanReceivesForTweaks(tweakKey: string, indices: number[], extraMeta?: JSONObject): Promise<string[]>;
|
|
12
|
+
private _getDefaultGatewayInfo;
|
|
13
|
+
/** https://web.fedimint.org/core/FedimintWallet/LightningService/payInvoice#lightning-payinvoice-invoice-string */
|
|
14
|
+
payInvoice(invoice: string, gatewayInfo?: GatewayInfo, extraMeta?: JSONObject): Promise<OutgoingLightningPayment>;
|
|
15
|
+
/** https://web.fedimint.org/core/FedimintWallet/LightningService/payInvoice#lightning-payinvoicesync-invoice-string */
|
|
16
|
+
payInvoiceSync(invoice: string, timeoutMs?: number, gatewayInfo?: GatewayInfo, extraMeta?: JSONObject): Promise<{
|
|
17
|
+
success: false;
|
|
18
|
+
error?: string;
|
|
19
|
+
} | {
|
|
20
|
+
success: true;
|
|
21
|
+
data: {
|
|
22
|
+
feeMsats: number;
|
|
23
|
+
preimage: string;
|
|
24
|
+
};
|
|
25
|
+
}>;
|
|
26
|
+
subscribeLnClaim(operationId: string, onSuccess?: (state: LnReceiveState) => void, onError?: (error: string) => void): import("../types").CancelFunction;
|
|
27
|
+
/** https://web.fedimint.org/core/FedimintWallet/LightningService/payInvoice#lightning-payinvoice-invoice-string */
|
|
28
|
+
subscribeLnPay(operationId: string, onSuccess?: (state: LnPayState) => void, onError?: (error: string) => void): import("../types").CancelFunction;
|
|
29
|
+
/** https://web.fedimint.org/core/FedimintWallet/LightningService/payInvoice#lightning-payinvoice-invoice-string */
|
|
30
|
+
waitForPay(operationId: string): Promise<{
|
|
31
|
+
success: false;
|
|
32
|
+
error?: string;
|
|
33
|
+
} | {
|
|
34
|
+
success: true;
|
|
35
|
+
data: {
|
|
36
|
+
preimage: string;
|
|
37
|
+
};
|
|
38
|
+
}>;
|
|
39
|
+
/** https://web.fedimint.org/core/FedimintWallet/LightningService/createInvoice#lightning-createinvoice */
|
|
40
|
+
subscribeLnReceive(operationId: string, onSuccess?: (state: LnReceiveState) => void, onError?: (error: string) => void): import("../types").CancelFunction;
|
|
41
|
+
/** https://web.fedimint.org/core/FedimintWallet/LightningService/createInvoice#lightning-createinvoice */
|
|
42
|
+
waitForReceive(operationId: string, timeoutMs?: number): Promise<LnReceiveState>;
|
|
43
|
+
getGateway(gatewayId?: string | null, forceInternal?: boolean): Promise<LightningGateway | null>;
|
|
44
|
+
listGateways(): Promise<LightningGateway[]>;
|
|
45
|
+
updateGatewayCache(): Promise<import("../types").JSONValue>;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=LightningService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LightningService.d.ts","sourceRoot":"","sources":["../../../src/services/LightningService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,KAAK,EACV,oBAAoB,EACpB,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,wBAAwB,EACzB,MAAM,UAAU,CAAA;AAEjB,qBAAa,gBAAgB;IACf,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;IAExC,0GAA0G;IACpG,aAAa,CACjB,WAAW,EAAE,MAAM,EACnB,WAAW,EA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E,MAAM,CAAA;SAAE;;IA4BjD,0GAA0G;IAC1G,kBAAkB,CAChB,WAAW,EAAE,MAAM,EACnB,SAAS,GAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAe,EACrD,OAAO,GAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAe;IAW7C,0GAA0G;IACpG,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,GAAE,MAAc;IAyB7D,UAAU,CACd,SAAS,GAAE,MAAM,GAAG,IAAW,EAC/B,aAAa,GAAE,OAAe;IAY1B,YAAY;IAQZ,kBAAkB;CAGzB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { WorkerClient } from '../worker';
|
|
2
|
+
import type { Duration, JSONObject, JSONValue, NoteCountByDenomination, ReissueExternalNotesState, SpendNotesState } from '../types';
|
|
3
|
+
export declare class MintService {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: WorkerClient);
|
|
6
|
+
/** https://web.fedimint.org/core/FedimintWallet/MintService/redeemEcash */
|
|
7
|
+
redeemEcash(notes: string): Promise<string>;
|
|
8
|
+
reissueExternalNotes(oobNotes: string, extraMeta?: JSONObject): Promise<string>;
|
|
9
|
+
subscribeReissueExternalNotes(operationId: string, onSuccess?: (state: ReissueExternalNotesState) => void, onError?: (error: string) => void): import("../types").CancelFunction;
|
|
10
|
+
/** https://web.fedimint.org/core/FedimintWallet/MintService/spendNotes */
|
|
11
|
+
spendNotes(amountMsats: number, tryCancelAfter?: number | Duration, // defaults to 1 day
|
|
12
|
+
includeInvite?: boolean, extraMeta?: JSONValue): Promise<{
|
|
13
|
+
notes: string;
|
|
14
|
+
operation_id: string;
|
|
15
|
+
}>;
|
|
16
|
+
/** https://web.fedimint.org/core/FedimintWallet/MintService/parseEcash */
|
|
17
|
+
parseNotes(oobNotes: string): Promise<number>;
|
|
18
|
+
tryCancelSpendNotes(operationId: string): Promise<void>;
|
|
19
|
+
subscribeSpendNotes(operationId: string, onSuccess?: (state: SpendNotesState) => void, onError?: (error: string) => void): import("../types").CancelFunction;
|
|
20
|
+
awaitSpendOobRefund(operationId: string): Promise<JSONValue>;
|
|
21
|
+
getNotesByDenomination(): Promise<NoteCountByDenomination>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=MintService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MintService.d.ts","sourceRoot":"","sources":["../../../src/services/MintService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,SAAS,EAGT,uBAAuB,EACvB,yBAAyB,EACzB,eAAe,EAChB,MAAM,UAAU,CAAA;AAEjB,qBAAa,WAAW;IACV,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;IAExC,2EAA2E;IACrE,WAAW,CAAC,KAAK,EAAE,MAAM;IAWzB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,GAAE,UAAe;IAWvE,6BAA6B,CAC3B,WAAW,EAAE,MAAM,EACnB,SAAS,GAAE,CAAC,KAAK,EAAE,yBAAyB,KAAK,IAAe,EAChE,OAAO,GAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAe;IAa7C,0EAA0E;IACpE,UAAU,CACd,WAAW,EAAE,MAAM,EAInB,cAAc,GAAE,MAAM,GAAG,QAAoB,EAAE,oBAAoB;IACnE,aAAa,GAAE,OAAe,EAC9B,SAAS,GAAE,SAAc;;;;IA0B3B,0EAA0E;IACpE,UAAU,CAAC,QAAQ,EAAE,MAAM;IAM3B,mBAAmB,CAAC,WAAW,EAAE,MAAM;IAM7C,mBAAmB,CACjB,WAAW,EAAE,MAAM,EACnB,SAAS,GAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAe,EACtD,OAAO,GAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAe;IAWvC,mBAAmB,CAAC,WAAW,EAAE,MAAM;IAMvC,sBAAsB;CAO7B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { JSONValue } from '../types';
|
|
2
|
+
import { WorkerClient } from '../worker';
|
|
3
|
+
export declare class RecoveryService {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: WorkerClient);
|
|
6
|
+
hasPendingRecoveries(): Promise<boolean>;
|
|
7
|
+
waitForAllRecoveries(): Promise<void>;
|
|
8
|
+
subscribeToRecoveryProgress(onSuccess: (progress: {
|
|
9
|
+
module_id: number;
|
|
10
|
+
progress: JSONValue;
|
|
11
|
+
}) => void, onError: (error: string) => void): import("../types").CancelFunction;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=RecoveryService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RecoveryService.d.ts","sourceRoot":"","sources":["../../../src/services/RecoveryService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,qBAAa,eAAe;IACd,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;IAElC,oBAAoB;IAQpB,oBAAoB;IAI1B,2BAA2B,CACzB,SAAS,EAAE,CAAC,QAAQ,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,SAAS,CAAA;KAAE,KAAK,IAAI,EACzE,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI;CAOnC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { WalletSummary } from '../types';
|
|
2
|
+
import { WorkerClient } from '../worker';
|
|
3
|
+
export declare class WalletService {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: WorkerClient);
|
|
6
|
+
getWalletSummary(): Promise<WalletSummary>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=WalletService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WalletService.d.ts","sourceRoot":"","sources":["../../../src/services/WalletService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,qBAAa,aAAa;IACZ,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;IAElC,gBAAgB,IAAI,OAAO,CAAC,aAAa,CAAC;CAGjD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { MintService } from './MintService';
|
|
2
|
+
export { BalanceService } from './BalanceService';
|
|
3
|
+
export { LightningService } from './LightningService';
|
|
4
|
+
export { RecoveryService } from './RecoveryService';
|
|
5
|
+
export { FederationService } from './FederationService';
|
|
6
|
+
export { WalletService } from './WalletService';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
type Alias<T> = T & {};
|
|
2
|
+
type Resolve<T> = T & unknown;
|
|
3
|
+
type Seconds = Alias<number>;
|
|
4
|
+
type Nanos = Alias<number>;
|
|
5
|
+
type Duration = {
|
|
6
|
+
nanos: Nanos;
|
|
7
|
+
secs: Seconds;
|
|
8
|
+
};
|
|
9
|
+
type MSats = Alias<number>;
|
|
10
|
+
type Sats = Alias<number>;
|
|
11
|
+
type JSONValue = string | number | boolean | null | {
|
|
12
|
+
[key: string]: JSONValue;
|
|
13
|
+
} | JSONValue[];
|
|
14
|
+
type JSONObject = Record<string, JSONValue>;
|
|
15
|
+
type Result<T, U = string> = {
|
|
16
|
+
success: true;
|
|
17
|
+
data?: T;
|
|
18
|
+
} | {
|
|
19
|
+
success: false;
|
|
20
|
+
error: U;
|
|
21
|
+
};
|
|
22
|
+
export { Alias, Resolve, Duration, MSats, Sats, JSONValue, JSONObject, Result };
|
|
23
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/types/utils.ts"],"names":[],"mappings":"AAAA,KAAK,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAA;AACtB,KAAK,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAA;AAE7B,KAAK,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAA;AAC5B,KAAK,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAA;AAE1B,KAAK,QAAQ,GAAG;IACd,KAAK,EAAE,KAAK,CAAA;IACZ,IAAI,EAAE,OAAO,CAAA;CACd,CAAA;AAED,KAAK,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAA;AAC1B,KAAK,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,CAAA;AAEzB,KAAK,SAAS,GACV,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAC5B,SAAS,EAAE,CAAA;AAEf,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;AAE3C,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,IACrB;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,CAAC,EAAE,CAAC,CAAA;CAAE,GAC3B;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,CAAA;AAEhC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { MSats, Duration, JSONValue, JSONObject } from './utils';
|
|
2
|
+
declare const MODULE_KINDS: readonly ["", "ln", "mint", "wallet"];
|
|
3
|
+
type ModuleKind = (typeof MODULE_KINDS)[number];
|
|
4
|
+
type FederationConfig = JSONObject;
|
|
5
|
+
type GatewayInfo = {
|
|
6
|
+
gateway_id: string;
|
|
7
|
+
api: string;
|
|
8
|
+
node_pub_key: string;
|
|
9
|
+
federation_index: number;
|
|
10
|
+
route_hints: RouteHint[];
|
|
11
|
+
fees: FeeToAmount;
|
|
12
|
+
};
|
|
13
|
+
type LightningGateway = {
|
|
14
|
+
info: GatewayInfo;
|
|
15
|
+
vetted: boolean;
|
|
16
|
+
ttl: Duration;
|
|
17
|
+
};
|
|
18
|
+
type RouteHint = {};
|
|
19
|
+
type FeeToAmount = {};
|
|
20
|
+
type OutgoingLightningPayment = {
|
|
21
|
+
payment_type: PayType;
|
|
22
|
+
contract_id: string;
|
|
23
|
+
fee: MSats;
|
|
24
|
+
};
|
|
25
|
+
type PayType = {
|
|
26
|
+
lightning: string;
|
|
27
|
+
} | {
|
|
28
|
+
internal: string;
|
|
29
|
+
};
|
|
30
|
+
type LnPayState = 'created' | 'canceled' | {
|
|
31
|
+
funded: {
|
|
32
|
+
block_height: number;
|
|
33
|
+
};
|
|
34
|
+
} | {
|
|
35
|
+
waiting_for_refund: {
|
|
36
|
+
error_reason: string;
|
|
37
|
+
};
|
|
38
|
+
} | 'awaiting_change' | {
|
|
39
|
+
success: {
|
|
40
|
+
preimage: string;
|
|
41
|
+
};
|
|
42
|
+
} | {
|
|
43
|
+
refunded: {
|
|
44
|
+
gateway_error: string;
|
|
45
|
+
};
|
|
46
|
+
} | {
|
|
47
|
+
unexpected_error: {
|
|
48
|
+
error_message: string;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
type LnReceiveState = 'created' | {
|
|
52
|
+
waiting_for_payment: {
|
|
53
|
+
invoice: string;
|
|
54
|
+
timeout: number;
|
|
55
|
+
};
|
|
56
|
+
} | {
|
|
57
|
+
canceled: {
|
|
58
|
+
reason: string;
|
|
59
|
+
};
|
|
60
|
+
} | 'funded' | 'awaiting_funds' | 'claimed';
|
|
61
|
+
type CreateBolt11Response = {
|
|
62
|
+
operation_id: string;
|
|
63
|
+
invoice: string;
|
|
64
|
+
};
|
|
65
|
+
type StreamError = {
|
|
66
|
+
error: string;
|
|
67
|
+
data: never;
|
|
68
|
+
end: never;
|
|
69
|
+
};
|
|
70
|
+
type StreamSuccess<T extends JSONValue> = {
|
|
71
|
+
data: T;
|
|
72
|
+
error: never;
|
|
73
|
+
end: never;
|
|
74
|
+
};
|
|
75
|
+
type StreamEnd = {
|
|
76
|
+
end: string;
|
|
77
|
+
data: never;
|
|
78
|
+
error: never;
|
|
79
|
+
};
|
|
80
|
+
type StreamResult<T extends JSONValue> = StreamSuccess<T> | StreamError | StreamEnd;
|
|
81
|
+
type CancelFunction = () => void;
|
|
82
|
+
type ReissueExternalNotesState = 'Created' | 'Issuing' | 'Done';
|
|
83
|
+
type MintSpendNotesResponse = Array<string>;
|
|
84
|
+
type SpendNotesState = 'Created' | 'UserCanceledProcessing' | 'UserCanceledSuccess' | 'UserCanceledFailure' | 'Success' | 'Refunded';
|
|
85
|
+
type TxOutputSummary = {
|
|
86
|
+
outpoint: {
|
|
87
|
+
txid: string;
|
|
88
|
+
vout: number;
|
|
89
|
+
};
|
|
90
|
+
amount: number;
|
|
91
|
+
};
|
|
92
|
+
type WalletSummary = {
|
|
93
|
+
spendable_utxos: TxOutputSummary[];
|
|
94
|
+
unsigned_peg_out_txos: TxOutputSummary[];
|
|
95
|
+
unsigned_change_utxos: TxOutputSummary[];
|
|
96
|
+
unconfirmed_peg_out_txos: TxOutputSummary[];
|
|
97
|
+
unconfirmed_change_utxos: TxOutputSummary[];
|
|
98
|
+
};
|
|
99
|
+
/** Keys are powers of 2 */
|
|
100
|
+
type NoteCountByDenomination = Record<number, number>;
|
|
101
|
+
export { LightningGateway, FederationConfig, RouteHint, FeeToAmount, OutgoingLightningPayment, PayType, LnPayState, LnReceiveState, CreateBolt11Response, GatewayInfo, StreamError, StreamSuccess, StreamResult, ModuleKind, CancelFunction, ReissueExternalNotesState, MintSpendNotesResponse, SpendNotesState, WalletSummary, TxOutputSummary, NoteCountByDenomination, };
|
|
102
|
+
//# sourceMappingURL=wallet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../../src/types/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEhE,QAAA,MAAM,YAAY,uCAAwC,CAAA;AAC1D,KAAK,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AAG/C,KAAK,gBAAgB,GAAG,UAAU,CAAA;AAElC,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,GAAG,EAAE,MAAM,CAAA;IACX,YAAY,EAAE,MAAM,CAAA;IACpB,gBAAgB,EAAE,MAAM,CAAA;IACxB,WAAW,EAAE,SAAS,EAAE,CAAA;IACxB,IAAI,EAAE,WAAW,CAAA;CAClB,CAAA;AACD,KAAK,gBAAg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S,EACT,WAAW,EACX,wBAAwB,EACxB,OAAO,EACP,UAAU,EACV,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,WAAW,EACX,aAAa,EACb,YAAY,EACZ,UAAU,EACV,cAAc,EACd,yBAAyB,EACzB,sBAAsB,EACtB,eAAe,EACf,aAAa,EACb,eAAe,EACf,uBAAuB,GACxB,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
declare const WorkerMessageTypes: readonly ["init", "initialized", "rpc", "log", "open", "join", "error", "unsubscribe", "cleanup", "parseInviteCode", "parseBolt11Invoice", "previewFederation"];
|
|
2
|
+
export type WorkerMessageType = (typeof WorkerMessageTypes)[number];
|
|
3
|
+
export {};
|
|
4
|
+
//# sourceMappingURL=worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../../src/types/worker.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,kBAAkB,iKAad,CAAA;AAEV,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare const logLevels: readonly ["debug", "info", "warn", "error", "none"];
|
|
2
|
+
export type LogLevel = (typeof logLevels)[number];
|
|
3
|
+
export declare class Logger {
|
|
4
|
+
private level;
|
|
5
|
+
constructor(level?: LogLevel);
|
|
6
|
+
setLevel(level: LogLevel): void;
|
|
7
|
+
coerceLevel(level: string): LogLevel;
|
|
8
|
+
log(level: string, message: string, ...args: any[]): void;
|
|
9
|
+
debug(message: string, ...args: any[]): void;
|
|
10
|
+
info(message: string, ...args: any[]): void;
|
|
11
|
+
warn(message: string, ...args: any[]): void;
|
|
12
|
+
error(message: string, ...args: any[]): void;
|
|
13
|
+
private shouldLog;
|
|
14
|
+
}
|
|
15
|
+
export declare const logger: Logger;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,SAAS,qDAAsD,CAAA;AACrE,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAA;AAEjD,qBAAa,MAAM;IACjB,OAAO,CAAC,KAAK,CAAU;gBAEX,KAAK,GAAE,QAAiB;IAIpC,QAAQ,CAAC,KAAK,EAAE,QAAQ;IAIxB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ;IAOpC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IASlD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAIrC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAIpC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAIpC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAIrC,OAAO,CAAC,SAAS;CAYlB;AAED,eAAO,MAAM,MAAM,QAAe,CAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { CancelFunction, JSONValue, ModuleKind, StreamError, WorkerMessageType } from '../types';
|
|
2
|
+
export declare class WorkerClient {
|
|
3
|
+
private worker;
|
|
4
|
+
private requestCounter;
|
|
5
|
+
private requestCallbacks;
|
|
6
|
+
private initPromise;
|
|
7
|
+
constructor();
|
|
8
|
+
initialize(): Promise<boolean>;
|
|
9
|
+
private handleWorkerLogs;
|
|
10
|
+
private handleWorkerError;
|
|
11
|
+
private handleWorkerMessage;
|
|
12
|
+
sendSingleMessage<Response extends JSONValue = JSONValue, Payload extends JSONValue = JSONValue>(type: WorkerMessageType, payload?: Payload): Promise<Response>;
|
|
13
|
+
/**
|
|
14
|
+
* @summary Initiates an RPC stream with the specified module and method.
|
|
15
|
+
*
|
|
16
|
+
* @description
|
|
17
|
+
* This function sets up an RPC stream by sending a request to a worker and
|
|
18
|
+
* handling responses asynchronously. It ensures that unsubscription is handled
|
|
19
|
+
* correctly, even if the unsubscribe function is called before the subscription
|
|
20
|
+
* is fully established, by deferring the unsubscription attempt using `setTimeout`.
|
|
21
|
+
*
|
|
22
|
+
* The function operates in a non-blocking manner, leveraging Promises to manage
|
|
23
|
+
* asynchronous operations and callbacks to handle responses.
|
|
24
|
+
*
|
|
25
|
+
*
|
|
26
|
+
* @template Response - The expected type of the successful response.
|
|
27
|
+
* @template Body - The type of the request body.
|
|
28
|
+
* @param module - The module kind to interact with.
|
|
29
|
+
* @param method - The method name to invoke on the module.
|
|
30
|
+
* @param body - The request payload.
|
|
31
|
+
* @param onSuccess - Callback invoked with the response data on success.
|
|
32
|
+
* @param onError - Callback invoked with error information if an error occurs.
|
|
33
|
+
* @param onEnd - Optional callback invoked when the stream ends.
|
|
34
|
+
* @returns A function that can be called to cancel the subscription.
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
|
+
rpcStream<Response extends JSONValue = JSONValue, Body extends JSONValue = JSONValue>(module: ModuleKind, method: string, body: Body, onSuccess: (res: Response) => void, onError: (res: StreamError['error']) => void, onEnd?: () => void): CancelFunction;
|
|
38
|
+
private _rpcStreamInner;
|
|
39
|
+
rpcSingle<Response extends JSONValue = JSONValue, Error extends string = string>(module: ModuleKind, method: string, body: JSONValue): Promise<Response>;
|
|
40
|
+
cleanup(): Promise<void>;
|
|
41
|
+
_getRequestCounter(): number;
|
|
42
|
+
_getRequestCallbackMap(): Map<number, (value: any) => void>;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=WorkerClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorkerClient.d.ts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