@fast-china/axios
Version:
Fast Axios 请求工具库.
1 lines • 2.65 kB
Source Map (JSON)
{"version":3,"file":"crypto.mjs","sources":["../../../../../src/axios/types/crypto.ts"],"sourcesContent":["import type { FastAxiosRequestConfig } from \"./options\";\nimport type { AxiosResponse, InternalAxiosRequestConfig } from \"axios\";\n\ntype CryptoEncryptHandle = <Input>(config: InternalAxiosRequestConfig<Input>, timestamp: number) => void;\ntype CryptoEncryptUseHandle = { use: (fn: CryptoEncryptHandle) => void };\ntype CryptoDecryptHandle = <Output = any, Input = any>(response: AxiosResponse<Output, Input>, options: FastAxiosRequestConfig<Input>) => any | void;\ntype CryptoDecryptUseHandle = { use: (fn: CryptoDecryptHandle) => void };\n\nexport class CryptoManage {\n\tprivate _handle: {\n\t\tencrypt: CryptoEncryptHandle;\n\t\tdecrypt: CryptoDecryptHandle;\n\t};\n\n\t/** 加密 */\n\treadonly encrypt: CryptoEncryptHandle & CryptoEncryptUseHandle;\n\t/** 解密 */\n\treadonly decrypt: CryptoDecryptHandle & CryptoDecryptUseHandle;\n\n\tconstructor() {\n\t\tthis._handle = {\n\t\t\tencrypt: <Input>(config: InternalAxiosRequestConfig<Input>, timestamp: number): void => {\n\t\t\t\treturn;\n\t\t\t},\n\t\t\tdecrypt: <Output = any, Input = any>(response: AxiosResponse<Output, Input>, options: FastAxiosRequestConfig<Input>): any | void => {\n\t\t\t\treturn null;\n\t\t\t},\n\t\t};\n\n\t\tconst encryptProxy: CryptoEncryptHandle & CryptoEncryptUseHandle = <Input>(\n\t\t\tconfig: InternalAxiosRequestConfig<Input>,\n\t\t\ttimestamp: number\n\t\t): void => {\n\t\t\tthis._handle.encrypt<Input>(config, timestamp);\n\t\t};\n\t\tencryptProxy.use = (fn: CryptoEncryptHandle): void => {\n\t\t\tthis._handle.encrypt = fn;\n\t\t};\n\t\tthis.encrypt = encryptProxy;\n\n\t\tconst decryptProxy: CryptoDecryptHandle & CryptoDecryptUseHandle = <Output = any, Input = any>(\n\t\t\tresponse: AxiosResponse<Output, Input>,\n\t\t\toptions: FastAxiosRequestConfig<Input>\n\t\t): any | void => {\n\t\t\treturn this._handle.decrypt<Output, Input>(response, options);\n\t\t};\n\t\tdecryptProxy.use = (fn: CryptoDecryptHandle): void => {\n\t\t\tthis._handle.decrypt = fn;\n\t\t};\n\t\tthis.decrypt = decryptProxy;\n\t}\n}\n"],"names":[],"mappings":";;;AAQO,MAAM,aAAa;AAAA,EAWzB,cAAc;AAVN;AAMC;AAAA;AAEA;AAAA;AAGR,SAAK,UAAU;AAAA,MACd,SAAS,CAAQ,QAA2C,cAA4B;AACvF;AAAA,MACD;AAAA,MACA,SAAS,CAA4B,UAAwC,YAAuD;AAC5H,eAAA;AAAA,MAAA;AAAA,IAET;AAEM,UAAA,eAA6D,CAClE,QACA,cACU;AACL,WAAA,QAAQ,QAAe,QAAQ,SAAS;AAAA,IAC9C;AACa,iBAAA,MAAM,CAAC,OAAkC;AACrD,WAAK,QAAQ,UAAU;AAAA,IACxB;AACA,SAAK,UAAU;AAET,UAAA,eAA6D,CAClE,UACA,YACgB;AAChB,aAAO,KAAK,QAAQ,QAAuB,UAAU,OAAO;AAAA,IAC7D;AACa,iBAAA,MAAM,CAAC,OAAkC;AACrD,WAAK,QAAQ,UAAU;AAAA,IACxB;AACA,SAAK,UAAU;AAAA,EAAA;AAEjB;"}