• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025-2025 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_PARAM_UTILS_H
17 #define USER_AUTH_PARAM_UTILS_H
18 
19 #include <mutex>
20 
21 #include "nocopyable.h"
22 
23 #include "ability.h"
24 
25 #include "auth_common.h"
26 #include "user_auth_napi_client_impl.h"
27 #include "user_auth_api_event_reporter.h"
28 
29 namespace OHOS {
30 namespace UserIam {
31 namespace UserAuth {
32 class UserAuthParamUtils : public NoCopyable {
33 public:
34     static UserAuthResultCode InitAuthParam(napi_env env, napi_value value, AuthParamInner &authParam);
35     static UserAuthResultCode InitWidgetParam(napi_env env, napi_value value,
36         UserAuthNapiClientImpl::WidgetParamNapi &widgetParam,
37         std::shared_ptr<AbilityRuntime::Context> &abilityContext);
38 
39 private:
40     static UserAuthResultCode InitChallenge(napi_env env, napi_value value, AuthParamInner &authParam);
41     static UserAuthResultCode InitAuthType(napi_env env, napi_value value, AuthParamInner &authParam);
42     static UserAuthResultCode InitAuthTrustLevel(napi_env env, napi_value value, AuthParamInner &authParam);
43     static UserAuthResultCode InitReuseUnlockResult(napi_env env, napi_value value, AuthParamInner &authParam);
44     static UserAuthResultCode InitUserId(napi_env env, napi_value value, AuthParamInner &authParam);
45     static UserAuthResultCode ProcessAuthTrustLevelAndUserId(napi_env env, napi_value value,
46         AuthParamInner &authParam);
47     static UserAuthResultCode ProcessReuseUnlockResult(napi_env env, napi_value value, AuthParamInner &authParam);
48     static UserAuthResultCode ProcessWindowMode(napi_env env, napi_value value,
49         UserAuthNapiClientImpl::WidgetParamNapi &widgetParam);
50     static UserAuthResultCode ProcessContext(napi_env env, napi_value value,
51         UserAuthNapiClientImpl::WidgetParamNapi &widgetParam,
52         std::shared_ptr<AbilityRuntime::Context> &abilityContext);
53     static bool CheckUIContext(const std::shared_ptr<OHOS::AbilityRuntime::Context> context);
54     static UserAuthResultCode ProcessSkipLockedBiometricAuth(napi_env env, napi_value value,
55         AuthParamInner &authParam);
56 };
57 } // namespace UserAuth
58 } // namespace UserIam
59 } // namespace OHOS
60 #endif // USER_AUTH_PARAM_UTILS_H
61