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 RESULT_CONVERT_H 17 #define RESULT_CONVERT_H 18 19 #include <string> 20 #include <vector> 21 #include "napi/native_api.h" 22 #include "napi/native_common.h" 23 #include "nocopyable.h" 24 #include "userauth_info.h" 25 #include "auth_common.h" 26 #include "auth_object.h" 27 28 namespace OHOS { 29 namespace UserIAM { 30 namespace UserAuth { 31 class ResultConvert { 32 public: 33 DISALLOW_COPY_AND_MOVE(ResultConvert); 34 ResultConvert(); 35 virtual ~ResultConvert(); 36 napi_value Uint64ToUint8Napi(napi_env env, uint64_t value); 37 std::vector<uint8_t> NapiGetValueUint8Array(napi_env env, napi_value jsObject, std::string key); 38 napi_valuetype GetType(napi_env env, napi_value value); 39 std::string GetStringValueByKey(napi_env env, napi_value jsObject, std::string key); 40 int32_t GetInt32ValueByKey(napi_env env, napi_value jsObject, std::string key); 41 int32_t NapiGetValueInt32(napi_env env, napi_value value); 42 std::vector<uint32_t> GetInt32ArrayValueByKey(napi_env env, napi_value jsObject, std::string key); 43 44 private: 45 std::vector<uint32_t> GetCppArrayUint32(napi_env env, napi_value value); 46 std::string NapiGetValueString(napi_env env, napi_value value); 47 napi_value GetNapiValue(napi_env env, const std::string keyChar, napi_value object); 48 }; 49 } // namespace UserAuth 50 } // namespace UserIAM 51 } // namespace OHOS 52 #endif // RESULT_CONVERT_H 53