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 CM_NAPI_INSTALL_APP_CERT_COMMON_H 17 #define CM_NAPI_INSTALL_APP_CERT_COMMON_H 18 19 #include "napi/native_api.h" 20 #include "napi/native_node_api.h" 21 #include "cm_type.h" 22 23 struct InstallAppCertAsyncContextT { 24 napi_async_work asyncWork = nullptr; 25 napi_deferred deferred = nullptr; 26 napi_ref callback = nullptr; 27 28 int32_t result = 0; 29 struct CmBlob *keystore = nullptr; 30 struct CmBlob *keystorePwd = nullptr; 31 struct CmBlob *keyAlias = nullptr; 32 struct CmBlob *keyUri = nullptr; 33 uint32_t store = 0; 34 35 /* add auth storage level: default el1, only valid while install private cert */ 36 enum CmAuthStorageLevel level = CM_AUTH_STORAGE_LEVEL_EL1; 37 }; 38 using InstallAppCertAsyncContext = InstallAppCertAsyncContextT *; 39 40 namespace CMNapi { 41 InstallAppCertAsyncContext CreateInstallAppCertAsyncContext(); 42 43 void DeleteInstallAppCertAsyncContext(napi_env env, InstallAppCertAsyncContext &context); 44 45 napi_value InstallAppCertParseParams( 46 napi_env env, napi_callback_info info, InstallAppCertAsyncContext context, uint32_t store); 47 48 napi_value InstallAppCertAsyncWork(napi_env env, InstallAppCertAsyncContext asyncContext); 49 50 napi_value CMNapiInstallAppCertCommon(napi_env env, napi_callback_info info, uint32_t store); 51 } // namespace CertManagerNapi 52 53 #endif // CM_NAPI_INSTALL_APP_CERT_COMMON_H