UNPKG

bytefun-js

Version:

ByteFun JavaScript SDK

304 lines (301 loc) 10.5 kB
/* * Copyright 2025-2101 广州莱聚信息科技有限公司. * * This software is part of the bytefun Library. * * Licensed under the GNU Lesser General Public License, Version 3.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.gnu.org/licenses/lgpl-3.0.html * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * This software includes third-party libraries: * - jss (https://github.com/cssinjs/jss) * Licensed under the MIT License. * - sm-crypto (https://github.com/JuneAndGreen/sm-crypto) * Licensed under the MIT License. * - DOMPurify (https://github.com/cure53/DOMPurify) * Licensed under the MPL-2.0 OR Apache-2.0 License. */ export declare const md5: (str: string) => string; export interface IImageDownLoadCallback { onSuc(bitmap: any): void; onFail(e: Error): void; } export declare class WrapViewAndData { view: any; urlBg: string; viewW: number; viewH: number; bgImgStyle: number; } export interface IImageModel { src: string; defaultImg: string; failImg: string; scaleType: number; otherStationSrc: string; otherStationRound: number; isSvg: number; svgColor: string; } export declare class NetRequest { static readonly METHOD_GET = 0; static readonly METHOD_POST = 1; static readonly METHOD_PUT = 2; static readonly METHOD_DELETE = 3; private reqURL; private internal; private tag; method: number; header: Record<string, any>; private postParam; constructor(url: string); setMethod(method: number): void; getParam(): Record<string, any>; getParamToString(): string; setPostParam(postParam: Record<string, any> | Array<any> | string): void; getReqURL(): string; setReqURL(reqURL: string): void; getTag(): any; setTag(tag: any): void; setInternal(internal: boolean): void; isInternal(): boolean; setHeader(header: Record<string, any>): void; } export interface INetCallback { onFailure(e: Error, netRequest: NetRequest): void; onResponse(response: any, netRequest: NetRequest): void; } export interface IByteFunView { jumpPage(pageId: string): void; getScanId(): string; } export interface ImageLoadCallback { failure: (event: any) => void; success: (event: any) => void; } export interface ImageView { loadImage(url: string, callback: ImageLoadCallback): void; } export interface IImageToViewCallback { onSuc(view: ImageView, imageModel: IImageModel, drawable: any, wrapViewAndData?: WrapViewAndData): void; onFail(e: Error, view: ImageView, drawable: any, wrapViewAndData?: WrapViewAndData): void; } export interface IWXPayCallback { onOrderSuc(code: number): void; onOrderFail(code: number): void; onCallWXSuc(code: number): void; onCallWXFail(code: number): void; onPaySuc(code: number): void; onPayFail(code: number): void; onPayCancel(code: number): void; } export interface IZFBPayCallback { onOrderSuc(): void; onOrderFail(): void; onPaySuc(): void; onPayMaybeSuc(): void; onPayFail(): void; onPayCancel(): void; } export interface IWXShareCallback { onFailure(code: number): void; onResponse(code: number): void; } export interface IZFBShareCallback { onFailure(code: number): void; onResponse(code: number): void; } export interface IWXAuthCallback { onAuthSuc(code: number, authCode: string): void; onAuthFail(code: number): void; onCallWXSuc(code: number): void; onCallWXFail(code: number): void; onAuthCancel(code: number): void; onAuthReject(code: number): void; } export interface IZFBAuthCallback { onAuthSuc(code: number, authCode: string): void; onAuthFail(code: number): void; onAuthCancel(code: number): void; onUserFrozen(code: number): void; } export interface IWXQrCodeAuthCallback { onFailure(e: Error, netRequest: NetRequest): void; onSuccess(response: any, netRequest: NetRequest): void; } export interface IQrPayCallback { onPaySuc(code: string): void; onPayFail(code: string): void; onCreateQrCodeSuc(url: string): void; onCreateQrCodeFail(errMsg: string): void; } export interface IFileSelectCallback { onSuc(file: File, path: string): void; onFail(errMsg: string): void; } export interface IQrScanCallback { onSuc(result: string): void; onFail(errMsg: string): void; } export interface ILocationCallback { onSuccess(lng: number, lat: number, radius: number, address: Record<string, any>): void; onFail(error: string): void; } export interface IPageLoadCallback { onSuc(data: string): void; onFail(msg?: any): void; } export interface IFilePickEvent { accept: Array<string>; exAccept: any; } export declare class IQrPayEvent { cid: string; duration: number; platform: string; payParams: Record<string, string>; } export interface IShareZFBLinkEvent { url: string; title: string; desc: string; thumb: string; } export interface IShareZFBTextEvent { text: string; } export interface IShareZFBImageEvent { url: string; } export interface IShareWXTextEvent { text: string; } export interface IShareWXImageEvent { url: string; } export interface IShareWXBaseMulEvent { url: string; title: string; desc: string; thumb: string; scene: number; } export interface IShareWXLinkEvent extends IShareWXBaseMulEvent { } export interface IShareWXMinAPPEvent extends IShareWXBaseMulEvent { userName: string; path: string; proType: number; } export interface IShareWXMusicEvent extends IShareWXBaseMulEvent { } export interface IShareWXVideoEvent extends IShareWXBaseMulEvent { } export interface IWXAuthEvent { authCode: string; } export interface ILocationStartEvent { locType: number; locTime: number; coordType: number; } export interface IServerLib { downloadImg(context: any, imgUrl: string, iImageDownLoadCallback: IImageDownLoadCallback): void; savePageCacheData(context: any, pageID: string, pageData: string): void; loadPageCacheData(context: any, pageID: string, callback: IPageLoadCallback): void; delPageCacheData(context: any, pageID: string): void; saveSpData(context: any, key: string, data: any): void; loadSpData(context: any, key: string, dataType: number): any; setImgToImageView(context: any, imageView: ImageView, imageModel: IImageModel, imageCallback: IImageToViewCallback): void; stopLoadImgToImageView(view: any): void; addThreadPoolTask(runnable: any): void; netRequest(netRequest: NetRequest, callback: INetCallback): void; qrScan(context: any, byteFunView: IByteFunView, callback: IQrScanCallback): void; wxPay(context: any, netRequest: NetRequest, callback: IWXPayCallback): void; qrCodePay(context: any, netRequest: NetRequest, qrPayEvent: IQrPayEvent, container: HTMLElement, callback: IQrPayCallback): void; zfbPay(context: any, netRequest: NetRequest, callback: IZFBPayCallback): void; wxShareText(context: any, shareWXTextEvent: IShareWXTextEvent, iwxShareCallback: IWXShareCallback): void; wxShareImage(context: any, shareWXImageEvent: IShareWXImageEvent, iwxShareCallback: IWXShareCallback): void; wxShareLink(context: any, shareWXLinkEvent: IShareWXLinkEvent, iwxShareCallback: IWXShareCallback): void; wxShareMusic(context: any, shareWXMusicEvent: IShareWXMusicEvent, iwxShareCallback: IWXShareCallback): void; wxShareVideo(context: any, shareWXVideoEvent: IShareWXVideoEvent, iwxShareCallback: IWXShareCallback): void; wxShareMinApp(context: any, shareWXMinAPPEvent: IShareWXMinAPPEvent, iwxShareCallback: IWXShareCallback): void; zfbShareText(context: any, shareZFBTextEvent: IShareZFBTextEvent, izfbShareCallback: IZFBShareCallback): void; zfbShareImage(context: any, shareZFBImageEvent: IShareZFBImageEvent, izfbShareCallback: IZFBShareCallback): void; zfbShareLink(context: any, shareZFBLinkEvent: IShareZFBLinkEvent, izfbShareCallback: IZFBShareCallback): void; wxQrCodeAuth(context: any, netRequest: NetRequest, container: HTMLElement, iwxQrCodeAuthCallback: IWXQrCodeAuthCallback): void; wxAuth(context: any, wxAuthEvent: IWXAuthEvent, iwxAuthCallback: IWXAuthCallback): void; zfbAuth(context: any, netRequest: NetRequest, izfbAuthCallback: IZFBAuthCallback): void; md5(data: string): string; filePick(context: any, filePickEvent: IFilePickEvent, iFileSelectCallback: IFileSelectCallback): void; startLocation(context: any, locationStartEvent: ILocationStartEvent, byteFunView: IByteFunView, iLocationCallback: ILocationCallback): void; stopLocation(context: any, byteFunView: IByteFunView): void; hasAssetsFile(fileName: string): boolean; } export declare enum Platform { H5 = "h5", LINUX = "linux", MAC = "mac", WINDOW = "window" } export interface SdkOption { el: string | HTMLDivElement; basePath?: string; serverLib: IServerLib; appId: string; appKey: string; mode?: "hash" | "history"; initJson?: any; platform?: Platform; debug?: boolean; } export declare class ByteFunSDK { static init(option: SdkOption): void; static setBizFunction(bizFunction: any): void; static setBizVar(bizVar: any): void; static setBizCallback(bizCallback: any): void; } export declare class NetworkError extends Error { status: number; constructor(message: string); } export interface SignOptions { pointPool: string; der: boolean; hash: boolean; publicKey: string; userId: string; } export interface SM4Options { padding: string; mode: string; iv: Array<string>; output: string; } export type ISignOptions = Omit<SignOptions, "pointPool" | "publicKey">; export declare const sm2: { generateKeyPairHex: () => string; compressPublicKeyHex: (key: string) => string; comparePublicKeyHex: (publicKey1: string, publicKey2: string) => boolean; doEncrypt: (msg: string, publicKey: string, chipherModel?: number) => string; doDecrypt: (encryptData: string, privateKey: string, chipherModel?: number) => string; doSignature: (signData: string, privateKey: string, options: SignOptions) => string; doVerifySignature: (msg: string, signHex: String, publicKey: string, options: ISignOptions) => boolean; getPublicKeyFromPrivateKey: (privateKey: string) => string; getPoint: ()=> string; verifyPublicKey: (publicKey: string) => boolean; } export declare function sm3(message: string): string; export declare const sm4: { encrypt: (inArray: string, key: string,options?: SM4Options) => string; decrypt: (inArray: string, key: string,options?: SM4Options) => string; } export {};