1 /* 2 * Copyright (c) 2024 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 17 #ifndef APPACCOUNT_DEFINATION_H 18 #define APPACCOUNT_DEFINATION_H 19 20 #include "cj_common_ffi.h" 21 22 using WantHandle = void*; 23 typedef struct { 24 char *key; 25 char *value; 26 } CHashStrStrPair; 27 28 typedef struct { 29 CHashStrStrPair *headers; 30 int64_t size; 31 } CHashStrStrArr; 32 33 typedef struct { 34 CHashStrStrArr customData; 35 } CCreateAccountOptions; 36 37 typedef struct { 38 char *owner; 39 char *name; 40 } CAppAccountInfo; 41 42 typedef struct { 43 CAppAccountInfo *head; 44 int64_t size; 45 } CArrAppAccountInfo; 46 47 typedef struct { 48 char *authType; 49 char *token; 50 CAppAccountInfo account; 51 } CAuthTokenInfo; 52 53 typedef struct { 54 CAuthTokenInfo *head; 55 int64_t size; 56 } CArrAuthTokenInfo; 57 58 typedef struct { 59 char *owner; 60 int32_t iconId; 61 int32_t labelId; 62 } CAuthenticatorInfo; 63 64 typedef struct { 65 CArrAppAccountInfo allowedAccounts; 66 CArrString allowedOwners; 67 CArrString requiredLabels; 68 } CSelectAccountsOptions; 69 70 typedef struct { 71 int32_t err; 72 CArrAppAccountInfo cArrAppAccountInfo; 73 } ErrCArrAppAccountInfo; 74 75 typedef struct { 76 int32_t err; 77 CArrAuthTokenInfo cArrAuthTokenInfo; 78 } ErrCArrAuthTokenInfo; 79 80 typedef struct { 81 int32_t err; 82 CAuthenticatorInfo cAuthenticatorInfo; 83 } ErrCAuthenticatorInfo; 84 85 typedef struct { 86 CAppAccountInfo account; 87 CAuthTokenInfo tokenInfo; 88 bool flag; 89 } CAuthResult; 90 91 typedef struct { 92 int8_t valueType; 93 char *key; 94 void *value; 95 int64_t size; 96 } CParameters; 97 98 typedef struct { 99 CParameters *head; 100 int64_t size; 101 } CArrParameters; 102 103 typedef struct { 104 char *credentialType; 105 char *credential; 106 CArrParameters parameters; 107 } CVerifyCredentialOptions; 108 109 typedef struct { 110 CArrParameters properties; 111 CArrParameters parameters; 112 } CSetPropertiesOptions; 113 114 typedef struct { 115 CArrString reruiredLabels; 116 char *authType; 117 CArrParameters parameters; 118 } CCreateAccountImplicityOptions; 119 120 typedef struct { 121 void(*onResult) (int32_t, CAuthResult); 122 void(*onRequestRedirected) (WantHandle); 123 void(*onRequestContinued) (); 124 } CAuthCallback; 125 126 namespace OHOS::AccountSA { 127 char *MallocCString(const std::string &origin); 128 char *MallocCString(const std::string &origin, int32_t &code); 129 } // namespace OHOS::AccountSA 130 #endif