1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef USER_AUTH_IMPL_H 17 #define USER_AUTH_IMPL_H 18 19 #include "auth_common.h" 20 #include "napi/native_api.h" 21 #include "napi/native_common.h" 22 #include "user_auth_api_event_reporter.h" 23 #include "user_auth_common_defines.h" 24 25 namespace OHOS { 26 namespace UserIam { 27 namespace UserAuth { 28 class UserAuthImpl { 29 public: 30 static napi_value GetVersion(napi_env env, napi_callback_info info); 31 static napi_value GetAvailableStatus(napi_env env, napi_callback_info info); 32 static napi_value Auth(napi_env env, napi_callback_info info); 33 static napi_value Execute(napi_env env, napi_callback_info info); 34 static napi_value CancelAuth(napi_env env, napi_callback_info info); 35 static napi_value GetEnrolledState(napi_env env, napi_callback_info info); 36 static napi_value QueryReusableAuthResult(napi_env env, napi_callback_info info); 37 38 private: 39 UserAuthImpl() = default; 40 ~UserAuthImpl() = default; 41 42 static napi_status ParseExecuteInfo(napi_env env, napi_value value, AuthType &authType, ResultCode &resultCode); 43 static napi_status ParseExecuteAuthType(napi_env env, napi_value value, AuthType &authType, ResultCode &resultCode); 44 static napi_status ParseExecuteSecureLevel(napi_env env, napi_value value, 45 AuthTrustLevel &authTrustLevel, ResultCode &resultCode); 46 static ResultCode CheckAuthTypeAndAuthTrustLevel(AuthType authType, AuthTrustLevel authTrustLevel); 47 static napi_value DoGetEnrolledStateResult(napi_env env, EnrolledState enrolledState, 48 UserAuthApiEventReporter &reporter); 49 static UserAuthResultCode ParseReusableAuthResultParam(napi_env env, napi_callback_info info, 50 WidgetAuthParam &authParam); 51 }; 52 } // namespace UserAuth 53 } // namespace UserIam 54 } // namespace OHOS 55 #endif // USER_AUTH_IMPL_H 56