@unicitylabs/sphere-sdk 0.7.1 → 0.7.2
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 +0 -58
- package/dist/core/index.cjs +34 -28
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +15 -19
- package/dist/core/index.d.ts +15 -19
- package/dist/core/index.js +33 -27
- package/dist/core/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/browser/ipfs.cjs.map +1 -1
- package/dist/impl/browser/ipfs.js.map +1 -1
- package/dist/impl/nodejs/index.cjs.map +1 -1
- package/dist/impl/nodejs/index.js.map +1 -1
- package/dist/index.cjs +34 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -40
- package/dist/index.d.ts +15 -40
- package/dist/index.js +33 -58
- package/dist/index.js.map +1 -1
- package/dist/l1/index.cjs.map +1 -1
- package/dist/l1/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2094,6 +2094,20 @@ declare function signMessage(privateKeyHex: string, message: string): string;
|
|
|
2094
2094
|
* @returns `true` if the signature is valid and matches the expected public key
|
|
2095
2095
|
*/
|
|
2096
2096
|
declare function verifySignedMessage(message: string, signature: string, expectedPubkey: string): boolean;
|
|
2097
|
+
/**
|
|
2098
|
+
* Recover the compressed secp256k1 public key from a signed message.
|
|
2099
|
+
*
|
|
2100
|
+
* Use this when the server needs to identify the signer (not just verify
|
|
2101
|
+
* a signature against a known pubkey). Combined with `sphere.resolve(pubkey)`
|
|
2102
|
+
* it gives a fully cryptographically-attributable identity for backend auth,
|
|
2103
|
+
* without trusting any client-supplied identifier claim.
|
|
2104
|
+
*
|
|
2105
|
+
* @param message - The plaintext that was signed
|
|
2106
|
+
* @param signature - 130-char hex (v + r + s) as produced by `signMessage`
|
|
2107
|
+
* @returns - Compressed 66-char hex pubkey
|
|
2108
|
+
* @throws - On malformed signature length or out-of-range recovery byte
|
|
2109
|
+
*/
|
|
2110
|
+
declare function recoverPubkeyFromSignature(message: string, signature: string): string;
|
|
2097
2111
|
|
|
2098
2112
|
/**
|
|
2099
2113
|
* INSTANT_SPLIT V5 Types
|
|
@@ -7277,23 +7291,6 @@ interface LegacyFileImportOptions {
|
|
|
7277
7291
|
onDecryptProgress?: DecryptionProgressCallback;
|
|
7278
7292
|
}
|
|
7279
7293
|
|
|
7280
|
-
/**
|
|
7281
|
-
* Compute the Unicity L3 DIRECT:// address that corresponds to a given
|
|
7282
|
-
* compressed secp256k1 public key.
|
|
7283
|
-
*
|
|
7284
|
-
* Deterministic — the underlying primitive `UnmaskedPredicateReference.create`
|
|
7285
|
-
* only uses the public key, so the private key is never needed. This lets
|
|
7286
|
-
* a backend trust only one thing from the client (the chain pubkey, whose
|
|
7287
|
-
* ownership the client proves via signature) and derive everything else
|
|
7288
|
-
* locally. Closes the entire class of "client claims an identifier the
|
|
7289
|
-
* server can't verify" bugs at the API level.
|
|
7290
|
-
*
|
|
7291
|
-
* @param chainPubkey 33-byte compressed secp256k1 pubkey, hex-encoded
|
|
7292
|
-
* (66 chars, leading 02 or 03).
|
|
7293
|
-
* @throws if chainPubkey doesn't match the compressed-secp256k1 format.
|
|
7294
|
-
*/
|
|
7295
|
-
declare function computeDirectAddressFromChainPubkey(chainPubkey: string): Promise<string>;
|
|
7296
|
-
|
|
7297
7294
|
declare function isValidNametag(nametag: string): boolean;
|
|
7298
7295
|
|
|
7299
7296
|
/** Steps reported by the onProgress callback during wallet init/create/load/import */
|
|
@@ -7535,7 +7532,6 @@ interface SphereInitResult {
|
|
|
7535
7532
|
/** Generated mnemonic (only if autoGenerate was used) */
|
|
7536
7533
|
generatedMnemonic?: string;
|
|
7537
7534
|
}
|
|
7538
|
-
|
|
7539
7535
|
declare class Sphere {
|
|
7540
7536
|
private static instance;
|
|
7541
7537
|
private _initialized;
|
|
@@ -10125,25 +10121,4 @@ declare function normalizeAddress(address: string): string;
|
|
|
10125
10121
|
*/
|
|
10126
10122
|
declare function addressesMatch(a: string, b: string): boolean;
|
|
10127
10123
|
|
|
10128
|
-
type
|
|
10129
|
-
declare class AuthVerificationError extends Error {
|
|
10130
|
-
readonly code: AuthVerificationErrorCode;
|
|
10131
|
-
constructor(message: string, code: AuthVerificationErrorCode);
|
|
10132
|
-
}
|
|
10133
|
-
interface SphereAuthInput {
|
|
10134
|
-
/** The exact text that was presented to the wallet for signing. */
|
|
10135
|
-
readonly challenge: string;
|
|
10136
|
-
/** Hex signature returned by the wallet's sign_message intent. */
|
|
10137
|
-
readonly signature: string;
|
|
10138
|
-
/** Compressed secp256k1 pubkey (66-char hex) the client claims to own. */
|
|
10139
|
-
readonly chainPubkey: string;
|
|
10140
|
-
}
|
|
10141
|
-
interface SphereAuthResult {
|
|
10142
|
-
/** Pubkey, proven via signature. */
|
|
10143
|
-
readonly chainPubkey: string;
|
|
10144
|
-
/** Unicity L3 DIRECT:// address, derived from chainPubkey (never claimed). */
|
|
10145
|
-
readonly directAddress: string;
|
|
10146
|
-
}
|
|
10147
|
-
declare function verifySphereAuth(input: SphereAuthInput): Promise<SphereAuthResult>;
|
|
10148
|
-
|
|
10149
|
-
export { type AddressInfo, type AddressMode, type AddressType, type AggregatorClient, type AggregatorEvent, type AggregatorEventCallback, type AggregatorEventType, type AggregatorProvider, type AggregatorProviderConfig, type Asset, AuthVerificationError, type AuthVerificationErrorCode, type BackgroundProgressStatus, type BaseProvider, type BroadcastHandler, type BroadcastMessage, type BuildSplitBundleResult, type CMasterKeyData, COIN_TYPES, type CheckNetworkHealthOptions, CoinGeckoPriceProvider, type CombinedTransferBundleV6, CommunicationsModule, type CommunicationsModuleConfig, type CommunicationsModuleDependencies, type ComposingIndicator, type ConversationPage, type CreateGroupOptions, type CreateInvoiceRequest, DEFAULT_AGGREGATOR_TIMEOUT, DEFAULT_AGGREGATOR_URL, DEFAULT_DERIVATION_PATH, DEFAULT_ELECTRUM_URL, DEFAULT_GROUP_RELAYS, DEFAULT_IPFS_BOOTSTRAP_PEERS, DEFAULT_IPFS_GATEWAYS, DEFAULT_MARKET_API_URL, DEFAULT_NOSTR_RELAYS, DEV_AGGREGATOR_URL, type DecryptionProgressCallback, type DerivationMode, type DirectMessage, type DirectTokenEntry, type DiscoverAddressProgress, type DiscoverAddressesOptions, type DiscoverAddressesResult, type DiscoveredAddress, type EncryptedData, type ExtendedValidationResult, type FullIdentity, type GetConversationPageOptions, type GetInvoicesOptions, type GetSwapsFilter, GroupChatModule, type GroupChatModuleConfig, type GroupChatModuleDependencies, type GroupData, type GroupMemberData, type GroupMessageData, GroupRole, GroupVisibility, type HealthCheckFn, type Identity, type IdentityConfig, type InclusionProof, type IncomingBroadcast, type IncomingMessage, type IncomingPaymentRequest, type IncomingTokenTransfer, type IncomingTransfer, type InitProgress, type InitProgressCallback, type InitProgressStep, type InstantSplitBundle, type InstantSplitBundleV4, type InstantSplitBundleV5, type InstantSplitOptions, type InstantSplitProcessResult, type InstantSplitResult, type InstantSplitV5RecoveryMetadata, type IntentStatus, type IntentType, type InvalidatedNametagEntry, type InvoiceRequestedAsset, index as L1, type L1Balance, L1PaymentsModule, type L1PaymentsModuleConfig, type L1PaymentsModuleDependencies, type L1SendRequest, type L1SendResult, type L1Transaction, type L1Utxo, LIMITS, type LegacyFileImportOptions, type LegacyFileInfo, type LegacyFileParseResult, type LegacyFileParsedData, type LegacyFileType, type LoadResult, type LogHandler, type LogLevel, type LoggerConfig, type LoggingConfig, type ManifestAuxiliary, type ManifestFields, type ManifestSignatures, type MarketIntent, MarketModule, type MarketModuleConfig, type MarketModuleDependencies, type MessageHandler, type MintOutboxEntry, type MintParams, type MintResult, NETWORKS, NIP29_KINDS, NOSTR_EVENT_KINDS, type NametagBindingProof, type NametagData, type NetworkHealthResult, type NetworkType, type OracleEvent, type OracleEventCallback, type OracleEventType, type OracleProvider, type OutboxEntry, type OutgoingPaymentRequest, type ParsedAddress, type ParsedStorageData, type PayInvoiceParams, type PaymentRequest, type PaymentRequestHandler, type PaymentRequestResponse, type PaymentRequestResponseHandler, type PaymentRequestResponseType, type PaymentRequestResult, type PaymentRequestStatus, type PaymentSession, type PaymentSessionDirection, type PaymentSessionError, type PaymentSessionErrorCode, type PaymentSessionStatus, PaymentsModule, type PaymentsModuleConfig, type PaymentsModuleDependencies, type PeerInfo, type PendingV5Finalization, type PostIntentRequest, type PostIntentResult, type PricePlatform, type PriceProvider, type PriceProviderConfig, type ProviderMetadata, type ProviderRole, type ProviderStatus, type ProviderStatusInfo, type ReceiveOptions, type ReceiveResult, type RegistryNetwork, type ReturnPaymentParams, SIGN_MESSAGE_PREFIX, STORAGE_KEYS, STORAGE_KEYS_ADDRESS, STORAGE_KEYS_GLOBAL, STORAGE_PREFIX, type SaveResult, type ScanAddressProgress, type ScanAddressesOptions, type ScanAddressesResult, type ScannedAddressResult, type SearchFilters, type SearchIntentResult, type SearchOptions, type SearchResult, type ServiceHealthResult, type SpentTokenInfo, type SpentTokenResult, Sphere, type SphereAuthInput, type SphereAuthResult, type SphereConfig, type SphereCreateOptions, SphereError, type SphereErrorCode, type SphereEventHandler, type SphereEventMap, type SphereEventType, type SphereImportOptions, type SphereInitOptions, type SphereInitResult, type SphereLoadOptions, type SphereStatus, type SplitPaymentSession, type SplitRecoveryResult, type StorageEvent, type StorageEventCallback, type StorageEventType, type StorageProvider, type StorageProviderConfig, type SubmitResult, type SwapDeal, type SwapManifest, SwapModule, type SwapModuleConfig, type SwapProgress, type SwapProposalResult, type SwapRef, type SwapRole, type SyncResult, TEST_AGGREGATOR_URL, TEST_ELECTRUM_URL, TEST_NOSTR_RELAYS, TIMEOUTS, type Token, type TokenDefinition, type TokenIcon, type TokenPrice, TokenRegistry, type TokenState, type TokenStatus, type TokenStorageProvider, type TokenTransferDetail, type TokenTransferHandler, type TokenTransferPayload, type ValidationResult as TokenValidationResult, TokenValidator, type TombstoneEntry, type TrackedAddress, type TrackedAddressEntry, type TransactionHistoryEntry, type TransferCommitment, type TransferMode, type TransferRequest, type TransferResult, type TransferStatus, type TransportEvent, type TransportEventCallback, type TransportEventType, type TransportProvider, type TransportProviderConfig, type TrustBaseLoader, type TxfAuthenticator, type TxfGenesis, type TxfGenesisData, type TxfInclusionProof, type TxfIntegrity, type TxfInvalidEntry, type TxfMerkleStep, type TxfMerkleTreePath, type TxfMeta, type TxfOutboxEntry, type TxfSentEntry, type TxfState, type TxfStorageData, type TxfStorageDataBase, type TxfToken, type TxfTombstone, type TxfTransaction, type UnconfirmedResolutionResult, type V5FinalizationStage, type ValidationAction, type ValidationIssue, type ValidationResult$1 as ValidationResult, type WaitOptions, type WalletDatInfo, type WalletInfo, type WalletJSON$1 as WalletJSON, type WalletJSONExportOptions$1 as WalletJSONExportOptions, type WalletSource, addressesMatch, archivedKeyFromTokenId, base58Decode, base58Encode, buildManifest, buildTxfStorageData, bytesToHex, checkNetworkHealth, coinIdsMatch, computeDirectAddressFromChainPubkey, computeSwapId, countCommittedTransactions, createAddress, createCommunicationsModule, createGroupChatModule, createKeyPair, createL1PaymentsModule, createMarketModule, createNametagBinding, createPaymentSession, createPaymentSessionError, createPaymentsModule, createPriceProvider, createSphere, createSplitPaymentSession, createSwapModule, createTokenValidator, decodeBech32, decrypt$1 as decrypt, decryptCMasterKey, decryptJson, decryptMnemonic, decryptPrivateKey, decryptSimple, decryptTextFormatKey, decryptWallet, decryptWithSalt, deriveAddressInfo, deriveChildKey$1 as deriveChildKey, deriveKeyAtPath$1 as deriveKeyAtPath, doubleSha256, encodeBech32, encrypt$1 as encrypt, encryptMnemonic, encryptSimple, encryptWallet, extractFromText, findPattern, forkedKeyFromTokenIdAndState, formatAmount, generateAddressFromMasterKey, generateMasterKey, generateMnemonic, generatePrivateKey, getAddressHrp, getAddressId, getAddressStorageKey, getCoinIdByName, getCoinIdBySymbol, getCurrentStateHash, getPublicKey, getSphere, getTokenDecimals, getTokenDefinition, getTokenIconUrl, getTokenId, getTokenName, getTokenSymbol, hasMissingNewStateHash, hasUncommittedTransactions, hasValidTxfData, hash160, hashSignMessage, hexToBytes, hexToWIF, identityFromMnemonicSync, initSphere, isArchivedKey, isCombinedTransferBundleV6, isForkedKey, isInstantSplitBundle, isInstantSplitBundleV4, isInstantSplitBundleV5, isKnownToken, isPaymentSessionTerminal, isPaymentSessionTimedOut, isSQLiteDatabase, isSphereError, isTextWalletEncrypted, isTokenKey, isValidAddress, isValidBech32, isValidDirectAddress, isValidNametag, isValidPrivateKey, isValidTokenId, isWalletDatEncrypted, isWalletTextFormat, keyFromTokenId, loadSphere, logger, mnemonicToSeedSync, normalizeAddress, normalizeCoinId, normalizeSdkTokenToStorage, objectToTxf, parseAddress, parseAndDecryptWalletDat, parseAndDecryptWalletText, parseForkedKey, parseTxfStorageData, parseWalletDat, parseWalletText, randomBytes, randomHex, randomUUID, ripemd160, sha256, signMessage, signSwapManifest, sleep, sphereExists, toHumanReadable, toSmallestUnit, tokenIdFromArchivedKey, tokenIdFromKey, tokenToTxf, txfToToken, validateManifest, validateMnemonic, verifyManifestIntegrity, verifyNametagBinding, verifySignedMessage, verifySphereAuth, verifySwapSignature };
|
|
10124
|
+
export { type AddressInfo, type AddressMode, type AddressType, type AggregatorClient, type AggregatorEvent, type AggregatorEventCallback, type AggregatorEventType, type AggregatorProvider, type AggregatorProviderConfig, type Asset, type BackgroundProgressStatus, type BaseProvider, type BroadcastHandler, type BroadcastMessage, type BuildSplitBundleResult, type CMasterKeyData, COIN_TYPES, type CheckNetworkHealthOptions, CoinGeckoPriceProvider, type CombinedTransferBundleV6, CommunicationsModule, type CommunicationsModuleConfig, type CommunicationsModuleDependencies, type ComposingIndicator, type ConversationPage, type CreateGroupOptions, type CreateInvoiceRequest, DEFAULT_AGGREGATOR_TIMEOUT, DEFAULT_AGGREGATOR_URL, DEFAULT_DERIVATION_PATH, DEFAULT_ELECTRUM_URL, DEFAULT_GROUP_RELAYS, DEFAULT_IPFS_BOOTSTRAP_PEERS, DEFAULT_IPFS_GATEWAYS, DEFAULT_MARKET_API_URL, DEFAULT_NOSTR_RELAYS, DEV_AGGREGATOR_URL, type DecryptionProgressCallback, type DerivationMode, type DirectMessage, type DirectTokenEntry, type DiscoverAddressProgress, type DiscoverAddressesOptions, type DiscoverAddressesResult, type DiscoveredAddress, type EncryptedData, type ExtendedValidationResult, type FullIdentity, type GetConversationPageOptions, type GetInvoicesOptions, type GetSwapsFilter, GroupChatModule, type GroupChatModuleConfig, type GroupChatModuleDependencies, type GroupData, type GroupMemberData, type GroupMessageData, GroupRole, GroupVisibility, type HealthCheckFn, type Identity, type IdentityConfig, type InclusionProof, type IncomingBroadcast, type IncomingMessage, type IncomingPaymentRequest, type IncomingTokenTransfer, type IncomingTransfer, type InitProgress, type InitProgressCallback, type InitProgressStep, type InstantSplitBundle, type InstantSplitBundleV4, type InstantSplitBundleV5, type InstantSplitOptions, type InstantSplitProcessResult, type InstantSplitResult, type InstantSplitV5RecoveryMetadata, type IntentStatus, type IntentType, type InvalidatedNametagEntry, type InvoiceRequestedAsset, index as L1, type L1Balance, L1PaymentsModule, type L1PaymentsModuleConfig, type L1PaymentsModuleDependencies, type L1SendRequest, type L1SendResult, type L1Transaction, type L1Utxo, LIMITS, type LegacyFileImportOptions, type LegacyFileInfo, type LegacyFileParseResult, type LegacyFileParsedData, type LegacyFileType, type LoadResult, type LogHandler, type LogLevel, type LoggerConfig, type LoggingConfig, type ManifestAuxiliary, type ManifestFields, type ManifestSignatures, type MarketIntent, MarketModule, type MarketModuleConfig, type MarketModuleDependencies, type MessageHandler, type MintOutboxEntry, type MintParams, type MintResult, NETWORKS, NIP29_KINDS, NOSTR_EVENT_KINDS, type NametagBindingProof, type NametagData, type NetworkHealthResult, type NetworkType, type OracleEvent, type OracleEventCallback, type OracleEventType, type OracleProvider, type OutboxEntry, type OutgoingPaymentRequest, type ParsedAddress, type ParsedStorageData, type PayInvoiceParams, type PaymentRequest, type PaymentRequestHandler, type PaymentRequestResponse, type PaymentRequestResponseHandler, type PaymentRequestResponseType, type PaymentRequestResult, type PaymentRequestStatus, type PaymentSession, type PaymentSessionDirection, type PaymentSessionError, type PaymentSessionErrorCode, type PaymentSessionStatus, PaymentsModule, type PaymentsModuleConfig, type PaymentsModuleDependencies, type PeerInfo, type PendingV5Finalization, type PostIntentRequest, type PostIntentResult, type PricePlatform, type PriceProvider, type PriceProviderConfig, type ProviderMetadata, type ProviderRole, type ProviderStatus, type ProviderStatusInfo, type ReceiveOptions, type ReceiveResult, type RegistryNetwork, type ReturnPaymentParams, SIGN_MESSAGE_PREFIX, STORAGE_KEYS, STORAGE_KEYS_ADDRESS, STORAGE_KEYS_GLOBAL, STORAGE_PREFIX, type SaveResult, type ScanAddressProgress, type ScanAddressesOptions, type ScanAddressesResult, type ScannedAddressResult, type SearchFilters, type SearchIntentResult, type SearchOptions, type SearchResult, type ServiceHealthResult, type SpentTokenInfo, type SpentTokenResult, Sphere, type SphereConfig, type SphereCreateOptions, SphereError, type SphereErrorCode, type SphereEventHandler, type SphereEventMap, type SphereEventType, type SphereImportOptions, type SphereInitOptions, type SphereInitResult, type SphereLoadOptions, type SphereStatus, type SplitPaymentSession, type SplitRecoveryResult, type StorageEvent, type StorageEventCallback, type StorageEventType, type StorageProvider, type StorageProviderConfig, type SubmitResult, type SwapDeal, type SwapManifest, SwapModule, type SwapModuleConfig, type SwapProgress, type SwapProposalResult, type SwapRef, type SwapRole, type SyncResult, TEST_AGGREGATOR_URL, TEST_ELECTRUM_URL, TEST_NOSTR_RELAYS, TIMEOUTS, type Token, type TokenDefinition, type TokenIcon, type TokenPrice, TokenRegistry, type TokenState, type TokenStatus, type TokenStorageProvider, type TokenTransferDetail, type TokenTransferHandler, type TokenTransferPayload, type ValidationResult as TokenValidationResult, TokenValidator, type TombstoneEntry, type TrackedAddress, type TrackedAddressEntry, type TransactionHistoryEntry, type TransferCommitment, type TransferMode, type TransferRequest, type TransferResult, type TransferStatus, type TransportEvent, type TransportEventCallback, type TransportEventType, type TransportProvider, type TransportProviderConfig, type TrustBaseLoader, type TxfAuthenticator, type TxfGenesis, type TxfGenesisData, type TxfInclusionProof, type TxfIntegrity, type TxfInvalidEntry, type TxfMerkleStep, type TxfMerkleTreePath, type TxfMeta, type TxfOutboxEntry, type TxfSentEntry, type TxfState, type TxfStorageData, type TxfStorageDataBase, type TxfToken, type TxfTombstone, type TxfTransaction, type UnconfirmedResolutionResult, type V5FinalizationStage, type ValidationAction, type ValidationIssue, type ValidationResult$1 as ValidationResult, type WaitOptions, type WalletDatInfo, type WalletInfo, type WalletJSON$1 as WalletJSON, type WalletJSONExportOptions$1 as WalletJSONExportOptions, type WalletSource, addressesMatch, archivedKeyFromTokenId, base58Decode, base58Encode, buildManifest, buildTxfStorageData, bytesToHex, checkNetworkHealth, coinIdsMatch, computeSwapId, countCommittedTransactions, createAddress, createCommunicationsModule, createGroupChatModule, createKeyPair, createL1PaymentsModule, createMarketModule, createNametagBinding, createPaymentSession, createPaymentSessionError, createPaymentsModule, createPriceProvider, createSphere, createSplitPaymentSession, createSwapModule, createTokenValidator, decodeBech32, decrypt$1 as decrypt, decryptCMasterKey, decryptJson, decryptMnemonic, decryptPrivateKey, decryptSimple, decryptTextFormatKey, decryptWallet, decryptWithSalt, deriveAddressInfo, deriveChildKey$1 as deriveChildKey, deriveKeyAtPath$1 as deriveKeyAtPath, doubleSha256, encodeBech32, encrypt$1 as encrypt, encryptMnemonic, encryptSimple, encryptWallet, extractFromText, findPattern, forkedKeyFromTokenIdAndState, formatAmount, generateAddressFromMasterKey, generateMasterKey, generateMnemonic, generatePrivateKey, getAddressHrp, getAddressId, getAddressStorageKey, getCoinIdByName, getCoinIdBySymbol, getCurrentStateHash, getPublicKey, getSphere, getTokenDecimals, getTokenDefinition, getTokenIconUrl, getTokenId, getTokenName, getTokenSymbol, hasMissingNewStateHash, hasUncommittedTransactions, hasValidTxfData, hash160, hashSignMessage, hexToBytes, hexToWIF, identityFromMnemonicSync, initSphere, isArchivedKey, isCombinedTransferBundleV6, isForkedKey, isInstantSplitBundle, isInstantSplitBundleV4, isInstantSplitBundleV5, isKnownToken, isPaymentSessionTerminal, isPaymentSessionTimedOut, isSQLiteDatabase, isSphereError, isTextWalletEncrypted, isTokenKey, isValidAddress, isValidBech32, isValidDirectAddress, isValidNametag, isValidPrivateKey, isValidTokenId, isWalletDatEncrypted, isWalletTextFormat, keyFromTokenId, loadSphere, logger, mnemonicToSeedSync, normalizeAddress, normalizeCoinId, normalizeSdkTokenToStorage, objectToTxf, parseAddress, parseAndDecryptWalletDat, parseAndDecryptWalletText, parseForkedKey, parseTxfStorageData, parseWalletDat, parseWalletText, randomBytes, randomHex, randomUUID, recoverPubkeyFromSignature, ripemd160, sha256, signMessage, signSwapManifest, sleep, sphereExists, toHumanReadable, toSmallestUnit, tokenIdFromArchivedKey, tokenIdFromKey, tokenToTxf, txfToToken, validateManifest, validateMnemonic, verifyManifestIntegrity, verifyNametagBinding, verifySignedMessage, verifySwapSignature };
|
package/dist/index.d.ts
CHANGED
|
@@ -2094,6 +2094,20 @@ declare function signMessage(privateKeyHex: string, message: string): string;
|
|
|
2094
2094
|
* @returns `true` if the signature is valid and matches the expected public key
|
|
2095
2095
|
*/
|
|
2096
2096
|
declare function verifySignedMessage(message: string, signature: string, expectedPubkey: string): boolean;
|
|
2097
|
+
/**
|
|
2098
|
+
* Recover the compressed secp256k1 public key from a signed message.
|
|
2099
|
+
*
|
|
2100
|
+
* Use this when the server needs to identify the signer (not just verify
|
|
2101
|
+
* a signature against a known pubkey). Combined with `sphere.resolve(pubkey)`
|
|
2102
|
+
* it gives a fully cryptographically-attributable identity for backend auth,
|
|
2103
|
+
* without trusting any client-supplied identifier claim.
|
|
2104
|
+
*
|
|
2105
|
+
* @param message - The plaintext that was signed
|
|
2106
|
+
* @param signature - 130-char hex (v + r + s) as produced by `signMessage`
|
|
2107
|
+
* @returns - Compressed 66-char hex pubkey
|
|
2108
|
+
* @throws - On malformed signature length or out-of-range recovery byte
|
|
2109
|
+
*/
|
|
2110
|
+
declare function recoverPubkeyFromSignature(message: string, signature: string): string;
|
|
2097
2111
|
|
|
2098
2112
|
/**
|
|
2099
2113
|
* INSTANT_SPLIT V5 Types
|
|
@@ -7277,23 +7291,6 @@ interface LegacyFileImportOptions {
|
|
|
7277
7291
|
onDecryptProgress?: DecryptionProgressCallback;
|
|
7278
7292
|
}
|
|
7279
7293
|
|
|
7280
|
-
/**
|
|
7281
|
-
* Compute the Unicity L3 DIRECT:// address that corresponds to a given
|
|
7282
|
-
* compressed secp256k1 public key.
|
|
7283
|
-
*
|
|
7284
|
-
* Deterministic — the underlying primitive `UnmaskedPredicateReference.create`
|
|
7285
|
-
* only uses the public key, so the private key is never needed. This lets
|
|
7286
|
-
* a backend trust only one thing from the client (the chain pubkey, whose
|
|
7287
|
-
* ownership the client proves via signature) and derive everything else
|
|
7288
|
-
* locally. Closes the entire class of "client claims an identifier the
|
|
7289
|
-
* server can't verify" bugs at the API level.
|
|
7290
|
-
*
|
|
7291
|
-
* @param chainPubkey 33-byte compressed secp256k1 pubkey, hex-encoded
|
|
7292
|
-
* (66 chars, leading 02 or 03).
|
|
7293
|
-
* @throws if chainPubkey doesn't match the compressed-secp256k1 format.
|
|
7294
|
-
*/
|
|
7295
|
-
declare function computeDirectAddressFromChainPubkey(chainPubkey: string): Promise<string>;
|
|
7296
|
-
|
|
7297
7294
|
declare function isValidNametag(nametag: string): boolean;
|
|
7298
7295
|
|
|
7299
7296
|
/** Steps reported by the onProgress callback during wallet init/create/load/import */
|
|
@@ -7535,7 +7532,6 @@ interface SphereInitResult {
|
|
|
7535
7532
|
/** Generated mnemonic (only if autoGenerate was used) */
|
|
7536
7533
|
generatedMnemonic?: string;
|
|
7537
7534
|
}
|
|
7538
|
-
|
|
7539
7535
|
declare class Sphere {
|
|
7540
7536
|
private static instance;
|
|
7541
7537
|
private _initialized;
|
|
@@ -10125,25 +10121,4 @@ declare function normalizeAddress(address: string): string;
|
|
|
10125
10121
|
*/
|
|
10126
10122
|
declare function addressesMatch(a: string, b: string): boolean;
|
|
10127
10123
|
|
|
10128
|
-
type
|
|
10129
|
-
declare class AuthVerificationError extends Error {
|
|
10130
|
-
readonly code: AuthVerificationErrorCode;
|
|
10131
|
-
constructor(message: string, code: AuthVerificationErrorCode);
|
|
10132
|
-
}
|
|
10133
|
-
interface SphereAuthInput {
|
|
10134
|
-
/** The exact text that was presented to the wallet for signing. */
|
|
10135
|
-
readonly challenge: string;
|
|
10136
|
-
/** Hex signature returned by the wallet's sign_message intent. */
|
|
10137
|
-
readonly signature: string;
|
|
10138
|
-
/** Compressed secp256k1 pubkey (66-char hex) the client claims to own. */
|
|
10139
|
-
readonly chainPubkey: string;
|
|
10140
|
-
}
|
|
10141
|
-
interface SphereAuthResult {
|
|
10142
|
-
/** Pubkey, proven via signature. */
|
|
10143
|
-
readonly chainPubkey: string;
|
|
10144
|
-
/** Unicity L3 DIRECT:// address, derived from chainPubkey (never claimed). */
|
|
10145
|
-
readonly directAddress: string;
|
|
10146
|
-
}
|
|
10147
|
-
declare function verifySphereAuth(input: SphereAuthInput): Promise<SphereAuthResult>;
|
|
10148
|
-
|
|
10149
|
-
export { type AddressInfo, type AddressMode, type AddressType, type AggregatorClient, type AggregatorEvent, type AggregatorEventCallback, type AggregatorEventType, type AggregatorProvider, type AggregatorProviderConfig, type Asset, AuthVerificationError, type AuthVerificationErrorCode, type BackgroundProgressStatus, type BaseProvider, type BroadcastHandler, type BroadcastMessage, type BuildSplitBundleResult, type CMasterKeyData, COIN_TYPES, type CheckNetworkHealthOptions, CoinGeckoPriceProvider, type CombinedTransferBundleV6, CommunicationsModule, type CommunicationsModuleConfig, type CommunicationsModuleDependencies, type ComposingIndicator, type ConversationPage, type CreateGroupOptions, type CreateInvoiceRequest, DEFAULT_AGGREGATOR_TIMEOUT, DEFAULT_AGGREGATOR_URL, DEFAULT_DERIVATION_PATH, DEFAULT_ELECTRUM_URL, DEFAULT_GROUP_RELAYS, DEFAULT_IPFS_BOOTSTRAP_PEERS, DEFAULT_IPFS_GATEWAYS, DEFAULT_MARKET_API_URL, DEFAULT_NOSTR_RELAYS, DEV_AGGREGATOR_URL, type DecryptionProgressCallback, type DerivationMode, type DirectMessage, type DirectTokenEntry, type DiscoverAddressProgress, type DiscoverAddressesOptions, type DiscoverAddressesResult, type DiscoveredAddress, type EncryptedData, type ExtendedValidationResult, type FullIdentity, type GetConversationPageOptions, type GetInvoicesOptions, type GetSwapsFilter, GroupChatModule, type GroupChatModuleConfig, type GroupChatModuleDependencies, type GroupData, type GroupMemberData, type GroupMessageData, GroupRole, GroupVisibility, type HealthCheckFn, type Identity, type IdentityConfig, type InclusionProof, type IncomingBroadcast, type IncomingMessage, type IncomingPaymentRequest, type IncomingTokenTransfer, type IncomingTransfer, type InitProgress, type InitProgressCallback, type InitProgressStep, type InstantSplitBundle, type InstantSplitBundleV4, type InstantSplitBundleV5, type InstantSplitOptions, type InstantSplitProcessResult, type InstantSplitResult, type InstantSplitV5RecoveryMetadata, type IntentStatus, type IntentType, type InvalidatedNametagEntry, type InvoiceRequestedAsset, index as L1, type L1Balance, L1PaymentsModule, type L1PaymentsModuleConfig, type L1PaymentsModuleDependencies, type L1SendRequest, type L1SendResult, type L1Transaction, type L1Utxo, LIMITS, type LegacyFileImportOptions, type LegacyFileInfo, type LegacyFileParseResult, type LegacyFileParsedData, type LegacyFileType, type LoadResult, type LogHandler, type LogLevel, type LoggerConfig, type LoggingConfig, type ManifestAuxiliary, type ManifestFields, type ManifestSignatures, type MarketIntent, MarketModule, type MarketModuleConfig, type MarketModuleDependencies, type MessageHandler, type MintOutboxEntry, type MintParams, type MintResult, NETWORKS, NIP29_KINDS, NOSTR_EVENT_KINDS, type NametagBindingProof, type NametagData, type NetworkHealthResult, type NetworkType, type OracleEvent, type OracleEventCallback, type OracleEventType, type OracleProvider, type OutboxEntry, type OutgoingPaymentRequest, type ParsedAddress, type ParsedStorageData, type PayInvoiceParams, type PaymentRequest, type PaymentRequestHandler, type PaymentRequestResponse, type PaymentRequestResponseHandler, type PaymentRequestResponseType, type PaymentRequestResult, type PaymentRequestStatus, type PaymentSession, type PaymentSessionDirection, type PaymentSessionError, type PaymentSessionErrorCode, type PaymentSessionStatus, PaymentsModule, type PaymentsModuleConfig, type PaymentsModuleDependencies, type PeerInfo, type PendingV5Finalization, type PostIntentRequest, type PostIntentResult, type PricePlatform, type PriceProvider, type PriceProviderConfig, type ProviderMetadata, type ProviderRole, type ProviderStatus, type ProviderStatusInfo, type ReceiveOptions, type ReceiveResult, type RegistryNetwork, type ReturnPaymentParams, SIGN_MESSAGE_PREFIX, STORAGE_KEYS, STORAGE_KEYS_ADDRESS, STORAGE_KEYS_GLOBAL, STORAGE_PREFIX, type SaveResult, type ScanAddressProgress, type ScanAddressesOptions, type ScanAddressesResult, type ScannedAddressResult, type SearchFilters, type SearchIntentResult, type SearchOptions, type SearchResult, type ServiceHealthResult, type SpentTokenInfo, type SpentTokenResult, Sphere, type SphereAuthInput, type SphereAuthResult, type SphereConfig, type SphereCreateOptions, SphereError, type SphereErrorCode, type SphereEventHandler, type SphereEventMap, type SphereEventType, type SphereImportOptions, type SphereInitOptions, type SphereInitResult, type SphereLoadOptions, type SphereStatus, type SplitPaymentSession, type SplitRecoveryResult, type StorageEvent, type StorageEventCallback, type StorageEventType, type StorageProvider, type StorageProviderConfig, type SubmitResult, type SwapDeal, type SwapManifest, SwapModule, type SwapModuleConfig, type SwapProgress, type SwapProposalResult, type SwapRef, type SwapRole, type SyncResult, TEST_AGGREGATOR_URL, TEST_ELECTRUM_URL, TEST_NOSTR_RELAYS, TIMEOUTS, type Token, type TokenDefinition, type TokenIcon, type TokenPrice, TokenRegistry, type TokenState, type TokenStatus, type TokenStorageProvider, type TokenTransferDetail, type TokenTransferHandler, type TokenTransferPayload, type ValidationResult as TokenValidationResult, TokenValidator, type TombstoneEntry, type TrackedAddress, type TrackedAddressEntry, type TransactionHistoryEntry, type TransferCommitment, type TransferMode, type TransferRequest, type TransferResult, type TransferStatus, type TransportEvent, type TransportEventCallback, type TransportEventType, type TransportProvider, type TransportProviderConfig, type TrustBaseLoader, type TxfAuthenticator, type TxfGenesis, type TxfGenesisData, type TxfInclusionProof, type TxfIntegrity, type TxfInvalidEntry, type TxfMerkleStep, type TxfMerkleTreePath, type TxfMeta, type TxfOutboxEntry, type TxfSentEntry, type TxfState, type TxfStorageData, type TxfStorageDataBase, type TxfToken, type TxfTombstone, type TxfTransaction, type UnconfirmedResolutionResult, type V5FinalizationStage, type ValidationAction, type ValidationIssue, type ValidationResult$1 as ValidationResult, type WaitOptions, type WalletDatInfo, type WalletInfo, type WalletJSON$1 as WalletJSON, type WalletJSONExportOptions$1 as WalletJSONExportOptions, type WalletSource, addressesMatch, archivedKeyFromTokenId, base58Decode, base58Encode, buildManifest, buildTxfStorageData, bytesToHex, checkNetworkHealth, coinIdsMatch, computeDirectAddressFromChainPubkey, computeSwapId, countCommittedTransactions, createAddress, createCommunicationsModule, createGroupChatModule, createKeyPair, createL1PaymentsModule, createMarketModule, createNametagBinding, createPaymentSession, createPaymentSessionError, createPaymentsModule, createPriceProvider, createSphere, createSplitPaymentSession, createSwapModule, createTokenValidator, decodeBech32, decrypt$1 as decrypt, decryptCMasterKey, decryptJson, decryptMnemonic, decryptPrivateKey, decryptSimple, decryptTextFormatKey, decryptWallet, decryptWithSalt, deriveAddressInfo, deriveChildKey$1 as deriveChildKey, deriveKeyAtPath$1 as deriveKeyAtPath, doubleSha256, encodeBech32, encrypt$1 as encrypt, encryptMnemonic, encryptSimple, encryptWallet, extractFromText, findPattern, forkedKeyFromTokenIdAndState, formatAmount, generateAddressFromMasterKey, generateMasterKey, generateMnemonic, generatePrivateKey, getAddressHrp, getAddressId, getAddressStorageKey, getCoinIdByName, getCoinIdBySymbol, getCurrentStateHash, getPublicKey, getSphere, getTokenDecimals, getTokenDefinition, getTokenIconUrl, getTokenId, getTokenName, getTokenSymbol, hasMissingNewStateHash, hasUncommittedTransactions, hasValidTxfData, hash160, hashSignMessage, hexToBytes, hexToWIF, identityFromMnemonicSync, initSphere, isArchivedKey, isCombinedTransferBundleV6, isForkedKey, isInstantSplitBundle, isInstantSplitBundleV4, isInstantSplitBundleV5, isKnownToken, isPaymentSessionTerminal, isPaymentSessionTimedOut, isSQLiteDatabase, isSphereError, isTextWalletEncrypted, isTokenKey, isValidAddress, isValidBech32, isValidDirectAddress, isValidNametag, isValidPrivateKey, isValidTokenId, isWalletDatEncrypted, isWalletTextFormat, keyFromTokenId, loadSphere, logger, mnemonicToSeedSync, normalizeAddress, normalizeCoinId, normalizeSdkTokenToStorage, objectToTxf, parseAddress, parseAndDecryptWalletDat, parseAndDecryptWalletText, parseForkedKey, parseTxfStorageData, parseWalletDat, parseWalletText, randomBytes, randomHex, randomUUID, ripemd160, sha256, signMessage, signSwapManifest, sleep, sphereExists, toHumanReadable, toSmallestUnit, tokenIdFromArchivedKey, tokenIdFromKey, tokenToTxf, txfToToken, validateManifest, validateMnemonic, verifyManifestIntegrity, verifyNametagBinding, verifySignedMessage, verifySphereAuth, verifySwapSignature };
|
|
10124
|
+
export { type AddressInfo, type AddressMode, type AddressType, type AggregatorClient, type AggregatorEvent, type AggregatorEventCallback, type AggregatorEventType, type AggregatorProvider, type AggregatorProviderConfig, type Asset, type BackgroundProgressStatus, type BaseProvider, type BroadcastHandler, type BroadcastMessage, type BuildSplitBundleResult, type CMasterKeyData, COIN_TYPES, type CheckNetworkHealthOptions, CoinGeckoPriceProvider, type CombinedTransferBundleV6, CommunicationsModule, type CommunicationsModuleConfig, type CommunicationsModuleDependencies, type ComposingIndicator, type ConversationPage, type CreateGroupOptions, type CreateInvoiceRequest, DEFAULT_AGGREGATOR_TIMEOUT, DEFAULT_AGGREGATOR_URL, DEFAULT_DERIVATION_PATH, DEFAULT_ELECTRUM_URL, DEFAULT_GROUP_RELAYS, DEFAULT_IPFS_BOOTSTRAP_PEERS, DEFAULT_IPFS_GATEWAYS, DEFAULT_MARKET_API_URL, DEFAULT_NOSTR_RELAYS, DEV_AGGREGATOR_URL, type DecryptionProgressCallback, type DerivationMode, type DirectMessage, type DirectTokenEntry, type DiscoverAddressProgress, type DiscoverAddressesOptions, type DiscoverAddressesResult, type DiscoveredAddress, type EncryptedData, type ExtendedValidationResult, type FullIdentity, type GetConversationPageOptions, type GetInvoicesOptions, type GetSwapsFilter, GroupChatModule, type GroupChatModuleConfig, type GroupChatModuleDependencies, type GroupData, type GroupMemberData, type GroupMessageData, GroupRole, GroupVisibility, type HealthCheckFn, type Identity, type IdentityConfig, type InclusionProof, type IncomingBroadcast, type IncomingMessage, type IncomingPaymentRequest, type IncomingTokenTransfer, type IncomingTransfer, type InitProgress, type InitProgressCallback, type InitProgressStep, type InstantSplitBundle, type InstantSplitBundleV4, type InstantSplitBundleV5, type InstantSplitOptions, type InstantSplitProcessResult, type InstantSplitResult, type InstantSplitV5RecoveryMetadata, type IntentStatus, type IntentType, type InvalidatedNametagEntry, type InvoiceRequestedAsset, index as L1, type L1Balance, L1PaymentsModule, type L1PaymentsModuleConfig, type L1PaymentsModuleDependencies, type L1SendRequest, type L1SendResult, type L1Transaction, type L1Utxo, LIMITS, type LegacyFileImportOptions, type LegacyFileInfo, type LegacyFileParseResult, type LegacyFileParsedData, type LegacyFileType, type LoadResult, type LogHandler, type LogLevel, type LoggerConfig, type LoggingConfig, type ManifestAuxiliary, type ManifestFields, type ManifestSignatures, type MarketIntent, MarketModule, type MarketModuleConfig, type MarketModuleDependencies, type MessageHandler, type MintOutboxEntry, type MintParams, type MintResult, NETWORKS, NIP29_KINDS, NOSTR_EVENT_KINDS, type NametagBindingProof, type NametagData, type NetworkHealthResult, type NetworkType, type OracleEvent, type OracleEventCallback, type OracleEventType, type OracleProvider, type OutboxEntry, type OutgoingPaymentRequest, type ParsedAddress, type ParsedStorageData, type PayInvoiceParams, type PaymentRequest, type PaymentRequestHandler, type PaymentRequestResponse, type PaymentRequestResponseHandler, type PaymentRequestResponseType, type PaymentRequestResult, type PaymentRequestStatus, type PaymentSession, type PaymentSessionDirection, type PaymentSessionError, type PaymentSessionErrorCode, type PaymentSessionStatus, PaymentsModule, type PaymentsModuleConfig, type PaymentsModuleDependencies, type PeerInfo, type PendingV5Finalization, type PostIntentRequest, type PostIntentResult, type PricePlatform, type PriceProvider, type PriceProviderConfig, type ProviderMetadata, type ProviderRole, type ProviderStatus, type ProviderStatusInfo, type ReceiveOptions, type ReceiveResult, type RegistryNetwork, type ReturnPaymentParams, SIGN_MESSAGE_PREFIX, STORAGE_KEYS, STORAGE_KEYS_ADDRESS, STORAGE_KEYS_GLOBAL, STORAGE_PREFIX, type SaveResult, type ScanAddressProgress, type ScanAddressesOptions, type ScanAddressesResult, type ScannedAddressResult, type SearchFilters, type SearchIntentResult, type SearchOptions, type SearchResult, type ServiceHealthResult, type SpentTokenInfo, type SpentTokenResult, Sphere, type SphereConfig, type SphereCreateOptions, SphereError, type SphereErrorCode, type SphereEventHandler, type SphereEventMap, type SphereEventType, type SphereImportOptions, type SphereInitOptions, type SphereInitResult, type SphereLoadOptions, type SphereStatus, type SplitPaymentSession, type SplitRecoveryResult, type StorageEvent, type StorageEventCallback, type StorageEventType, type StorageProvider, type StorageProviderConfig, type SubmitResult, type SwapDeal, type SwapManifest, SwapModule, type SwapModuleConfig, type SwapProgress, type SwapProposalResult, type SwapRef, type SwapRole, type SyncResult, TEST_AGGREGATOR_URL, TEST_ELECTRUM_URL, TEST_NOSTR_RELAYS, TIMEOUTS, type Token, type TokenDefinition, type TokenIcon, type TokenPrice, TokenRegistry, type TokenState, type TokenStatus, type TokenStorageProvider, type TokenTransferDetail, type TokenTransferHandler, type TokenTransferPayload, type ValidationResult as TokenValidationResult, TokenValidator, type TombstoneEntry, type TrackedAddress, type TrackedAddressEntry, type TransactionHistoryEntry, type TransferCommitment, type TransferMode, type TransferRequest, type TransferResult, type TransferStatus, type TransportEvent, type TransportEventCallback, type TransportEventType, type TransportProvider, type TransportProviderConfig, type TrustBaseLoader, type TxfAuthenticator, type TxfGenesis, type TxfGenesisData, type TxfInclusionProof, type TxfIntegrity, type TxfInvalidEntry, type TxfMerkleStep, type TxfMerkleTreePath, type TxfMeta, type TxfOutboxEntry, type TxfSentEntry, type TxfState, type TxfStorageData, type TxfStorageDataBase, type TxfToken, type TxfTombstone, type TxfTransaction, type UnconfirmedResolutionResult, type V5FinalizationStage, type ValidationAction, type ValidationIssue, type ValidationResult$1 as ValidationResult, type WaitOptions, type WalletDatInfo, type WalletInfo, type WalletJSON$1 as WalletJSON, type WalletJSONExportOptions$1 as WalletJSONExportOptions, type WalletSource, addressesMatch, archivedKeyFromTokenId, base58Decode, base58Encode, buildManifest, buildTxfStorageData, bytesToHex, checkNetworkHealth, coinIdsMatch, computeSwapId, countCommittedTransactions, createAddress, createCommunicationsModule, createGroupChatModule, createKeyPair, createL1PaymentsModule, createMarketModule, createNametagBinding, createPaymentSession, createPaymentSessionError, createPaymentsModule, createPriceProvider, createSphere, createSplitPaymentSession, createSwapModule, createTokenValidator, decodeBech32, decrypt$1 as decrypt, decryptCMasterKey, decryptJson, decryptMnemonic, decryptPrivateKey, decryptSimple, decryptTextFormatKey, decryptWallet, decryptWithSalt, deriveAddressInfo, deriveChildKey$1 as deriveChildKey, deriveKeyAtPath$1 as deriveKeyAtPath, doubleSha256, encodeBech32, encrypt$1 as encrypt, encryptMnemonic, encryptSimple, encryptWallet, extractFromText, findPattern, forkedKeyFromTokenIdAndState, formatAmount, generateAddressFromMasterKey, generateMasterKey, generateMnemonic, generatePrivateKey, getAddressHrp, getAddressId, getAddressStorageKey, getCoinIdByName, getCoinIdBySymbol, getCurrentStateHash, getPublicKey, getSphere, getTokenDecimals, getTokenDefinition, getTokenIconUrl, getTokenId, getTokenName, getTokenSymbol, hasMissingNewStateHash, hasUncommittedTransactions, hasValidTxfData, hash160, hashSignMessage, hexToBytes, hexToWIF, identityFromMnemonicSync, initSphere, isArchivedKey, isCombinedTransferBundleV6, isForkedKey, isInstantSplitBundle, isInstantSplitBundleV4, isInstantSplitBundleV5, isKnownToken, isPaymentSessionTerminal, isPaymentSessionTimedOut, isSQLiteDatabase, isSphereError, isTextWalletEncrypted, isTokenKey, isValidAddress, isValidBech32, isValidDirectAddress, isValidNametag, isValidPrivateKey, isValidTokenId, isWalletDatEncrypted, isWalletTextFormat, keyFromTokenId, loadSphere, logger, mnemonicToSeedSync, normalizeAddress, normalizeCoinId, normalizeSdkTokenToStorage, objectToTxf, parseAddress, parseAndDecryptWalletDat, parseAndDecryptWalletText, parseForkedKey, parseTxfStorageData, parseWalletDat, parseWalletText, randomBytes, randomHex, randomUUID, recoverPubkeyFromSignature, ripemd160, sha256, signMessage, signSwapManifest, sleep, sphereExists, toHumanReadable, toSmallestUnit, tokenIdFromArchivedKey, tokenIdFromKey, tokenToTxf, txfToToken, validateManifest, validateMnemonic, verifyManifestIntegrity, verifyNametagBinding, verifySignedMessage, verifySwapSignature };
|
package/dist/index.js
CHANGED
|
@@ -4927,6 +4927,27 @@ function verifySignedMessage(message, signature, expectedPubkey) {
|
|
|
4927
4927
|
return false;
|
|
4928
4928
|
}
|
|
4929
4929
|
}
|
|
4930
|
+
function recoverPubkeyFromSignature(message, signature) {
|
|
4931
|
+
if (signature.length !== 130) {
|
|
4932
|
+
throw new SphereError(
|
|
4933
|
+
`Invalid signature length: expected 130 hex chars, got ${signature.length}`,
|
|
4934
|
+
"SIGNING_ERROR"
|
|
4935
|
+
);
|
|
4936
|
+
}
|
|
4937
|
+
const v = parseInt(signature.slice(0, 2), 16) - 31;
|
|
4938
|
+
const r = signature.slice(2, 66);
|
|
4939
|
+
const s = signature.slice(66, 130);
|
|
4940
|
+
if (v < 0 || v > 3) {
|
|
4941
|
+
throw new SphereError(
|
|
4942
|
+
`Invalid recovery byte: v=${v} out of range [0..3]`,
|
|
4943
|
+
"SIGNING_ERROR"
|
|
4944
|
+
);
|
|
4945
|
+
}
|
|
4946
|
+
const hashHex = hashSignMessage(message);
|
|
4947
|
+
const hashBytes = Buffer.from(hashHex, "hex");
|
|
4948
|
+
const recovered = ec.recoverPubKey(hashBytes, { r, s }, v);
|
|
4949
|
+
return recovered.encode("hex", true);
|
|
4950
|
+
}
|
|
4930
4951
|
|
|
4931
4952
|
// l1/crypto.ts
|
|
4932
4953
|
import CryptoJS3 from "crypto-js";
|
|
@@ -27631,42 +27652,27 @@ async function parseAndDecryptWalletDat(data, password, onProgress) {
|
|
|
27631
27652
|
|
|
27632
27653
|
// core/Sphere.ts
|
|
27633
27654
|
import { SigningService as SigningService2 } from "@unicitylabs/state-transition-sdk/lib/sign/SigningService";
|
|
27634
|
-
import { normalizeNametag as normalizeNametag2, isPhoneNumber } from "@unicitylabs/nostr-js-sdk";
|
|
27635
|
-
|
|
27636
|
-
// core/address-derivation.ts
|
|
27637
27655
|
import { TokenType as TokenType5 } from "@unicitylabs/state-transition-sdk/lib/token/TokenType";
|
|
27638
27656
|
import { HashAlgorithm as HashAlgorithm7 } from "@unicitylabs/state-transition-sdk/lib/hash/HashAlgorithm";
|
|
27639
27657
|
import { UnmaskedPredicateReference as UnmaskedPredicateReference3 } from "@unicitylabs/state-transition-sdk/lib/predicate/embedded/UnmaskedPredicateReference";
|
|
27640
|
-
|
|
27641
|
-
var COMPRESSED_PUBKEY_RE = /^(02|03)[0-9a-fA-F]{64}$/;
|
|
27642
|
-
async function computeDirectAddressFromChainPubkey(chainPubkey) {
|
|
27643
|
-
if (typeof chainPubkey !== "string" || !COMPRESSED_PUBKEY_RE.test(chainPubkey)) {
|
|
27644
|
-
throw new Error(
|
|
27645
|
-
`computeDirectAddressFromChainPubkey: chainPubkey must be 66-char hex with 02/03 prefix, got "${String(chainPubkey).slice(0, 12)}..."`
|
|
27646
|
-
);
|
|
27647
|
-
}
|
|
27648
|
-
const tokenTypeBytes = Buffer.from(UNICITY_TOKEN_TYPE_HEX2, "hex");
|
|
27649
|
-
const tokenType = new TokenType5(tokenTypeBytes);
|
|
27650
|
-
const publicKeyBytes = Buffer.from(chainPubkey, "hex");
|
|
27651
|
-
const predicateRef = await UnmaskedPredicateReference3.create(
|
|
27652
|
-
tokenType,
|
|
27653
|
-
"secp256k1",
|
|
27654
|
-
publicKeyBytes,
|
|
27655
|
-
HashAlgorithm7.SHA256
|
|
27656
|
-
);
|
|
27657
|
-
return (await predicateRef.toAddress()).toString();
|
|
27658
|
-
}
|
|
27659
|
-
|
|
27660
|
-
// core/Sphere.ts
|
|
27658
|
+
import { normalizeNametag as normalizeNametag2, isPhoneNumber } from "@unicitylabs/nostr-js-sdk";
|
|
27661
27659
|
function isValidNametag2(nametag) {
|
|
27662
27660
|
if (isPhoneNumber(nametag)) return true;
|
|
27663
27661
|
return /^[a-z0-9_-]{3,20}$/.test(nametag);
|
|
27664
27662
|
}
|
|
27663
|
+
var UNICITY_TOKEN_TYPE_HEX2 = "f8aa13834268d29355ff12183066f0cb902003629bbc5eb9ef0efbe397867509";
|
|
27665
27664
|
async function deriveL3PredicateAddress(privateKey) {
|
|
27666
27665
|
const secret = Buffer.from(privateKey, "hex");
|
|
27667
27666
|
const signingService = await SigningService2.createFromSecret(secret);
|
|
27668
|
-
const
|
|
27669
|
-
|
|
27667
|
+
const tokenTypeBytes = Buffer.from(UNICITY_TOKEN_TYPE_HEX2, "hex");
|
|
27668
|
+
const tokenType = new TokenType5(tokenTypeBytes);
|
|
27669
|
+
const predicateRef = UnmaskedPredicateReference3.create(
|
|
27670
|
+
tokenType,
|
|
27671
|
+
signingService.algorithm,
|
|
27672
|
+
signingService.publicKey,
|
|
27673
|
+
HashAlgorithm7.SHA256
|
|
27674
|
+
);
|
|
27675
|
+
return (await (await predicateRef).toAddress()).toString();
|
|
27670
27676
|
}
|
|
27671
27677
|
var Sphere = class _Sphere {
|
|
27672
27678
|
// Singleton
|
|
@@ -31685,37 +31691,7 @@ function createPriceProvider(config) {
|
|
|
31685
31691
|
throw new SphereError(`Unsupported price platform: ${String(config.platform)}`, "INVALID_CONFIG");
|
|
31686
31692
|
}
|
|
31687
31693
|
}
|
|
31688
|
-
|
|
31689
|
-
// core/auth.ts
|
|
31690
|
-
var AuthVerificationError = class extends Error {
|
|
31691
|
-
code;
|
|
31692
|
-
constructor(message, code) {
|
|
31693
|
-
super(message);
|
|
31694
|
-
this.name = "AuthVerificationError";
|
|
31695
|
-
this.code = code;
|
|
31696
|
-
}
|
|
31697
|
-
};
|
|
31698
|
-
async function verifySphereAuth(input) {
|
|
31699
|
-
const { challenge, signature, chainPubkey } = input;
|
|
31700
|
-
let directAddress;
|
|
31701
|
-
try {
|
|
31702
|
-
directAddress = await computeDirectAddressFromChainPubkey(chainPubkey);
|
|
31703
|
-
} catch (err) {
|
|
31704
|
-
throw new AuthVerificationError(
|
|
31705
|
-
`chainPubkey is malformed: ${err.message}`,
|
|
31706
|
-
"PUBKEY_MALFORMED"
|
|
31707
|
-
);
|
|
31708
|
-
}
|
|
31709
|
-
if (!verifySignedMessage(challenge, signature, chainPubkey)) {
|
|
31710
|
-
throw new AuthVerificationError(
|
|
31711
|
-
"Signature does not verify against chainPubkey",
|
|
31712
|
-
"SIGNATURE_INVALID"
|
|
31713
|
-
);
|
|
31714
|
-
}
|
|
31715
|
-
return { chainPubkey, directAddress };
|
|
31716
|
-
}
|
|
31717
31694
|
export {
|
|
31718
|
-
AuthVerificationError,
|
|
31719
31695
|
COIN_TYPES,
|
|
31720
31696
|
CoinGeckoPriceProvider,
|
|
31721
31697
|
CommunicationsModule,
|
|
@@ -31766,7 +31742,6 @@ export {
|
|
|
31766
31742
|
bytesToHex3 as bytesToHex,
|
|
31767
31743
|
checkNetworkHealth,
|
|
31768
31744
|
coinIdsMatch,
|
|
31769
|
-
computeDirectAddressFromChainPubkey,
|
|
31770
31745
|
computeSwapId,
|
|
31771
31746
|
countCommittedTransactions,
|
|
31772
31747
|
createAddress,
|
|
@@ -31879,6 +31854,7 @@ export {
|
|
|
31879
31854
|
randomBytes2 as randomBytes,
|
|
31880
31855
|
randomHex,
|
|
31881
31856
|
randomUUID,
|
|
31857
|
+
recoverPubkeyFromSignature,
|
|
31882
31858
|
ripemd160,
|
|
31883
31859
|
sha2562 as sha256,
|
|
31884
31860
|
signMessage,
|
|
@@ -31896,7 +31872,6 @@ export {
|
|
|
31896
31872
|
verifyManifestIntegrity,
|
|
31897
31873
|
verifyNametagBinding,
|
|
31898
31874
|
verifySignedMessage,
|
|
31899
|
-
verifySphereAuth,
|
|
31900
31875
|
verifySwapSignature
|
|
31901
31876
|
};
|
|
31902
31877
|
/*! Bundled license information:
|