1 /* 2 * Copyright (c) 2021-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 OS_ACCOUNT_INTERFACES_KITS_NAPI_APPACCOUNT_INCLUDE_NAPI_APP_ACCOUNT_H 17 #define OS_ACCOUNT_INTERFACES_KITS_NAPI_APPACCOUNT_INCLUDE_NAPI_APP_ACCOUNT_H 18 19 #include "napi/native_api.h" 20 21 namespace OHOS { 22 namespace AccountJsKit { 23 static thread_local napi_ref appAccountRef_ = nullptr; 24 class NapiAppAccount { 25 public: 26 static napi_value Init(napi_env env, napi_value exports); 27 28 private: 29 static napi_value CreateAppAccountManager(napi_env env, napi_callback_info cbInfo); 30 static napi_value AddAccount(napi_env env, napi_callback_info cbInfo); 31 static napi_value AddAccountImplicitly(napi_env env, napi_callback_info cbInfo); 32 static napi_value DeleteAccount(napi_env env, napi_callback_info cbInfo); 33 static napi_value DisableAppAccess(napi_env env, napi_callback_info cbInfo); 34 static napi_value EnableAppAccess(napi_env env, napi_callback_info cbInfo); 35 static napi_value CheckAppAccountSyncEnable(napi_env env, napi_callback_info cbInfo); 36 static napi_value SetAccountCredential(napi_env env, napi_callback_info cbInfo); 37 static napi_value SetAccountExtraInfo(napi_env env, napi_callback_info cbInfo); 38 static napi_value SetAppAccountSyncEnable(napi_env env, napi_callback_info cbInfo); 39 static napi_value SetAssociatedData(napi_env env, napi_callback_info cbInfo); 40 static napi_value GetAllAccessibleAccounts(napi_env env, napi_callback_info cbInfo); 41 static napi_value GetAllAccounts(napi_env env, napi_callback_info cbInfo); 42 static napi_value GetAccountCredential(napi_env env, napi_callback_info cbInfo); 43 static napi_value GetAccountExtraInfo(napi_env env, napi_callback_info cbInfo); 44 static napi_value GetAssociatedData(napi_env env, napi_callback_info cbInfo); 45 static napi_value GetAssociatedDataSync(napi_env env, napi_callback_info cbInfo); 46 static napi_value Authenticate(napi_env env, napi_callback_info cbInfo); 47 static napi_value GetOAuthToken(napi_env env, napi_callback_info cbInfo); 48 static napi_value SetOAuthToken(napi_env env, napi_callback_info cbInfo); 49 static napi_value DeleteOAuthToken(napi_env env, napi_callback_info cbInfo); 50 static napi_value SetOAuthTokenVisibility(napi_env env, napi_callback_info cbInfo); 51 static napi_value CheckOAuthTokenVisibility(napi_env env, napi_callback_info cbInfo); 52 static napi_value GetAuthenticatorInfo(napi_env env, napi_callback_info cbinfo); 53 static napi_value GetAllOAuthTokens(napi_env env, napi_callback_info cbInfo); 54 static napi_value GetOAuthList(napi_env env, napi_callback_info cbInfo); 55 static napi_value GetAuthenticatorCallback(napi_env env, napi_callback_info cbInfo); 56 static napi_value CheckAppAccess(napi_env env, napi_callback_info cbInfo); 57 static napi_value CheckAccountLabels(napi_env env, napi_callback_info cbInfo); 58 static napi_value SelectAccountsByOptions(napi_env env, napi_callback_info cbInfo); 59 static napi_value VerifyCredential(napi_env env, napi_callback_info cbInfo); 60 static napi_value SetAuthenticatorProperties(napi_env env, napi_callback_info cbInfo); 61 static napi_value DeleteAccountCredential(napi_env env, napi_callback_info cbInfo); 62 static napi_value Subscribe(napi_env env, napi_callback_info cbInfo); 63 static napi_value Unsubscribe(napi_env env, napi_callback_info cbInfo); 64 static napi_value JsConstructor(napi_env env, napi_callback_info cbinfo); 65 66 static napi_value CreateAccount(napi_env env, napi_callback_info cbinfo); 67 static napi_value CreateAccountImplicitly(napi_env env, napi_callback_info cbinfo); 68 static napi_value RemoveAccount(napi_env env, napi_callback_info cbinfo); 69 static napi_value SetAppAccess(napi_env env, napi_callback_info cbinfo); 70 static napi_value SetCredential(napi_env env, napi_callback_info cbinfo); 71 static napi_value GetCredential(napi_env env, napi_callback_info cbinfo); 72 static napi_value DeleteCredential(napi_env env, napi_callback_info cbinfo); 73 static napi_value SetExtraInfo(napi_env env, napi_callback_info cbinfo); 74 static napi_value GetExtraInfo(napi_env env, napi_callback_info cbinfo); 75 static napi_value SetDataSyncEnabled(napi_env env, napi_callback_info cbinfo); 76 static napi_value CheckDataSyncEnabled(napi_env env, napi_callback_info cbinfo); 77 static napi_value SetCustomData(napi_env env, napi_callback_info cbinfo); 78 static napi_value GetCustomData(napi_env env, napi_callback_info cbinfo); 79 static napi_value GetAccountsByOwner(napi_env env, napi_callback_info cbinfo); 80 static napi_value Auth(napi_env env, napi_callback_info cbinfo); 81 static napi_value GetAuthToken(napi_env env, napi_callback_info cbinfo); 82 static napi_value SetAuthToken(napi_env env, napi_callback_info cbinfo); 83 static napi_value DeleteAuthToken(napi_env env, napi_callback_info cbinfo); 84 static napi_value GetAllAuthTokens(napi_env env, napi_callback_info cbinfo); 85 static napi_value GetAuthList(napi_env env, napi_callback_info cbinfo); 86 static napi_value SetAuthTokenVisibility(napi_env env, napi_callback_info cbinfo); 87 static napi_value CheckAuthTokenVisibility(napi_env env, napi_callback_info cbinfo); 88 static napi_value GetAuthCallback(napi_env env, napi_callback_info cbinfo); 89 static napi_value QueryAuthenticatorInfo(napi_env env, napi_callback_info cbinfo); 90 91 static napi_value CreateAccountInternal(napi_env env, napi_callback_info cbInfo, bool isThrowable); 92 static napi_value CreateAccountImplicitlyInternal(napi_env env, napi_callback_info cbinfo, bool isThrowable); 93 static napi_value RemoveAccountInternal(napi_env env, napi_callback_info cbinfo, bool isThrowable); 94 static napi_value SetAppAccessInternal(napi_env env, napi_callback_info cbinfo, bool isThrowable); 95 static napi_value SetCredentialInternal(napi_env env, napi_callback_info cbinfo, bool isThrowable); 96 static napi_value GetCredentialInternal(napi_env env, napi_callback_info cbinfo, bool isThrowable); 97 static napi_value DeleteCredentialInternal(napi_env env, napi_callback_info cbInfo, bool isThrowable); 98 static napi_value SetExtraInfoInternal(napi_env env, napi_callback_info cbinfo, bool isThrowable); 99 static napi_value GetExtraInfoInternal(napi_env env, napi_callback_info cbinfo, bool isThrowable); 100 static napi_value SetDataSyncEnabledInternal(napi_env env, napi_callback_info cbinfo, bool isThrowable); 101 static napi_value CheckDataSyncEnabledInternal(napi_env env, napi_callback_info cbinfo, bool isThrowable); 102 static napi_value SetCustomDataInternal(napi_env env, napi_callback_info cbinfo, bool isThrowable); 103 static napi_value GetCustomDataInternal(napi_env env, napi_callback_info cbinfo, bool isThrowable); 104 static napi_value GetAllAccessibleAccountsInternal(napi_env env, napi_callback_info cbInfo, bool isThrowable); 105 static napi_value GetAccountsByOwnerInternal(napi_env env, napi_callback_info cbinfo, bool isThrowable); 106 static napi_value AuthInternal(napi_env env, napi_callback_info cbinfo, bool isThrowable); 107 static napi_value GetAuthTokenInternal(napi_env env, napi_callback_info cbinfo, bool isThrowable); 108 static napi_value SetAuthTokenInternal(napi_env env, napi_callback_info cbinfo, bool isThrowable); 109 static napi_value DeleteAuthTokenInternal(napi_env env, napi_callback_info cbinfo, bool isThrowable); 110 static napi_value GetAllAuthTokensInternal(napi_env env, napi_callback_info cbinfo, bool isThrowable); 111 static napi_value GetAuthListInternal(napi_env env, napi_callback_info cbinfo, bool isThrowable); 112 static napi_value SetAuthTokenVisibilityInternal(napi_env env, napi_callback_info cbinfo, bool isThrowable); 113 static napi_value CheckAuthTokenVisibilityInternal(napi_env env, napi_callback_info cbinfo, bool isThrowable); 114 static napi_value GetAuthCallbackInternal(napi_env env, napi_callback_info cbinfo, bool isThrowable); 115 static napi_value QueryAuthenticatorInfoInternal(napi_env env, napi_callback_info cbinfo, bool isThrowable); 116 }; 117 } // namespace AccountJsKit 118 } // namespace OHOS 119 120 #endif // OS_ACCOUNT_INTERFACES_KITS_NAPI_APPACCOUNT_INCLUDE_NAPI_APP_ACCOUNT_H 121