@unicitylabs/sphere-sdk 0.13.2 → 0.13.3-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 +7 -65
- package/dist/connect/index.cjs +1 -1
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/index.js +1 -1
- package/dist/connect/index.js.map +1 -1
- package/dist/core/index.cjs +490 -1279
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +58 -134
- package/dist/core/index.d.ts +58 -134
- package/dist/core/index.js +490 -1272
- package/dist/core/index.js.map +1 -1
- package/dist/impl/browser/connect/index.cjs +1 -1
- package/dist/impl/browser/connect/index.cjs.map +1 -1
- package/dist/impl/browser/connect/index.js +1 -1
- package/dist/impl/browser/connect/index.js.map +1 -1
- package/dist/impl/nodejs/index.d.cts +0 -22
- package/dist/impl/nodejs/index.d.ts +0 -22
- package/dist/impl/shared/wallet-api/index.d.cts +0 -22
- package/dist/impl/shared/wallet-api/index.d.ts +0 -22
- package/dist/index.cjs +499 -1391
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +79 -357
- package/dist/index.d.ts +79 -357
- package/dist/index.js +499 -1364
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/core/index.d.cts
CHANGED
|
@@ -464,9 +464,6 @@ interface TokenStorageProvider<TData = unknown> extends BaseProvider {
|
|
|
464
464
|
interface TxfStorageDataBase {
|
|
465
465
|
_meta: TxfMeta;
|
|
466
466
|
_tombstones?: TxfTombstone[];
|
|
467
|
-
_outbox?: TxfOutboxEntry[];
|
|
468
|
-
_sent?: TxfSentEntry[];
|
|
469
|
-
_invalid?: TxfInvalidEntry[];
|
|
470
467
|
_history?: HistoryRecord[];
|
|
471
468
|
[key: `_${string}`]: unknown;
|
|
472
469
|
}
|
|
@@ -482,25 +479,6 @@ interface TxfTombstone {
|
|
|
482
479
|
stateHash: string;
|
|
483
480
|
timestamp: number;
|
|
484
481
|
}
|
|
485
|
-
interface TxfOutboxEntry {
|
|
486
|
-
id: string;
|
|
487
|
-
status: string;
|
|
488
|
-
tokenId: string;
|
|
489
|
-
recipient: string;
|
|
490
|
-
createdAt: number;
|
|
491
|
-
data: unknown;
|
|
492
|
-
}
|
|
493
|
-
interface TxfSentEntry {
|
|
494
|
-
tokenId: string;
|
|
495
|
-
recipient: string;
|
|
496
|
-
txHash: string;
|
|
497
|
-
sentAt: number;
|
|
498
|
-
}
|
|
499
|
-
interface TxfInvalidEntry {
|
|
500
|
-
tokenId: string;
|
|
501
|
-
reason: string;
|
|
502
|
-
detectedAt: number;
|
|
503
|
-
}
|
|
504
482
|
|
|
505
483
|
/**
|
|
506
484
|
* Oracle Provider Interface
|
|
@@ -3380,6 +3358,21 @@ declare class PaymentsModule {
|
|
|
3380
3358
|
* and the SENT history record (dedupKey'd by transferId — idempotent).
|
|
3381
3359
|
*/
|
|
3382
3360
|
private resumeIntent;
|
|
3361
|
+
/**
|
|
3362
|
+
* A resumed split that produced no output: a lost source means the leg delivered
|
|
3363
|
+
* nothing (returns false), and every checkpoint failure keeps the intent open by
|
|
3364
|
+
* throwing. There is no path here that records the spend.
|
|
3365
|
+
*/
|
|
3366
|
+
private classifyResumeSplitFailure;
|
|
3367
|
+
/**
|
|
3368
|
+
* Drop the local records of the sources a resume consumed (present when
|
|
3369
|
+
* resuming on the originating device). M7: each removal carries the LOCAL state
|
|
3370
|
+
* we spent, so a source a concurrent claim reactivated to a NEW state (a
|
|
3371
|
+
* self-send round-trip) is KEPT, not destroyed.
|
|
3372
|
+
*/
|
|
3373
|
+
private dropResumedSources;
|
|
3374
|
+
/** §10: the SENT record — same dedupKey as the original attempt, so a resume after the history POST is a server-side no-op. */
|
|
3375
|
+
private recordResumedSentHistory;
|
|
3383
3376
|
/**
|
|
3384
3377
|
* Persist the token state to every (non-disabled) token storage provider.
|
|
3385
3378
|
*
|
|
@@ -7470,13 +7463,15 @@ interface DerivedAddressInfo {
|
|
|
7470
7463
|
declare function discoverAddressesImpl(deriveTransportPubkey: (index: number) => DerivedAddressInfo, batchResolve: (transportPubkeys: string[]) => Promise<PeerInfo[]>, options?: DiscoverAddressesOptions): Promise<DiscoverAddressesResult>;
|
|
7471
7464
|
|
|
7472
7465
|
/**
|
|
7473
|
-
*
|
|
7466
|
+
* Text Wallet Backup Serialization Types
|
|
7474
7467
|
*/
|
|
7475
7468
|
|
|
7476
|
-
type LegacyFileType = 'dat' | 'txt' | 'json' | 'mnemonic' | 'unknown';
|
|
7477
7469
|
/**
|
|
7478
|
-
*
|
|
7470
|
+
* Result of parsing a text wallet backup file
|
|
7479
7471
|
*/
|
|
7472
|
+
/** Backup file shapes `Sphere.importFromLegacyFile` accepts. Bitcoin Core `.dat` was removed (#604 — L3-only). */
|
|
7473
|
+
type LegacyFileType = 'txt' | 'json' | 'mnemonic' | 'unknown';
|
|
7474
|
+
/** Reports PBKDF2 progress while decrypting a password-protected backup. */
|
|
7480
7475
|
type DecryptionProgressCallback = (iteration: number, total: number) => Promise<void> | void;
|
|
7481
7476
|
|
|
7482
7477
|
/**
|
|
@@ -7520,7 +7515,6 @@ type DecryptionProgressCallback = (iteration: number, total: number) => Promise<
|
|
|
7520
7515
|
*/
|
|
7521
7516
|
|
|
7522
7517
|
declare function isValidNametag(nametag: string): boolean;
|
|
7523
|
-
|
|
7524
7518
|
/** Steps reported by the onProgress callback during wallet init/create/load/import */
|
|
7525
7519
|
type InitProgressStep = 'clearing' | 'storing_keys' | 'initializing' | 'recovering_nametag' | 'registering_nametag' | 'syncing_identity' | 'syncing_tokens' | 'discovering_addresses' | 'finalizing' | 'complete';
|
|
7526
7520
|
/** Progress info passed to onProgress callback */
|
|
@@ -8159,6 +8153,43 @@ declare class Sphere {
|
|
|
8159
8153
|
* modules fall back to their legacy path, same as init).
|
|
8160
8154
|
*/
|
|
8161
8155
|
setOracleApiKey(apiKey: string): Promise<void>;
|
|
8156
|
+
/**
|
|
8157
|
+
* Import a wallet from a backup file: a `UNICITY WALLET DETAILS` text backup
|
|
8158
|
+
* (the format `exportToTxt` writes, optionally password-encrypted), a legacy
|
|
8159
|
+
* flat-JSON webwallet export, or a bare mnemonic in a text file.
|
|
8160
|
+
*
|
|
8161
|
+
* @example
|
|
8162
|
+
* const result = await Sphere.importFromLegacyFile({
|
|
8163
|
+
* fileContent: await file.text(),
|
|
8164
|
+
* fileName: file.name,
|
|
8165
|
+
* password, // when the backup is encrypted
|
|
8166
|
+
* ...providers,
|
|
8167
|
+
* });
|
|
8168
|
+
*/
|
|
8169
|
+
static importFromLegacyFile(options: Omit<SphereImportOptions, 'mnemonic' | 'masterKey' | 'chainCode' | 'derivationPath' | 'basePath' | 'derivationMode'> & {
|
|
8170
|
+
/** The backup file's text. */
|
|
8171
|
+
fileContent: string;
|
|
8172
|
+
/** File name (used for type detection) */
|
|
8173
|
+
fileName: string;
|
|
8174
|
+
/** Password for encrypted files */
|
|
8175
|
+
password?: string;
|
|
8176
|
+
/** Progress callback for long decryption operations */
|
|
8177
|
+
onDecryptProgress?: DecryptionProgressCallback;
|
|
8178
|
+
}): Promise<{
|
|
8179
|
+
success: boolean;
|
|
8180
|
+
sphere?: Sphere;
|
|
8181
|
+
mnemonic?: string;
|
|
8182
|
+
needsPassword?: boolean;
|
|
8183
|
+
error?: string;
|
|
8184
|
+
}>;
|
|
8185
|
+
/**
|
|
8186
|
+
* Detect legacy file type from filename and content
|
|
8187
|
+
*/
|
|
8188
|
+
static detectLegacyFileType(fileName: string, content: string): LegacyFileType;
|
|
8189
|
+
/**
|
|
8190
|
+
* Check if a legacy file is encrypted
|
|
8191
|
+
*/
|
|
8192
|
+
static isLegacyFileEncrypted(fileName: string, content: string): boolean;
|
|
8162
8193
|
/**
|
|
8163
8194
|
* Check if wallet has BIP32 master key for HD derivation
|
|
8164
8195
|
*/
|
|
@@ -8243,60 +8274,6 @@ declare class Sphere {
|
|
|
8243
8274
|
mnemonic?: string;
|
|
8244
8275
|
error?: string;
|
|
8245
8276
|
}>;
|
|
8246
|
-
/**
|
|
8247
|
-
* Import wallet from legacy file (.dat, .txt, or mnemonic text)
|
|
8248
|
-
*
|
|
8249
|
-
* Supports:
|
|
8250
|
-
* - Bitcoin Core wallet.dat files (SQLite format, encrypted or unencrypted)
|
|
8251
|
-
* - Text backup files (UNICITY WALLET DETAILS format)
|
|
8252
|
-
* - Plain mnemonic text (12 or 24 words)
|
|
8253
|
-
*
|
|
8254
|
-
* @returns Object with success status, created Sphere instance, and optionally recovered mnemonic
|
|
8255
|
-
*
|
|
8256
|
-
* @example
|
|
8257
|
-
* ```ts
|
|
8258
|
-
* // Import from .dat file
|
|
8259
|
-
* const fileBuffer = await file.arrayBuffer();
|
|
8260
|
-
* const result = await Sphere.importFromLegacyFile({
|
|
8261
|
-
* fileContent: new Uint8Array(fileBuffer),
|
|
8262
|
-
* fileName: 'wallet.dat',
|
|
8263
|
-
* password: 'wallet-password', // if encrypted
|
|
8264
|
-
* storage, transport, oracle,
|
|
8265
|
-
* });
|
|
8266
|
-
*
|
|
8267
|
-
* // Import from .txt file
|
|
8268
|
-
* const textContent = await file.text();
|
|
8269
|
-
* const result = await Sphere.importFromLegacyFile({
|
|
8270
|
-
* fileContent: textContent,
|
|
8271
|
-
* fileName: 'backup.txt',
|
|
8272
|
-
* storage, transport, oracle,
|
|
8273
|
-
* });
|
|
8274
|
-
* ```
|
|
8275
|
-
*/
|
|
8276
|
-
static importFromLegacyFile(options: Omit<SphereImportOptions, 'mnemonic' | 'masterKey' | 'chainCode' | 'derivationPath' | 'basePath' | 'derivationMode'> & {
|
|
8277
|
-
/** File content - Uint8Array for .dat, string for .txt */
|
|
8278
|
-
fileContent: string | Uint8Array;
|
|
8279
|
-
/** File name (used for type detection) */
|
|
8280
|
-
fileName: string;
|
|
8281
|
-
/** Password for encrypted files */
|
|
8282
|
-
password?: string;
|
|
8283
|
-
/** Progress callback for long decryption operations */
|
|
8284
|
-
onDecryptProgress?: DecryptionProgressCallback;
|
|
8285
|
-
}): Promise<{
|
|
8286
|
-
success: boolean;
|
|
8287
|
-
sphere?: Sphere;
|
|
8288
|
-
mnemonic?: string;
|
|
8289
|
-
needsPassword?: boolean;
|
|
8290
|
-
error?: string;
|
|
8291
|
-
}>;
|
|
8292
|
-
/**
|
|
8293
|
-
* Detect legacy file type from filename and content
|
|
8294
|
-
*/
|
|
8295
|
-
static detectLegacyFileType(fileName: string, content: string | Uint8Array): LegacyFileType;
|
|
8296
|
-
/**
|
|
8297
|
-
* Check if a legacy file is encrypted
|
|
8298
|
-
*/
|
|
8299
|
-
static isLegacyFileEncrypted(fileName: string, content: string | Uint8Array): boolean;
|
|
8300
8277
|
/**
|
|
8301
8278
|
* Get the current active address index
|
|
8302
8279
|
*
|
|
@@ -9036,59 +9013,6 @@ declare const CurrencyUtils: {
|
|
|
9036
9013
|
format: typeof formatAmount;
|
|
9037
9014
|
};
|
|
9038
9015
|
|
|
9039
|
-
/**
|
|
9040
|
-
* Bech32 Encoding/Decoding
|
|
9041
|
-
* BIP-173 implementation for address encoding
|
|
9042
|
-
*/
|
|
9043
|
-
/** Bech32 character set from BIP-173 */
|
|
9044
|
-
declare const CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
|
|
9045
|
-
/**
|
|
9046
|
-
* Convert between bit arrays (8→5 or 5→8)
|
|
9047
|
-
*/
|
|
9048
|
-
declare function convertBits(data: number[], fromBits: number, toBits: number, pad: boolean): number[] | null;
|
|
9049
|
-
/**
|
|
9050
|
-
* Encode data to bech32 address
|
|
9051
|
-
*
|
|
9052
|
-
* @example
|
|
9053
|
-
* ```ts
|
|
9054
|
-
* const address = encodeBech32('bc', 1, pubkeyHash);
|
|
9055
|
-
* // 'bc1qw...'
|
|
9056
|
-
* ```
|
|
9057
|
-
*/
|
|
9058
|
-
declare function encodeBech32(hrp: string, version: number, program: Uint8Array): string;
|
|
9059
|
-
/**
|
|
9060
|
-
* Decode bech32 address
|
|
9061
|
-
*
|
|
9062
|
-
* @example
|
|
9063
|
-
* ```ts
|
|
9064
|
-
* const result = decodeBech32('bc1qw...');
|
|
9065
|
-
* // { hrp: 'bc', witnessVersion: 1, data: Uint8Array }
|
|
9066
|
-
* ```
|
|
9067
|
-
*/
|
|
9068
|
-
declare function decodeBech32(addr: string): {
|
|
9069
|
-
hrp: string;
|
|
9070
|
-
witnessVersion: number;
|
|
9071
|
-
data: Uint8Array;
|
|
9072
|
-
} | null;
|
|
9073
|
-
/**
|
|
9074
|
-
* Create address from public key hash
|
|
9075
|
-
*
|
|
9076
|
-
* @example
|
|
9077
|
-
* ```ts
|
|
9078
|
-
* const address = createAddress('bc', pubkeyHash);
|
|
9079
|
-
* // 'bc1...'
|
|
9080
|
-
* ```
|
|
9081
|
-
*/
|
|
9082
|
-
declare function createAddress(hrp: string, pubkeyHash: Uint8Array | string): string;
|
|
9083
|
-
/**
|
|
9084
|
-
* Validate bech32 address
|
|
9085
|
-
*/
|
|
9086
|
-
declare function isValidBech32(addr: string): boolean;
|
|
9087
|
-
/**
|
|
9088
|
-
* Get HRP from address
|
|
9089
|
-
*/
|
|
9090
|
-
declare function getAddressHrp(addr: string): string | null;
|
|
9091
|
-
|
|
9092
9016
|
/**
|
|
9093
9017
|
* Browser-safe UUID v4 generation.
|
|
9094
9018
|
*
|
|
@@ -9335,4 +9259,4 @@ interface CheckNetworkHealthOptions {
|
|
|
9335
9259
|
*/
|
|
9336
9260
|
declare function checkNetworkHealth(network?: NetworkType, options?: CheckNetworkHealthOptions): Promise<NetworkHealthResult>;
|
|
9337
9261
|
|
|
9338
|
-
export { type AddressInfo, type AddressModuleSet,
|
|
9262
|
+
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 SphereWalletApiSession, 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, getSphere, 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
|
@@ -464,9 +464,6 @@ interface TokenStorageProvider<TData = unknown> extends BaseProvider {
|
|
|
464
464
|
interface TxfStorageDataBase {
|
|
465
465
|
_meta: TxfMeta;
|
|
466
466
|
_tombstones?: TxfTombstone[];
|
|
467
|
-
_outbox?: TxfOutboxEntry[];
|
|
468
|
-
_sent?: TxfSentEntry[];
|
|
469
|
-
_invalid?: TxfInvalidEntry[];
|
|
470
467
|
_history?: HistoryRecord[];
|
|
471
468
|
[key: `_${string}`]: unknown;
|
|
472
469
|
}
|
|
@@ -482,25 +479,6 @@ interface TxfTombstone {
|
|
|
482
479
|
stateHash: string;
|
|
483
480
|
timestamp: number;
|
|
484
481
|
}
|
|
485
|
-
interface TxfOutboxEntry {
|
|
486
|
-
id: string;
|
|
487
|
-
status: string;
|
|
488
|
-
tokenId: string;
|
|
489
|
-
recipient: string;
|
|
490
|
-
createdAt: number;
|
|
491
|
-
data: unknown;
|
|
492
|
-
}
|
|
493
|
-
interface TxfSentEntry {
|
|
494
|
-
tokenId: string;
|
|
495
|
-
recipient: string;
|
|
496
|
-
txHash: string;
|
|
497
|
-
sentAt: number;
|
|
498
|
-
}
|
|
499
|
-
interface TxfInvalidEntry {
|
|
500
|
-
tokenId: string;
|
|
501
|
-
reason: string;
|
|
502
|
-
detectedAt: number;
|
|
503
|
-
}
|
|
504
482
|
|
|
505
483
|
/**
|
|
506
484
|
* Oracle Provider Interface
|
|
@@ -3380,6 +3358,21 @@ declare class PaymentsModule {
|
|
|
3380
3358
|
* and the SENT history record (dedupKey'd by transferId — idempotent).
|
|
3381
3359
|
*/
|
|
3382
3360
|
private resumeIntent;
|
|
3361
|
+
/**
|
|
3362
|
+
* A resumed split that produced no output: a lost source means the leg delivered
|
|
3363
|
+
* nothing (returns false), and every checkpoint failure keeps the intent open by
|
|
3364
|
+
* throwing. There is no path here that records the spend.
|
|
3365
|
+
*/
|
|
3366
|
+
private classifyResumeSplitFailure;
|
|
3367
|
+
/**
|
|
3368
|
+
* Drop the local records of the sources a resume consumed (present when
|
|
3369
|
+
* resuming on the originating device). M7: each removal carries the LOCAL state
|
|
3370
|
+
* we spent, so a source a concurrent claim reactivated to a NEW state (a
|
|
3371
|
+
* self-send round-trip) is KEPT, not destroyed.
|
|
3372
|
+
*/
|
|
3373
|
+
private dropResumedSources;
|
|
3374
|
+
/** §10: the SENT record — same dedupKey as the original attempt, so a resume after the history POST is a server-side no-op. */
|
|
3375
|
+
private recordResumedSentHistory;
|
|
3383
3376
|
/**
|
|
3384
3377
|
* Persist the token state to every (non-disabled) token storage provider.
|
|
3385
3378
|
*
|
|
@@ -7470,13 +7463,15 @@ interface DerivedAddressInfo {
|
|
|
7470
7463
|
declare function discoverAddressesImpl(deriveTransportPubkey: (index: number) => DerivedAddressInfo, batchResolve: (transportPubkeys: string[]) => Promise<PeerInfo[]>, options?: DiscoverAddressesOptions): Promise<DiscoverAddressesResult>;
|
|
7471
7464
|
|
|
7472
7465
|
/**
|
|
7473
|
-
*
|
|
7466
|
+
* Text Wallet Backup Serialization Types
|
|
7474
7467
|
*/
|
|
7475
7468
|
|
|
7476
|
-
type LegacyFileType = 'dat' | 'txt' | 'json' | 'mnemonic' | 'unknown';
|
|
7477
7469
|
/**
|
|
7478
|
-
*
|
|
7470
|
+
* Result of parsing a text wallet backup file
|
|
7479
7471
|
*/
|
|
7472
|
+
/** Backup file shapes `Sphere.importFromLegacyFile` accepts. Bitcoin Core `.dat` was removed (#604 — L3-only). */
|
|
7473
|
+
type LegacyFileType = 'txt' | 'json' | 'mnemonic' | 'unknown';
|
|
7474
|
+
/** Reports PBKDF2 progress while decrypting a password-protected backup. */
|
|
7480
7475
|
type DecryptionProgressCallback = (iteration: number, total: number) => Promise<void> | void;
|
|
7481
7476
|
|
|
7482
7477
|
/**
|
|
@@ -7520,7 +7515,6 @@ type DecryptionProgressCallback = (iteration: number, total: number) => Promise<
|
|
|
7520
7515
|
*/
|
|
7521
7516
|
|
|
7522
7517
|
declare function isValidNametag(nametag: string): boolean;
|
|
7523
|
-
|
|
7524
7518
|
/** Steps reported by the onProgress callback during wallet init/create/load/import */
|
|
7525
7519
|
type InitProgressStep = 'clearing' | 'storing_keys' | 'initializing' | 'recovering_nametag' | 'registering_nametag' | 'syncing_identity' | 'syncing_tokens' | 'discovering_addresses' | 'finalizing' | 'complete';
|
|
7526
7520
|
/** Progress info passed to onProgress callback */
|
|
@@ -8159,6 +8153,43 @@ declare class Sphere {
|
|
|
8159
8153
|
* modules fall back to their legacy path, same as init).
|
|
8160
8154
|
*/
|
|
8161
8155
|
setOracleApiKey(apiKey: string): Promise<void>;
|
|
8156
|
+
/**
|
|
8157
|
+
* Import a wallet from a backup file: a `UNICITY WALLET DETAILS` text backup
|
|
8158
|
+
* (the format `exportToTxt` writes, optionally password-encrypted), a legacy
|
|
8159
|
+
* flat-JSON webwallet export, or a bare mnemonic in a text file.
|
|
8160
|
+
*
|
|
8161
|
+
* @example
|
|
8162
|
+
* const result = await Sphere.importFromLegacyFile({
|
|
8163
|
+
* fileContent: await file.text(),
|
|
8164
|
+
* fileName: file.name,
|
|
8165
|
+
* password, // when the backup is encrypted
|
|
8166
|
+
* ...providers,
|
|
8167
|
+
* });
|
|
8168
|
+
*/
|
|
8169
|
+
static importFromLegacyFile(options: Omit<SphereImportOptions, 'mnemonic' | 'masterKey' | 'chainCode' | 'derivationPath' | 'basePath' | 'derivationMode'> & {
|
|
8170
|
+
/** The backup file's text. */
|
|
8171
|
+
fileContent: string;
|
|
8172
|
+
/** File name (used for type detection) */
|
|
8173
|
+
fileName: string;
|
|
8174
|
+
/** Password for encrypted files */
|
|
8175
|
+
password?: string;
|
|
8176
|
+
/** Progress callback for long decryption operations */
|
|
8177
|
+
onDecryptProgress?: DecryptionProgressCallback;
|
|
8178
|
+
}): Promise<{
|
|
8179
|
+
success: boolean;
|
|
8180
|
+
sphere?: Sphere;
|
|
8181
|
+
mnemonic?: string;
|
|
8182
|
+
needsPassword?: boolean;
|
|
8183
|
+
error?: string;
|
|
8184
|
+
}>;
|
|
8185
|
+
/**
|
|
8186
|
+
* Detect legacy file type from filename and content
|
|
8187
|
+
*/
|
|
8188
|
+
static detectLegacyFileType(fileName: string, content: string): LegacyFileType;
|
|
8189
|
+
/**
|
|
8190
|
+
* Check if a legacy file is encrypted
|
|
8191
|
+
*/
|
|
8192
|
+
static isLegacyFileEncrypted(fileName: string, content: string): boolean;
|
|
8162
8193
|
/**
|
|
8163
8194
|
* Check if wallet has BIP32 master key for HD derivation
|
|
8164
8195
|
*/
|
|
@@ -8243,60 +8274,6 @@ declare class Sphere {
|
|
|
8243
8274
|
mnemonic?: string;
|
|
8244
8275
|
error?: string;
|
|
8245
8276
|
}>;
|
|
8246
|
-
/**
|
|
8247
|
-
* Import wallet from legacy file (.dat, .txt, or mnemonic text)
|
|
8248
|
-
*
|
|
8249
|
-
* Supports:
|
|
8250
|
-
* - Bitcoin Core wallet.dat files (SQLite format, encrypted or unencrypted)
|
|
8251
|
-
* - Text backup files (UNICITY WALLET DETAILS format)
|
|
8252
|
-
* - Plain mnemonic text (12 or 24 words)
|
|
8253
|
-
*
|
|
8254
|
-
* @returns Object with success status, created Sphere instance, and optionally recovered mnemonic
|
|
8255
|
-
*
|
|
8256
|
-
* @example
|
|
8257
|
-
* ```ts
|
|
8258
|
-
* // Import from .dat file
|
|
8259
|
-
* const fileBuffer = await file.arrayBuffer();
|
|
8260
|
-
* const result = await Sphere.importFromLegacyFile({
|
|
8261
|
-
* fileContent: new Uint8Array(fileBuffer),
|
|
8262
|
-
* fileName: 'wallet.dat',
|
|
8263
|
-
* password: 'wallet-password', // if encrypted
|
|
8264
|
-
* storage, transport, oracle,
|
|
8265
|
-
* });
|
|
8266
|
-
*
|
|
8267
|
-
* // Import from .txt file
|
|
8268
|
-
* const textContent = await file.text();
|
|
8269
|
-
* const result = await Sphere.importFromLegacyFile({
|
|
8270
|
-
* fileContent: textContent,
|
|
8271
|
-
* fileName: 'backup.txt',
|
|
8272
|
-
* storage, transport, oracle,
|
|
8273
|
-
* });
|
|
8274
|
-
* ```
|
|
8275
|
-
*/
|
|
8276
|
-
static importFromLegacyFile(options: Omit<SphereImportOptions, 'mnemonic' | 'masterKey' | 'chainCode' | 'derivationPath' | 'basePath' | 'derivationMode'> & {
|
|
8277
|
-
/** File content - Uint8Array for .dat, string for .txt */
|
|
8278
|
-
fileContent: string | Uint8Array;
|
|
8279
|
-
/** File name (used for type detection) */
|
|
8280
|
-
fileName: string;
|
|
8281
|
-
/** Password for encrypted files */
|
|
8282
|
-
password?: string;
|
|
8283
|
-
/** Progress callback for long decryption operations */
|
|
8284
|
-
onDecryptProgress?: DecryptionProgressCallback;
|
|
8285
|
-
}): Promise<{
|
|
8286
|
-
success: boolean;
|
|
8287
|
-
sphere?: Sphere;
|
|
8288
|
-
mnemonic?: string;
|
|
8289
|
-
needsPassword?: boolean;
|
|
8290
|
-
error?: string;
|
|
8291
|
-
}>;
|
|
8292
|
-
/**
|
|
8293
|
-
* Detect legacy file type from filename and content
|
|
8294
|
-
*/
|
|
8295
|
-
static detectLegacyFileType(fileName: string, content: string | Uint8Array): LegacyFileType;
|
|
8296
|
-
/**
|
|
8297
|
-
* Check if a legacy file is encrypted
|
|
8298
|
-
*/
|
|
8299
|
-
static isLegacyFileEncrypted(fileName: string, content: string | Uint8Array): boolean;
|
|
8300
8277
|
/**
|
|
8301
8278
|
* Get the current active address index
|
|
8302
8279
|
*
|
|
@@ -9036,59 +9013,6 @@ declare const CurrencyUtils: {
|
|
|
9036
9013
|
format: typeof formatAmount;
|
|
9037
9014
|
};
|
|
9038
9015
|
|
|
9039
|
-
/**
|
|
9040
|
-
* Bech32 Encoding/Decoding
|
|
9041
|
-
* BIP-173 implementation for address encoding
|
|
9042
|
-
*/
|
|
9043
|
-
/** Bech32 character set from BIP-173 */
|
|
9044
|
-
declare const CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
|
|
9045
|
-
/**
|
|
9046
|
-
* Convert between bit arrays (8→5 or 5→8)
|
|
9047
|
-
*/
|
|
9048
|
-
declare function convertBits(data: number[], fromBits: number, toBits: number, pad: boolean): number[] | null;
|
|
9049
|
-
/**
|
|
9050
|
-
* Encode data to bech32 address
|
|
9051
|
-
*
|
|
9052
|
-
* @example
|
|
9053
|
-
* ```ts
|
|
9054
|
-
* const address = encodeBech32('bc', 1, pubkeyHash);
|
|
9055
|
-
* // 'bc1qw...'
|
|
9056
|
-
* ```
|
|
9057
|
-
*/
|
|
9058
|
-
declare function encodeBech32(hrp: string, version: number, program: Uint8Array): string;
|
|
9059
|
-
/**
|
|
9060
|
-
* Decode bech32 address
|
|
9061
|
-
*
|
|
9062
|
-
* @example
|
|
9063
|
-
* ```ts
|
|
9064
|
-
* const result = decodeBech32('bc1qw...');
|
|
9065
|
-
* // { hrp: 'bc', witnessVersion: 1, data: Uint8Array }
|
|
9066
|
-
* ```
|
|
9067
|
-
*/
|
|
9068
|
-
declare function decodeBech32(addr: string): {
|
|
9069
|
-
hrp: string;
|
|
9070
|
-
witnessVersion: number;
|
|
9071
|
-
data: Uint8Array;
|
|
9072
|
-
} | null;
|
|
9073
|
-
/**
|
|
9074
|
-
* Create address from public key hash
|
|
9075
|
-
*
|
|
9076
|
-
* @example
|
|
9077
|
-
* ```ts
|
|
9078
|
-
* const address = createAddress('bc', pubkeyHash);
|
|
9079
|
-
* // 'bc1...'
|
|
9080
|
-
* ```
|
|
9081
|
-
*/
|
|
9082
|
-
declare function createAddress(hrp: string, pubkeyHash: Uint8Array | string): string;
|
|
9083
|
-
/**
|
|
9084
|
-
* Validate bech32 address
|
|
9085
|
-
*/
|
|
9086
|
-
declare function isValidBech32(addr: string): boolean;
|
|
9087
|
-
/**
|
|
9088
|
-
* Get HRP from address
|
|
9089
|
-
*/
|
|
9090
|
-
declare function getAddressHrp(addr: string): string | null;
|
|
9091
|
-
|
|
9092
9016
|
/**
|
|
9093
9017
|
* Browser-safe UUID v4 generation.
|
|
9094
9018
|
*
|
|
@@ -9335,4 +9259,4 @@ interface CheckNetworkHealthOptions {
|
|
|
9335
9259
|
*/
|
|
9336
9260
|
declare function checkNetworkHealth(network?: NetworkType, options?: CheckNetworkHealthOptions): Promise<NetworkHealthResult>;
|
|
9337
9261
|
|
|
9338
|
-
export { type AddressInfo, type AddressModuleSet,
|
|
9262
|
+
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 SphereWalletApiSession, 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, getSphere, 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 };
|