• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef DEVATTEST_NAPI_H
16 #define DEVATTEST_NAPI_H
17 
18 #include "napi/native_api.h"
19 #include "napi/native_node_api.h"
20 #include "devattest_napi_error.h"
21 
22 namespace OHOS {
23 namespace DevAttest {
24 #define PARAM1 1
25 
26 #define DEVICE_ATTEST_NAPI_RETURN_UNDEF(env, errCode)                             \
27 do {                                                                              \
28     napi_value undefined;                                                         \
29     napi_get_undefined((env), &undefined);                                        \
30     int32_t jsErrCode = ConvertToJsErrCode((errCode));                            \
31     std::string jsErrMsg = ConvertToJsErrMsg(jsErrCode);                          \
32     napi_throw_error((env), std::to_string(jsErrCode).c_str(), jsErrMsg.c_str()); \
33     return undefined;                                                             \
34 } while (0)
35 
36 class DevAttestNapi {
37 public:
38     static napi_value Init(napi_env env, napi_value exports);
39 private:
40     DevAttestNapi() = default;
41     ~DevAttestNapi() = default;
42     static napi_value GetAttestResultInfo(napi_env env, napi_callback_info info);
43     static napi_value GetAttestResultInfoSync(napi_env env, napi_callback_info info);
44 };
45 } // namespace DevAttest
46 } // namespace OHOS
47 #endif // DEVATTEST_NAPI_H
48