steem-auth-vue
Version:
A Vue 3 authentication component for Steem blockchain and MeeRay sidechain
81 lines (79 loc) • 3.12 kB
TypeScript
import { ITransaction } from '../interfaces';
declare global {
interface Window {
steem_keychain: {
requestBroadcast: (username: string, operations: any[], keyType: string, callback: (response: any) => void) => void;
requestSignBuffer: (username: string, message: string, keyType: string, callback: (response: {
success: boolean;
result: string;
message: string;
}) => void) => void;
};
}
}
export declare const setPinRequestHandler: (handler: (username: string, callback: (pin: string) => void) => void) => void;
export declare const setActiveKeyRequestHandler: (handler: (username: string, operationType: string, payload: any, callback: (activeKey: string) => void) => void) => void;
/**
* Transaction hook callback signature
* @param txId - The transaction ID from the blockchain
* @param operation - The operation type (e.g., 'custom_json', 'transfer')
* @param params - The operation parameters
* @param options - Additional options passed to send()
*/
export type TransactionHookCallback = (txId: string, operation: string, params: any, options?: any) => void;
declare class TransactionService {
/**
* Global transaction hooks that get called whenever a transaction is sent
* Allows external apps to track all transactions without modifying code
*/
private static transactionHooks;
/**
* Register a global transaction hook
* The callback will be invoked for every transaction sent via TransactionService
*
* @param callback - Function to call when transactions are sent
* @returns Cleanup function to unregister the hook
*
* @example
* ```typescript
* const unregister = TransactionService.registerTransactionHook((txId, operation, params) => {
* console.log('Transaction sent:', txId, operation)
* // Track transaction, show notification, etc.
* })
*
* // Later, to stop listening:
* unregister()
* ```
*/
static registerTransactionHook(callback: TransactionHookCallback): () => void;
/**
* Unregister a transaction hook
*
* @param callback - The callback function to remove
*/
static unregisterTransactionHook(callback: TransactionHookCallback): void;
/**
* Clear all transaction hooks
* Useful for testing or cleanup
*/
static clearTransactionHooks(): void;
/**
* Get the number of active transaction hooks
*/
static getHookCount(): number;
send(trx: string, payload: any, options?: {
requiredAuth?: 'posting' | 'active' | 'owner';
activeKey?: string;
}): Promise<ITransaction>;
/**
* Helper method to call all registered transaction hooks
* @private
*/
private _callTransactionHooks;
private _sendWithKeychain;
private _sendWithSteemLogin;
private _sendWithKey;
}
export { TransactionService };
declare const _default: TransactionService;
export default _default;