import { BaseCoin, BitGoBase, BitGoRequest, CoinConstructor, DecryptKeysOptions, DecryptOptions, EcdhDerivedKeypair, EncryptOptions, EnvironmentName, GetSharingKeyOptions, GetSigningKeyApi, IRequestTracer } from '@bitgo/sdk-core'; import { type IHmacAuthStrategy } from '@bitgo/sdk-hmac'; import { ECPairInterface } from '@bitgo/utxo-lib'; import * as superagent from 'superagent'; import { AccessTokenOptions, AddAccessTokenOptions, AddAccessTokenResponse, AuthenticateOptions, AuthenticateWithAuthCodeOptions, BitGoAPIOptions, BitGoJson, BitGoSimulateWebhookOptions, CalculateHmacSubjectOptions, CalculateRequestHeadersOptions, CalculateRequestHmacOptions, ChangePasswordOptions, Constants, DeprecatedVerifyAddressOptions, EstimateFeeOptions, ExtendTokenOptions, GetEcdhSecretOptions, GetUserOptions, ListWebhookNotificationsOptions, LoginResponse, PingOptions, ProcessedAuthenticationOptions, ReconstitutedSecret, ReconstituteSecretOptions, RegisterPushTokenOptions, RemoveAccessTokenOptions, RequestHeaders, RequestMethods, SplitSecret, SplitSecretOptions, TokenIssuance, TokenIssuanceResponse, UnlockOptions, User, VerifyPasswordOptions, VerifyPushTokenOptions, VerifyResponseInfo, VerifyResponseOptions, VerifyShardsOptions, WebhookOptions } from './types'; export declare class BitGoAPI implements BitGoBase { protected _keychains: any; protected _wallets: any; protected _markets?: any; protected _blockchain?: any; protected _travelRule?: any; protected _pendingApprovals?: any; protected static _constants: any; protected static _constantsExpire: any; protected static _testnetWarningMessage: boolean; readonly env: EnvironmentName; protected readonly _baseUrl: string; protected readonly _baseApiUrl: string; protected readonly _baseApiUrlV2: string; protected readonly _baseApiUrlV3: string; protected readonly _env: EnvironmentName; protected readonly _authVersion: Exclude; protected _hmacVerification: boolean; protected readonly _proxy?: string; protected _user?: User; protected _extensionKey?: ECPairInterface; protected _reqId?: IRequestTracer; protected _token?: string; protected _version: string; protected _userAgent?: string; protected _ecdhXprv?: string; protected _refreshToken?: string; protected readonly _clientId?: string; protected readonly _clientSecret?: string; protected _validate: boolean; readonly cookiesPropagationEnabled: boolean; private _customProxyAgent?; private _requestIdPrefix?; private getAdditionalHeadersCb?; protected _hmacAuthStrategy: IHmacAuthStrategy; constructor(params?: BitGoAPIOptions); /** * Initialize client constants if provided. * @param clientConstants - The client constants from params * @private */ private _initializeClientConstants; /** * Get a superagent request for specified http method and URL configured to the SDK configuration * @param method - http method for the new request * @param url - URL for the new request */ protected getAgentRequest(method: RequestMethods, url: string): superagent.SuperAgentRequest; /** * Create a basecoin object * @param name */ coin(name: string): BaseCoin; /** * Return the current BitGo environment */ getEnv(): EnvironmentName; /** * Return the current auth version used for requests to the BitGo server */ getAuthVersion(): number; /** * Signs and sends a v2-authenticated request, then verifies the response HMAC. * Extracted from the req.then override in requestPatch to keep that method readable. */ private _sendRequestWithHmac; /** * This is a patching function which can apply our authorization * headers to any outbound request. * @param method */ private requestPatch; get(url: string): BitGoRequest; post(url: string): BitGoRequest; put(url: string): BitGoRequest; del(url: string): BitGoRequest; patch(url: string): BitGoRequest; options(url: string): BitGoRequest; /** * Calculate the HMAC for the given key and message * @param key {String} - the key to use for the HMAC * @param message {String} - the actual message to HMAC * @returns {*} - the result of the HMAC operation */ calculateHMAC(key: string, message: string): string; /** * Calculate the subject string that is to be HMAC'ed for a HTTP request or response * @param urlPath request url, including query params * @param text request body text * @param timestamp request timestamp from `Date.now()` * @param statusCode Only set for HTTP responses, leave blank for requests * @param method request method * @returns {string | Buffer} */ calculateHMACSubject(params: CalculateHmacSubjectOptions): T; /** * Calculate the HMAC for an HTTP request */ calculateRequestHMAC(params: CalculateRequestHmacOptions): string; /** * Calculate request headers with HMAC */ calculateRequestHeaders(params: CalculateRequestHeadersOptions): RequestHeaders; /** * Verify the HMAC for an HTTP response (synchronous, uses sdk-hmac directly). * Kept for backward compatibility with external callers. */ verifyResponse(params: VerifyResponseOptions): VerifyResponseInfo; /** * Verify the HMAC for an HTTP response via the configured strategy (async). * Used internally by the request pipeline. */ verifyResponseAsync(params: VerifyResponseOptions): Promise; /** * Fetch useful constant values from the BitGo server. * These values do change infrequently, so they need to be fetched, * but are unlikely to change during the lifetime of a BitGo object, * so they can safely cached. */ fetchConstants(): Promise; /** * Create a url for calling BitGo platform APIs * @param path * @param version */ url(path: string, version?: number): string; /** * Create a url for calling BitGo microservice APIs */ microservicesUrl(path: string): string; /** * Gets the version of the BitGoJS package */ version(): string; /** * Test connectivity to the server * @param params */ ping({ reqId }?: PingOptions): Promise; /** * Set a request tracer to provide request IDs during multi-request workflows */ setRequestTracer(reqTracer: IRequestTracer): void; /** * Utility function to encrypt locally. */ encrypt(params: EncryptOptions): string; /** * Async encrypt that dispatches to v1 (SJCL) or v2 (Argon2id + AES-256-GCM) * based on `encryptionVersion`. */ encryptAsync(params: EncryptOptions): Promise; /** * Create an encryption session for multi-call operations. * Runs Argon2id once; all subsequent calls derive keys via HKDF. */ createEncryptionSession(password: string): Promise; /** * Decrypt an encrypted string locally. */ decrypt(params: DecryptOptions): string; /** * Async decrypt that auto-detects v1 (SJCL) or v2 (Argon2id). * Migration path from sync decrypt() -- use this before the breaking release. */ decryptAsync(params: DecryptOptions): Promise; /** * Attempt to decrypt multiple wallet keys with the provided passphrase * @param {DecryptKeysOptions} params - Parameters object containing wallet key pairs and password * @param {Array<{walletId: string, encryptedPrv: string}>} params.walletIdEncryptedKeyPairs - Array of wallet ID and encrypted private key pairs * @param {string} params.password - The passphrase to attempt decryption with * @returns {string[]} - Array of wallet IDs for which decryption failed */ decryptKeys(params: DecryptKeysOptions): string[]; /** * Serialize this BitGo object to a JSON object. * * Caution: contains sensitive data */ toJSON(): BitGoJson; /** * Get the current user */ user(): User | undefined; /** * Deserialize a JSON serialized BitGo object. * * Overwrites the properties on the current BitGo object with * those of the deserialzed object. * * @param json */ fromJSON(json: BitGoJson): void; /** * Process the username, password and otp into an object containing the username and hashed password, ready to * send to bitgo for authentication. */ preprocessAuthenticationParams({ username, password, otp, forceSMS, extensible, trust, forReset2FA, initialHash, fingerprintHash, }: AuthenticateOptions): Promise; /** * Validate the passkey response is in the expected format * Should be as is returned from navigator.credentials.get() */ validatePasskeyResponse(passkeyResponse: string): void; /** * Synchronous method for activating an access token. */ authenticateWithAccessToken({ accessToken }: AccessTokenOptions): void; /** * Creates a new ECDH keychain for the user. * @param {string} loginPassword - The user's login password. * @returns {Promise} - A promise that resolves with the new ECDH keychain data. * @throws {Error} - Throws an error if there is an issue creating the keychain. */ createUserEcdhKeychain(loginPassword: string): Promise; /** * Updates the user's settings with the provided parameters. * @param {Object} params - The parameters to update the user's settings with. * @returns {Promise} * @throws {Error} - Throws an error if there is an issue updating the user's settings. */ private updateUserSettings; /** * Ensures that the user's ECDH keychain is created for wallet sharing and TSS wallets. * If the keychain does not exist, it will be created and the user's settings will be updated. * @param {string} loginPassword - The user's login password. * @returns {Promise} - A promise that resolves with the user's settings ensuring we have the ecdhKeychain in there. * @throws {Error} - Throws an error if there is an issue creating the keychain or updating the user's settings. */ private ensureUserEcdhKeychainIsCreated; /** * Login to the bitgo platform. */ authenticate(params: AuthenticateOptions): Promise; /** * Login to the bitgo platform with passkey. */ authenticateWithPasskey(passkey: string, initialHash?: string, fingerprintHash?: string): Promise; /** * * @param responseBody Response body object * @param password Password for the symmetric decryption */ handleTokenIssuance(responseBody: TokenIssuanceResponse, password?: string): TokenIssuance; /** */ verifyPassword(params?: VerifyPasswordOptions): Promise; /** * Clear out all state from this BitGo object, effectively logging out the current user. */ clear(): void; clearAsync(): Promise; /** * Use refresh token to get new access token. * If the refresh token is null/defined, then we use the stored token from auth */ refreshToken(params?: { refreshToken?: string; }): Promise; /** * * listAccessTokens * Get information on all of the BitGo access tokens on the user * @return { * id: * label: * user: * enterprise * client: * scope: * created: * expires: * origin: * isExtensible: * extensionAddress:
* unlock: * } */ listAccessTokens(): Promise; /** * addAccessToken * Add a BitGo API Access Token to the current user account * @param params { * otp: (required) * label: (required)