• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_INSTANCE_V9_H
17 #define USER_AUTH_INSTANCE_V9_H
18 
19 #include <mutex>
20 
21 #include "nocopyable.h"
22 
23 #include "napi/native_api.h"
24 #include "auth_common.h"
25 
26 #include "user_auth_callback_v9.h"
27 
28 namespace OHOS {
29 namespace UserIam {
30 namespace UserAuth {
31 class AuthInstanceV9 : public NoCopyable {
32 public:
33     static UserAuthResultCode GetAvailableStatus(napi_env env, napi_callback_info info);
34 
35     explicit AuthInstanceV9(napi_env env);
36     ~AuthInstanceV9() override = default;
37 
38     UserAuthResultCode Init(napi_env env, napi_callback_info info);
39     UserAuthResultCode On(napi_env env, napi_callback_info info);
40     UserAuthResultCode Off(napi_env env, napi_callback_info info);
41     UserAuthResultCode Start(napi_env env, napi_callback_info info);
42     UserAuthResultCode Cancel(napi_env env, napi_callback_info info);
43 
44 private:
45     static UserAuthResultCode GetAvailableStatusInner(napi_env env, napi_callback_info info);
46 
47     napi_status InitChallenge(napi_env env, napi_value value);
48     std::shared_ptr<JsRefHolder> GetCallback(napi_env env, napi_value value);
49 
50     std::vector<uint8_t> challenge_ = {};
51     AuthType authType_ = FACE;
52     AuthTrustLevel authTrustLevel_ = ATL1;
53     uint64_t contextId_ = 0;
54     bool isAuthStarted_ = false;
55     std::mutex mutex_;
56     std::shared_ptr<UserAuthCallbackV9> callback_ = nullptr;
57 };
58 } // namespace UserAuth
59 } // namespace UserIam
60 } // namespace OHOS
61 #endif // USER_AUTH_INSTANCE_V9_H
62