@unicitylabs/sphere-sdk 0.15.0-dev.1 → 0.16.0-dev.1
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/README.md +15 -5
- package/dist/connect/index.cjs +23 -25
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/index.d.cts +4 -0
- package/dist/connect/index.d.ts +4 -0
- package/dist/connect/index.js +23 -25
- package/dist/connect/index.js.map +1 -1
- package/dist/core/index.cjs +726 -225
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +172 -21
- package/dist/core/index.d.ts +172 -21
- package/dist/core/index.js +726 -224
- package/dist/core/index.js.map +1 -1
- package/dist/impl/browser/connect/index.cjs +23 -25
- package/dist/impl/browser/connect/index.cjs.map +1 -1
- package/dist/impl/browser/connect/index.js +23 -25
- package/dist/impl/browser/connect/index.js.map +1 -1
- package/dist/impl/browser/index.cjs +331 -504
- package/dist/impl/browser/index.cjs.map +1 -1
- package/dist/impl/browser/index.js +331 -504
- package/dist/impl/browser/index.js.map +1 -1
- package/dist/impl/nodejs/connect/index.cjs +22 -24
- package/dist/impl/nodejs/connect/index.cjs.map +1 -1
- package/dist/impl/nodejs/connect/index.js +22 -24
- package/dist/impl/nodejs/connect/index.js.map +1 -1
- package/dist/impl/nodejs/index.cjs +298 -569
- package/dist/impl/nodejs/index.cjs.map +1 -1
- package/dist/impl/nodejs/index.d.cts +90 -13
- package/dist/impl/nodejs/index.d.ts +90 -13
- package/dist/impl/nodejs/index.js +298 -569
- package/dist/impl/nodejs/index.js.map +1 -1
- package/dist/impl/shared/wallet-api/index.d.cts +54 -2
- package/dist/impl/shared/wallet-api/index.d.ts +54 -2
- package/dist/index.cjs +728 -225
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +227 -108
- package/dist/index.d.ts +227 -108
- package/dist/index.js +728 -224
- package/dist/index.js.map +1 -1
- package/dist/modules/payments-v2/index.cjs +11 -7
- package/dist/modules/payments-v2/index.cjs.map +1 -1
- package/dist/modules/payments-v2/index.d.cts +56 -3
- package/dist/modules/payments-v2/index.d.ts +56 -3
- package/dist/modules/payments-v2/index.js +11 -7
- package/dist/modules/payments-v2/index.js.map +1 -1
- package/dist/token-engine/index.cjs +46 -0
- package/dist/token-engine/index.cjs.map +1 -1
- package/dist/token-engine/index.js +46 -0
- package/dist/token-engine/index.js.map +1 -1
- package/package.json +2 -1
package/dist/core/index.d.cts
CHANGED
|
@@ -882,6 +882,25 @@ interface SphereStatus {
|
|
|
882
882
|
* All operations are async for platform flexibility
|
|
883
883
|
*/
|
|
884
884
|
interface StorageProvider extends BaseProvider {
|
|
885
|
+
/**
|
|
886
|
+
* Stable identity of the BACKING STORE this provider addresses — not of this
|
|
887
|
+
* object, and not of the class (`id` is a class constant like `'file-storage'`,
|
|
888
|
+
* which is exactly the wrong granularity).
|
|
889
|
+
*
|
|
890
|
+
* Two providers that return the SAME value address the same data, so erasing
|
|
891
|
+
* through one erases through the other: `Sphere.clear({ storage })` tears down
|
|
892
|
+
* the live Spheres of every provider sharing this value, not merely those built
|
|
893
|
+
* on this object. Compose it from everything that selects the store (file path,
|
|
894
|
+
* database name, key prefix) behind a scheme prefix, so two kinds of store can
|
|
895
|
+
* never collide on one string.
|
|
896
|
+
*
|
|
897
|
+
* It must not change over the provider's lifetime — it is read again on teardown,
|
|
898
|
+
* and a value that moved would strand the entry it was registered under.
|
|
899
|
+
*
|
|
900
|
+
* Optional: omit it and liveness falls back to per-object identity, i.e. a
|
|
901
|
+
* second provider over the same data is treated as unrelated.
|
|
902
|
+
*/
|
|
903
|
+
readonly backingStoreId?: string;
|
|
885
904
|
/**
|
|
886
905
|
* Set identity for scoped storage
|
|
887
906
|
*/
|
|
@@ -911,11 +930,44 @@ interface StorageProvider extends BaseProvider {
|
|
|
911
930
|
*/
|
|
912
931
|
clear(prefix?: string): Promise<void>;
|
|
913
932
|
/**
|
|
914
|
-
* Save tracked addresses (only user state: index, hidden, timestamps)
|
|
933
|
+
* Save tracked addresses (only user state: index, hidden, timestamps).
|
|
934
|
+
*
|
|
935
|
+
* MUST MERGE, NEVER REPLACE (#766 item 5). `entries` is ONE writer's snapshot,
|
|
936
|
+
* not the whole truth: every Sphere sharing this storage keeps its own copy of
|
|
937
|
+
* the registry and persists all of it, so writing the argument verbatim is a
|
|
938
|
+
* lost update — A activates index 1, B (whose snapshot predates that) activates
|
|
939
|
+
* index 2, and B's write erases index 1 while A still reports it. This happens
|
|
940
|
+
* on a single network with a single provider; do NOT "fix" it by renaming or
|
|
941
|
+
* network-scoping the key.
|
|
942
|
+
*
|
|
943
|
+
* The contract, implemented by `storage/tracked-addresses.ts` — reuse those
|
|
944
|
+
* helpers rather than re-deriving this:
|
|
945
|
+
* - read the stored registry, union it with `entries` BY `index`;
|
|
946
|
+
* - on a conflicting index, the entry with the greater `updatedAt` supplies
|
|
947
|
+
* `hidden`, and `createdAt` keeps the earlier value;
|
|
948
|
+
* - serialize concurrent calls on the provider instance, so one call's read
|
|
949
|
+
* cannot interleave with another's write;
|
|
950
|
+
* - a failed write must not brick later writes, and must still reject to its
|
|
951
|
+
* own caller.
|
|
952
|
+
*
|
|
953
|
+
* An `index` must be a UINT32 — a BIP32 child number. `deriveKeyAtPath` parseInt()s
|
|
954
|
+
* that path segment, so `1.5` derives index 1's keys and the row aliases a real
|
|
955
|
+
* address. The ceiling matters too: `deriveChildKey` pads the child number to 8 hex
|
|
956
|
+
* digits, so anything above `0xffffffff` emits extra bytes and derives off-standard.
|
|
957
|
+
* An `entries` row that is not one must REJECT the whole call (`mergeTrackedAddresses`
|
|
958
|
+
* throws `VALIDATION_ERROR`); dropping it silently on a write reports a save that
|
|
959
|
+
* never happened. Already-stored rows are dropped on READ instead, so one bad row
|
|
960
|
+
* cannot brick every later write. Validate before opening the write transaction if
|
|
961
|
+
* your platform would otherwise replace the reason with a generic abort.
|
|
962
|
+
*
|
|
963
|
+
* A union is safe because there is no delete path: entries are only ever added,
|
|
964
|
+
* and wiping the wallet removes the key itself (`Sphere.clear()`). Adding a
|
|
965
|
+
* per-entry delete would require revisiting this contract.
|
|
915
966
|
*/
|
|
916
967
|
saveTrackedAddresses(entries: TrackedAddressEntry[]): Promise<void>;
|
|
917
968
|
/**
|
|
918
|
-
* Load tracked addresses
|
|
969
|
+
* Load tracked addresses. Tolerant: unusable/corrupt storage reads as `[]`
|
|
970
|
+
* (see `parseTrackedAddresses` in `storage/tracked-addresses.ts`).
|
|
919
971
|
*/
|
|
920
972
|
loadTrackedAddresses(): Promise<TrackedAddressEntry[]>;
|
|
921
973
|
}
|
|
@@ -2141,10 +2193,11 @@ declare class MarketModule {
|
|
|
2141
2193
|
declare const NETWORKS: {
|
|
2142
2194
|
readonly mainnet: {
|
|
2143
2195
|
readonly name: "Mainnet";
|
|
2144
|
-
readonly
|
|
2145
|
-
readonly
|
|
2196
|
+
readonly networkId: 1;
|
|
2197
|
+
readonly aggregatorUrl: "https://gateway.mainnet.unicity.network";
|
|
2198
|
+
readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
|
|
2146
2199
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
2147
|
-
readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.
|
|
2200
|
+
readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.mainnet.json";
|
|
2148
2201
|
};
|
|
2149
2202
|
readonly testnet: {
|
|
2150
2203
|
readonly name: "Testnet2";
|
|
@@ -2162,13 +2215,6 @@ declare const NETWORKS: {
|
|
|
2162
2215
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
2163
2216
|
readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet2.json";
|
|
2164
2217
|
};
|
|
2165
|
-
readonly dev: {
|
|
2166
|
-
readonly name: "Development";
|
|
2167
|
-
readonly aggregatorUrl: "https://dev-aggregator.dyndns.org/rpc";
|
|
2168
|
-
readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
|
|
2169
|
-
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
2170
|
-
readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
|
|
2171
|
-
};
|
|
2172
2218
|
};
|
|
2173
2219
|
type NetworkType = keyof typeof NETWORKS;
|
|
2174
2220
|
|
|
@@ -3282,9 +3328,26 @@ interface AddressModuleSet {
|
|
|
3282
3328
|
initialized: boolean;
|
|
3283
3329
|
}
|
|
3284
3330
|
declare class Sphere {
|
|
3285
|
-
private static
|
|
3331
|
+
private static readonly _liveByStorage;
|
|
3332
|
+
/** Fallback keys for providers that declare no `backingStoreId` — one per object. */
|
|
3333
|
+
private static readonly _objectStoreKeys;
|
|
3334
|
+
/**
|
|
3335
|
+
* How many times each backing store has been cleared. An init is invisible to `clear()`
|
|
3336
|
+
* until it PUBLISHES (#767), so a clear cannot destroy one in flight and would wipe the
|
|
3337
|
+
* store under it. Every init records this number before its first storage work and
|
|
3338
|
+
* publication refuses if it moved (#772). Only cleared stores get an entry, so the
|
|
3339
|
+
* strongly-held keys are bounded by the stores a process actually clears.
|
|
3340
|
+
*/
|
|
3341
|
+
private static readonly _clearGenerations;
|
|
3286
3342
|
private static _orphanCacheCleaned;
|
|
3287
3343
|
private _initialized;
|
|
3344
|
+
/**
|
|
3345
|
+
* Destroyed latch (#770). Distinct from `_initialized`, which destroy() clears LAST — after
|
|
3346
|
+
* every teardown step — so it cannot mark "teardown has begun". This is set as destroy()'s
|
|
3347
|
+
* very FIRST statement, so the WHOLE teardown window is guarded, not just the instant after
|
|
3348
|
+
* it. Read by ensureAlive() and by the §7 lifecycle mutex.
|
|
3349
|
+
*/
|
|
3350
|
+
private _destroyed;
|
|
3288
3351
|
private _trackedAddressesLoaded;
|
|
3289
3352
|
private _identity;
|
|
3290
3353
|
private _masterKey;
|
|
@@ -3337,6 +3400,8 @@ declare class Sphere {
|
|
|
3337
3400
|
* the rebuild after an api-key change share one pool configuration.
|
|
3338
3401
|
*/
|
|
3339
3402
|
private _verification;
|
|
3403
|
+
/** This Sphere's OWN token registry. Disposed by destroy(); never the process global. */
|
|
3404
|
+
private _registry;
|
|
3340
3405
|
private eventHandlers;
|
|
3341
3406
|
private _disabledProviders;
|
|
3342
3407
|
private _providerEventCleanups;
|
|
@@ -3408,6 +3473,23 @@ declare class Sphere {
|
|
|
3408
3473
|
* bundle). This method ensures the main bundle's TokenRegistry is configured.
|
|
3409
3474
|
*/
|
|
3410
3475
|
private static configureTokenRegistry;
|
|
3476
|
+
/**
|
|
3477
|
+
* Build the registry THIS Sphere owns, so its metadata cannot be repointed by another
|
|
3478
|
+
* Sphere's init. The global is still configured above for consumers that read it
|
|
3479
|
+
* directly; this instance is what the payments facade presents from.
|
|
3480
|
+
*/
|
|
3481
|
+
/**
|
|
3482
|
+
* Own a registry for the duration of `bringUp`, disposing it if any of that rejects.
|
|
3483
|
+
*
|
|
3484
|
+
* `bringUp` must cover EVERY fallible step from here until the Sphere is returned to
|
|
3485
|
+
* its caller — until then nobody holds anything they could destroy, so a
|
|
3486
|
+
* registry left behind is unreachable and its hourly fetch runs for the life of the
|
|
3487
|
+
* process. Guarding a named subset of the steps is what failed twice: the guarded region
|
|
3488
|
+
* and the fallible region were separate things, and drifted. Publication is the LAST
|
|
3489
|
+
* guarded step for the same reason: it can refuse, and a refusal must tear down.
|
|
3490
|
+
*/
|
|
3491
|
+
private static withOwnedRegistry;
|
|
3492
|
+
private static createOwnedRegistry;
|
|
3411
3493
|
/**
|
|
3412
3494
|
* Create new wallet with mnemonic
|
|
3413
3495
|
*/
|
|
@@ -3436,6 +3518,7 @@ declare class Sphere {
|
|
|
3436
3518
|
static clear(options: {
|
|
3437
3519
|
storage: StorageProvider;
|
|
3438
3520
|
}): Promise<void>;
|
|
3521
|
+
private static clearStore;
|
|
3439
3522
|
/**
|
|
3440
3523
|
* Raw `indexedDB.deleteDatabase` sweep of `sphere-token-storage-*` databases
|
|
3441
3524
|
* left by pre-flip versions (tokens are server-custody now). Browser-only,
|
|
@@ -3450,13 +3533,27 @@ declare class Sphere {
|
|
|
3450
3533
|
*/
|
|
3451
3534
|
private static cleanupOrphanedVestingCache;
|
|
3452
3535
|
/**
|
|
3453
|
-
*
|
|
3536
|
+
* The key a provider registers under: the store it addresses, so every provider
|
|
3537
|
+
* over one dataDir/DB shares an entry. A provider that declares no store keeps a
|
|
3538
|
+
* private key, leaving custom implementations scoped by object identity.
|
|
3454
3539
|
*/
|
|
3455
|
-
static
|
|
3540
|
+
private static storeKeyOf;
|
|
3541
|
+
/** The clears this store has seen. Absent means none — `clear()` creates the entry. */
|
|
3542
|
+
private static clearGenerationOf;
|
|
3543
|
+
private static bumpClearGeneration;
|
|
3456
3544
|
/**
|
|
3457
|
-
*
|
|
3545
|
+
* Make a fully-built Sphere reachable — or refuse, if `clear()` emptied the store
|
|
3546
|
+
* under it while it was building. Check and registration are one SYNCHRONOUS step on
|
|
3547
|
+
* purpose: split by an await, a clear could land between them and wipe a store whose
|
|
3548
|
+
* Sphere is already published. The refusal throws inside `withOwnedRegistry`, whose
|
|
3549
|
+
* teardown then destroys the half-built Sphere the caller never received.
|
|
3458
3550
|
*/
|
|
3459
|
-
static
|
|
3551
|
+
private static publishLive;
|
|
3552
|
+
/** Record a fully-built Sphere against the storage it owns. See `_liveByStorage`. */
|
|
3553
|
+
private static registerLive;
|
|
3554
|
+
private static unregisterLive;
|
|
3555
|
+
/** Snapshot — callers iterate this while destroy() mutates the underlying Set. */
|
|
3556
|
+
private static liveOn;
|
|
3460
3557
|
/**
|
|
3461
3558
|
* Validate mnemonic using BIP39
|
|
3462
3559
|
*/
|
|
@@ -3625,7 +3722,8 @@ declare class Sphere {
|
|
|
3625
3722
|
/**
|
|
3626
3723
|
* Import wallet from JSON backup
|
|
3627
3724
|
*
|
|
3628
|
-
* @returns
|
|
3725
|
+
* @returns `{ success, sphere?, mnemonic?, error? }`. `sphere` is the instance built
|
|
3726
|
+
* on the SUPPLIED storage — hold it, there is no global to look it up from (#766).
|
|
3629
3727
|
*
|
|
3630
3728
|
* @example
|
|
3631
3729
|
* ```ts
|
|
@@ -3642,6 +3740,7 @@ declare class Sphere {
|
|
|
3642
3740
|
password?: string;
|
|
3643
3741
|
}): Promise<{
|
|
3644
3742
|
success: boolean;
|
|
3743
|
+
sphere?: Sphere;
|
|
3645
3744
|
mnemonic?: string;
|
|
3646
3745
|
error?: string;
|
|
3647
3746
|
}>;
|
|
@@ -3741,6 +3840,18 @@ declare class Sphere {
|
|
|
3741
3840
|
* independently in background. The payments vertical is NOT created here —
|
|
3742
3841
|
* the caller starts it via stopThenStartPaymentsV2 (§7 single vertical).
|
|
3743
3842
|
*/
|
|
3843
|
+
/** Tear one address's module set down. Each address owns its own engine, so its own pool. */
|
|
3844
|
+
private static destroyModuleSet;
|
|
3845
|
+
/**
|
|
3846
|
+
* Undo a module set built while `destroy()` was running.
|
|
3847
|
+
*
|
|
3848
|
+
* `destroy()`'s teardown loop has already emptied `_addressModules`, so a set
|
|
3849
|
+
* registered after it would stay live and unreachable — its own engine (and worker
|
|
3850
|
+
* pool), and a transport mux `ensureTransportMux` rebuilt because teardown had just
|
|
3851
|
+
* nulled the field. Then re-raise, so the switch fails rather than reporting success
|
|
3852
|
+
* on a destroyed Sphere (#770, #772 review).
|
|
3853
|
+
*/
|
|
3854
|
+
private discardModulesBuiltDuringDestroy;
|
|
3744
3855
|
private initializeAddressModules;
|
|
3745
3856
|
/**
|
|
3746
3857
|
* Ensure the transport multiplexer exists and register an address.
|
|
@@ -3749,6 +3860,8 @@ declare class Sphere {
|
|
|
3749
3860
|
* @returns AddressTransportAdapter or null if transport is not Nostr-based
|
|
3750
3861
|
*/
|
|
3751
3862
|
private ensureTransportMux;
|
|
3863
|
+
/** A BIP32 child number: an integer in 0…0xffffffff. Anything else aliases an address. */
|
|
3864
|
+
private static assertDerivableIndex;
|
|
3752
3865
|
/**
|
|
3753
3866
|
* Derive address at a specific index
|
|
3754
3867
|
*
|
|
@@ -3987,6 +4100,29 @@ declare class Sphere {
|
|
|
3987
4100
|
* Strip @ prefix and normalize a nametag (lowercase, phone E.164, strip @unicity suffix).
|
|
3988
4101
|
*/
|
|
3989
4102
|
private cleanNametag;
|
|
4103
|
+
/**
|
|
4104
|
+
* Disconnect transport, storage and oracle, attempting each even if an earlier one
|
|
4105
|
+
* rejects. They are separate resources, and one failure must not skip the rest — that
|
|
4106
|
+
* is how a partial teardown leaves connections open, which is exactly the state the
|
|
4107
|
+
* failed-initialization path calls destroy() in.
|
|
4108
|
+
*/
|
|
4109
|
+
private disconnectProvidersIndependently;
|
|
4110
|
+
/** Run one teardown step, logging rather than propagating so the next one still runs. */
|
|
4111
|
+
private static safeDisconnect;
|
|
4112
|
+
/**
|
|
4113
|
+
* Tear this Sphere down: stop the vertical, destroy the modules, disconnect the providers
|
|
4114
|
+
* and zero the key material. Idempotent by construction (every step is null-guarded) and
|
|
4115
|
+
* deliberately WITHOUT an early return on re-entry, which would change what a double call
|
|
4116
|
+
* means.
|
|
4117
|
+
*
|
|
4118
|
+
* #770: the FIRST statement flips `_destroyed` — before any await, and before this queues
|
|
4119
|
+
* its own stop on the §7 lifecycle mutex. That position is load-bearing. Every guard reads
|
|
4120
|
+
* the flag, so from that instant any switchToAddress step not yet begun refuses; and
|
|
4121
|
+
* because it flips SYNCHRONOUSLY at entry, a stop/start pair the mutex runs after this call
|
|
4122
|
+
* sees `true` and skips its start. Set it beside `_initialized` at the bottom instead and a
|
|
4123
|
+
* concurrent switch re-arms a wallet whose owner already had destroy() return: fresh
|
|
4124
|
+
* sockets, a fresh wallet-api session, a whole fresh vertical nothing will ever stop.
|
|
4125
|
+
*/
|
|
3990
4126
|
destroy(): Promise<void>;
|
|
3991
4127
|
private storeMnemonic;
|
|
3992
4128
|
private storeMasterKey;
|
|
@@ -4024,7 +4160,17 @@ declare class Sphere {
|
|
|
4024
4160
|
private initializeModules;
|
|
4025
4161
|
/** §7 mutex: run one stop/start lifecycle op after all queued ones settle. */
|
|
4026
4162
|
private queuePaymentsV2Op;
|
|
4027
|
-
/**
|
|
4163
|
+
/**
|
|
4164
|
+
* Switch/boot: stop whatever runs, then start `index`'s vertical — atomically vs other
|
|
4165
|
+
* lifecycle ops.
|
|
4166
|
+
*
|
|
4167
|
+
* #770: the destroyed check between the two halves settles the FACADE vector on its own.
|
|
4168
|
+
* `_destroyed` flips synchronously at destroy() entry, so any closure that BEGINS executing
|
|
4169
|
+
* after destroy() was called sees `true`, and any closure already past the check has
|
|
4170
|
+
* facade.start() in flight — which destroy()'s own queued stop is necessarily ordered
|
|
4171
|
+
* after. The TRANSPORT vector is not on this mutex at all; the ensureAlive() calls in
|
|
4172
|
+
* switchToAddress are what cover it.
|
|
4173
|
+
*/
|
|
4028
4174
|
private stopThenStartPaymentsV2;
|
|
4029
4175
|
/**
|
|
4030
4176
|
* Compose + start the payments vertical for ONE address (the §7 rule:
|
|
@@ -4035,6 +4181,12 @@ declare class Sphere {
|
|
|
4035
4181
|
private startPaymentsV2Inner;
|
|
4036
4182
|
/** P9 §7: stop the active vertical and await quiescence (in-flight ops settle). */
|
|
4037
4183
|
private stopPaymentsV2Inner;
|
|
4184
|
+
/**
|
|
4185
|
+
* Refuse once destroy() has STARTED (#770). `_initialized` cannot carry this: destroy()
|
|
4186
|
+
* clears it last, so every teardown step is a window in which a concurrent call still reads
|
|
4187
|
+
* a ready Sphere and re-arms it.
|
|
4188
|
+
*/
|
|
4189
|
+
private ensureAlive;
|
|
4038
4190
|
private ensureReady;
|
|
4039
4191
|
private emitEvent;
|
|
4040
4192
|
private encrypt;
|
|
@@ -4044,7 +4196,6 @@ declare const createSphere: typeof Sphere.create;
|
|
|
4044
4196
|
declare const loadSphere: typeof Sphere.load;
|
|
4045
4197
|
declare const importSphere: typeof Sphere.import;
|
|
4046
4198
|
declare const initSphere: typeof Sphere.init;
|
|
4047
|
-
declare const getSphere: typeof Sphere.getInstance;
|
|
4048
4199
|
declare const sphereExists: typeof Sphere.exists;
|
|
4049
4200
|
|
|
4050
4201
|
/**
|
|
@@ -4588,4 +4739,4 @@ interface CheckNetworkHealthOptions {
|
|
|
4588
4739
|
*/
|
|
4589
4740
|
declare function checkNetworkHealth(network?: NetworkType, options?: CheckNetworkHealthOptions): Promise<NetworkHealthResult>;
|
|
4590
4741
|
|
|
4591
|
-
export { type AddressInfo, type AddressModuleSet, type CheckNetworkHealthOptions, CurrencyUtils, DEFAULT_DERIVATION_PATH, DEFAULT_TOKEN_DECIMALS, DELIVERY_ENCRYPTION_HKDF_INFO, type DeliveryBundle, type DerivedKey, type DiscoverAddressProgress, type DiscoverAddressesOptions, type DiscoverAddressesResult, type DiscoveredAddress, type EncryptedData, type EncryptionOptions, FIELD_ENCRYPTION_HKDF_INFO, FIELD_ENVELOPE_MAX_BYTES, FIELD_ENVELOPE_NONCE_BYTES, FIELD_ENVELOPE_PREFIX, type InitProgress, type InitProgressCallback, type InitProgressStep, type KeyPair, type LogHandler, type LogLevel, type LoggerConfig, type MasterKey, PartialSendConflictError, SIGN_MESSAGE_PREFIX, Sphere, type SphereCreateOptions, SphereError, type SphereErrorCode, type SphereImportOptions, type SphereInitOptions, type SphereInitResult, type SphereLoadOptions, type WalletApiTransportConfig, assertFieldEnvelopeShape, base58Decode, base58Encode, bytesToHex, checkNetworkHealth, createKeyPair, createSphere, decrypt, decryptDeliveryBundle, decryptField, decryptFieldBytes, decryptJson, decryptMnemonic, decryptSimple, decryptWithSalt, deriveAddressInfo, deriveChildKey, deriveDeliveryEncryptionKey, deriveFieldEncryptionKey, deriveKeyAtPath, deserializeEncrypted, discoverAddressesImpl, doubleSha256, encrypt, encryptDeliveryBundle, encryptField, encryptFieldBytes, encryptMnemonic, encryptSimple, entropyToMnemonic, extractFromText, findPattern, formatAmount, generateAddressFromMasterKey, generateAddressInfo, generateMasterKey, generateMnemonic, generateRandomKey, getPublicKey,
|
|
4742
|
+
export { type AddressInfo, type AddressModuleSet, type CheckNetworkHealthOptions, CurrencyUtils, DEFAULT_DERIVATION_PATH, DEFAULT_TOKEN_DECIMALS, DELIVERY_ENCRYPTION_HKDF_INFO, type DeliveryBundle, type DerivedKey, type DiscoverAddressProgress, type DiscoverAddressesOptions, type DiscoverAddressesResult, type DiscoveredAddress, type EncryptedData, type EncryptionOptions, FIELD_ENCRYPTION_HKDF_INFO, FIELD_ENVELOPE_MAX_BYTES, FIELD_ENVELOPE_NONCE_BYTES, FIELD_ENVELOPE_PREFIX, type InitProgress, type InitProgressCallback, type InitProgressStep, type KeyPair, type LogHandler, type LogLevel, type LoggerConfig, type MasterKey, PartialSendConflictError, SIGN_MESSAGE_PREFIX, Sphere, type SphereCreateOptions, SphereError, type SphereErrorCode, type SphereImportOptions, type SphereInitOptions, type SphereInitResult, type SphereLoadOptions, type WalletApiTransportConfig, assertFieldEnvelopeShape, base58Decode, base58Encode, bytesToHex, checkNetworkHealth, createKeyPair, createSphere, decrypt, decryptDeliveryBundle, decryptField, decryptFieldBytes, decryptJson, decryptMnemonic, decryptSimple, decryptWithSalt, deriveAddressInfo, deriveChildKey, deriveDeliveryEncryptionKey, deriveFieldEncryptionKey, deriveKeyAtPath, deserializeEncrypted, discoverAddressesImpl, doubleSha256, encrypt, encryptDeliveryBundle, encryptField, encryptFieldBytes, encryptMnemonic, encryptSimple, entropyToMnemonic, extractFromText, findPattern, formatAmount, generateAddressFromMasterKey, generateAddressInfo, generateMasterKey, generateMnemonic, generateRandomKey, getPublicKey, hash160, hashSignMessage, hexToBytes, identityFromMnemonic, identityFromMnemonicSync, importSphere, initSphere, isEncryptedData, isPossiblyCommittedSendOutcome, isSphereError, isValidNametag, isValidPrivateKey, loadSphere, logger, mnemonicToEntropy, mnemonicToSeed, mnemonicToSeedSync, parseTokenAmount, randomBytes, randomHex, randomUUID, recoverPubkeyFromSignature, ripemd160, safeParseTokenAmount, serializeEncrypted, sha256, signMessage, sleep, sphereExists, toHumanReadable, validateMnemonic, verifySignedMessage };
|
package/dist/core/index.d.ts
CHANGED
|
@@ -882,6 +882,25 @@ interface SphereStatus {
|
|
|
882
882
|
* All operations are async for platform flexibility
|
|
883
883
|
*/
|
|
884
884
|
interface StorageProvider extends BaseProvider {
|
|
885
|
+
/**
|
|
886
|
+
* Stable identity of the BACKING STORE this provider addresses — not of this
|
|
887
|
+
* object, and not of the class (`id` is a class constant like `'file-storage'`,
|
|
888
|
+
* which is exactly the wrong granularity).
|
|
889
|
+
*
|
|
890
|
+
* Two providers that return the SAME value address the same data, so erasing
|
|
891
|
+
* through one erases through the other: `Sphere.clear({ storage })` tears down
|
|
892
|
+
* the live Spheres of every provider sharing this value, not merely those built
|
|
893
|
+
* on this object. Compose it from everything that selects the store (file path,
|
|
894
|
+
* database name, key prefix) behind a scheme prefix, so two kinds of store can
|
|
895
|
+
* never collide on one string.
|
|
896
|
+
*
|
|
897
|
+
* It must not change over the provider's lifetime — it is read again on teardown,
|
|
898
|
+
* and a value that moved would strand the entry it was registered under.
|
|
899
|
+
*
|
|
900
|
+
* Optional: omit it and liveness falls back to per-object identity, i.e. a
|
|
901
|
+
* second provider over the same data is treated as unrelated.
|
|
902
|
+
*/
|
|
903
|
+
readonly backingStoreId?: string;
|
|
885
904
|
/**
|
|
886
905
|
* Set identity for scoped storage
|
|
887
906
|
*/
|
|
@@ -911,11 +930,44 @@ interface StorageProvider extends BaseProvider {
|
|
|
911
930
|
*/
|
|
912
931
|
clear(prefix?: string): Promise<void>;
|
|
913
932
|
/**
|
|
914
|
-
* Save tracked addresses (only user state: index, hidden, timestamps)
|
|
933
|
+
* Save tracked addresses (only user state: index, hidden, timestamps).
|
|
934
|
+
*
|
|
935
|
+
* MUST MERGE, NEVER REPLACE (#766 item 5). `entries` is ONE writer's snapshot,
|
|
936
|
+
* not the whole truth: every Sphere sharing this storage keeps its own copy of
|
|
937
|
+
* the registry and persists all of it, so writing the argument verbatim is a
|
|
938
|
+
* lost update — A activates index 1, B (whose snapshot predates that) activates
|
|
939
|
+
* index 2, and B's write erases index 1 while A still reports it. This happens
|
|
940
|
+
* on a single network with a single provider; do NOT "fix" it by renaming or
|
|
941
|
+
* network-scoping the key.
|
|
942
|
+
*
|
|
943
|
+
* The contract, implemented by `storage/tracked-addresses.ts` — reuse those
|
|
944
|
+
* helpers rather than re-deriving this:
|
|
945
|
+
* - read the stored registry, union it with `entries` BY `index`;
|
|
946
|
+
* - on a conflicting index, the entry with the greater `updatedAt` supplies
|
|
947
|
+
* `hidden`, and `createdAt` keeps the earlier value;
|
|
948
|
+
* - serialize concurrent calls on the provider instance, so one call's read
|
|
949
|
+
* cannot interleave with another's write;
|
|
950
|
+
* - a failed write must not brick later writes, and must still reject to its
|
|
951
|
+
* own caller.
|
|
952
|
+
*
|
|
953
|
+
* An `index` must be a UINT32 — a BIP32 child number. `deriveKeyAtPath` parseInt()s
|
|
954
|
+
* that path segment, so `1.5` derives index 1's keys and the row aliases a real
|
|
955
|
+
* address. The ceiling matters too: `deriveChildKey` pads the child number to 8 hex
|
|
956
|
+
* digits, so anything above `0xffffffff` emits extra bytes and derives off-standard.
|
|
957
|
+
* An `entries` row that is not one must REJECT the whole call (`mergeTrackedAddresses`
|
|
958
|
+
* throws `VALIDATION_ERROR`); dropping it silently on a write reports a save that
|
|
959
|
+
* never happened. Already-stored rows are dropped on READ instead, so one bad row
|
|
960
|
+
* cannot brick every later write. Validate before opening the write transaction if
|
|
961
|
+
* your platform would otherwise replace the reason with a generic abort.
|
|
962
|
+
*
|
|
963
|
+
* A union is safe because there is no delete path: entries are only ever added,
|
|
964
|
+
* and wiping the wallet removes the key itself (`Sphere.clear()`). Adding a
|
|
965
|
+
* per-entry delete would require revisiting this contract.
|
|
915
966
|
*/
|
|
916
967
|
saveTrackedAddresses(entries: TrackedAddressEntry[]): Promise<void>;
|
|
917
968
|
/**
|
|
918
|
-
* Load tracked addresses
|
|
969
|
+
* Load tracked addresses. Tolerant: unusable/corrupt storage reads as `[]`
|
|
970
|
+
* (see `parseTrackedAddresses` in `storage/tracked-addresses.ts`).
|
|
919
971
|
*/
|
|
920
972
|
loadTrackedAddresses(): Promise<TrackedAddressEntry[]>;
|
|
921
973
|
}
|
|
@@ -2141,10 +2193,11 @@ declare class MarketModule {
|
|
|
2141
2193
|
declare const NETWORKS: {
|
|
2142
2194
|
readonly mainnet: {
|
|
2143
2195
|
readonly name: "Mainnet";
|
|
2144
|
-
readonly
|
|
2145
|
-
readonly
|
|
2196
|
+
readonly networkId: 1;
|
|
2197
|
+
readonly aggregatorUrl: "https://gateway.mainnet.unicity.network";
|
|
2198
|
+
readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
|
|
2146
2199
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
2147
|
-
readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.
|
|
2200
|
+
readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.mainnet.json";
|
|
2148
2201
|
};
|
|
2149
2202
|
readonly testnet: {
|
|
2150
2203
|
readonly name: "Testnet2";
|
|
@@ -2162,13 +2215,6 @@ declare const NETWORKS: {
|
|
|
2162
2215
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
2163
2216
|
readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet2.json";
|
|
2164
2217
|
};
|
|
2165
|
-
readonly dev: {
|
|
2166
|
-
readonly name: "Development";
|
|
2167
|
-
readonly aggregatorUrl: "https://dev-aggregator.dyndns.org/rpc";
|
|
2168
|
-
readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
|
|
2169
|
-
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
2170
|
-
readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
|
|
2171
|
-
};
|
|
2172
2218
|
};
|
|
2173
2219
|
type NetworkType = keyof typeof NETWORKS;
|
|
2174
2220
|
|
|
@@ -3282,9 +3328,26 @@ interface AddressModuleSet {
|
|
|
3282
3328
|
initialized: boolean;
|
|
3283
3329
|
}
|
|
3284
3330
|
declare class Sphere {
|
|
3285
|
-
private static
|
|
3331
|
+
private static readonly _liveByStorage;
|
|
3332
|
+
/** Fallback keys for providers that declare no `backingStoreId` — one per object. */
|
|
3333
|
+
private static readonly _objectStoreKeys;
|
|
3334
|
+
/**
|
|
3335
|
+
* How many times each backing store has been cleared. An init is invisible to `clear()`
|
|
3336
|
+
* until it PUBLISHES (#767), so a clear cannot destroy one in flight and would wipe the
|
|
3337
|
+
* store under it. Every init records this number before its first storage work and
|
|
3338
|
+
* publication refuses if it moved (#772). Only cleared stores get an entry, so the
|
|
3339
|
+
* strongly-held keys are bounded by the stores a process actually clears.
|
|
3340
|
+
*/
|
|
3341
|
+
private static readonly _clearGenerations;
|
|
3286
3342
|
private static _orphanCacheCleaned;
|
|
3287
3343
|
private _initialized;
|
|
3344
|
+
/**
|
|
3345
|
+
* Destroyed latch (#770). Distinct from `_initialized`, which destroy() clears LAST — after
|
|
3346
|
+
* every teardown step — so it cannot mark "teardown has begun". This is set as destroy()'s
|
|
3347
|
+
* very FIRST statement, so the WHOLE teardown window is guarded, not just the instant after
|
|
3348
|
+
* it. Read by ensureAlive() and by the §7 lifecycle mutex.
|
|
3349
|
+
*/
|
|
3350
|
+
private _destroyed;
|
|
3288
3351
|
private _trackedAddressesLoaded;
|
|
3289
3352
|
private _identity;
|
|
3290
3353
|
private _masterKey;
|
|
@@ -3337,6 +3400,8 @@ declare class Sphere {
|
|
|
3337
3400
|
* the rebuild after an api-key change share one pool configuration.
|
|
3338
3401
|
*/
|
|
3339
3402
|
private _verification;
|
|
3403
|
+
/** This Sphere's OWN token registry. Disposed by destroy(); never the process global. */
|
|
3404
|
+
private _registry;
|
|
3340
3405
|
private eventHandlers;
|
|
3341
3406
|
private _disabledProviders;
|
|
3342
3407
|
private _providerEventCleanups;
|
|
@@ -3408,6 +3473,23 @@ declare class Sphere {
|
|
|
3408
3473
|
* bundle). This method ensures the main bundle's TokenRegistry is configured.
|
|
3409
3474
|
*/
|
|
3410
3475
|
private static configureTokenRegistry;
|
|
3476
|
+
/**
|
|
3477
|
+
* Build the registry THIS Sphere owns, so its metadata cannot be repointed by another
|
|
3478
|
+
* Sphere's init. The global is still configured above for consumers that read it
|
|
3479
|
+
* directly; this instance is what the payments facade presents from.
|
|
3480
|
+
*/
|
|
3481
|
+
/**
|
|
3482
|
+
* Own a registry for the duration of `bringUp`, disposing it if any of that rejects.
|
|
3483
|
+
*
|
|
3484
|
+
* `bringUp` must cover EVERY fallible step from here until the Sphere is returned to
|
|
3485
|
+
* its caller — until then nobody holds anything they could destroy, so a
|
|
3486
|
+
* registry left behind is unreachable and its hourly fetch runs for the life of the
|
|
3487
|
+
* process. Guarding a named subset of the steps is what failed twice: the guarded region
|
|
3488
|
+
* and the fallible region were separate things, and drifted. Publication is the LAST
|
|
3489
|
+
* guarded step for the same reason: it can refuse, and a refusal must tear down.
|
|
3490
|
+
*/
|
|
3491
|
+
private static withOwnedRegistry;
|
|
3492
|
+
private static createOwnedRegistry;
|
|
3411
3493
|
/**
|
|
3412
3494
|
* Create new wallet with mnemonic
|
|
3413
3495
|
*/
|
|
@@ -3436,6 +3518,7 @@ declare class Sphere {
|
|
|
3436
3518
|
static clear(options: {
|
|
3437
3519
|
storage: StorageProvider;
|
|
3438
3520
|
}): Promise<void>;
|
|
3521
|
+
private static clearStore;
|
|
3439
3522
|
/**
|
|
3440
3523
|
* Raw `indexedDB.deleteDatabase` sweep of `sphere-token-storage-*` databases
|
|
3441
3524
|
* left by pre-flip versions (tokens are server-custody now). Browser-only,
|
|
@@ -3450,13 +3533,27 @@ declare class Sphere {
|
|
|
3450
3533
|
*/
|
|
3451
3534
|
private static cleanupOrphanedVestingCache;
|
|
3452
3535
|
/**
|
|
3453
|
-
*
|
|
3536
|
+
* The key a provider registers under: the store it addresses, so every provider
|
|
3537
|
+
* over one dataDir/DB shares an entry. A provider that declares no store keeps a
|
|
3538
|
+
* private key, leaving custom implementations scoped by object identity.
|
|
3454
3539
|
*/
|
|
3455
|
-
static
|
|
3540
|
+
private static storeKeyOf;
|
|
3541
|
+
/** The clears this store has seen. Absent means none — `clear()` creates the entry. */
|
|
3542
|
+
private static clearGenerationOf;
|
|
3543
|
+
private static bumpClearGeneration;
|
|
3456
3544
|
/**
|
|
3457
|
-
*
|
|
3545
|
+
* Make a fully-built Sphere reachable — or refuse, if `clear()` emptied the store
|
|
3546
|
+
* under it while it was building. Check and registration are one SYNCHRONOUS step on
|
|
3547
|
+
* purpose: split by an await, a clear could land between them and wipe a store whose
|
|
3548
|
+
* Sphere is already published. The refusal throws inside `withOwnedRegistry`, whose
|
|
3549
|
+
* teardown then destroys the half-built Sphere the caller never received.
|
|
3458
3550
|
*/
|
|
3459
|
-
static
|
|
3551
|
+
private static publishLive;
|
|
3552
|
+
/** Record a fully-built Sphere against the storage it owns. See `_liveByStorage`. */
|
|
3553
|
+
private static registerLive;
|
|
3554
|
+
private static unregisterLive;
|
|
3555
|
+
/** Snapshot — callers iterate this while destroy() mutates the underlying Set. */
|
|
3556
|
+
private static liveOn;
|
|
3460
3557
|
/**
|
|
3461
3558
|
* Validate mnemonic using BIP39
|
|
3462
3559
|
*/
|
|
@@ -3625,7 +3722,8 @@ declare class Sphere {
|
|
|
3625
3722
|
/**
|
|
3626
3723
|
* Import wallet from JSON backup
|
|
3627
3724
|
*
|
|
3628
|
-
* @returns
|
|
3725
|
+
* @returns `{ success, sphere?, mnemonic?, error? }`. `sphere` is the instance built
|
|
3726
|
+
* on the SUPPLIED storage — hold it, there is no global to look it up from (#766).
|
|
3629
3727
|
*
|
|
3630
3728
|
* @example
|
|
3631
3729
|
* ```ts
|
|
@@ -3642,6 +3740,7 @@ declare class Sphere {
|
|
|
3642
3740
|
password?: string;
|
|
3643
3741
|
}): Promise<{
|
|
3644
3742
|
success: boolean;
|
|
3743
|
+
sphere?: Sphere;
|
|
3645
3744
|
mnemonic?: string;
|
|
3646
3745
|
error?: string;
|
|
3647
3746
|
}>;
|
|
@@ -3741,6 +3840,18 @@ declare class Sphere {
|
|
|
3741
3840
|
* independently in background. The payments vertical is NOT created here —
|
|
3742
3841
|
* the caller starts it via stopThenStartPaymentsV2 (§7 single vertical).
|
|
3743
3842
|
*/
|
|
3843
|
+
/** Tear one address's module set down. Each address owns its own engine, so its own pool. */
|
|
3844
|
+
private static destroyModuleSet;
|
|
3845
|
+
/**
|
|
3846
|
+
* Undo a module set built while `destroy()` was running.
|
|
3847
|
+
*
|
|
3848
|
+
* `destroy()`'s teardown loop has already emptied `_addressModules`, so a set
|
|
3849
|
+
* registered after it would stay live and unreachable — its own engine (and worker
|
|
3850
|
+
* pool), and a transport mux `ensureTransportMux` rebuilt because teardown had just
|
|
3851
|
+
* nulled the field. Then re-raise, so the switch fails rather than reporting success
|
|
3852
|
+
* on a destroyed Sphere (#770, #772 review).
|
|
3853
|
+
*/
|
|
3854
|
+
private discardModulesBuiltDuringDestroy;
|
|
3744
3855
|
private initializeAddressModules;
|
|
3745
3856
|
/**
|
|
3746
3857
|
* Ensure the transport multiplexer exists and register an address.
|
|
@@ -3749,6 +3860,8 @@ declare class Sphere {
|
|
|
3749
3860
|
* @returns AddressTransportAdapter or null if transport is not Nostr-based
|
|
3750
3861
|
*/
|
|
3751
3862
|
private ensureTransportMux;
|
|
3863
|
+
/** A BIP32 child number: an integer in 0…0xffffffff. Anything else aliases an address. */
|
|
3864
|
+
private static assertDerivableIndex;
|
|
3752
3865
|
/**
|
|
3753
3866
|
* Derive address at a specific index
|
|
3754
3867
|
*
|
|
@@ -3987,6 +4100,29 @@ declare class Sphere {
|
|
|
3987
4100
|
* Strip @ prefix and normalize a nametag (lowercase, phone E.164, strip @unicity suffix).
|
|
3988
4101
|
*/
|
|
3989
4102
|
private cleanNametag;
|
|
4103
|
+
/**
|
|
4104
|
+
* Disconnect transport, storage and oracle, attempting each even if an earlier one
|
|
4105
|
+
* rejects. They are separate resources, and one failure must not skip the rest — that
|
|
4106
|
+
* is how a partial teardown leaves connections open, which is exactly the state the
|
|
4107
|
+
* failed-initialization path calls destroy() in.
|
|
4108
|
+
*/
|
|
4109
|
+
private disconnectProvidersIndependently;
|
|
4110
|
+
/** Run one teardown step, logging rather than propagating so the next one still runs. */
|
|
4111
|
+
private static safeDisconnect;
|
|
4112
|
+
/**
|
|
4113
|
+
* Tear this Sphere down: stop the vertical, destroy the modules, disconnect the providers
|
|
4114
|
+
* and zero the key material. Idempotent by construction (every step is null-guarded) and
|
|
4115
|
+
* deliberately WITHOUT an early return on re-entry, which would change what a double call
|
|
4116
|
+
* means.
|
|
4117
|
+
*
|
|
4118
|
+
* #770: the FIRST statement flips `_destroyed` — before any await, and before this queues
|
|
4119
|
+
* its own stop on the §7 lifecycle mutex. That position is load-bearing. Every guard reads
|
|
4120
|
+
* the flag, so from that instant any switchToAddress step not yet begun refuses; and
|
|
4121
|
+
* because it flips SYNCHRONOUSLY at entry, a stop/start pair the mutex runs after this call
|
|
4122
|
+
* sees `true` and skips its start. Set it beside `_initialized` at the bottom instead and a
|
|
4123
|
+
* concurrent switch re-arms a wallet whose owner already had destroy() return: fresh
|
|
4124
|
+
* sockets, a fresh wallet-api session, a whole fresh vertical nothing will ever stop.
|
|
4125
|
+
*/
|
|
3990
4126
|
destroy(): Promise<void>;
|
|
3991
4127
|
private storeMnemonic;
|
|
3992
4128
|
private storeMasterKey;
|
|
@@ -4024,7 +4160,17 @@ declare class Sphere {
|
|
|
4024
4160
|
private initializeModules;
|
|
4025
4161
|
/** §7 mutex: run one stop/start lifecycle op after all queued ones settle. */
|
|
4026
4162
|
private queuePaymentsV2Op;
|
|
4027
|
-
/**
|
|
4163
|
+
/**
|
|
4164
|
+
* Switch/boot: stop whatever runs, then start `index`'s vertical — atomically vs other
|
|
4165
|
+
* lifecycle ops.
|
|
4166
|
+
*
|
|
4167
|
+
* #770: the destroyed check between the two halves settles the FACADE vector on its own.
|
|
4168
|
+
* `_destroyed` flips synchronously at destroy() entry, so any closure that BEGINS executing
|
|
4169
|
+
* after destroy() was called sees `true`, and any closure already past the check has
|
|
4170
|
+
* facade.start() in flight — which destroy()'s own queued stop is necessarily ordered
|
|
4171
|
+
* after. The TRANSPORT vector is not on this mutex at all; the ensureAlive() calls in
|
|
4172
|
+
* switchToAddress are what cover it.
|
|
4173
|
+
*/
|
|
4028
4174
|
private stopThenStartPaymentsV2;
|
|
4029
4175
|
/**
|
|
4030
4176
|
* Compose + start the payments vertical for ONE address (the §7 rule:
|
|
@@ -4035,6 +4181,12 @@ declare class Sphere {
|
|
|
4035
4181
|
private startPaymentsV2Inner;
|
|
4036
4182
|
/** P9 §7: stop the active vertical and await quiescence (in-flight ops settle). */
|
|
4037
4183
|
private stopPaymentsV2Inner;
|
|
4184
|
+
/**
|
|
4185
|
+
* Refuse once destroy() has STARTED (#770). `_initialized` cannot carry this: destroy()
|
|
4186
|
+
* clears it last, so every teardown step is a window in which a concurrent call still reads
|
|
4187
|
+
* a ready Sphere and re-arms it.
|
|
4188
|
+
*/
|
|
4189
|
+
private ensureAlive;
|
|
4038
4190
|
private ensureReady;
|
|
4039
4191
|
private emitEvent;
|
|
4040
4192
|
private encrypt;
|
|
@@ -4044,7 +4196,6 @@ declare const createSphere: typeof Sphere.create;
|
|
|
4044
4196
|
declare const loadSphere: typeof Sphere.load;
|
|
4045
4197
|
declare const importSphere: typeof Sphere.import;
|
|
4046
4198
|
declare const initSphere: typeof Sphere.init;
|
|
4047
|
-
declare const getSphere: typeof Sphere.getInstance;
|
|
4048
4199
|
declare const sphereExists: typeof Sphere.exists;
|
|
4049
4200
|
|
|
4050
4201
|
/**
|
|
@@ -4588,4 +4739,4 @@ interface CheckNetworkHealthOptions {
|
|
|
4588
4739
|
*/
|
|
4589
4740
|
declare function checkNetworkHealth(network?: NetworkType, options?: CheckNetworkHealthOptions): Promise<NetworkHealthResult>;
|
|
4590
4741
|
|
|
4591
|
-
export { type AddressInfo, type AddressModuleSet, type CheckNetworkHealthOptions, CurrencyUtils, DEFAULT_DERIVATION_PATH, DEFAULT_TOKEN_DECIMALS, DELIVERY_ENCRYPTION_HKDF_INFO, type DeliveryBundle, type DerivedKey, type DiscoverAddressProgress, type DiscoverAddressesOptions, type DiscoverAddressesResult, type DiscoveredAddress, type EncryptedData, type EncryptionOptions, FIELD_ENCRYPTION_HKDF_INFO, FIELD_ENVELOPE_MAX_BYTES, FIELD_ENVELOPE_NONCE_BYTES, FIELD_ENVELOPE_PREFIX, type InitProgress, type InitProgressCallback, type InitProgressStep, type KeyPair, type LogHandler, type LogLevel, type LoggerConfig, type MasterKey, PartialSendConflictError, SIGN_MESSAGE_PREFIX, Sphere, type SphereCreateOptions, SphereError, type SphereErrorCode, type SphereImportOptions, type SphereInitOptions, type SphereInitResult, type SphereLoadOptions, type WalletApiTransportConfig, assertFieldEnvelopeShape, base58Decode, base58Encode, bytesToHex, checkNetworkHealth, createKeyPair, createSphere, decrypt, decryptDeliveryBundle, decryptField, decryptFieldBytes, decryptJson, decryptMnemonic, decryptSimple, decryptWithSalt, deriveAddressInfo, deriveChildKey, deriveDeliveryEncryptionKey, deriveFieldEncryptionKey, deriveKeyAtPath, deserializeEncrypted, discoverAddressesImpl, doubleSha256, encrypt, encryptDeliveryBundle, encryptField, encryptFieldBytes, encryptMnemonic, encryptSimple, entropyToMnemonic, extractFromText, findPattern, formatAmount, generateAddressFromMasterKey, generateAddressInfo, generateMasterKey, generateMnemonic, generateRandomKey, getPublicKey,
|
|
4742
|
+
export { type AddressInfo, type AddressModuleSet, type CheckNetworkHealthOptions, CurrencyUtils, DEFAULT_DERIVATION_PATH, DEFAULT_TOKEN_DECIMALS, DELIVERY_ENCRYPTION_HKDF_INFO, type DeliveryBundle, type DerivedKey, type DiscoverAddressProgress, type DiscoverAddressesOptions, type DiscoverAddressesResult, type DiscoveredAddress, type EncryptedData, type EncryptionOptions, FIELD_ENCRYPTION_HKDF_INFO, FIELD_ENVELOPE_MAX_BYTES, FIELD_ENVELOPE_NONCE_BYTES, FIELD_ENVELOPE_PREFIX, type InitProgress, type InitProgressCallback, type InitProgressStep, type KeyPair, type LogHandler, type LogLevel, type LoggerConfig, type MasterKey, PartialSendConflictError, SIGN_MESSAGE_PREFIX, Sphere, type SphereCreateOptions, SphereError, type SphereErrorCode, type SphereImportOptions, type SphereInitOptions, type SphereInitResult, type SphereLoadOptions, type WalletApiTransportConfig, assertFieldEnvelopeShape, base58Decode, base58Encode, bytesToHex, checkNetworkHealth, createKeyPair, createSphere, decrypt, decryptDeliveryBundle, decryptField, decryptFieldBytes, decryptJson, decryptMnemonic, decryptSimple, decryptWithSalt, deriveAddressInfo, deriveChildKey, deriveDeliveryEncryptionKey, deriveFieldEncryptionKey, deriveKeyAtPath, deserializeEncrypted, discoverAddressesImpl, doubleSha256, encrypt, encryptDeliveryBundle, encryptField, encryptFieldBytes, encryptMnemonic, encryptSimple, entropyToMnemonic, extractFromText, findPattern, formatAmount, generateAddressFromMasterKey, generateAddressInfo, generateMasterKey, generateMnemonic, generateRandomKey, getPublicKey, hash160, hashSignMessage, hexToBytes, identityFromMnemonic, identityFromMnemonicSync, importSphere, initSphere, isEncryptedData, isPossiblyCommittedSendOutcome, isSphereError, isValidNametag, isValidPrivateKey, loadSphere, logger, mnemonicToEntropy, mnemonicToSeed, mnemonicToSeedSync, parseTokenAmount, randomBytes, randomHex, randomUUID, recoverPubkeyFromSignature, ripemd160, safeParseTokenAmount, serializeEncrypted, sha256, signMessage, sleep, sphereExists, toHumanReadable, validateMnemonic, verifySignedMessage };
|