@unicitylabs/sphere-sdk 0.17.2-dev.3 → 0.17.3
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 +1 -0
- 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 +53 -2
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +25 -9
- package/dist/core/index.d.ts +25 -9
- package/dist/core/index.js +52 -2
- 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/browser/index.cjs.map +1 -1
- package/dist/impl/browser/index.js.map +1 -1
- package/dist/impl/nodejs/index.cjs.map +1 -1
- package/dist/impl/nodejs/index.js.map +1 -1
- package/dist/impl/wallet-api-v2/index.cjs.map +1 -1
- package/dist/impl/wallet-api-v2/index.js.map +1 -1
- package/dist/index.cjs +53 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -9
- package/dist/index.d.ts +25 -9
- package/dist/index.js +52 -2
- package/dist/index.js.map +1 -1
- package/dist/modules/payments-v2/index.cjs.map +1 -1
- package/dist/modules/payments-v2/index.js.map +1 -1
- package/dist/token-engine/index.cjs.map +1 -1
- package/dist/token-engine/index.d.cts +1 -1
- package/dist/token-engine/index.d.ts +1 -1
- package/dist/token-engine/index.js.map +1 -1
- package/package.json +1 -1
package/dist/core/index.d.cts
CHANGED
|
@@ -445,7 +445,7 @@ interface PaymentsV2 {
|
|
|
445
445
|
* }
|
|
446
446
|
* ```
|
|
447
447
|
*/
|
|
448
|
-
type SphereErrorCode = 'NOT_INITIALIZED' | 'ALREADY_INITIALIZED' | 'INVALID_CONFIG' | 'INVALID_IDENTITY' | 'INSUFFICIENT_BALANCE' | 'INVALID_RECIPIENT' | 'TRANSFER_FAILED' | 'TRANSFER_CONFLICT' | 'CERTIFICATION_UNCONFIRMED' | 'CHECKPOINT_PERSIST_FAILED' | 'SPLIT_CHECKPOINT_LOST' | 'CHECKPOINT_TRUSTBASE_MISMATCH' | 'STORAGE_ERROR' | 'SEND_SYNC_PENDING' | 'SEND_PARTIALLY_COMPLETED' | 'TRANSPORT_ERROR' | 'AGGREGATOR_ERROR' | 'VALIDATION_ERROR' | 'INVALID_AMOUNT' | 'NETWORK_ERROR' | 'TIMEOUT' | 'DECRYPTION_ERROR' | 'MODULE_NOT_AVAILABLE' | 'SIGNING_ERROR' | 'SEND_QUEUE_TIMEOUT' | 'SEND_INSUFFICIENT_BALANCE' | 'SEND_RESERVATION_CANCELLED' | 'SEND_QUEUE_FULL' | 'MODULE_DESTROYED' | 'REENTRANT_GATE' | 'INVOICE_NO_TARGETS' | 'INVOICE_INVALID_ADDRESS' | 'INVOICE_NO_ASSETS' | 'INVOICE_INVALID_ASSET' | 'INVOICE_INVALID_AMOUNT' | 'INVOICE_INVALID_COIN' | 'INVOICE_INVALID_NFT' | 'INVOICE_PAST_DUE_DATE' | 'INVOICE_DUPLICATE_ADDRESS' | 'INVOICE_DUPLICATE_COIN' | 'INVOICE_DUPLICATE_NFT' | 'INVOICE_MINT_FAILED' | 'INVOICE_INVALID_PROOF' | 'INVOICE_WRONG_TOKEN_TYPE' | 'INVOICE_INVALID_DATA' | 'INVOICE_ALREADY_EXISTS' | 'INVOICE_NOT_FOUND' | 'INVOICE_NOT_TARGET' | 'INVOICE_ALREADY_CLOSED' | 'INVOICE_ALREADY_CANCELLED' | 'INVOICE_ORACLE_REQUIRED' | 'INVOICE_TERMINATED' | 'INVOICE_INVALID_TARGET' | 'INVOICE_INVALID_ASSET_INDEX' | 'INVOICE_RETURN_EXCEEDS_BALANCE' | 'INVOICE_INVALID_DELIVERY_METHOD' | 'INVOICE_INVALID_REFUND_ADDRESS' | 'INVOICE_INVALID_CONTACT' | 'INVOICE_INVALID_ID' | 'INVOICE_TOO_MANY_TARGETS' | 'INVOICE_TOO_MANY_ASSETS' | 'INVOICE_MEMO_TOO_LONG' | 'INVOICE_TERMS_TOO_LARGE' | 'INVOICE_NOT_TERMINATED' | 'INVOICE_NOT_CANCELLED' | 'INVOICE_STORAGE_FAILED' | 'RATE_LIMITED' | 'COMMUNICATIONS_UNAVAILABLE' | 'SWAP_INVALID_DEAL' | 'SWAP_INVALID_MANIFEST' | 'SWAP_NOT_FOUND' | 'SWAP_WRONG_STATE' | 'SWAP_RESOLVE_FAILED' | 'SWAP_DM_SEND_FAILED' | 'SWAP_ESCROW_REJECTED' | 'SWAP_DEPOSIT_FAILED' | 'SWAP_PAYOUT_VERIFICATION_FAILED' | 'SWAP_ALREADY_EXISTS' | 'SWAP_ALREADY_COMPLETED' | 'SWAP_ALREADY_CANCELLED' | 'SWAP_TIMEOUT' | 'SWAP_LIMIT_EXCEEDED' | 'SWAP_ALREADY_INITIALIZED' | 'SWAP_MODULE_DESTROYED' | 'SWAP_NOT_INITIALIZED';
|
|
448
|
+
type SphereErrorCode = 'NOT_INITIALIZED' | 'ALREADY_INITIALIZED' | 'INVALID_CONFIG' | 'INVALID_IDENTITY' | 'INSUFFICIENT_BALANCE' | 'INVALID_RECIPIENT' | 'TRANSFER_FAILED' | 'TRANSFER_CONFLICT' | 'CERTIFICATION_UNCONFIRMED' | 'CHECKPOINT_PERSIST_FAILED' | 'SPLIT_CHECKPOINT_LOST' | 'CHECKPOINT_TRUSTBASE_MISMATCH' | 'STORAGE_ERROR' | 'SEND_SYNC_PENDING' | 'SEND_PARTIALLY_COMPLETED' | 'TRANSPORT_ERROR' | 'AGGREGATOR_ERROR' | 'VALIDATION_ERROR' | 'INVALID_AMOUNT' | 'NETWORK_ERROR' | 'TIMEOUT' | 'DECRYPTION_ERROR' | 'MODULE_NOT_AVAILABLE' | 'PAYMENTS_NOT_COMPOSED' | 'SIGNING_ERROR' | 'SEND_QUEUE_TIMEOUT' | 'SEND_INSUFFICIENT_BALANCE' | 'SEND_RESERVATION_CANCELLED' | 'SEND_QUEUE_FULL' | 'MODULE_DESTROYED' | 'REENTRANT_GATE' | 'INVOICE_NO_TARGETS' | 'INVOICE_INVALID_ADDRESS' | 'INVOICE_NO_ASSETS' | 'INVOICE_INVALID_ASSET' | 'INVOICE_INVALID_AMOUNT' | 'INVOICE_INVALID_COIN' | 'INVOICE_INVALID_NFT' | 'INVOICE_PAST_DUE_DATE' | 'INVOICE_DUPLICATE_ADDRESS' | 'INVOICE_DUPLICATE_COIN' | 'INVOICE_DUPLICATE_NFT' | 'INVOICE_MINT_FAILED' | 'INVOICE_INVALID_PROOF' | 'INVOICE_WRONG_TOKEN_TYPE' | 'INVOICE_INVALID_DATA' | 'INVOICE_ALREADY_EXISTS' | 'INVOICE_NOT_FOUND' | 'INVOICE_NOT_TARGET' | 'INVOICE_ALREADY_CLOSED' | 'INVOICE_ALREADY_CANCELLED' | 'INVOICE_ORACLE_REQUIRED' | 'INVOICE_TERMINATED' | 'INVOICE_INVALID_TARGET' | 'INVOICE_INVALID_ASSET_INDEX' | 'INVOICE_RETURN_EXCEEDS_BALANCE' | 'INVOICE_INVALID_DELIVERY_METHOD' | 'INVOICE_INVALID_REFUND_ADDRESS' | 'INVOICE_INVALID_CONTACT' | 'INVOICE_INVALID_ID' | 'INVOICE_TOO_MANY_TARGETS' | 'INVOICE_TOO_MANY_ASSETS' | 'INVOICE_MEMO_TOO_LONG' | 'INVOICE_TERMS_TOO_LARGE' | 'INVOICE_NOT_TERMINATED' | 'INVOICE_NOT_CANCELLED' | 'INVOICE_STORAGE_FAILED' | 'RATE_LIMITED' | 'COMMUNICATIONS_UNAVAILABLE' | 'SWAP_INVALID_DEAL' | 'SWAP_INVALID_MANIFEST' | 'SWAP_NOT_FOUND' | 'SWAP_WRONG_STATE' | 'SWAP_RESOLVE_FAILED' | 'SWAP_DM_SEND_FAILED' | 'SWAP_ESCROW_REJECTED' | 'SWAP_DEPOSIT_FAILED' | 'SWAP_PAYOUT_VERIFICATION_FAILED' | 'SWAP_ALREADY_EXISTS' | 'SWAP_ALREADY_COMPLETED' | 'SWAP_ALREADY_CANCELLED' | 'SWAP_TIMEOUT' | 'SWAP_LIMIT_EXCEEDED' | 'SWAP_ALREADY_INITIALIZED' | 'SWAP_MODULE_DESTROYED' | 'SWAP_NOT_INITIALIZED';
|
|
449
449
|
declare class SphereError extends Error {
|
|
450
450
|
readonly code: SphereErrorCode;
|
|
451
451
|
readonly cause?: unknown;
|
|
@@ -3165,6 +3165,9 @@ interface WalletApiTransportConfig {
|
|
|
3165
3165
|
/** DI seam: supply the whole per-address bundle (offline tests, custom hosts). */
|
|
3166
3166
|
paymentsV2Transport?(args: PaymentsV2TransportArgs): PaymentsV2Transport;
|
|
3167
3167
|
}
|
|
3168
|
+
/** The messaging-only opt-out (#793) — sharing the `walletApi` field is what makes "configured" and "deliberately absent" mutually exclusive. */
|
|
3169
|
+
declare const NO_PAYMENTS = "none";
|
|
3170
|
+
type WalletApiOption = WalletApiTransportConfig | typeof NO_PAYMENTS;
|
|
3168
3171
|
|
|
3169
3172
|
/**
|
|
3170
3173
|
* Text Wallet Backup Serialization Types
|
|
@@ -3234,14 +3237,17 @@ interface InitProgress {
|
|
|
3234
3237
|
/** Callback for tracking wallet initialization progress */
|
|
3235
3238
|
type InitProgressCallback = (progress: InitProgress) => void;
|
|
3236
3239
|
/**
|
|
3237
|
-
* The wallet-api transport config every wallet
|
|
3238
|
-
*
|
|
3239
|
-
*
|
|
3240
|
-
* four init-option shapes below.
|
|
3240
|
+
* The wallet-api transport config every wallet that moves money needs:
|
|
3241
|
+
* `{ network, baseUrl, deviceId?, ... }` — `createWalletApiProviders`
|
|
3242
|
+
* (impl/shared/wallet-api) builds it. Shared by all four init-option shapes below.
|
|
3241
3243
|
*/
|
|
3242
3244
|
interface SphereWalletApiOptions {
|
|
3243
|
-
/**
|
|
3244
|
-
|
|
3245
|
+
/**
|
|
3246
|
+
* Wallet-api transport config — REQUIRED, with one explicit escape: `'none'`
|
|
3247
|
+
* composes no money at all (#793). Omitting the field still throws INVALID_CONFIG:
|
|
3248
|
+
* "I forgot it" must never read the same as "I meant it".
|
|
3249
|
+
*/
|
|
3250
|
+
walletApi?: WalletApiOption;
|
|
3245
3251
|
/** @deprecated REMOVED with the P11 flip — any truthy value throws INVALID_CONFIG (invoicing no longer exists in the SDK). */
|
|
3246
3252
|
accounting?: unknown;
|
|
3247
3253
|
/** @deprecated REMOVED with the P11 flip — any truthy value throws INVALID_CONFIG (swaps no longer exist in the SDK). */
|
|
@@ -3530,7 +3536,11 @@ declare class Sphere {
|
|
|
3530
3536
|
private _market;
|
|
3531
3537
|
/** The ACTIVE address's running vertical — §7: exactly one at a time, ever. */
|
|
3532
3538
|
private _paymentsV2Active;
|
|
3533
|
-
/**
|
|
3539
|
+
/**
|
|
3540
|
+
* Money composition, set at init. `null` = never resolved (a construction bug),
|
|
3541
|
+
* `NO_PAYMENTS` = the explicit #793 opt-out, an object = a real composition. One
|
|
3542
|
+
* spelling for the last two would read a forgotten resolve as messaging-only.
|
|
3543
|
+
*/
|
|
3534
3544
|
private _paymentsV2Composition;
|
|
3535
3545
|
/**
|
|
3536
3546
|
* §7 lifecycle mutex: every stop/start pair runs strictly serialized, so
|
|
@@ -3717,6 +3727,12 @@ declare class Sphere {
|
|
|
3717
3727
|
static generateMnemonic(strength?: 128 | 256): string;
|
|
3718
3728
|
/** Payments (the §4 facade — the active address's running vertical). */
|
|
3719
3729
|
get payments(): PaymentsV2;
|
|
3730
|
+
/**
|
|
3731
|
+
* Whether this Sphere composes money at all (#793) — fixed for the instance's life,
|
|
3732
|
+
* so a messaging-only wallet can branch without a try/catch. Not a liveness check:
|
|
3733
|
+
* `true` still leaves `payments` throwing NOT_INITIALIZED mid-init or mid-switch.
|
|
3734
|
+
*/
|
|
3735
|
+
get hasPayments(): boolean;
|
|
3720
3736
|
/** Communications module */
|
|
3721
3737
|
get communications(): CommunicationsModule;
|
|
3722
3738
|
/** Group chat module (NIP-29). Null if not configured. */
|
|
@@ -4891,4 +4907,4 @@ interface CheckNetworkHealthOptions {
|
|
|
4891
4907
|
*/
|
|
4892
4908
|
declare function checkNetworkHealth(network?: NetworkType, options?: CheckNetworkHealthOptions): Promise<NetworkHealthResult>;
|
|
4893
4909
|
|
|
4894
|
-
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 };
|
|
4910
|
+
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, NO_PAYMENTS, PartialSendConflictError, SIGN_MESSAGE_PREFIX, Sphere, type SphereCreateOptions, SphereError, type SphereErrorCode, type SphereImportOptions, type SphereInitOptions, type SphereInitResult, type SphereLoadOptions, type WalletApiOption, 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
|
@@ -445,7 +445,7 @@ interface PaymentsV2 {
|
|
|
445
445
|
* }
|
|
446
446
|
* ```
|
|
447
447
|
*/
|
|
448
|
-
type SphereErrorCode = 'NOT_INITIALIZED' | 'ALREADY_INITIALIZED' | 'INVALID_CONFIG' | 'INVALID_IDENTITY' | 'INSUFFICIENT_BALANCE' | 'INVALID_RECIPIENT' | 'TRANSFER_FAILED' | 'TRANSFER_CONFLICT' | 'CERTIFICATION_UNCONFIRMED' | 'CHECKPOINT_PERSIST_FAILED' | 'SPLIT_CHECKPOINT_LOST' | 'CHECKPOINT_TRUSTBASE_MISMATCH' | 'STORAGE_ERROR' | 'SEND_SYNC_PENDING' | 'SEND_PARTIALLY_COMPLETED' | 'TRANSPORT_ERROR' | 'AGGREGATOR_ERROR' | 'VALIDATION_ERROR' | 'INVALID_AMOUNT' | 'NETWORK_ERROR' | 'TIMEOUT' | 'DECRYPTION_ERROR' | 'MODULE_NOT_AVAILABLE' | 'SIGNING_ERROR' | 'SEND_QUEUE_TIMEOUT' | 'SEND_INSUFFICIENT_BALANCE' | 'SEND_RESERVATION_CANCELLED' | 'SEND_QUEUE_FULL' | 'MODULE_DESTROYED' | 'REENTRANT_GATE' | 'INVOICE_NO_TARGETS' | 'INVOICE_INVALID_ADDRESS' | 'INVOICE_NO_ASSETS' | 'INVOICE_INVALID_ASSET' | 'INVOICE_INVALID_AMOUNT' | 'INVOICE_INVALID_COIN' | 'INVOICE_INVALID_NFT' | 'INVOICE_PAST_DUE_DATE' | 'INVOICE_DUPLICATE_ADDRESS' | 'INVOICE_DUPLICATE_COIN' | 'INVOICE_DUPLICATE_NFT' | 'INVOICE_MINT_FAILED' | 'INVOICE_INVALID_PROOF' | 'INVOICE_WRONG_TOKEN_TYPE' | 'INVOICE_INVALID_DATA' | 'INVOICE_ALREADY_EXISTS' | 'INVOICE_NOT_FOUND' | 'INVOICE_NOT_TARGET' | 'INVOICE_ALREADY_CLOSED' | 'INVOICE_ALREADY_CANCELLED' | 'INVOICE_ORACLE_REQUIRED' | 'INVOICE_TERMINATED' | 'INVOICE_INVALID_TARGET' | 'INVOICE_INVALID_ASSET_INDEX' | 'INVOICE_RETURN_EXCEEDS_BALANCE' | 'INVOICE_INVALID_DELIVERY_METHOD' | 'INVOICE_INVALID_REFUND_ADDRESS' | 'INVOICE_INVALID_CONTACT' | 'INVOICE_INVALID_ID' | 'INVOICE_TOO_MANY_TARGETS' | 'INVOICE_TOO_MANY_ASSETS' | 'INVOICE_MEMO_TOO_LONG' | 'INVOICE_TERMS_TOO_LARGE' | 'INVOICE_NOT_TERMINATED' | 'INVOICE_NOT_CANCELLED' | 'INVOICE_STORAGE_FAILED' | 'RATE_LIMITED' | 'COMMUNICATIONS_UNAVAILABLE' | 'SWAP_INVALID_DEAL' | 'SWAP_INVALID_MANIFEST' | 'SWAP_NOT_FOUND' | 'SWAP_WRONG_STATE' | 'SWAP_RESOLVE_FAILED' | 'SWAP_DM_SEND_FAILED' | 'SWAP_ESCROW_REJECTED' | 'SWAP_DEPOSIT_FAILED' | 'SWAP_PAYOUT_VERIFICATION_FAILED' | 'SWAP_ALREADY_EXISTS' | 'SWAP_ALREADY_COMPLETED' | 'SWAP_ALREADY_CANCELLED' | 'SWAP_TIMEOUT' | 'SWAP_LIMIT_EXCEEDED' | 'SWAP_ALREADY_INITIALIZED' | 'SWAP_MODULE_DESTROYED' | 'SWAP_NOT_INITIALIZED';
|
|
448
|
+
type SphereErrorCode = 'NOT_INITIALIZED' | 'ALREADY_INITIALIZED' | 'INVALID_CONFIG' | 'INVALID_IDENTITY' | 'INSUFFICIENT_BALANCE' | 'INVALID_RECIPIENT' | 'TRANSFER_FAILED' | 'TRANSFER_CONFLICT' | 'CERTIFICATION_UNCONFIRMED' | 'CHECKPOINT_PERSIST_FAILED' | 'SPLIT_CHECKPOINT_LOST' | 'CHECKPOINT_TRUSTBASE_MISMATCH' | 'STORAGE_ERROR' | 'SEND_SYNC_PENDING' | 'SEND_PARTIALLY_COMPLETED' | 'TRANSPORT_ERROR' | 'AGGREGATOR_ERROR' | 'VALIDATION_ERROR' | 'INVALID_AMOUNT' | 'NETWORK_ERROR' | 'TIMEOUT' | 'DECRYPTION_ERROR' | 'MODULE_NOT_AVAILABLE' | 'PAYMENTS_NOT_COMPOSED' | 'SIGNING_ERROR' | 'SEND_QUEUE_TIMEOUT' | 'SEND_INSUFFICIENT_BALANCE' | 'SEND_RESERVATION_CANCELLED' | 'SEND_QUEUE_FULL' | 'MODULE_DESTROYED' | 'REENTRANT_GATE' | 'INVOICE_NO_TARGETS' | 'INVOICE_INVALID_ADDRESS' | 'INVOICE_NO_ASSETS' | 'INVOICE_INVALID_ASSET' | 'INVOICE_INVALID_AMOUNT' | 'INVOICE_INVALID_COIN' | 'INVOICE_INVALID_NFT' | 'INVOICE_PAST_DUE_DATE' | 'INVOICE_DUPLICATE_ADDRESS' | 'INVOICE_DUPLICATE_COIN' | 'INVOICE_DUPLICATE_NFT' | 'INVOICE_MINT_FAILED' | 'INVOICE_INVALID_PROOF' | 'INVOICE_WRONG_TOKEN_TYPE' | 'INVOICE_INVALID_DATA' | 'INVOICE_ALREADY_EXISTS' | 'INVOICE_NOT_FOUND' | 'INVOICE_NOT_TARGET' | 'INVOICE_ALREADY_CLOSED' | 'INVOICE_ALREADY_CANCELLED' | 'INVOICE_ORACLE_REQUIRED' | 'INVOICE_TERMINATED' | 'INVOICE_INVALID_TARGET' | 'INVOICE_INVALID_ASSET_INDEX' | 'INVOICE_RETURN_EXCEEDS_BALANCE' | 'INVOICE_INVALID_DELIVERY_METHOD' | 'INVOICE_INVALID_REFUND_ADDRESS' | 'INVOICE_INVALID_CONTACT' | 'INVOICE_INVALID_ID' | 'INVOICE_TOO_MANY_TARGETS' | 'INVOICE_TOO_MANY_ASSETS' | 'INVOICE_MEMO_TOO_LONG' | 'INVOICE_TERMS_TOO_LARGE' | 'INVOICE_NOT_TERMINATED' | 'INVOICE_NOT_CANCELLED' | 'INVOICE_STORAGE_FAILED' | 'RATE_LIMITED' | 'COMMUNICATIONS_UNAVAILABLE' | 'SWAP_INVALID_DEAL' | 'SWAP_INVALID_MANIFEST' | 'SWAP_NOT_FOUND' | 'SWAP_WRONG_STATE' | 'SWAP_RESOLVE_FAILED' | 'SWAP_DM_SEND_FAILED' | 'SWAP_ESCROW_REJECTED' | 'SWAP_DEPOSIT_FAILED' | 'SWAP_PAYOUT_VERIFICATION_FAILED' | 'SWAP_ALREADY_EXISTS' | 'SWAP_ALREADY_COMPLETED' | 'SWAP_ALREADY_CANCELLED' | 'SWAP_TIMEOUT' | 'SWAP_LIMIT_EXCEEDED' | 'SWAP_ALREADY_INITIALIZED' | 'SWAP_MODULE_DESTROYED' | 'SWAP_NOT_INITIALIZED';
|
|
449
449
|
declare class SphereError extends Error {
|
|
450
450
|
readonly code: SphereErrorCode;
|
|
451
451
|
readonly cause?: unknown;
|
|
@@ -3165,6 +3165,9 @@ interface WalletApiTransportConfig {
|
|
|
3165
3165
|
/** DI seam: supply the whole per-address bundle (offline tests, custom hosts). */
|
|
3166
3166
|
paymentsV2Transport?(args: PaymentsV2TransportArgs): PaymentsV2Transport;
|
|
3167
3167
|
}
|
|
3168
|
+
/** The messaging-only opt-out (#793) — sharing the `walletApi` field is what makes "configured" and "deliberately absent" mutually exclusive. */
|
|
3169
|
+
declare const NO_PAYMENTS = "none";
|
|
3170
|
+
type WalletApiOption = WalletApiTransportConfig | typeof NO_PAYMENTS;
|
|
3168
3171
|
|
|
3169
3172
|
/**
|
|
3170
3173
|
* Text Wallet Backup Serialization Types
|
|
@@ -3234,14 +3237,17 @@ interface InitProgress {
|
|
|
3234
3237
|
/** Callback for tracking wallet initialization progress */
|
|
3235
3238
|
type InitProgressCallback = (progress: InitProgress) => void;
|
|
3236
3239
|
/**
|
|
3237
|
-
* The wallet-api transport config every wallet
|
|
3238
|
-
*
|
|
3239
|
-
*
|
|
3240
|
-
* four init-option shapes below.
|
|
3240
|
+
* The wallet-api transport config every wallet that moves money needs:
|
|
3241
|
+
* `{ network, baseUrl, deviceId?, ... }` — `createWalletApiProviders`
|
|
3242
|
+
* (impl/shared/wallet-api) builds it. Shared by all four init-option shapes below.
|
|
3241
3243
|
*/
|
|
3242
3244
|
interface SphereWalletApiOptions {
|
|
3243
|
-
/**
|
|
3244
|
-
|
|
3245
|
+
/**
|
|
3246
|
+
* Wallet-api transport config — REQUIRED, with one explicit escape: `'none'`
|
|
3247
|
+
* composes no money at all (#793). Omitting the field still throws INVALID_CONFIG:
|
|
3248
|
+
* "I forgot it" must never read the same as "I meant it".
|
|
3249
|
+
*/
|
|
3250
|
+
walletApi?: WalletApiOption;
|
|
3245
3251
|
/** @deprecated REMOVED with the P11 flip — any truthy value throws INVALID_CONFIG (invoicing no longer exists in the SDK). */
|
|
3246
3252
|
accounting?: unknown;
|
|
3247
3253
|
/** @deprecated REMOVED with the P11 flip — any truthy value throws INVALID_CONFIG (swaps no longer exist in the SDK). */
|
|
@@ -3530,7 +3536,11 @@ declare class Sphere {
|
|
|
3530
3536
|
private _market;
|
|
3531
3537
|
/** The ACTIVE address's running vertical — §7: exactly one at a time, ever. */
|
|
3532
3538
|
private _paymentsV2Active;
|
|
3533
|
-
/**
|
|
3539
|
+
/**
|
|
3540
|
+
* Money composition, set at init. `null` = never resolved (a construction bug),
|
|
3541
|
+
* `NO_PAYMENTS` = the explicit #793 opt-out, an object = a real composition. One
|
|
3542
|
+
* spelling for the last two would read a forgotten resolve as messaging-only.
|
|
3543
|
+
*/
|
|
3534
3544
|
private _paymentsV2Composition;
|
|
3535
3545
|
/**
|
|
3536
3546
|
* §7 lifecycle mutex: every stop/start pair runs strictly serialized, so
|
|
@@ -3717,6 +3727,12 @@ declare class Sphere {
|
|
|
3717
3727
|
static generateMnemonic(strength?: 128 | 256): string;
|
|
3718
3728
|
/** Payments (the §4 facade — the active address's running vertical). */
|
|
3719
3729
|
get payments(): PaymentsV2;
|
|
3730
|
+
/**
|
|
3731
|
+
* Whether this Sphere composes money at all (#793) — fixed for the instance's life,
|
|
3732
|
+
* so a messaging-only wallet can branch without a try/catch. Not a liveness check:
|
|
3733
|
+
* `true` still leaves `payments` throwing NOT_INITIALIZED mid-init or mid-switch.
|
|
3734
|
+
*/
|
|
3735
|
+
get hasPayments(): boolean;
|
|
3720
3736
|
/** Communications module */
|
|
3721
3737
|
get communications(): CommunicationsModule;
|
|
3722
3738
|
/** Group chat module (NIP-29). Null if not configured. */
|
|
@@ -4891,4 +4907,4 @@ interface CheckNetworkHealthOptions {
|
|
|
4891
4907
|
*/
|
|
4892
4908
|
declare function checkNetworkHealth(network?: NetworkType, options?: CheckNetworkHealthOptions): Promise<NetworkHealthResult>;
|
|
4893
4909
|
|
|
4894
|
-
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 };
|
|
4910
|
+
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, NO_PAYMENTS, PartialSendConflictError, SIGN_MESSAGE_PREFIX, Sphere, type SphereCreateOptions, SphereError, type SphereErrorCode, type SphereImportOptions, type SphereInitOptions, type SphereInitResult, type SphereLoadOptions, type WalletApiOption, 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.js
CHANGED
|
@@ -4539,6 +4539,26 @@ var GroupVisibility = {
|
|
|
4539
4539
|
PRIVATE: "PRIVATE"
|
|
4540
4540
|
};
|
|
4541
4541
|
|
|
4542
|
+
// modules/groupchat/group-id.ts
|
|
4543
|
+
var MAX_SLUG_LENGTH = 24;
|
|
4544
|
+
var RANDOM_BYTES = 8;
|
|
4545
|
+
function groupIdSlug(name) {
|
|
4546
|
+
const slug = name.normalize("NFKD").replace(/\p{M}/gu, "").toLowerCase().replace(/['\u2019]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
4547
|
+
if (slug.length <= MAX_SLUG_LENGTH) return slug;
|
|
4548
|
+
const head = slug.slice(0, MAX_SLUG_LENGTH + 1);
|
|
4549
|
+
const hyphen = head.lastIndexOf("-");
|
|
4550
|
+
return hyphen > 0 ? head.slice(0, hyphen) : slug.slice(0, MAX_SLUG_LENGTH);
|
|
4551
|
+
}
|
|
4552
|
+
function newGroupId(name) {
|
|
4553
|
+
const crypto2 = globalThis.crypto;
|
|
4554
|
+
if (typeof crypto2?.getRandomValues !== "function") {
|
|
4555
|
+
throw new SphereError("Creating a group requires crypto.getRandomValues", "INVALID_CONFIG");
|
|
4556
|
+
}
|
|
4557
|
+
const bytes = crypto2.getRandomValues(new Uint8Array(RANDOM_BYTES));
|
|
4558
|
+
const random = Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
4559
|
+
return `${groupIdSlug(name) || "group"}-${random}`;
|
|
4560
|
+
}
|
|
4561
|
+
|
|
4542
4562
|
// modules/groupchat/GroupChatModule.ts
|
|
4543
4563
|
function createNip29Filter(data) {
|
|
4544
4564
|
return new Filter3(data);
|
|
@@ -5150,9 +5170,9 @@ var GroupChatModule = class {
|
|
|
5150
5170
|
if (!this.client) return null;
|
|
5151
5171
|
const creatorPubkey = this.getMyPublicKey();
|
|
5152
5172
|
if (!creatorPubkey) return null;
|
|
5153
|
-
const proposedGroupId = options.name.toLowerCase().replace(/[^a-z0-9]/g, "").slice(0, 20) || this.randomId();
|
|
5154
5173
|
try {
|
|
5155
5174
|
const isPrivate = options.visibility === GroupVisibility.PRIVATE;
|
|
5175
|
+
const proposedGroupId = newGroupId(options.name);
|
|
5156
5176
|
const eventId = await this.client.createAndPublishEvent({
|
|
5157
5177
|
kind: NIP29_KINDS.CREATE_GROUP,
|
|
5158
5178
|
tags: [["h", proposedGroupId]],
|
|
@@ -16956,7 +16976,16 @@ var WalletApiSplitCheckpointStore = class {
|
|
|
16956
16976
|
};
|
|
16957
16977
|
|
|
16958
16978
|
// core/payments-v2-wiring.ts
|
|
16979
|
+
var NO_PAYMENTS = "none";
|
|
16980
|
+
function readPaymentsOptOut(walletApi) {
|
|
16981
|
+
if (walletApi === NO_PAYMENTS) return NO_PAYMENTS;
|
|
16982
|
+
throw new SphereError(
|
|
16983
|
+
`walletApi must be a wallet-api transport config or the literal '${NO_PAYMENTS}' (the explicit messaging-only opt-out, #793) \u2014 received ${JSON.stringify(walletApi)}.`,
|
|
16984
|
+
"INVALID_CONFIG"
|
|
16985
|
+
);
|
|
16986
|
+
}
|
|
16959
16987
|
function resolvePaymentsV2Composition(walletApi, sphereNetwork) {
|
|
16988
|
+
if (typeof walletApi === "string") return readPaymentsOptOut(walletApi);
|
|
16960
16989
|
const source = walletApi;
|
|
16961
16990
|
const network = typeof source?.network === "string" && source.network !== "" ? source.network : null;
|
|
16962
16991
|
if (!source || network === null) {
|
|
@@ -17236,7 +17265,11 @@ var Sphere = class _Sphere {
|
|
|
17236
17265
|
// The payments vertical (the ONLY money path since the P11 flip)
|
|
17237
17266
|
/** The ACTIVE address's running vertical — §7: exactly one at a time, ever. */
|
|
17238
17267
|
_paymentsV2Active = null;
|
|
17239
|
-
/**
|
|
17268
|
+
/**
|
|
17269
|
+
* Money composition, set at init. `null` = never resolved (a construction bug),
|
|
17270
|
+
* `NO_PAYMENTS` = the explicit #793 opt-out, an object = a real composition. One
|
|
17271
|
+
* spelling for the last two would read a forgotten resolve as messaging-only.
|
|
17272
|
+
*/
|
|
17240
17273
|
_paymentsV2Composition = null;
|
|
17241
17274
|
/**
|
|
17242
17275
|
* §7 lifecycle mutex: every stop/start pair runs strictly serialized, so
|
|
@@ -17912,10 +17945,24 @@ var Sphere = class _Sphere {
|
|
|
17912
17945
|
get payments() {
|
|
17913
17946
|
const facade = this._paymentsV2Active?.facade;
|
|
17914
17947
|
if (!facade) {
|
|
17948
|
+
if (this._paymentsV2Composition === NO_PAYMENTS) {
|
|
17949
|
+
throw new SphereError(
|
|
17950
|
+
"payments is not composed: this Sphere was initialised with `walletApi: 'none'`, the explicit messaging-only composition. Money has no path here \u2014 re-init with a wallet-api transport config to move any.",
|
|
17951
|
+
"PAYMENTS_NOT_COMPOSED"
|
|
17952
|
+
);
|
|
17953
|
+
}
|
|
17915
17954
|
throw new SphereError("Sphere not initialized", "NOT_INITIALIZED");
|
|
17916
17955
|
}
|
|
17917
17956
|
return facade;
|
|
17918
17957
|
}
|
|
17958
|
+
/**
|
|
17959
|
+
* Whether this Sphere composes money at all (#793) — fixed for the instance's life,
|
|
17960
|
+
* so a messaging-only wallet can branch without a try/catch. Not a liveness check:
|
|
17961
|
+
* `true` still leaves `payments` throwing NOT_INITIALIZED mid-init or mid-switch.
|
|
17962
|
+
*/
|
|
17963
|
+
get hasPayments() {
|
|
17964
|
+
return this._paymentsV2Composition !== NO_PAYMENTS;
|
|
17965
|
+
}
|
|
17919
17966
|
/** Communications module */
|
|
17920
17967
|
get communications() {
|
|
17921
17968
|
this.ensureReady();
|
|
@@ -19943,6 +19990,7 @@ var Sphere = class _Sphere {
|
|
|
19943
19990
|
* breaks initialization.
|
|
19944
19991
|
*/
|
|
19945
19992
|
async buildTokenEngine(identity) {
|
|
19993
|
+
if (this._paymentsV2Composition === NO_PAYMENTS) return void 0;
|
|
19946
19994
|
const oracle = this._oracle;
|
|
19947
19995
|
const privateKey = (identity ?? this._identity)?.privateKey;
|
|
19948
19996
|
const trustBaseJson = oracle.getTrustBaseJson?.() ?? null;
|
|
@@ -20048,6 +20096,7 @@ var Sphere = class _Sphere {
|
|
|
20048
20096
|
* setOracleApiKey rebuild is what future operations snapshot.
|
|
20049
20097
|
*/
|
|
20050
20098
|
async startPaymentsV2Inner(index, identity) {
|
|
20099
|
+
if (this._paymentsV2Composition === NO_PAYMENTS) return;
|
|
20051
20100
|
if (!this._paymentsV2Composition) {
|
|
20052
20101
|
throw new SphereError("wallet-api composition required for money", "INVALID_CONFIG");
|
|
20053
20102
|
}
|
|
@@ -20427,6 +20476,7 @@ export {
|
|
|
20427
20476
|
FIELD_ENVELOPE_MAX_BYTES,
|
|
20428
20477
|
FIELD_ENVELOPE_NONCE_BYTES,
|
|
20429
20478
|
FIELD_ENVELOPE_PREFIX,
|
|
20479
|
+
NO_PAYMENTS,
|
|
20430
20480
|
PartialSendConflictError,
|
|
20431
20481
|
SIGN_MESSAGE_PREFIX,
|
|
20432
20482
|
Sphere,
|