1 /* 2 * Copyright (c) 2023 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_INSTANCE_V10_H 17 #define USER_AUTH_INSTANCE_V10_H 18 19 #include <mutex> 20 21 #include "nocopyable.h" 22 23 #include "auth_common.h" 24 #include "auth_instance_v9.h" 25 #include "user_auth_callback_v10.h" 26 27 namespace OHOS { 28 namespace UserIam { 29 namespace UserAuth { 30 class UserAuthInstanceV10 : public NoCopyable { 31 public: 32 explicit UserAuthInstanceV10(napi_env env); 33 ~UserAuthInstanceV10() override = default; 34 35 UserAuthResultCode Init(napi_env env, napi_callback_info info); 36 UserAuthResultCode On(napi_env env, napi_callback_info info); 37 UserAuthResultCode Off(napi_env env, napi_callback_info info); 38 UserAuthResultCode Start(napi_env env, napi_callback_info info); 39 UserAuthResultCode Cancel(napi_env env, napi_callback_info info); 40 41 private: 42 UserAuthResultCode InitChallenge(napi_env env, napi_value value); 43 UserAuthResultCode InitAuthType(napi_env env, napi_value value); 44 UserAuthResultCode InitAuthParam(napi_env env, napi_value value); 45 UserAuthResultCode InitWidgetParam(napi_env env, napi_value value); 46 std::shared_ptr<JsRefHolder> GetCallback(napi_env env, napi_value value); 47 48 AuthParam authParam_; 49 WidgetParam widgetParam_; 50 51 uint64_t contextId_ = 0; 52 bool isAuthStarted_ = false; 53 std::mutex mutex_; 54 std::shared_ptr<UserAuthCallbackV10> callback_ = nullptr; 55 }; 56 } // namespace UserAuth 57 } // namespace UserIam 58 } // namespace OHOS 59 #endif // USER_AUTH_INSTANCE_V10_H 60