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 16import{AsyncCallback} from './basic'; 17declare namespace userIDM { 18 /** 19 * js @calss UserIdentityManager. 20 */ 21 class UserIdentityManager { 22 /** 23 * constructor. 24 * 25 * @return Constructor to get the userauth class instance. 26 */ 27 constructor(); 28 29 /** 30 * openSession. 31 * 32 * <p>Permissions required: {@code ohos.permission.MANAGE_USER_IDM} 33 * 34 * Start an IDM operation to obtain challenge value. 35 * A challenge value of 0 indicates that opensession failed. 36 * 37 * @return Uint8Array is success or fail. 38 */ 39 openSession() : Promise<Uint8Array>; 40 openSession(callback : AsyncCallback<Uint8Array>) : void; 41 42 /** 43 * addCredential. 44 * 45 * <p>Permissions required: {@code ohos.permission.MANAGE_USER_IDM} 46 * 47 * Add user credential information, pass in credential addition method and credential information 48 * (credential type, subtype, if adding user's non password credentials, pass in password authentication token), 49 * and get the result / acquireinfo callback. 50 * 51 * @param credentialInfo Incoming credential addition method and credential information 52 * (credential type, subtype, password authentication token). 53 * @param callback Get results / acquireinfo callback. 54 */ 55 addCredential(credentialInfo : CredentialInfo, callback : IIdmCallback) : void; 56 57 /** 58 * updateCredential. 59 * 60 * <p>Permissions required: {@code ohos.permission.MANAGE_USER_IDM} 61 * 62 * @param credentialInfo Incoming credential addition method and credential information 63 * (credential type, subtype, password authentication token). 64 * @param callback Get results / acquireinfo callback. 65 */ 66 updateCredential(credentialInfo:CredentialInfo, callback:IIdmCallback) : void; 67 68 /** 69 * closeSession. 70 * 71 * <p>Permissions required: {@code ohos.permission.MANAGE_USER_IDM} 72 * 73 * End an IDM operation. 74 */ 75 closeSession() : void; 76 77 /** 78 * cancel. 79 * 80 * <p>Permissions required: {@code ohos.permission.MANAGE_USER_IDM} 81 * 82 * Cancel entry and pass in challenge value. 83 * 84 * @param challenge challenge value. 85 */ 86 cancel(challenge : Uint8Array) : number; 87 88 /** 89 * delUser. 90 * 91 * <p>Permissions required: {@code ohos.permission.MANAGE_USER_IDM} 92 * 93 * Delete the user credential information, pass in the user password authentication token and callback, 94 * and obtain the deletion result through the callback. 95 * 96 * @param token User password authentication token. 97 * @param callback Get deletion result through callback. 98 */ 99 delUser(token : Uint8Array, callback : IIdmCallback) : void; 100 101 /** 102 * delCred. 103 * 104 * <p>Permissions required: {@code ohos.permission.MANAGE_USER_IDM} 105 * 106 * Delete the user credential information, pass in the credential id, password authentication token and callback, 107 * and obtain the deletion result through the callback. 108 * Only deleting non password credentials is supported. 109 * 110 * @param credentialId Credential index. 111 * @param token Password authentication token. 112 * @param callback Get deletion result through callback. 113 */ 114 delCred(credentialId : Uint8Array, token : Uint8Array, callback : IIdmCallback) : void; 115 116 /** 117 * getAuthInfo. 118 * 119 * <p>Permissions required: {@code ohos.permission.ACCESS_USER_IDM} 120 * 121 * @param authType Credential type. 122 * @param callback Returns all registered credential information of this type for the current user. 123 */ 124 getAuthInfo(callback : AsyncCallback<Array<EnrolledCredInfo>>,authType? : AuthType) : void; 125 getAuthInfo(authType? : AuthType) : Promise<Array<EnrolledCredInfo>>; 126 } 127 128 /** 129 * Credential information. 130 */ 131 interface CredentialInfo { 132 credType : AuthType; 133 credSubType : AuthSubType; 134 token : Uint8Array; 135 } 136 137 /** 138 * Return result code and additional information through callback / acquireinfo. 139 */ 140 interface IIdmCallback { 141 onResult:(result : number, extraInfo : RequestResult)=>void; 142 onAcquireInfo?:(module : number, acquire : number, extraInfo : any)=>void; 143 } 144 145 /** 146 * Add credential result: credential index value. 147 */ 148 interface RequestResult { 149 credentialId?:Uint8Array; 150 } 151 152 /** 153 * Registered credential information: credential index, 154 * credential type, subtype, credential template id. 155 */ 156 interface EnrolledCredInfo { 157 credentialId:Uint8Array; 158 authType:AuthType; 159 authSubType:AuthSubType; 160 templateId:Uint8Array; 161 } 162 163 /** 164 * Credential type for authentication. 165 */ 166 enum AuthType{ 167 /** 168 * Authentication type pin. 169 */ 170 PIN = 1, 171 /** 172 * Authentication type face. 173 */ 174 FACE = 2 175 } 176 177 /** 178 * Credential subtype. 179 */ 180 enum AuthSubType { 181 /** 182 * Authentication subtype six number pin. 183 */ 184 PIN_SIX = 10000, 185 /** 186 * Authentication subtype self defined number pin. 187 */ 188 PIN_NUMBER = 10001, 189 /** 190 * Authentication subtype mixed pin. 191 */ 192 PIN_MIXED = 10002, 193 /** 194 * Authentication subtype 2D face. 195 */ 196 FACE_2D = 20000, 197 /** 198 * Authentication subtype 3D face. 199 */ 200 FACE_3D = 20001 201 } 202} //namespace userIDM 203export default userIDM;