@fedimint/core-web 0.0.6 → 0.0.7

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 (64) hide show
  1. package/README.md +6 -71
  2. package/dist/{FedimintWallet.d.ts → dts/FedimintWallet.d.ts} +2 -2
  3. package/dist/dts/FedimintWallet.d.ts.map +1 -0
  4. package/dist/dts/index.d.ts +3 -0
  5. package/dist/dts/index.d.ts.map +1 -0
  6. package/dist/{services → dts/services}/BalanceService.d.ts +5 -4
  7. package/dist/dts/services/BalanceService.d.ts.map +1 -0
  8. package/dist/{services → dts/services}/FederationService.d.ts +1 -1
  9. package/dist/dts/services/FederationService.d.ts.map +1 -0
  10. package/dist/dts/services/LightningService.d.ts +21 -0
  11. package/dist/dts/services/LightningService.d.ts.map +1 -0
  12. package/dist/{services → dts/services}/MintService.d.ts +6 -5
  13. package/dist/dts/services/MintService.d.ts.map +1 -0
  14. package/dist/{services → dts/services}/RecoveryService.d.ts +1 -1
  15. package/dist/dts/services/RecoveryService.d.ts.map +1 -0
  16. package/dist/dts/services/index.d.ts.map +1 -0
  17. package/dist/dts/types/index.d.ts +4 -0
  18. package/dist/dts/types/index.d.ts.map +1 -0
  19. package/dist/dts/types/utils.d.ts +16 -0
  20. package/dist/dts/types/utils.d.ts.map +1 -0
  21. package/dist/{types → dts/types}/wallet.d.ts +4 -14
  22. package/dist/dts/types/wallet.d.ts.map +1 -0
  23. package/dist/dts/types/worker.d.ts +4 -0
  24. package/dist/dts/types/worker.d.ts.map +1 -0
  25. package/dist/dts/utils/logger.d.ts.map +1 -0
  26. package/dist/{worker → dts/worker}/WorkerClient.d.ts +3 -3
  27. package/dist/dts/worker/WorkerClient.d.ts.map +1 -0
  28. package/dist/dts/worker/index.d.ts.map +1 -0
  29. package/dist/index.d.ts +298 -5
  30. package/dist/index.js +1 -1
  31. package/dist/index.js.map +1 -1
  32. package/package.json +8 -5
  33. package/src/FedimintWallet.ts +10 -10
  34. package/src/index.ts +2 -22
  35. package/src/services/BalanceService.ts +5 -4
  36. package/src/services/FederationService.ts +1 -1
  37. package/src/services/LightningService.test.ts +83 -37
  38. package/src/services/LightningService.ts +68 -40
  39. package/src/services/MintService.test.ts +8 -1
  40. package/src/services/MintService.ts +6 -5
  41. package/src/services/RecoveryService.ts +1 -1
  42. package/src/test/crypto.ts +44 -0
  43. package/src/types/index.ts +3 -0
  44. package/src/types/utils.ts +25 -0
  45. package/src/types/wallet.ts +4 -23
  46. package/src/types/worker.ts +12 -0
  47. package/src/worker/WorkerClient.ts +25 -18
  48. package/src/worker/worker.test.ts +1 -1
  49. package/dist/FedimintWallet.d.ts.map +0 -1
  50. package/dist/index.d.ts.map +0 -1
  51. package/dist/services/BalanceService.d.ts.map +0 -1
  52. package/dist/services/FederationService.d.ts.map +0 -1
  53. package/dist/services/LightningService.d.ts +0 -18
  54. package/dist/services/LightningService.d.ts.map +0 -1
  55. package/dist/services/MintService.d.ts.map +0 -1
  56. package/dist/services/RecoveryService.d.ts.map +0 -1
  57. package/dist/services/index.d.ts.map +0 -1
  58. package/dist/types/wallet.d.ts.map +0 -1
  59. package/dist/utils/logger.d.ts.map +0 -1
  60. package/dist/worker/WorkerClient.d.ts.map +0 -1
  61. package/dist/worker/index.d.ts.map +0 -1
  62. /package/dist/{services → dts/services}/index.d.ts +0 -0
  63. /package/dist/{utils → dts/utils}/logger.d.ts +0 -0
  64. /package/dist/{worker → dts/worker}/index.d.ts +0 -0
package/README.md CHANGED
@@ -1,80 +1,15 @@
1
1
  # @fedimint/core-web
2
2
 
3
- ### THIS IS A WORK IN PROGRESS AND NOT READY FOR SERIOUS USE
3
+ ### This is early software. Use with caution. Report Bugs.
4
4
 
5
- This package provides a typescript interface for a fedimint client in the browser.
5
+ Check out the [Getting Started Guide](https://web.fedimint.org/core/getting-started.html) for more information.
6
6
 
7
- It contains the wasm-pack output of the rust-based [fedimint client](https://github.com/fedimint/fedimint/tree/master/fedimint-client-wasm).
7
+ ---
8
8
 
9
- ## Key Features:
9
+ Also check out the examples for working code
10
10
 
11
- - **WebAssembly-powered Client**: Exposes the robust, fault-tolerant fedimint-client (built in Rust) via WebAssembly. Lazy-Loads within a web worker for performance.
12
- - **eCash Payments**: Includes support for joining federations, sending/receiving eCash, and managing balances.
13
- - **Lightning Payments**: Ships with zero-setup Lightning Network payments.
14
- - 🛠️ **State Management**: Handles the complex state management and storage challenges for browser wallets.
15
- - 🤫 **Privacy Included**: Offers a privacy-centric wallet by default.
16
- - ⚙️ **Framework Agnostic**: Designed as a "core" library compatible with vanilla JavaScript, laying the groundwork for future framework-specific packages.
17
-
18
- ## Installation
19
-
20
- ```bash
21
- // npm or yarn or pnpm
22
- pnpm add @fedimint/core-web
23
- ```
24
-
25
- ## Setup
26
-
27
- This package relies on the wasm binary to be bundled with your application. You will likely need to update your bundler's or framework's configuration to load the wasm file. Setup guides for popular frameworks are coming soon.
28
-
29
- See the `vite.config.ts` file in the [vite-core example](../../examples/vite-core/vite.config.ts) for an example of configuring wasm within a web-worker using Vite.
30
-
31
- ## Usage
32
-
33
- ```ts
34
- import { FedimintWallet } from '@fedimint/core-web'
35
-
36
- // Create the Wallet client
37
- const wallet = new FedimintWallet()
38
-
39
- // This should be called only once in the application
40
- // lifecycle. It will automatically load your saved
41
- // wallet state from previous sessions.
42
- await wallet.open()
43
-
44
- // Joining a Federation
45
-
46
- // You can't join a federation
47
- // if your wallet is already open
48
- if (!wallet.isOpen()) {
49
- // Check out [bitcoin mints](https://bitcoinmints.com/?tab=mints&showFedimint=true) for
50
- // a list of federations with public invite codes.
51
- const inviteCode = 'fed11qgqpw9thwvaz7t...'
52
-
53
- await wallet.joinFederation(inviteCode)
54
- // After you've joined a federation, your federation state
55
- // will be stored in the browser. Future calls to `open()`
56
- // will automatically load your saved federation.
57
- }
58
-
59
- // Get Wallet Balance (sync)
60
- const balance = await wallet.balance.getBalance()
61
-
62
- // Subscribe to Balance Updates
63
- const unsubscribe = wallet.balance.subscribeBalance((balance: number) => {
64
- console.log('updated balance', balance)
65
- })
66
- // Make sure to call `unsubscribe()` when you're done
67
-
68
- // Receive Ecash Payments
69
- await wallet.mint.reissueNotes('A11qgqpw9thwvaz7t...')
70
-
71
- // Pay Lightning Invoice
72
- await wallet.lightning.payInvoice('lnbc...')
73
- ```
74
-
75
- ### Check out the example
76
-
77
- - Vite + React: [`examples/vite-core`](../../examples/vite-core/README.md) [(demo)](https://fedimint.github.io/fedimint-web-sdk/)
11
+ - [Vite + React](https://web.fedimint.org/examples/vite-react)
12
+ - [Bare JS](https://web.fedimint.org/examples/bare-js)
78
13
 
79
14
  ### Resources
80
15
 
@@ -41,8 +41,8 @@ export declare class FedimintWallet {
41
41
  */
42
42
  constructor(lazy?: boolean);
43
43
  initialize(): Promise<void>;
44
- waitForOpen(): Promise<void | null>;
45
- open(clientName?: string): Promise<any>;
44
+ waitForOpen(): Promise<void>;
45
+ open(clientName?: string): Promise<boolean>;
46
46
  joinFederation(inviteCode: string, clientName?: string): Promise<void>;
47
47
  /**
48
48
  * This should ONLY be called when UNLOADING the wallet client.
@@ -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,EAChB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAU,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAItD,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;IAEhC,OAAO,CAAC,YAAY,CAAuC;IAC3D,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,OAAO,CAAiB;IAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;gBACS,IAAI,GAAE,OAAe;IAkB3B,UAAU;IAMV,WAAW;IAKX,IAAI,CAAC,UAAU,GAAE,MAA4B;IAc7C,cAAc,CAClB,UAAU,EAAE,MAAM,EAClB,UAAU,GAAE,MAA4B;IAkB1C;;;OAGG;IACG,OAAO;IAMb,MAAM;IAIN;;;OAGG;IACH,WAAW,CAAC,KAAK,EAAE,QAAQ;CAI5B"}
@@ -0,0 +1,3 @@
1
+ export { FedimintWallet } from './FedimintWallet';
2
+ export type * from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -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"}
@@ -1,3 +1,4 @@
1
+ import type { MSats } from '../types';
1
2
  import { WorkerClient } from '../worker';
2
3
  /**
3
4
  * Balance Service
@@ -8,16 +9,16 @@ export declare class BalanceService {
8
9
  private client;
9
10
  constructor(client: WorkerClient);
10
11
  /**
11
- * Get the balance of the current wallet
12
+ * Get the balance of the current wallet in milli-satoshis (MSats)
12
13
  *
13
14
  * @example
14
15
  * ```ts
15
16
  * const balance = await wallet.balance.getBalance()
16
17
  * ```
17
18
  */
18
- getBalance(): Promise<number>;
19
+ getBalance(): Promise<MSats>;
19
20
  /**
20
- * Subscribe to the balance of the current wallet
21
+ * Subscribe to the balance of the current wallet in milli-satoshis (MSats)
21
22
  *
22
23
  * @example
23
24
  * ```ts
@@ -29,6 +30,6 @@ export declare class BalanceService {
29
30
  * unsubscribe()
30
31
  * ```
31
32
  */
32
- subscribeBalance(onSuccess?: (balance: number) => void, onError?: (error: string) => void): import("../types/wallet").CancelFunction;
33
+ subscribeBalance(onSuccess?: (balance: MSats) => void, onError?: (error: string) => void): import("../types").CancelFunction;
33
34
  }
34
35
  //# 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,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC;;;;GAIG;AACH,qBAAa,cAAc;IACb,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;IAExC;;;;;;;OAOG;IACG,UAAU,IAAI,OAAO,CAAC,KAAK,CAAC;IAIlC;;;;;;;;;;;;OAYG;IACH,gBAAgB,CACd,SAAS,GAAE,CAAC,OAAO,EAAE,KAAK,KAAK,IAAe,EAC9C,OAAO,GAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAe;CAY9C"}
@@ -1,4 +1,4 @@
1
- import { JSONValue } from '../types/wallet';
1
+ import type { JSONValue } from '../types';
2
2
  import { WorkerClient } from '../worker';
3
3
  export declare class FederationService {
4
4
  private client;
@@ -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,IAAI,OAAO,CAAC,SAAS,CAAC;IAI/B,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC;IAIlC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAInD,cAAc,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;CAG7C"}
@@ -0,0 +1,21 @@
1
+ import { WorkerClient } from '../worker';
2
+ import type { CreateBolt11Response, GatewayInfo, JSONObject, JSONValue, LightningGateway, LnPayState, LnReceiveState, MSats, OutgoingLightningPayment } from '../types';
3
+ export declare class LightningService {
4
+ private client;
5
+ constructor(client: WorkerClient);
6
+ createInvoice(amount: MSats, description: string, expiryTime?: number, // in seconds
7
+ extraMeta?: JSONObject, gatewayInfo?: GatewayInfo): Promise<CreateBolt11Response>;
8
+ createInvoiceTweaked(amount: MSats, description: string, tweakKey: string, index: number, expiryTime?: number, // in seconds
9
+ gatewayInfo?: GatewayInfo, extraMeta?: JSONObject): Promise<CreateBolt11Response>;
10
+ scanReceivesForTweaks(tweakKey: string, indices: number[], extraMeta?: JSONObject): Promise<string[]>;
11
+ private _getDefaultGatewayInfo;
12
+ payInvoice(invoice: string, gatewayInfo?: GatewayInfo, extraMeta?: JSONObject): Promise<OutgoingLightningPayment>;
13
+ subscribeLnClaim(operationId: string, onSuccess?: (state: LnReceiveState) => void, onError?: (error: string) => void): import("../types").CancelFunction;
14
+ subscribeLnPay(operationId: string, onSuccess?: (state: LnPayState) => void, onError?: (error: string) => void): import("../types").CancelFunction;
15
+ subscribeLnReceive(operationId: string, onSuccess?: (state: LnReceiveState) => void, onError?: (error: string) => void): import("../types").CancelFunction;
16
+ waitForReceive(operationId: string): Promise<LnReceiveState>;
17
+ getGateway(gatewayId?: string | null, forceInternal?: boolean): Promise<LightningGateway | null>;
18
+ listGateways(): Promise<LightningGateway[]>;
19
+ updateGatewayCache(): Promise<JSONValue>;
20
+ }
21
+ //# 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,SAAS,EACT,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,KAAK,EACL,wBAAwB,EACzB,MAAM,UAAU,CAAA;AAEjB,qBAAa,gBAAgB;IACf,OAAO,CAAC,MAAM;gBAA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,cAAc,CAAC;IAgB5D,UAAU,CACd,SAAS,GAAE,MAAM,GAAG,IAAW,EAC/B,aAAa,GAAE,OAAe,GAC7B,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAO7B,YAAY,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAI3C,kBAAkB,IAAI,OAAO,CAAC,SAAS,CAAC;CAG/C"}
@@ -1,15 +1,16 @@
1
1
  import { WorkerClient } from '../worker';
2
- import { Duration, JSONObject, JSONValue, MintSpendNotesResponse } from '../types/wallet';
2
+ import type { Duration, JSONObject, JSONValue, MintSpendNotesResponse, MSats } from '../types';
3
3
  export declare class MintService {
4
4
  private client;
5
5
  constructor(client: WorkerClient);
6
6
  redeemEcash(notes: string): Promise<void>;
7
7
  reissueExternalNotes(oobNotes: string, extraMeta?: JSONObject): Promise<string>;
8
- subscribeReissueExternalNotes(operationId: string, onSuccess?: (state: JSONValue) => void, onError?: (error: string) => void): import("../types/wallet").CancelFunction;
9
- spendNotes(minAmount: number, tryCancelAfter?: number | Duration, includeInvite?: boolean, extraMeta?: JSONValue): Promise<MintSpendNotesResponse>;
10
- validateNotes(oobNotes: string): Promise<number>;
8
+ subscribeReissueExternalNotes(operationId: string, onSuccess?: (state: JSONValue) => void, onError?: (error: string) => void): import("../types").CancelFunction;
9
+ spendNotes(minAmount: MSats, tryCancelAfter?: number | Duration, // in seconds or Duration object
10
+ includeInvite?: boolean, extraMeta?: JSONValue): Promise<MintSpendNotesResponse>;
11
+ parseNotes(oobNotes: string): Promise<MSats>;
11
12
  tryCancelSpendNotes(operationId: string): Promise<void>;
12
- subscribeSpendNotes(operationId: string, onSuccess?: (state: JSONValue) => void, onError?: (error: string) => void): import("../types/wallet").CancelFunction;
13
+ subscribeSpendNotes(operationId: string, onSuccess?: (state: JSONValue) => void, onError?: (error: string) => void): import("../types").CancelFunction;
13
14
  awaitSpendOobRefund(operationId: string): Promise<JSONValue>;
14
15
  }
15
16
  //# 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,EACT,sBAAsB,EACtB,KAAK,EAEN,MAAM,UAAU,CAAA;AAEjB,qBAAa,WAAW;IACV,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;IAElC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOzC,oBAAoB,CACxB,QAAQ,EAAE,MAAM,EAChB,SAAS,GAAE,UAAe,GACzB,OAAO,CAAC,MAAM,CAAC;IAOlB,6BAA6B,CAC3B,WAAW,EAAE,MAAM,EACnB,SAAS,GAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAe,EAChD,OAAO,GAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAe;IAavC,UAAU,CACd,SAAS,EAAE,KAAK,EAKhB,cAAc,GAAE,MAAM,GAAG,QAAY,EAAE,gCAAgC;IACvE,aAAa,GAAE,OAAe,EAC9B,SAAS,GAAE,SAAc,GACxB,OAAO,CAAC,sBAAsB,CAAC;IAyB5B,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAM5C,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAM7D,mBAAmB,CACjB,WAAW,EAAE,MAAM,EACnB,SAAS,GAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAe,EAChD,OAAO,GAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAe;IAavC,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;CAKnE"}
@@ -1,4 +1,4 @@
1
- import { JSONValue } from '../types/wallet';
1
+ import type { JSONValue } from '../types';
2
2
  import { WorkerClient } from '../worker';
3
3
  export declare class RecoveryService {
4
4
  private client;
@@ -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,IAAI,OAAO,CAAC,OAAO,CAAC;IAIxC,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3C,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,GAC/B,MAAM,IAAI;CAQd"}
@@ -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"}
@@ -0,0 +1,4 @@
1
+ export * from './wallet';
2
+ export * from './utils';
3
+ export * from './worker';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -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,16 @@
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
+ export { Alias, Resolve, Duration, MSats, Sats, JSONValue, JSONObject };
16
+ //# 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,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAAA"}
@@ -1,9 +1,6 @@
1
+ import { MSats, Duration, JSONValue } from './utils';
1
2
  declare const MODULE_KINDS: readonly ["", "ln", "mint"];
2
3
  type ModuleKind = (typeof MODULE_KINDS)[number];
3
- type JSONValue = string | number | boolean | null | {
4
- [key: string]: JSONValue;
5
- } | JSONValue[];
6
- type JSONObject = Record<string, JSONValue>;
7
4
  type GatewayInfo = {
8
5
  gateway_id: string;
9
6
  api: string;
@@ -15,17 +12,14 @@ type GatewayInfo = {
15
12
  type LightningGateway = {
16
13
  info: GatewayInfo;
17
14
  vetted: boolean;
18
- ttl: {
19
- nanos: number;
20
- secs: number;
21
- };
15
+ ttl: Duration;
22
16
  };
23
17
  type RouteHint = {};
24
18
  type FeeToAmount = {};
25
19
  type OutgoingLightningPayment = {
26
20
  payment_type: PayType;
27
21
  contract_id: string;
28
- fee: number;
22
+ fee: MSats;
29
23
  };
30
24
  type PayType = {
31
25
  type: 'Internal' | 'Lightning';
@@ -88,13 +82,9 @@ type ReissueExternalNotesState = 'Created' | 'Issuing' | 'Done' | {
88
82
  error: string;
89
83
  };
90
84
  };
91
- type Duration = {
92
- nanos: number;
93
- secs: number;
94
- };
95
85
  type MintSpendNotesResponse = {
96
86
  notes: string;
97
87
  operation_id: string;
98
88
  };
99
- export { JSONValue, JSONObject, LightningGateway, RouteHint, FeeToAmount, OutgoingLightningPayment, PayType, LnPayState, LnReceiveState, CreateBolt11Response, GatewayInfo, StreamError, StreamSuccess, StreamResult, ModuleKind, CancelFunction, ReissueExternalNotesState, Duration, MintSpendNotesResponse, };
89
+ export { LightningGateway, RouteHint, FeeToAmount, OutgoingLightningPayment, PayType, LnPayState, LnReceiveState, CreateBolt11Response, GatewayInfo, StreamError, StreamSuccess, StreamResult, ModuleKind, CancelFunction, ReissueExternalNotesState, MintSpendNotesResponse, };
100
90
  //# sourceMappingURL=wallet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../../src/types/wallet.ts"],"names":[],"mappings":"AAAA,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V,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,WAAW,EACX,aAAa,EACb,YAAY,EACZ,UAAU,EACV,cAAc,EACd,yBAAyB,EACzB,sBAAsB,GACvB,CAAA"}
@@ -0,0 +1,4 @@
1
+ declare const WorkerMessageTypes: readonly ["init", "initialized", "rpc", "log", "open", "join", "error", "unsubscribe"];
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,wFASd,CAAA;AAEV,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAA"}
@@ -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"}
@@ -1,15 +1,15 @@
1
- import { CancelFunction, JSONValue, ModuleKind, StreamError } from '../types/wallet';
1
+ import type { CancelFunction, JSONValue, ModuleKind, StreamError, WorkerMessageType } from '../types';
2
2
  export declare class WorkerClient {
3
3
  private worker;
4
4
  private requestCounter;
5
5
  private requestCallbacks;
6
6
  private initPromise;
7
7
  constructor();
8
- initialize(): Promise<void>;
8
+ initialize(): Promise<boolean>;
9
9
  private handleWorkerLogs;
10
10
  private handleWorkerError;
11
11
  private handleWorkerMessage;
12
- sendSingleMessage(type: string, payload?: any): Promise<any>;
12
+ sendSingleMessage<Response extends JSONValue = JSONValue, Payload extends JSONValue = JSONValue>(type: WorkerMessageType, payload?: Payload): Promise<Response>;
13
13
  /**
14
14
  * @summary Initiates an RPC stream with the specified module and method.
15
15
  *
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkerClient.d.ts","sourceRoot":"","sources":["../../../src/worker/WorkerClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EACT,UAAU,EACV,WAAW,EAEX,iBAAiB,EAClB,MAAM,UAAU,CAAA;AAKjB,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,cAAc,CAAI;IAC1B,OAAO,CAAC,gBAAgB,CAA0C;IAClE,OAAO,CAAC,WAAW,CAA0C;;IAc7D,UAAU;IAMV,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,mBAAmB;IAuB3B,iBAAiB,CACf,QAAQ,SAAS,SAAS,GAAG,SAAS,EACtC,OAAO,SAAS,SAAS,GAAG,SAAS,EACrC,IAAI,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;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