@alauda-fe/common
Version:
Alauda frontend team common codes.
19 lines (18 loc) • 1.21 kB
TypeScript
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
import { Observable } from 'rxjs';
import * as i0 from "@angular/core";
export declare class CryptoInterceptorService implements HttpInterceptor {
private readonly extraUrlRegexps;
constructor(extraUrlRegexps: RegExp[]);
private factoryContentType;
private encryptPayload;
private factoryReq;
/**
* 实现方案:
* 1. 请求和响应处理分开处理,在请求的header上加上加密标识,根据返回的响应header处理对应的加密策略,而不是使用请求时使用的策略。这样能规避服务端的主动加密策略(前端没有使用加密)
* 2. 如果解密失败,将不做任何处理,原样返回,因为理论上解密不应该失败,如果失败可能是不需要解密,最主要的是返回解密失败的信息比原样返回对业务来说更没意义
*/
intercept(req: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>>;
static ɵfac: i0.ɵɵFactoryDeclaration<CryptoInterceptorService, [{ optional: true; }]>;
static ɵprov: i0.ɵɵInjectableDeclaration<CryptoInterceptorService>;
}