import { AESKey, RSAKey } from '@daotl/cryptico'; import { AxiosRequestConfig } from 'axios'; import { KeyPairHex } from 'sm-crypto'; declare function aesEncrypt(data: string, aesKey: AESKey): string; declare function rsaEncrypt(data: string, rsaKey: { n: string; e1: string; }): string; declare function loadRSAKey(rsaKey: string): RSAKey; declare function encryptReq(reqContent: { contractID: string; }, pubKey: RSAKey): { action: string | null; contractID: string; arg: string; requester: string; }; type ClientResponse = Omit & { data?: Data; }; type PingResponse = ClientResponse<'pong'>; interface SaveFileRequest { content: string; isAppend: boolean; isPrivate: boolean; path: string; } interface ListProjectPermissionRequest { isPrivate: boolean; path: string; } interface ListProjectPermissionResponseData { permissions: string[]; ypk: string; } interface StartContractByYpkRequest { isPrivate: boolean; path: string; script: string; } interface ListAllUsersResponseDataListItem { key: string; value: string; } interface ListAllUsersResponseData { kv: ListAllUsersResponseDataListItem[]; time: ListAllUsersResponseDataListItem[]; } interface OnlineContractsItem { contractID: string; contractName: string; isMaster: boolean; type: string; yjsType: string; [key: string]: unknown; } interface OnlineItem { cimanager: string; contractVersion: number; events: number; ipPort: string; masterAddress: string; nodeName: string; peerID: string; pubKey: string; contracts: OnlineContractsItem[]; } interface ListNodesResponse { action: string; offline: string[]; online: OnlineItem[]; } interface DistributeContractResponse { action: string; progress: string; } interface ExecuteContractArgs extends RequestInit { method?: 'POST' | 'GET'; withSignature?: boolean; withDynamicAnalysis?: boolean; } interface ExecuteContractResponse { status?: boolean; data?: Data; executeTime?: number; cid?: string; isPrivate?: boolean; [key: string]: unknown; } interface ConfigNodeArgs { nodeName?: string; dataChain?: string; masterAddress?: string; nodeCenter?: string; LHSProxyAddress?: string; [K: string]: string | undefined; } interface LoadNodeConfigResponseData { doipConfig: string; [K: string]: string; } declare class HttpClient { private baseUrl; private sm2Key; private fetch; constructor(baseUrl: string, sm2Key: KeyPairHex, config?: AxiosRequestConfig); requestWithSignature(path: string, init?: Partial, sm2Key?: KeyPairHex): Promise>; retryRequestWithSignature(retryTimes: number, path: string, init?: Partial, sm2Key?: KeyPairHex): Promise>; sign(data: string, privateKey?: string): string; ping(): Promise; startContract(code: string): Promise>; startContractByYPK(_request: StartContractByYpkRequest): Promise>; executeContract(contractID: string, operation: string, arg: string, { method, withDynamicAnalysis, withSignature, }?: ExecuteContractArgs): Promise>>; killContractProcess(contractID: string, requestID?: string): Promise>; killAllContract(): Promise>; applyNodeRole(role: string): Promise>; authNodeRole(isAccept: boolean, authorizedPubKey: string, managerPair?: KeyPairHex): Promise>; distributeContract(nodeIDs: string, projectName: string, isPrivate: boolean): void; saveFile(_request: SaveFileRequest): Promise>; listProjectPermission(_request: ListProjectPermissionRequest): Promise>; startContractMultiPoint(peersID: string, type: number, selectUnitNum: number, projectName: string, isPrivate: boolean, sponsorPeerID: string): Promise>; loadNodeConfig(): Promise>; updateConfig(key: string, val: string): Promise>; resetNodeManager(): Promise; lockEdit(): Promise>; unlockEdit(): Promise>; addNode(nodePubKey: string): Promise>; applyRole(role: string): Promise>; authNodeManager(isAccept: boolean, authorizedPubKey: string): Promise>; listAllUsers(): Promise>; listNodes(): Promise; createTrustUnit(data: { nodeName: string; pubkey: string; }[], Msg: string): Promise<{ action: string; status: string; }>; listTrustUnits(): Promise>; listContractProcess(): Promise>; downloadContract(projectName: string, isPrivate: boolean, timestamp: number): Promise>; configNode(args: ConfigNodeArgs): Promise; } interface WsEvent { data: string; } type OnOpenHandler = (this: WebSocket, ev: Event) => void; type WsHandler = (ev: WsEvent, ws?: WebSocket) => void; interface SegmentData { action: 'sendSeg'; cid: string; data: string; } declare class WsSocket { private handlerList; private toSend; private isSending; private sendList; private toReceive; private wssocket; constructor(wsurl: string, onopen: OnOpenHandler, handler?: WsHandler); status(): WebSocket['CLOSED' | 'CLOSING' | 'CONNECTING' | 'OPEN']; sendNextSegment(): void; receiveSeg(obj: SegmentData): void; monitor(): void; send(data: string): void; addHandler(handler: WsHandler): void; } interface ResponseData { action: string; responseID?: string; status: true | false | string; result?: unknown; data: string; [K: string]: unknown; } declare class WsClient { private readonly sm2Key; private readonly wssocket; private readonly promiseCallbackPairs; private readonly sessionPromise; private sessionResolve; private readonly loginPromise; private loginResolve; constructor(url: string, onopen: OnOpenHandler, handler: WsHandler, sm2Key?: KeyPairHex); status(): WebSocket['CLOSED' | 'CLOSING' | 'CONNECTING' | 'OPEN']; sessionReceived(): Promise; login(): Promise; loggedIn(): Promise; matchCID(contractID: string): Promise; getMetabyCID(contractID: string): Promise; getMetabyReadme(keyword: string, page?: string, pageSize?: string): Promise; getMetabyPubkey(pubkey: string): Promise; segmentWord(words: string): Promise; getMetabyOwner(owner: string, page?: string, pageSize?: string): Promise; getDependentContract(contractName: string): Promise; queryContractLogByDate(start: number): Promise; queryDataByHash(hash: string): Promise; executeContract(contractID: string, method: string, arg: unknown): Promise; getSessionID(): Promise; listTheContractProcess(contractID: string): Promise; getMask(contractID: string): Promise; setMask(contractID: string, operation: string, arg: string): Promise; getMock(contractID: string): Promise; setMock(contractID: string, operation: string, arg: string): Promise; queryHashByOffset(offset: number, count: number): Promise; loadNodeConfig(): Promise; queryUserStat(): Promise; listNodes(): Promise; killContractProcess(id: string): Promise; distributeYPK(projectName: string, nodeIDs: string): Promise; listYPKs(): Promise; deleteFile(file: string): Promise; startContractByYPK(project: string): Promise; initBDServer(host: string, username: string, password: string, name: string, clusterHost: string): Promise; initBDCluster(host: string, username: string, password: string, name: string, sm2Key: string, agents: []): Promise; listCompiledFiles(): Promise; getManagerPubkey(): Promise; getClusterName(): Promise; setClusterName(name: string): Promise; } export { ClientResponse, ConfigNodeArgs, DistributeContractResponse, ExecuteContractArgs, ExecuteContractResponse, HttpClient, ListAllUsersResponseData, ListAllUsersResponseDataListItem, ListNodesResponse, ListProjectPermissionRequest, ListProjectPermissionResponseData, LoadNodeConfigResponseData, OnOpenHandler, OnlineContractsItem, OnlineItem, PingResponse, SaveFileRequest, StartContractByYpkRequest, WsClient, WsEvent, WsHandler, WsSocket, aesEncrypt, encryptReq, loadRSAKey, rsaEncrypt };