feat: 登录信息加密传输
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { baseRequestClient, requestClient } from '#/api/request';
|
||||
import {baseRequestClient, requestClient} from '#/api/request';
|
||||
import {type CredentialKeyMaterial, encryptCredentialPayload,} from '#/utils/credential-encryption';
|
||||
|
||||
export namespace AuthApi {
|
||||
/** 登录接口参数 */
|
||||
@@ -25,11 +26,27 @@ export namespace AuthApi {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录加密公钥
|
||||
*/
|
||||
export async function getCredentialKeyApi() {
|
||||
return requestClient.get<CredentialKeyMaterial>(
|
||||
'/api/v1/auth/credential-key',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
export async function loginApi(data: AuthApi.LoginParams) {
|
||||
return requestClient.post<AuthApi.LoginResult>('/api/v1/auth/login', data);
|
||||
const encryptedPayload = await encryptCredentialPayload(
|
||||
getCredentialKeyApi,
|
||||
data,
|
||||
);
|
||||
return requestClient.post<AuthApi.LoginResult>(
|
||||
'/api/v1/auth/login',
|
||||
encryptedPayload,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user