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 #ifndef OS_ACCOUNT_INTERFACES_INNERKITS_DOMAIN_ACCOUNT_INCLUDE_DOMAIN_ACCOUNT_LIB_H 17 #define OS_ACCOUNT_INTERFACES_INNERKITS_DOMAIN_ACCOUNT_INCLUDE_DOMAIN_ACCOUNT_LIB_H 18 #ifdef __cplusplus 19 extern "C" { 20 #endif 21 22 typedef struct { 23 char* data; 24 size_t length; 25 } PluginString; 26 27 typedef struct { 28 uint8_t* data; 29 size_t size; 30 size_t capcity; 31 } PluginUint8Vector; 32 33 typedef struct { 34 int32_t code; 35 PluginString msg; 36 } PluginBussnessError; 37 38 typedef struct { 39 PluginString id; 40 PluginString domain; 41 PluginString parameters; 42 } PluginServerConfigInfo; 43 44 typedef struct { 45 PluginString serverConfigId; 46 PluginString domain; 47 PluginString accountName; 48 PluginString accountId; 49 int32_t isAuthenticated; 50 } PluginDomainAccountInfo; 51 52 typedef struct { 53 PluginUint8Vector accountToken; 54 int32_t remainTimes; 55 int32_t freezingTime; 56 } PluginAuthResultInfo; 57 58 typedef struct { 59 PluginDomainAccountInfo domainAccountInfo; 60 int32_t callerUid; 61 } PluginGetDomainAccountInfoOptions; 62 63 typedef struct { 64 int32_t remainTimes; 65 int32_t freezingTime; 66 } PluginAuthStatusInfo; 67 68 typedef struct { 69 PluginDomainAccountInfo domainAccountInfo; 70 PluginUint8Vector domainAccountToken; 71 PluginString bussinessParams; 72 int32_t callerUid; 73 } PluginGetDomainAccessTokenOptions; 74 75 typedef struct { 76 int32_t authenicationValidityPeriod; 77 } PluginDomainAccountPolicy; 78 79 typedef PluginBussnessError* (*AddServerConfigFunc)(const PluginString *parameters, const int32_t callerLocalId, 80 PluginServerConfigInfo **serverConfigInfo); 81 typedef PluginBussnessError* (*RemoveServerConfigFunc)(const PluginString *serverConfigId, const int32_t callerLocalId); 82 typedef PluginBussnessError* (*GetAccountServerConfigFunc)(const PluginDomainAccountInfo *domainAccountInfo, 83 PluginServerConfigInfo **serverConfigInfo); 84 typedef PluginBussnessError* (*AuthFunc)(const PluginDomainAccountInfo *domainAccountInfo, 85 const PluginUint8Vector *credential, const int32_t callerLocalId, PluginAuthResultInfo **authResultInfo); 86 typedef PluginBussnessError* (*AuthWithPopupFunc)(const PluginDomainAccountInfo *domainAccountInfo, 87 PluginAuthResultInfo **authResultInfo); 88 typedef PluginBussnessError* (*AuthWithTokenFunc)(const PluginDomainAccountInfo *domainAccountInfo, 89 const PluginUint8Vector *token, PluginAuthResultInfo **authResultInfo); 90 typedef PluginBussnessError* (*GetAccountInfoFunc)(const PluginGetDomainAccountInfoOptions *options, 91 const int32_t callerLocalId, PluginDomainAccountInfo **domainAccountInfo); 92 typedef PluginBussnessError* (*GetAuthStatusInfoFunc)(const PluginDomainAccountInfo *domainAccountInfo, 93 PluginAuthStatusInfo **authStatusInfo); 94 typedef PluginBussnessError* (*BindAccountFunc)(const PluginDomainAccountInfo *domainAccountInfo, const int32_t localId, 95 const int32_t callerLocalId); 96 typedef PluginBussnessError* (*UnbindAccountFunc)(const PluginDomainAccountInfo *domainAccountInfo); 97 typedef PluginBussnessError* (*UpdateAccountInfoFunc)(const PluginDomainAccountInfo *domainAccountInfo, 98 const PluginDomainAccountInfo *newDomainAccountInfo); 99 typedef PluginBussnessError* (*IsAccountTokenValidFunc)(const PluginDomainAccountInfo *domainAccountInfo, 100 const PluginUint8Vector *token, int32_t *isValid); 101 typedef PluginBussnessError* (*IsAuthenticationExpiredFunc)(const PluginDomainAccountInfo *domainAccountInfo, 102 const PluginUint8Vector *token, int32_t *isValid); 103 typedef PluginBussnessError* (*GetAccessTokenFunc)(const PluginGetDomainAccessTokenOptions *options, 104 PluginUint8Vector **accessToken); 105 typedef PluginBussnessError* (*SetAccountPolicyFunc)(const PluginDomainAccountPolicy *domainAccountPolicy); 106 typedef PluginBussnessError* (*GetServerConfigFunc)(const PluginString *serverConfigId, const int32_t callerLocalId, 107 PluginServerConfigInfo **serverConfigInfo); 108 109 enum PluginMethodEnum { 110 ADD_SERVER_CONFIG = 0, 111 REMOVE_SERVER_CONFIG, 112 GET_ACCOUNT_SERVER_CONFIG, 113 AUTH, 114 AUTH_WITH_POPUP, 115 AUTH_WITH_TOKEN, 116 GET_ACCOUNT_INFO, 117 GET_AUTH_STATUS_INFO, 118 BIND_ACCOUNT, 119 UNBIND_ACCOUNT, 120 IS_ACCOUNT_TOKEN_VALID, 121 GET_ACCESS_TOKEN, 122 GET_SERVER_CONFIG, 123 UPDATE_ACCOUNT_INFO, 124 IS_AUTHENTICATION_EXPIRED, 125 SET_ACCOUNT_POLICY, 126 //this is last just for count enum 127 COUNT, 128 }; 129 130 #ifdef __cplusplus 131 } 132 #endif 133 #endif // OS_ACCOUNT_INTERFACES_INNERKITS_DOMAIN_ACCOUNT_INCLUDE_DOMAIN_ACCOUNT_LIB_H