1/* 2 * Copyright (c) 2021-2023 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 * @file 18 * @kit BasicServicesKit 19 */ 20 21import type { AsyncCallback, Callback } from './@ohos.base'; 22import type Want from './@ohos.app.ability.Want'; 23import type rpc from './@ohos.rpc'; 24 25/** 26 * This module provides the capability to manage application accounts. 27 * 28 * @namespace appAccount 29 * @syscap SystemCapability.Account.AppAccount 30 * @since 7 31 */ 32declare namespace appAccount { 33 /** 34 * Obtains the AppAccountManager instance. 35 * 36 * @returns { AppAccountManager } Returns the instance of the AppAccountManager. 37 * @syscap SystemCapability.Account.AppAccount 38 * @since 7 39 */ 40 function createAppAccountManager(): AppAccountManager; 41 42 /** 43 * Provides methods for managing application accounts. 44 * 45 * @interface AppAccountManager 46 * @syscap SystemCapability.Account.AppAccount 47 * @since 7 48 */ 49 interface AppAccountManager { 50 /** 51 * Adds the account name and extra information of this application to the account management service. 52 * <p> 53 * Only the owner of the application account has the permission to call this method. 54 * 55 * @param { string } name - Indicates the name of the application account to add. 56 * @param { AsyncCallback<void> } callback - Asynchronous callback interface. 57 * @syscap SystemCapability.Account.AppAccount 58 * @since 7 59 * @deprecated since 9 60 * @useinstead appAccount.AppAccountManager#createAccount 61 */ 62 addAccount(name: string, callback: AsyncCallback<void>): void; 63 64 /** 65 * Adds the account name and extra information of this application to the account management service. 66 * <p> 67 * Only the owner of the application account has the permission to call this method. 68 * 69 * @param { string } name - Indicates the name of the application account to add. 70 * @param { string } extraInfo - Indicates the extra information of the application account to add. 71 * The extra information cannot be sensitive information of the application account. 72 * @param { AsyncCallback<void> } callback - Asynchronous callback interface. 73 * @syscap SystemCapability.Account.AppAccount 74 * @since 7 75 * @deprecated since 9 76 * @useinstead appAccount.AppAccountManager#createAccount 77 */ 78 addAccount(name: string, extraInfo: string, callback: AsyncCallback<void>): void; 79 80 /** 81 * Adds the account name and extra information of this application to the account management service. 82 * <p> 83 * Only the owner of the application account has the permission to call this method. 84 * 85 * @param { string } name - Indicates the name of the application account to add. 86 * @param { string } [extraInfo] - Indicates the extra information of the application account to add. 87 * The extra information cannot be sensitive information of the application account. 88 * @returns { Promise<void> } The promise returned by the function. 89 * @syscap SystemCapability.Account.AppAccount 90 * @since 7 91 * @deprecated since 9 92 * @useinstead appAccount.AppAccountManager#createAccount 93 */ 94 addAccount(name: string, extraInfo?: string): Promise<void>; 95 96 /** 97 * Creates the account name and extra information of this application to the account management service. 98 * <p> 99 * Only the owner of the application account has the permission to call this method. 100 * 101 * @param { string } name - Indicates the name of the application account to add. 102 * @param { AsyncCallback<void> } callback - Asynchronous callback interface. 103 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 104 * <br> 2. Incorrect parameter types. 105 * @throws { BusinessError } 12300001 - System service exception. 106 * @throws { BusinessError } 12300002 - Invalid name. 107 * @throws { BusinessError } 12300004 - Account already exists. 108 * @throws { BusinessError } 12300007 - The number of accounts reaches the upper limit. 109 * @syscap SystemCapability.Account.AppAccount 110 * @since 9 111 */ 112 createAccount(name: string, callback: AsyncCallback<void>): void; 113 114 /** 115 * Creates the account name and extra information of this application to the account management service. 116 * <p> 117 * Only the owner of the application account has the permission to call this method. 118 * 119 * @param { string } name - Indicates the name of the application account to add. 120 * @param { CreateAccountOptions } options - Indicates the extra information of the application account to add. 121 * The extra information cannot be sensitive information of the application account. 122 * @param { AsyncCallback<void> } callback - Asynchronous callback interface. 123 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 124 * <br> 2. Incorrect parameter types. 125 * @throws { BusinessError } 12300001 - System service exception. 126 * @throws { BusinessError } 12300002 - Invalid name or options. 127 * @throws { BusinessError } 12300004 - Account already exists. 128 * @throws { BusinessError } 12300007 - The number of accounts reaches the upper limit. 129 * @syscap SystemCapability.Account.AppAccount 130 * @since 9 131 */ 132 createAccount(name: string, options: CreateAccountOptions, callback: AsyncCallback<void>): void; 133 134 /** 135 * Creates the account name and extra information of this application to the account management service. 136 * <p> 137 * Only the owner of the application account has the permission to call this method. 138 * 139 * @param { string } name - Indicates the name of the application account to add. 140 * @param { CreateAccountOptions } [options] - Indicates the extra information of the application account to add. 141 * The extra information cannot be sensitive information of the application account. 142 * @returns { Promise<void> } The promise returned by the function. 143 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 144 * <br> 2. Incorrect parameter types. 145 * @throws { BusinessError } 12300001 - System service exception. 146 * @throws { BusinessError } 12300002 - Invalid name or options. 147 * @throws { BusinessError } 12300004 - Account already exists. 148 * @throws { BusinessError } 12300007 - The number of accounts reaches the upper limit. 149 * @syscap SystemCapability.Account.AppAccount 150 * @since 9 151 */ 152 createAccount(name: string, options?: CreateAccountOptions): Promise<void>; 153 154 /** 155 * Adds an application account of a specified owner implicitly. 156 * 157 * @param { string } owner - Indicates the account owner of your application or third-party applications. 158 * @param { string } authType - Indicates the authentication type. 159 * @param { object } options - Indicates the authenticator-specific options for the request. 160 * @param { AuthenticatorCallback } callback - Indicates the authenticator callback. 161 * @syscap SystemCapability.Account.AppAccount 162 * @since 8 163 * @deprecated since 9 164 * @useinstead appAccount.AppAccountManager#createAccountImplicitly 165 */ 166 addAccountImplicitly( 167 owner: string, 168 authType: string, 169 options: { [key: string]: any }, 170 callback: AuthenticatorCallback 171 ): void; 172 173 /** 174 * Creates an application account of a specified owner implicitly. 175 * 176 * @param { string } owner - Indicates the account owner of your application or third-party applications. 177 * @param { AuthCallback } callback - Indicates the authenticator callback. 178 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 179 * <br> 2. Incorrect parameter types. 180 * @throws { BusinessError } 12300001 - System service exception. 181 * @throws { BusinessError } 12300002 - Invalid owner. 182 * @throws { BusinessError } 12300007 - The number of accounts reaches the upper limit. 183 * @throws { BusinessError } 12300010 - Account service busy. 184 * @throws { BusinessError } 12300113 - Authenticator service not found. 185 * @throws { BusinessError } 12300114 - Authenticator service exception. 186 * @syscap SystemCapability.Account.AppAccount 187 * @since 9 188 */ 189 createAccountImplicitly(owner: string, callback: AuthCallback): void; 190 191 /** 192 * Creates an application account of a specified owner implicitly. 193 * 194 * @param { string } owner - Indicates the account owner of your application or third-party applications. 195 * @param { CreateAccountImplicitlyOptions } options - Indicates the authenticator-specific options for the request. 196 * @param { AuthCallback } callback - Indicates the authenticator callback. 197 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 198 * <br> 2. Incorrect parameter types. 199 * @throws { BusinessError } 12300001 - System service exception. 200 * @throws { BusinessError } 12300002 - Invalid owner or options. 201 * @throws { BusinessError } 12300007 - The number of accounts reaches the upper limit. 202 * @throws { BusinessError } 12300010 - Account service busy. 203 * @throws { BusinessError } 12300113 - Authenticator service not found. 204 * @throws { BusinessError } 12300114 - Authenticator service exception. 205 * @syscap SystemCapability.Account.AppAccount 206 * @since 9 207 */ 208 createAccountImplicitly(owner: string, options: CreateAccountImplicitlyOptions, callback: AuthCallback): void; 209 210 /** 211 * Deletes an application account from the account management service. 212 * <p> 213 * Only the owner of the application account has the permission to call this method. 214 * 215 * @param { string } name - Indicates the name of the application account to delete. 216 * @param { AsyncCallback<void> } callback - Asynchronous callback interface. 217 * @syscap SystemCapability.Account.AppAccount 218 * @since 7 219 * @deprecated since 9 220 * @useinstead appAccount.AppAccountManager#removeAccount 221 */ 222 deleteAccount(name: string, callback: AsyncCallback<void>): void; 223 224 /** 225 * Deletes an application account from the account management service. 226 * <p> 227 * Only the owner of the application account has the permission to call this method. 228 * 229 * @param { string } name - Indicates the name of the application account to delete. 230 * @returns { Promise<void> } The promise returned by the function. 231 * @syscap SystemCapability.Account.AppAccount 232 * @since 7 233 * @deprecated since 9 234 * @useinstead appAccount.AppAccountManager#removeAccount 235 */ 236 deleteAccount(name: string): Promise<void>; 237 238 /** 239 * Removes an application account from the account management service. 240 * <p> 241 * Only the owner of the application account has the permission to call this method. 242 * 243 * @param { string } name - Indicates the name of the application account to delete. 244 * @param { AsyncCallback<void> } callback - Asynchronous callback interface. 245 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 246 * <br> 2. Incorrect parameter types. 247 * @throws { BusinessError } 12300001 - System service exception. 248 * @throws { BusinessError } 12300002 - Invalid name. 249 * @throws { BusinessError } 12300003 - Account not found. 250 * @syscap SystemCapability.Account.AppAccount 251 * @since 9 252 */ 253 removeAccount(name: string, callback: AsyncCallback<void>): void; 254 255 /** 256 * Removes an application account from the account management service. 257 * <p> 258 * Only the owner of the application account has the permission to call this method. 259 * 260 * @param { string } name - Indicates the name of the application account to delete. 261 * @returns { Promise<void> } The promise returned by the function. 262 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 263 * <br> 2. Incorrect parameter types. 264 * @throws { BusinessError } 12300001 - System service exception. 265 * @throws { BusinessError } 12300002 - Invalid name. 266 * @throws { BusinessError } 12300003 - Account not found. 267 * @syscap SystemCapability.Account.AppAccount 268 * @since 9 269 */ 270 removeAccount(name: string): Promise<void>; 271 272 /** 273 * Disables a third-party application with the specified bundle name from 274 * accessing the given application account. 275 * 276 * @param { string } name - Indicates the name of the application account to disable access from 277 * the third-party application. 278 * @param { string } bundleName - Indicates the bundle name of the third-party application. 279 * @param { AsyncCallback<void> } callback - Asynchronous callback interface. 280 * @syscap SystemCapability.Account.AppAccount 281 * @since 7 282 * @deprecated since 9 283 * @useinstead appAccount.AppAccountManager#setAppAccess 284 */ 285 disableAppAccess(name: string, bundleName: string, callback: AsyncCallback<void>): void; 286 287 /** 288 * Disables a third-party application with the specified bundle name from 289 * accessing the given application account. 290 * 291 * @param { string } name - Indicates the name of the application account to disable access from 292 * the third-party application. 293 * @param { string } bundleName - Indicates the bundle name of the third-party application. 294 * @returns { Promise<void> } The promise returned by the function. 295 * @syscap SystemCapability.Account.AppAccount 296 * @since 7 297 * @deprecated since 9 298 * @useinstead appAccount.AppAccountManager#setAppAccess 299 */ 300 disableAppAccess(name: string, bundleName: string): Promise<void>; 301 302 /** 303 * Enables a third-party application with the specified bundle name to access the given application 304 * account for data query and listening. 305 * 306 * @param { string } name - Indicates the name of the application account. 307 * @param { string } bundleName - Indicates the bundle name of the third-party application. 308 * @param { AsyncCallback<void> } callback - Asynchronous callback interface. 309 * @syscap SystemCapability.Account.AppAccount 310 * @since 7 311 * @deprecated since 9 312 * @useinstead appAccount.AppAccountManager#setAppAccess 313 */ 314 enableAppAccess(name: string, bundleName: string, callback: AsyncCallback<void>): void; 315 316 /** 317 * Enables a third-party application with the specified bundle name to access the given application 318 * account for data query and listening. 319 * 320 * @param { string } name - Indicates the name of the application account. 321 * @param { string } bundleName - Indicates the bundle name of the third-party application. 322 * @returns { Promise<void> } The promise returned by the function. 323 * @syscap SystemCapability.Account.AppAccount 324 * @since 7 325 * @deprecated since 9 326 * @useinstead appAccount.AppAccountManager#setAppAccess 327 */ 328 enableAppAccess(name: string, bundleName: string): Promise<void>; 329 330 /** 331 * Sets a third-party application with the specified bundle name to access the given application 332 * account for data query and listening. 333 * 334 * @param { string } name - Indicates the name of the application account. 335 * @param { string } bundleName - Indicates the bundle name of the third-party application. 336 * @param { boolean } isAccessible - Indicates the accessibility flag, true for accessible, false for inaccessible. 337 * @param { AsyncCallback<void> } callback - Asynchronous callback interface. 338 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 339 * <br> 2. Incorrect parameter types. 340 * @throws { BusinessError } 12300001 - System service exception. 341 * @throws { BusinessError } 12300002 - Invalid name or bundleName. 342 * @throws { BusinessError } 12300003 - Account not found. 343 * @throws { BusinessError } 12400001 - Application not found. 344 * @syscap SystemCapability.Account.AppAccount 345 * @since 9 346 */ 347 setAppAccess(name: string, bundleName: string, isAccessible: boolean, callback: AsyncCallback<void>): void; 348 349 /** 350 * Sets a third-party application with the specified bundle name to access the given application 351 * account for data query and listening. 352 * 353 * @param { string } name - Indicates the name of the application account. 354 * @param { string } bundleName - Indicates the bundle name of the third-party application. 355 * @param { boolean } isAccessible - Indicates the accessibility flag, true for accessible, false for inaccessible. 356 * @returns { Promise<void> } The promise returned by the function. 357 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 358 * <br> 2. Incorrect parameter types. 359 * @throws { BusinessError } 12300001 - System service exception. 360 * @throws { BusinessError } 12300002 - Invalid name or bundleName. 361 * @throws { BusinessError } 12300003 - Account not found. 362 * @throws { BusinessError } 12400001 - Application not found. 363 * @syscap SystemCapability.Account.AppAccount 364 * @since 9 365 */ 366 setAppAccess(name: string, bundleName: string, isAccessible: boolean): Promise<void>; 367 368 /** 369 * Checks whether a third-party application with the specified bundle name is allowed to access 370 * the given application account for data query and listening. 371 * 372 * @param { string } name - Indicates the name of the application account. 373 * @param { string } bundleName - Indicates the bundle name of the third-party application. 374 * @param { AsyncCallback<boolean> } callback - Asynchronous callback interface. 375 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 376 * <br> 2. Incorrect parameter types. 377 * @throws { BusinessError } 12300001 - System service exception. 378 * @throws { BusinessError } 12300002 - Invalid name or bundleName. 379 * @throws { BusinessError } 12300003 - Account not found. 380 * @syscap SystemCapability.Account.AppAccount 381 * @since 9 382 */ 383 checkAppAccess(name: string, bundleName: string, callback: AsyncCallback<boolean>): void; 384 385 /** 386 * Checks whether a third-party application with the specified bundle name is allowed to access 387 * the given application account for data query and listening. 388 * 389 * @param { string } name - Indicates the name of the application account. 390 * @param { string } bundleName - Indicates the bundle name of the third-party application. 391 * @returns { Promise<boolean> } The promise returned by the function. 392 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 393 * <br> 2. Incorrect parameter types. 394 * @throws { BusinessError } 12300001 - System service exception. 395 * @throws { BusinessError } 12300002 - Invalid name or bundleName. 396 * @throws { BusinessError } 12300003 - Account not found. 397 * @syscap SystemCapability.Account.AppAccount 398 * @since 9 399 */ 400 checkAppAccess(name: string, bundleName: string): Promise<boolean>; 401 402 /** 403 * Checks whether a specified application account allows application data synchronization. 404 * <p> 405 * If the same OHOS account has logged in to multiple devices, these devices constitute a super device 406 * through the distributed networking. On the connected devices, you can call this method to check 407 * whether application data can be synchronized. 408 * <p> 409 * 410 * @permission ohos.permission.DISTRIBUTED_DATASYNC 411 * @param { string } name - Indicates the name of the application account. 412 * @param { AsyncCallback<boolean> } callback - Asynchronous callback interface. 413 * @syscap SystemCapability.Account.AppAccount 414 * @since 7 415 * @deprecated since 9 416 * @useinstead appAccount.AppAccountManager#checkDataSyncEnabled 417 */ 418 checkAppAccountSyncEnable(name: string, callback: AsyncCallback<boolean>): void; 419 420 /** 421 * Checks whether a specified application account allows application data synchronization. 422 * <p> 423 * If the same OHOS account has logged in to multiple devices, these devices constitute a super device 424 * through the distributed networking. On the connected devices, you can call this method to check 425 * whether application data can be synchronized. 426 * <p> 427 * 428 * @permission ohos.permission.DISTRIBUTED_DATASYNC 429 * @param { string } name - Indicates the name of the application account. 430 * @returns { Promise<boolean> } Returns {@code true} if application data synchronization is allowed; returns {@code false} otherwise. 431 * @syscap SystemCapability.Account.AppAccount 432 * @since 7 433 * @deprecated since 9 434 * @useinstead appAccount.AppAccountManager#checkDataSyncEnabled 435 */ 436 checkAppAccountSyncEnable(name: string): Promise<boolean>; 437 438 /** 439 * Checks whether application data synchronization is enabled for the specified account. 440 * <p> 441 * If the same OHOS account has logged in to multiple devices, these devices constitute a super device 442 * through the distributed networking. On the connected devices, you can call this method to check 443 * whether application data can be synchronized. 444 * <p> 445 * 446 * @permission ohos.permission.DISTRIBUTED_DATASYNC 447 * @param { string } name - Indicates the name of the application account. 448 * @param { AsyncCallback<boolean> } callback - Asynchronous callback interface. 449 * @throws { BusinessError } 201 - Permission denied. 450 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 451 * <br> 2. Incorrect parameter types. 452 * @throws { BusinessError } 12300001 - System service exception. 453 * @throws { BusinessError } 12300002 - Invalid name. 454 * @throws { BusinessError } 12300003 - Account not found. 455 * @syscap SystemCapability.Account.AppAccount 456 * @since 9 457 */ 458 checkDataSyncEnabled(name: string, callback: AsyncCallback<boolean>): void; 459 460 /** 461 * Checks whether application data synchronization is enabled for the specified account. 462 * <p> 463 * If the same OHOS account has logged in to multiple devices, these devices constitute a super device 464 * through the distributed networking. On the connected devices, you can call this method to check 465 * whether application data can be synchronized. 466 * <p> 467 * 468 * @permission ohos.permission.DISTRIBUTED_DATASYNC 469 * @param { string } name - Indicates the name of the application account. 470 * @returns { Promise<boolean> } Returns {@code true} if application data synchronization is allowed; returns {@code false} otherwise. 471 * @throws { BusinessError } 201 - Permission denied. 472 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 473 * <br> 2. Incorrect parameter types. 474 * @throws { BusinessError } 12300001 - System service exception. 475 * @throws { BusinessError } 12300002 - Invalid name. 476 * @throws { BusinessError } 12300003 - Account not found. 477 * @syscap SystemCapability.Account.AppAccount 478 * @since 9 479 */ 480 checkDataSyncEnabled(name: string): Promise<boolean>; 481 482 /** 483 * Sets the credential for this application account. 484 * 485 * @param { string } name - Indicates the name of the application account. 486 * @param { string } credentialType - Indicates the type of the credential to set. 487 * @param { string } credential - Indicates the credential to set. 488 * @param { AsyncCallback<void> } callback - Asynchronous callback interface. 489 * @syscap SystemCapability.Account.AppAccount 490 * @since 7 491 * @deprecated since 9 492 * @useinstead appAccount.AppAccountManager#setCredential 493 */ 494 setAccountCredential(name: string, credentialType: string, credential: string, callback: AsyncCallback<void>): void; 495 496 /** 497 * Sets the credential for this application account. 498 * 499 * @param { string } name - Indicates the name of the application account. 500 * @param { string } credentialType - Indicates the type of the credential to set. 501 * @param { string } credential - Indicates the credential to set. 502 * @returns { Promise<void> } The promise returned by the function. 503 * @syscap SystemCapability.Account.AppAccount 504 * @since 7 505 * @deprecated since 9 506 * @useinstead appAccount.AppAccountManager#setCredential 507 */ 508 setAccountCredential(name: string, credentialType: string, credential: string): Promise<void>; 509 510 /** 511 * Sets the credential for this application account. 512 * 513 * @param { string } name - Indicates the name of the application account. 514 * @param { string } credentialType - Indicates the type of the credential to set. 515 * @param { string } credential - Indicates the credential to set. 516 * @param { AsyncCallback<void> } callback - Asynchronous callback interface. 517 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 518 * <br> 2. Incorrect parameter types. 519 * @throws { BusinessError } 12300001 - System service exception. 520 * @throws { BusinessError } 12300002 - Invalid name, credentialType or credential. 521 * @throws { BusinessError } 12300003 - Account not found. 522 * @syscap SystemCapability.Account.AppAccount 523 * @since 9 524 */ 525 setCredential(name: string, credentialType: string, credential: string, callback: AsyncCallback<void>): void; 526 527 /** 528 * Sets the credential for this application account. 529 * 530 * @param { string } name - Indicates the name of the application account. 531 * @param { string } credentialType - Indicates the type of the credential to set. 532 * @param { string } credential - Indicates the credential to set. 533 * @returns { Promise<void> } The promise returned by the function. 534 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 535 * <br> 2. Incorrect parameter types. 536 * @throws { BusinessError } 12300001 - System service exception. 537 * @throws { BusinessError } 12300002 - Invalid name, credentialType or credential. 538 * @throws { BusinessError } 12300003 - Account not found. 539 * @syscap SystemCapability.Account.AppAccount 540 * @since 9 541 */ 542 setCredential(name: string, credentialType: string, credential: string): Promise<void>; 543 544 /** 545 * Sets extra information for this application account. 546 * <p> 547 * You can call this method when you forget the extra information of your application account or 548 * need to modify the extra information. 549 * 550 * @param { string } name - Indicates the name of the application account. 551 * @param { string } extraInfo - Indicates the extra information to set. 552 * @param { AsyncCallback<void> } callback - Asynchronous callback interface. 553 * @syscap SystemCapability.Account.AppAccount 554 * @since 7 555 * @deprecated since 9 556 * @useinstead appAccount.AppAccountManager#setCustomData 557 */ 558 setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback<void>): void; 559 560 /** 561 * Sets extra information for this application account. 562 * <p> 563 * You can call this method when you forget the extra information of your application account or 564 * need to modify the extra information. 565 * 566 * @param { string } name - Indicates the name of the application account. 567 * @param { string } extraInfo - Indicates the extra information to set. 568 * @returns { Promise<void> } The promise returned by the function. 569 * @syscap SystemCapability.Account.AppAccount 570 * @since 7 571 * @deprecated since 9 572 * @useinstead appAccount.AppAccountManager#setCustomData 573 */ 574 setAccountExtraInfo(name: string, extraInfo: string): Promise<void>; 575 576 /** 577 * Sets whether a specified application account allows application data synchronization. 578 * <p> 579 * If the same OHOS account has logged in to multiple devices, these devices constitute a super device 580 * through the distributed networking. On the connected devices, you can call this method to set whether to 581 * allow cross-device data synchronization. If synchronization is allowed, application data can be synchronized 582 * among these devices in the event of any changes related to the application account. 583 * If synchronization is not allowed, the application data is stored only on the local device. 584 * <p> 585 * <b>Application account-related changes</b>: adding or deleting an application account, setting extra 586 * information (such as updating a token), and setting data associated with this application account 587 * <p> 588 * <b>Application data that can be synchronized</b>: application account name, token, 589 * and data associated with this application account 590 * <p> 591 * 592 * @permission ohos.permission.DISTRIBUTED_DATASYNC 593 * @param { string } name - Indicates the name of the application account. 594 * @param { boolean } isEnable - Specifies whether to allow application data synchronization. 595 * @param { AsyncCallback<void> } callback - Asynchronous callback interface. 596 * @syscap SystemCapability.Account.AppAccount 597 * @since 7 598 * @deprecated since 9 599 * @useinstead appAccount.AppAccountManager#setDataSyncEnabled 600 */ 601 setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback<void>): void; 602 603 /** 604 * Sets whether a specified application account allows application data synchronization. 605 * <p> 606 * If the same OHOS account has logged in to multiple devices, these devices constitute a super device 607 * through the distributed networking. On the connected devices, you can call this method to set whether to 608 * allow cross-device data synchronization. If synchronization is allowed, application data can be synchronized 609 * among these devices in the event of any changes related to the application account. 610 * If synchronization is not allowed, the application data is stored only on the local device. 611 * <p> 612 * <b>Application account-related changes</b>: adding or deleting an application account, setting extra 613 * information (such as updating a token), and setting data associated with this application account 614 * <p> 615 * <b>Application data that can be synchronized</b>: application account name, token, 616 * and data associated with this application account 617 * <p> 618 * 619 * @permission ohos.permission.DISTRIBUTED_DATASYNC 620 * @param { string } name - Indicates the name of the application account. 621 * @param { boolean } isEnable - Specifies whether to allow application data synchronization. 622 * @returns { Promise<void> } The promise returned by the function. 623 * @syscap SystemCapability.Account.AppAccount 624 * @since 7 625 * @deprecated since 9 626 * @useinstead appAccount.AppAccountManager#setDataSyncEnabled 627 */ 628 setAppAccountSyncEnable(name: string, isEnable: boolean): Promise<void>; 629 630 /** 631 * Sets whether a specified application account enables application data synchronization. 632 * <p> 633 * If the same OHOS account has logged in to multiple devices, these devices constitute a super device 634 * through the distributed networking. On the connected devices, you can call this method to set whether to 635 * enable cross-device data synchronization. If synchronization is enabled, application data can be synchronized 636 * among these devices in the event of any changes related to the application account. 637 * If synchronization is not enabled, the application data is stored only on the local device. 638 * <p> 639 * <b>Application account-related changes</b>: adding or deleting an application account, setting extra 640 * information (such as updating a token), and setting data associated with this application account 641 * <p> 642 * <b>Application data that can be synchronized</b>: application account name, token, 643 * and data associated with this application account 644 * <p> 645 * 646 * @permission ohos.permission.DISTRIBUTED_DATASYNC 647 * @param { string } name - Indicates the name of the application account. 648 * @param { boolean } isEnabled - Specifies whether to enable application data synchronization. 649 * @param { AsyncCallback<void> } callback - Asynchronous callback interface. 650 * @throws { BusinessError } 201 - Permission denied. 651 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 652 * <br> 2. Incorrect parameter types. 653 * @throws { BusinessError } 12300001 - System service exception. 654 * @throws { BusinessError } 12300002 - Invalid name. 655 * @throws { BusinessError } 12300003 - Account not found. 656 * @syscap SystemCapability.Account.AppAccount 657 * @since 9 658 */ 659 setDataSyncEnabled(name: string, isEnabled: boolean, callback: AsyncCallback<void>): void; 660 661 /** 662 * Sets whether a specified application account enables application data synchronization. 663 * <p> 664 * If the same OHOS account has logged in to multiple devices, these devices constitute a super device 665 * through the distributed networking. On the connected devices, you can call this method to set whether to 666 * enable cross-device data synchronization. If synchronization is enabled, application data can be synchronized 667 * among these devices in the event of any changes related to the application account. 668 * If synchronization is not enabled, the application data is stored only on the local device. 669 * <p> 670 * <b>Application account-related changes</b>: adding or deleting an application account, setting extra 671 * information (such as updating a token), and setting data associated with this application account 672 * <p> 673 * <b>Application data that can be synchronized</b>: application account name, token, 674 * and data associated with this application account 675 * <p> 676 * 677 * @permission ohos.permission.DISTRIBUTED_DATASYNC 678 * @param { string } name - Indicates the name of the application account. 679 * @param { boolean } isEnabled - Specifies whether to enable application data synchronization. 680 * @returns { Promise<void> } The promise returned by the function. 681 * @throws { BusinessError } 201 - Permission denied. 682 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 683 * <br> 2. Incorrect parameter types. 684 * @throws { BusinessError } 12300001 - System service exception. 685 * @throws { BusinessError } 12300002 - Invalid name. 686 * @throws { BusinessError } 12300003 - Account not found. 687 * @syscap SystemCapability.Account.AppAccount 688 * @since 9 689 */ 690 setDataSyncEnabled(name: string, isEnabled: boolean): Promise<void>; 691 692 /** 693 * Sets data associated with this application account. 694 * 695 * @param { string } name - Indicates the name of the application account. 696 * @param { string } key - Indicates the key of the data to set. The key can be customized. 697 * @param { string } value - Indicates the value of the data to set. 698 * @param { AsyncCallback<void> } callback - Asynchronous callback interface. 699 * @syscap SystemCapability.Account.AppAccount 700 * @since 7 701 * @deprecated since 9 702 * @useinstead appAccount.AppAccountManager#setCustomData 703 */ 704 setAssociatedData(name: string, key: string, value: string, callback: AsyncCallback<void>): void; 705 706 /** 707 * Sets data associated with this application account. 708 * 709 * @param { string } name - Indicates the name of the application account. 710 * @param { string } key - Indicates the key of the data to set. The key can be customized. 711 * @param { string } value - Indicates the value of the data to set. 712 * @returns { Promise<void> } The promise returned by the function. 713 * @syscap SystemCapability.Account.AppAccount 714 * @since 7 715 * @deprecated since 9 716 * @useinstead appAccount.AppAccountManager#setCustomData 717 */ 718 setAssociatedData(name: string, key: string, value: string): Promise<void>; 719 720 /** 721 * Sets data associated with this application account. 722 * 723 * @param { string } name - Indicates the name of the application account. 724 * @param { string } key - Indicates the key of the data to set. The key can be customized. 725 * @param { string } value - Indicates the value of the data to set. 726 * @param { AsyncCallback<void> } callback - Asynchronous callback interface. 727 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 728 * <br> 2. Incorrect parameter types. 729 * @throws { BusinessError } 12300001 - System service exception. 730 * @throws { BusinessError } 12300002 - Invalid name, key or value. 731 * @throws { BusinessError } 12300003 - Account not found. 732 * @throws { BusinessError } 12400003 - The number of custom data reaches the upper limit. 733 * @syscap SystemCapability.Account.AppAccount 734 * @since 9 735 */ 736 setCustomData(name: string, key: string, value: string, callback: AsyncCallback<void>): void; 737 738 /** 739 * Sets data associated with this application account. 740 * 741 * @param { string } name - Indicates the name of the application account. 742 * @param { string } key - Indicates the key of the data to set. The key can be customized. 743 * @param { string } value - Indicates the value of the data to set. 744 * @returns { Promise<void> } The promise returned by the function. 745 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 746 * <br> 2. Incorrect parameter types. 747 * @throws { BusinessError } 12300001 - System service exception. 748 * @throws { BusinessError } 12300002 - Invalid name, key or value. 749 * @throws { BusinessError } 12300003 - Account not found. 750 * @throws { BusinessError } 12400003 - The number of custom data reaches the upper limit. 751 * @syscap SystemCapability.Account.AppAccount 752 * @since 9 753 */ 754 setCustomData(name: string, key: string, value: string): Promise<void>; 755 756 /** 757 * Obtains information about all accessible accounts. 758 * This method applies to the following accounts: 759 * <br> Accounts of this application. 760 * <br> Accounts of third-party applications. To obtain such information, 761 * <br> your application must have gained authorization from the third-party applications. 762 * 763 * @permission ohos.permission.GET_ALL_APP_ACCOUNTS 764 * @param { AsyncCallback<Array<AppAccountInfo>> } callback - Asynchronous callback interface. 765 * @syscap SystemCapability.Account.AppAccount 766 * @since 7 767 * @deprecated since 9 768 * @useinstead appAccount.AppAccountManager#getAllAccounts 769 */ 770 getAllAccessibleAccounts(callback: AsyncCallback<Array<AppAccountInfo>>): void; 771 772 /** 773 * Obtains information about all accessible accounts. 774 * This method applies to the following accounts: 775 * <br> Accounts of this application. 776 * <br> Accounts of third-party applications. To obtain such information, 777 * <br> your application must have gained authorization from the third-party applications. 778 * 779 * @permission ohos.permission.GET_ALL_APP_ACCOUNTS 780 * @returns { Promise<Array<AppAccountInfo>> } Returns a list of application accounts. 781 * @syscap SystemCapability.Account.AppAccount 782 * @since 7 783 * @deprecated since 9 784 * @useinstead appAccount.AppAccountManager#getAllAccounts 785 */ 786 getAllAccessibleAccounts(): Promise<Array<AppAccountInfo>>; 787 788 /** 789 * Obtains information about all accessible accounts. 790 * This method applies to the following accounts: 791 * <br> Accounts of this application. 792 * <br> Accounts of third-party applications. To obtain such information, 793 * <br> your application must have gained authorization from the third-party applications or 794 * <br> have gained the ohos.permission.GET_ALL_APP_ACCOUNTS permission. 795 * 796 * @param { AsyncCallback<Array<AppAccountInfo>> } callback - Asynchronous callback interface. Returns a list of application accounts. 797 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 798 * <br> 2. Incorrect parameter types. 799 * @throws { BusinessError } 12300001 - System service exception. 800 * @syscap SystemCapability.Account.AppAccount 801 * @since 9 802 */ 803 getAllAccounts(callback: AsyncCallback<Array<AppAccountInfo>>): void; 804 805 /** 806 * Obtains information about all accessible accounts. 807 * This method applies to the following accounts: 808 * <br> Accounts of this application. 809 * <br> Accounts of third-party applications. To obtain such information, 810 * <br> your application must have gained authorization from the third-party applications or 811 * <br> have gained the ohos.permission.GET_ALL_APP_ACCOUNTS permission. 812 * 813 * @returns { Promise<Array<AppAccountInfo>> } Returns a list of application accounts. 814 * @throws { BusinessError } 12300001 - System service exception. 815 * @syscap SystemCapability.Account.AppAccount 816 * @since 9 817 */ 818 getAllAccounts(): Promise<Array<AppAccountInfo>>; 819 820 /** 821 * Obtains information about all accounts of a specified account owner. 822 * This method applies to the following accounts: 823 * <br> Accounts of this application. 824 * <br> Accounts of third-party applications. To obtain such information, 825 * <br> your application must have gained authorization from the third-party applications. 826 * 827 * @permission ohos.permission.GET_ALL_APP_ACCOUNTS 828 * @param { string } owner - Indicates the account owner of your application or third-party applications. 829 * @param { AsyncCallback<Array<AppAccountInfo>> } callback - Asynchronous callback interface. Returns a list of application accounts. 830 * @syscap SystemCapability.Account.AppAccount 831 * @since 7 832 * @deprecated since 9 833 * @useinstead appAccount.AppAccountManager#getAccountsByOwner 834 */ 835 getAllAccounts(owner: string, callback: AsyncCallback<Array<AppAccountInfo>>): void; 836 837 /** 838 * Obtains information about all accounts of a specified account owner. 839 * This method applies to the following accounts: 840 * <br> Accounts of this application. 841 * <br> Accounts of third-party applications. To obtain such information, 842 * <br> your application must have gained authorization from the third-party applications. 843 * 844 * @permission ohos.permission.GET_ALL_APP_ACCOUNTS 845 * @param { string } owner - Indicates the account owner of your application or third-party applications. 846 * @returns { Promise<Array<AppAccountInfo>> } Returns a list of application accounts. 847 * @syscap SystemCapability.Account.AppAccount 848 * @since 7 849 * @deprecated since 9 850 * @useinstead appAccount.AppAccountManager#getAccountsByOwner 851 */ 852 getAllAccounts(owner: string): Promise<Array<AppAccountInfo>>; 853 854 /** 855 * Gets information about all accounts of a specified account owner. 856 * This method applies to the following accounts: 857 * <br> Accounts of this application. 858 * <br> Accounts of third-party applications. To obtain such information, 859 * <br> your application must have gained authorization from the third-party applications or 860 * <br> have gained the ohos.permission.GET_ALL_APP_ACCOUNTS permission. 861 * 862 * @param { string } owner - Indicates the account owner of your application or third-party applications. 863 * @param { AsyncCallback<Array<AppAccountInfo>> } callback - Asynchronous callback interface. Returns a list of application accounts. 864 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 865 * <br> 2. Incorrect parameter types. 866 * @throws { BusinessError } 12300001 - System service exception. 867 * @throws { BusinessError } 12300002 - Invalid owner. 868 * @throws { BusinessError } 12400001 - Application not found. 869 * @syscap SystemCapability.Account.AppAccount 870 * @since 9 871 */ 872 getAccountsByOwner(owner: string, callback: AsyncCallback<Array<AppAccountInfo>>): void; 873 874 /** 875 * Gets information about all accounts of a specified account owner. 876 * This method applies to the following accounts: 877 * <br> Accounts of this application. 878 * <br> Accounts of third-party applications. To obtain such information, 879 * <br> your application must have gained authorization from the third-party applications or 880 * <br> have gained the ohos.permission.GET_ALL_APP_ACCOUNTS permission. 881 * 882 * @param { string } owner - Indicates the account owner of your application or third-party applications. 883 * @returns { Promise<Array<AppAccountInfo>> } Returns a list of application accounts. 884 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 885 * <br> 2. Incorrect parameter types. 886 * @throws { BusinessError } 12300001 - System service exception. 887 * @throws { BusinessError } 12300002 - Invalid owner. 888 * @throws { BusinessError } 12400001 - Application not found. 889 * @syscap SystemCapability.Account.AppAccount 890 * @since 9 891 */ 892 getAccountsByOwner(owner: string): Promise<Array<AppAccountInfo>>; 893 894 /** 895 * Obtains the credential of this application account. 896 * 897 * @param { string } name - Indicates the name of the application account. 898 * @param { string } credentialType - Indicates the type of the credential to obtain. 899 * @param { AsyncCallback<string> } callback - Asynchronous callback interface. Returns the credential of the application account. 900 * @syscap SystemCapability.Account.AppAccount 901 * @since 7 902 * @deprecated since 9 903 * @useinstead appAccount.AppAccountManager#getCredential 904 */ 905 getAccountCredential(name: string, credentialType: string, callback: AsyncCallback<string>): void; 906 907 /** 908 * Obtains the credential of this application account. 909 * 910 * @param { string } name - Indicates the name of the application account. 911 * @param { string } credentialType - Indicates the type of the credential to obtain. 912 * @returns { Promise<string> } Returns the credential of the application account. 913 * @syscap SystemCapability.Account.AppAccount 914 * @since 7 915 * @deprecated since 9 916 * @useinstead appAccount.AppAccountManager#getCredential 917 */ 918 getAccountCredential(name: string, credentialType: string): Promise<string>; 919 920 /** 921 * Obtains the credential of this application account. 922 * 923 * @param { string } name - Indicates the name of the application account. 924 * @param { string } credentialType - Indicates the type of the credential to obtain. 925 * @param { AsyncCallback<string> } callback - Asynchronous callback interface. Returns the credential of the application account. 926 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 927 * <br> 2. Incorrect parameter types. 928 * @throws { BusinessError } 12300001 - System service exception. 929 * @throws { BusinessError } 12300002 - Invalid name or credentialType. 930 * @throws { BusinessError } 12300003 - Account not found. 931 * @throws { BusinessError } 12300102 - Credential not found. 932 * @syscap SystemCapability.Account.AppAccount 933 * @since 9 934 */ 935 getCredential(name: string, credentialType: string, callback: AsyncCallback<string>): void; 936 937 /** 938 * Obtains the credential of this application account. 939 * 940 * @param { string } name - Indicates the name of the application account. 941 * @param { string } credentialType - Indicates the type of the credential to obtain. 942 * @returns { Promise<string> } Returns the credential of the application account. 943 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 944 * <br> 2. Incorrect parameter types. 945 * @throws { BusinessError } 12300001 - System service exception. 946 * @throws { BusinessError } 12300002 - Invalid name or credentialType. 947 * @throws { BusinessError } 12300003 - Account not found. 948 * @throws { BusinessError } 12300102 - Credential not found. 949 * @syscap SystemCapability.Account.AppAccount 950 * @since 9 951 */ 952 getCredential(name: string, credentialType: string): Promise<string>; 953 954 /** 955 * Obtains extra information of this application account. 956 * 957 * @param { string } name - Indicates the name of the application account. 958 * @param { AsyncCallback<string> } callback - Asynchronous callback interface. 959 * Returns the extra information of the account; returns {@code null} in other scenarios, 960 * for example, if the account does not exist. 961 * @syscap SystemCapability.Account.AppAccount 962 * @since 7 963 * @deprecated since 9 964 * @useinstead appAccount.AppAccountManager#getCustomData 965 */ 966 getAccountExtraInfo(name: string, callback: AsyncCallback<string>): void; 967 968 /** 969 * Obtains extra information of this application account. 970 * 971 * @param { string } name - Indicates the name of the application account. 972 * @returns { Promise<string> } Returns the extra information of the account; returns {@code null} in other scenarios, 973 * for example, if the account does not exist. 974 * @syscap SystemCapability.Account.AppAccount 975 * @since 7 976 * @deprecated since 9 977 * @useinstead appAccount.AppAccountManager#getCustomData 978 */ 979 getAccountExtraInfo(name: string): Promise<string>; 980 981 /** 982 * Obtains data associated with this application account. 983 * 984 * @param { string } name - Indicates the name of the application account. 985 * @param { string } key - Indicates the key of the data to obtain. 986 * @param { AsyncCallback<string> } callback - Asynchronous callback interface. Returns the associated data of the application account. 987 * @syscap SystemCapability.Account.AppAccount 988 * @since 7 989 * @deprecated since 9 990 * @useinstead appAccount.AppAccountManager#getCustomData 991 */ 992 getAssociatedData(name: string, key: string, callback: AsyncCallback<string>): void; 993 994 /** 995 * Obtains data associated with this application account. 996 * 997 * @param { string } name - Indicates the name of the application account. 998 * @param { string } key - Indicates the key of the data to obtain. 999 * @returns { Promise<string> } Returns the associated data of the application account. 1000 * @syscap SystemCapability.Account.AppAccount 1001 * @since 7 1002 * @deprecated since 9 1003 * @useinstead appAccount.AppAccountManager#getCustomData 1004 */ 1005 getAssociatedData(name: string, key: string): Promise<string>; 1006 1007 /** 1008 * Obtains data associated with this application account. 1009 * 1010 * @param { string } name - Indicates the name of the application account. 1011 * @param { string } key - Indicates the key of the data to obtain. 1012 * @param { AsyncCallback<string> } callback - Asynchronous callback interface. Returns the associated data of the application account. 1013 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1014 * <br> 2. Incorrect parameter types. 1015 * @throws { BusinessError } 12300001 - System service exception. 1016 * @throws { BusinessError } 12300002 - Invalid name or key. 1017 * @throws { BusinessError } 12300003 - Account not found. 1018 * @throws { BusinessError } 12400002 - Custom data not found. 1019 * @syscap SystemCapability.Account.AppAccount 1020 * @since 9 1021 */ 1022 getCustomData(name: string, key: string, callback: AsyncCallback<string>): void; 1023 1024 /** 1025 * Obtains data associated with this application account. 1026 * 1027 * @param { string } name - Indicates the name of the application account. 1028 * @param { string } key - Indicates the key of the data to obtain. 1029 * @returns { Promise<string> } Returns the associated data of the application account. 1030 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1031 * <br> 2. Incorrect parameter types. 1032 * @throws { BusinessError } 12300001 - System service exception. 1033 * @throws { BusinessError } 12300002 - Invalid name or key. 1034 * @throws { BusinessError } 12300003 - Account not found. 1035 * @throws { BusinessError } 12400002 - Custom data not found 1036 * @syscap SystemCapability.Account.AppAccount 1037 * @since 9 1038 */ 1039 getCustomData(name: string, key: string): Promise<string>; 1040 1041 /** 1042 * Obtains data associated with the specified account synchronously. 1043 * 1044 * @param { string } name - Indicates the name of the application account. 1045 * @param { string } key - Indicates the key of the data to obtain. 1046 * @returns { string } Returns the associated data of the application account. 1047 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1048 * <br> 2. Incorrect parameter types. 1049 * @throws { BusinessError } 12300001 - System service exception. 1050 * @throws { BusinessError } 12300002 - Invalid name or key. 1051 * @throws { BusinessError } 12300003 - Account not found. 1052 * @throws { BusinessError } 12400002 - Custom data not found. 1053 * @syscap SystemCapability.Account.AppAccount 1054 * @since 9 1055 */ 1056 getCustomDataSync(name: string, key: string): string; 1057 1058 /** 1059 * Subscribes to the change events of accounts of the specified owners. 1060 * <p> 1061 * When the account owner updates the account, the subscriber will receive a notification 1062 * about the account change event. 1063 * 1064 * @param { 'change' } type - Event type. 1065 * @param { Array<string> } owners - Indicates the account owners, which are specified 1066 * by {@link AppAccount#AppAccount(String name, String owner)}. 1067 * @param { Callback<Array<AppAccountInfo>> } callback - Asynchronous callback interface. 1068 * @syscap SystemCapability.Account.AppAccount 1069 * @since 7 1070 * @deprecated since 9 1071 * @useinstead appAccount.AppAccountManager#on 1072 */ 1073 on(type: 'change', owners: Array<string>, callback: Callback<Array<AppAccountInfo>>): void; 1074 1075 /** 1076 * Subscribes to the change events of accounts of the specified owners. 1077 * <p> 1078 * When the account owner updates the account, the subscriber will receive a notification 1079 * about the account change event. 1080 * 1081 * @param { 'accountChange' } type - Event type. 1082 * @param { Array<string> } owners - Indicates the account owners, which are specified 1083 * by {@link AppAccount#AppAccount(String name, String owner)}. 1084 * @param { Callback<Array<AppAccountInfo>> } callback - Asynchronous callback interface. 1085 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1086 * <br> 2. Incorrect parameter types. 1087 * @throws { BusinessError } 12300001 - System service exception. 1088 * @throws { BusinessError } 12300002 - Invalid type or owners. 1089 * @throws { BusinessError } 12400001 - Application not found. 1090 * @syscap SystemCapability.Account.AppAccount 1091 * @since 9 1092 */ 1093 on(type: 'accountChange', owners: Array<string>, callback: Callback<Array<AppAccountInfo>>): void; 1094 1095 /** 1096 * Unsubscribes from account events. 1097 * 1098 * @param { 'change' } type - Event type. 1099 * @param { Callback<Array<AppAccountInfo>> } [callback] - Asynchronous callback interface. 1100 * @syscap SystemCapability.Account.AppAccount 1101 * @since 7 1102 * @deprecated since 9 1103 * @useinstead appAccount.AppAccountManager#off 1104 */ 1105 off(type: 'change', callback?: Callback<Array<AppAccountInfo>>): void; 1106 1107 /** 1108 * Unsubscribes from account events. 1109 * 1110 * @param { 'accountChange' } type - Event type. 1111 * @param { Callback<Array<AppAccountInfo>> } [callback] - Asynchronous callback interface. 1112 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1113 * <br> 2. Incorrect parameter types. 1114 * @throws { BusinessError } 12300001 - System service exception. 1115 * @throws { BusinessError } 12300002 - Invalid type. 1116 * @syscap SystemCapability.Account.AppAccount 1117 * @since 9 1118 */ 1119 off(type: 'accountChange', callback?: Callback<Array<AppAccountInfo>>): void; 1120 1121 /** 1122 * Authenticates an application account to get an oauth token. 1123 * 1124 * @param { string } name - Indicates the account name of your application or third-party applications. 1125 * @param { string } owner - Indicates the account owner of your application or third-party applications. 1126 * @param { string } authType - Indicates the authentication type. 1127 * @param { object } options - Indicates the authenticator-specific options for the request. 1128 * @param { AuthenticatorCallback } callback - Indicates the authenticator callback. 1129 * @syscap SystemCapability.Account.AppAccount 1130 * @since 8 1131 * @deprecated since 9 1132 * @useinstead appAccount.AppAccountManager#auth 1133 */ 1134 authenticate( 1135 name: string, 1136 owner: string, 1137 authType: string, 1138 options: { [key: string]: any }, 1139 callback: AuthenticatorCallback 1140 ): void; 1141 1142 /** 1143 * Authenticates an application account to get an auth token. 1144 * 1145 * @param { string } name - Indicates the account name of your application or third-party applications. 1146 * @param { string } owner - Indicates the account owner of your application or third-party applications. 1147 * @param { string } authType - Indicates the authentication type. 1148 * @param { AuthCallback } callback - Indicates the authenticator callback. 1149 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1150 * <br> 2. Incorrect parameter types. 1151 * @throws { BusinessError } 12300001 - System service exception. 1152 * @throws { BusinessError } 12300002 - Invalid name, owner or authType. 1153 * @throws { BusinessError } 12300003 - Account not found. 1154 * @throws { BusinessError } 12300010 - Account service busy. 1155 * @throws { BusinessError } 12300113 - Authenticator service not found. 1156 * @throws { BusinessError } 12300114 - Authenticator service exception. 1157 * @syscap SystemCapability.Account.AppAccount 1158 * @since 9 1159 */ 1160 auth(name: string, owner: string, authType: string, callback: AuthCallback): void; 1161 1162 /** 1163 * Authenticates an application account to get an auth token. 1164 * 1165 * @param { string } name - Indicates the account name of your application or third-party applications. 1166 * @param { string } owner - Indicates the account owner of your application or third-party applications. 1167 * @param { string } authType - Indicates the authentication type. 1168 * @param { Record<string, Object> } options - Indicates the authenticator-specific options for the request. 1169 * @param { AuthCallback } callback - Indicates the authenticator callback. 1170 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1171 * <br> 2. Incorrect parameter types. 1172 * @throws { BusinessError } 12300001 - System service exception. 1173 * @throws { BusinessError } 12300002 - Invalid name, owner, authType or options. 1174 * @throws { BusinessError } 12300003 - Account not found. 1175 * @throws { BusinessError } 12300010 - Account service busy. 1176 * @throws { BusinessError } 12300113 - Authenticator service not found. 1177 * @throws { BusinessError } 12300114 - Authenticator service exception. 1178 * @syscap SystemCapability.Account.AppAccount 1179 * @since 9 1180 */ 1181 auth( 1182 name: string, 1183 owner: string, 1184 authType: string, 1185 options: Record<string, Object>, 1186 callback: AuthCallback 1187 ): void; 1188 1189 /** 1190 * Gets an oauth token with the specified authentication type from a particular application account. 1191 * 1192 * @param { string } name - Indicates the account name of your application or third-party applications. 1193 * @param { string } owner - Indicates the account owner of your application or third-party applications. 1194 * @param { string } authType - Indicates the authentication type. 1195 * @param { AsyncCallback<string> } callback - Asynchronous callback interface. Returns an oauth token. 1196 * @syscap SystemCapability.Account.AppAccount 1197 * @since 8 1198 * @deprecated since 9 1199 * @useinstead appAccount.AppAccountManager#getAuthToken 1200 */ 1201 getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCallback<string>): void; 1202 1203 /** 1204 * Gets an oauth token with the specified authentication type from a particular application account. 1205 * 1206 * @param { string } name - Indicates the account name of your application or third-party applications. 1207 * @param { string } owner - Indicates the account owner of your application or third-party applications. 1208 * @param { string } authType - Indicates the authentication type. 1209 * @returns { Promise<string> } Returns an oauth token. 1210 * @syscap SystemCapability.Account.AppAccount 1211 * @since 8 1212 * @deprecated since 9 1213 * @useinstead appAccount.AppAccountManager#getAuthToken 1214 */ 1215 getOAuthToken(name: string, owner: string, authType: string): Promise<string>; 1216 1217 /** 1218 * Gets an auth token with the specified authentication type from a particular application account. 1219 * 1220 * @param { string } name - Indicates the account name of your application or third-party applications. 1221 * @param { string } owner - Indicates the account owner of your application or third-party applications. 1222 * @param { string } authType - Indicates the authentication type. 1223 * @param { AsyncCallback<string> } callback - Asynchronous callback interface. Returns an auth token. 1224 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1225 * <br> 2. Incorrect parameter types. 1226 * @throws { BusinessError } 12300001 - System service exception. 1227 * @throws { BusinessError } 12300002 - Invalid name, owner or authType. 1228 * @throws { BusinessError } 12300003 - Account not found. 1229 * @throws { BusinessError } 12300107 - AuthType not found. 1230 * @syscap SystemCapability.Account.AppAccount 1231 * @since 9 1232 */ 1233 getAuthToken(name: string, owner: string, authType: string, callback: AsyncCallback<string>): void; 1234 1235 /** 1236 * Gets an auth token with the specified authentication type from a particular application account. 1237 * 1238 * @param { string } name - Indicates the account name of your application or third-party applications. 1239 * @param { string } owner - Indicates the account owner of your application or third-party applications. 1240 * @param { string } authType - Indicates the authentication type. 1241 * @returns { Promise<string> } Returns an auth token. 1242 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1243 * <br> 2. Incorrect parameter types. 1244 * @throws { BusinessError } 12300001 - System service exception. 1245 * @throws { BusinessError } 12300002 - Invalid name, owner or authType. 1246 * @throws { BusinessError } 12300003 - Account not found. 1247 * @throws { BusinessError } 12300107 - AuthType not found. 1248 * @syscap SystemCapability.Account.AppAccount 1249 * @since 9 1250 */ 1251 getAuthToken(name: string, owner: string, authType: string): Promise<string>; 1252 1253 /** 1254 * Sets an oauth token with the specified authentication type for a particular account. 1255 * <p> 1256 * Only the owner of the application account has the permission to call this method. 1257 * 1258 * @param { string } name - Indicates the account name of your application. 1259 * @param { string } authType - Indicates the authentication type. 1260 * @param { string } token - Indicates the oauth token. 1261 * @param { AsyncCallback<void> } callback - Asynchronous callback interface. 1262 * @syscap SystemCapability.Account.AppAccount 1263 * @since 8 1264 * @deprecated since 9 1265 * @useinstead appAccount.AppAccountManager#setAuthToken 1266 */ 1267 setOAuthToken(name: string, authType: string, token: string, callback: AsyncCallback<void>): void; 1268 1269 /** 1270 * Sets an oauth token with the specified authentication type for a particular account. 1271 * <p> 1272 * Only the owner of the application account has the permission to call this method. 1273 * 1274 * @param { string } name - Indicates the account name of your application. 1275 * @param { string } authType - Indicates the authentication type. 1276 * @param { string } token - Indicates the oauth token. 1277 * @returns { Promise<void> } The promise returned by the function. 1278 * @syscap SystemCapability.Account.AppAccount 1279 * @since 8 1280 * @deprecated since 9 1281 * @useinstead appAccount.AppAccountManager#setAuthToken 1282 */ 1283 setOAuthToken(name: string, authType: string, token: string): Promise<void>; 1284 1285 /** 1286 * Sets an auth token with the specified authentication type for a particular account. 1287 * <p> 1288 * Only the owner of the application account has the permission to call this method. 1289 * 1290 * @param { string } name - Indicates the account name of your application. 1291 * @param { string } authType - Indicates the authentication type. 1292 * @param { string } token - Indicates the auth token. 1293 * @param { AsyncCallback<void> } callback - Asynchronous callback interface. 1294 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1295 * <br> 2. Incorrect parameter types. 1296 * @throws { BusinessError } 12300001 - System service exception. 1297 * @throws { BusinessError } 12300002 - Invalid name, authType or token. 1298 * @throws { BusinessError } 12300003 - Account not found. 1299 * @throws { BusinessError } 12400004 - The number of tokens reaches the upper limit. 1300 * @syscap SystemCapability.Account.AppAccount 1301 * @since 9 1302 */ 1303 setAuthToken(name: string, authType: string, token: string, callback: AsyncCallback<void>): void; 1304 1305 /** 1306 * Sets an auth token with the specified authentication type for a particular account. 1307 * <p> 1308 * Only the owner of the application account has the permission to call this method. 1309 * 1310 * @param { string } name - Indicates the account name of your application. 1311 * @param { string } authType - Indicates the authentication type. 1312 * @param { string } token - Indicates the auth token. 1313 * @returns { Promise<void> } The promise returned by the function. 1314 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1315 * <br> 2. Incorrect parameter types. 1316 * @throws { BusinessError } 12300001 - System service exception. 1317 * @throws { BusinessError } 12300002 - Invalid name, authType or token. 1318 * @throws { BusinessError } 12300003 - Account not found. 1319 * @throws { BusinessError } 12400004 - The number of tokens reaches the upper limit. 1320 * @syscap SystemCapability.Account.AppAccount 1321 * @since 9 1322 */ 1323 setAuthToken(name: string, authType: string, token: string): Promise<void>; 1324 1325 /** 1326 * Deletes an oauth token for the specified application account. 1327 * <p> 1328 * Only tokens visible to the caller application can be deleted. 1329 * 1330 * @param { string } name - Indicates the account name of your application or third-party applications. 1331 * @param { string } owner - Indicates the account owner of your application or third-party applications. 1332 * @param { string } authType - Indicates the authentication type. 1333 * @param { string } token - Indicates the oauth token. 1334 * @param { AsyncCallback<void> } callback Asynchronous callback interface. 1335 * @syscap SystemCapability.Account.AppAccount 1336 * @since 8 1337 * @deprecated since 9 1338 * @useinstead appAccount.AppAccountManager#deleteAuthToken 1339 */ 1340 deleteOAuthToken(name: string, owner: string, authType: string, token: string, callback: AsyncCallback<void>): void; 1341 1342 /** 1343 * Deletes an oauth token for the specified application account. 1344 * <p> 1345 * Only tokens visible to the caller application can be deleted. 1346 * 1347 * @param { string } name - Indicates the account name of your application or third-party applications. 1348 * @param { string } owner - Indicates the account owner of your application or third-party applications. 1349 * @param { string } authType - Indicates the authentication type. 1350 * @param { string } token - Indicates the oauth token. 1351 * @returns { Promise<void> } The promise returned by the function. 1352 * @syscap SystemCapability.Account.AppAccount 1353 * @since 8 1354 * @deprecated since 9 1355 * @useinstead appAccount.AppAccountManager#deleteAuthToken 1356 */ 1357 deleteOAuthToken(name: string, owner: string, authType: string, token: string): Promise<void>; 1358 1359 /** 1360 * Deletes an auth token for the specified application account. 1361 * <p> 1362 * Only tokens visible to the caller application can be deleted. 1363 * 1364 * @param { string } name - Indicates the account name of your application or third-party applications. 1365 * @param { string } owner - Indicates the account owner of your application or third-party applications. 1366 * @param { string } authType - Indicates the authentication type. 1367 * @param { string } token - Indicates the auth token. 1368 * @param { AsyncCallback<void> } callback - Asynchronous callback interface. 1369 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1370 * <br> 2. Incorrect parameter types. 1371 * @throws { BusinessError } 12300001 - System service exception. 1372 * @throws { BusinessError } 12300002 - Invalid name, owner, authType or token. 1373 * @throws { BusinessError } 12300003 - Account not found. 1374 * @throws { BusinessError } 12300107 - AuthType not found. 1375 * @syscap SystemCapability.Account.AppAccount 1376 * @since 9 1377 */ 1378 deleteAuthToken(name: string, owner: string, authType: string, token: string, callback: AsyncCallback<void>): void; 1379 1380 /** 1381 * Deletes an auth token for the specified application account. 1382 * <p> 1383 * Only tokens visible to the caller application can be deleted. 1384 * 1385 * @param { string } name - Indicates the account name of your application or third-party applications. 1386 * @param { string } owner - Indicates the account owner of your application or third-party applications. 1387 * @param { string } authType - Indicates the authentication type. 1388 * @param { string } token - Indicates the auth token. 1389 * @returns { Promise<void> } The promise returned by the function. 1390 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1391 * <br> 2. Incorrect parameter types. 1392 * @throws { BusinessError } 12300001 - System service exception. 1393 * @throws { BusinessError } 12300002 - Invalid name, owner, authType or token. 1394 * @throws { BusinessError } 12300003 - Account not found. 1395 * @throws { BusinessError } 12300107 - AuthType not found. 1396 * @syscap SystemCapability.Account.AppAccount 1397 * @since 9 1398 */ 1399 deleteAuthToken(name: string, owner: string, authType: string, token: string): Promise<void>; 1400 1401 /** 1402 * Sets the oauth token visibility of the specified authentication type to a third-party application. 1403 * <p> 1404 * Only the owner of the application account has the permission to call this method. 1405 * 1406 * @param { string } name - Indicates the account name of your application. 1407 * @param { string } authType - Indicates the authentication type. 1408 * @param { string } bundleName - Indicates the bundle name of the third-party application. 1409 * @param { boolean } isVisible - Indicates the bool value of visibility. 1410 * @param { AsyncCallback<void> } callback - Asynchronous callback interface. 1411 * @syscap SystemCapability.Account.AppAccount 1412 * @since 8 1413 * @deprecated since 9 1414 * @useinstead appAccount.AppAccountManager#setAuthTokenVisibility 1415 */ 1416 setOAuthTokenVisibility( 1417 name: string, 1418 authType: string, 1419 bundleName: string, 1420 isVisible: boolean, 1421 callback: AsyncCallback<void> 1422 ): void; 1423 1424 /** 1425 * Sets the oauth token visibility of the specified authentication type to a third-party application. 1426 * <p> 1427 * Only the owner of the application account has the permission to call this method. 1428 * 1429 * @param { string } name - Indicates the account name of your application. 1430 * @param { string } authType - Indicates the authentication type. 1431 * @param { string } bundleName - Indicates the bundle name of the third-party application. 1432 * @param { boolean } isVisible - Indicates the bool value of visibility. 1433 * @returns { Promise<void> } The promise returned by the function. 1434 * @syscap SystemCapability.Account.AppAccount 1435 * @since 8 1436 * @deprecated since 9 1437 * @useinstead appAccount.AppAccountManager#setAuthTokenVisibility 1438 */ 1439 setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean): Promise<void>; 1440 1441 /** 1442 * Sets the auth token visibility of the specified authentication type to a third-party application. 1443 * <p> 1444 * Only the owner of the application account has the permission to call this method. 1445 * 1446 * @param { string } name - Indicates the account name of your application. 1447 * @param { string } authType - Indicates the authentication type. 1448 * @param { string } bundleName - Indicates the bundle name of the third-party application. 1449 * @param { boolean } isVisible - Indicates the bool value of visibility. 1450 * @param { AsyncCallback<void> } callback - Asynchronous callback interface. 1451 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1452 * <br> 2. Incorrect parameter types. 1453 * @throws { BusinessError } 12300001 - System service exception. 1454 * @throws { BusinessError } 12300002 - Invalid name, authType or bundleName. 1455 * @throws { BusinessError } 12300003 - Account not found. 1456 * @throws { BusinessError } 12300107 - AuthType not found. 1457 * @throws { BusinessError } 12400001 - Application not found. 1458 * @throws { BusinessError } 12400005 - The size of authorization list reaches the upper limit. 1459 * @syscap SystemCapability.Account.AppAccount 1460 * @since 9 1461 */ 1462 setAuthTokenVisibility( 1463 name: string, 1464 authType: string, 1465 bundleName: string, 1466 isVisible: boolean, 1467 callback: AsyncCallback<void> 1468 ): void; 1469 1470 /** 1471 * Sets the auth token visibility of the specified authentication type to a third-party application. 1472 * <p> 1473 * Only the owner of the application account has the permission to call this method. 1474 * 1475 * @param { string } name - Indicates the account name of your application. 1476 * @param { string } authType - Indicates the authentication type. 1477 * @param { string } bundleName - Indicates the bundle name of the third-party application. 1478 * @param { boolean } isVisible - Indicates the bool value of visibility. 1479 * @returns { Promise<void> } The promise returned by the function. 1480 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1481 * <br> 2. Incorrect parameter types. 1482 * @throws { BusinessError } 12300001 - System service exception. 1483 * @throws { BusinessError } 12300002 - Invalid name, authType or bundleName. 1484 * @throws { BusinessError } 12300003 - Account not found. 1485 * @throws { BusinessError } 12300107 - AuthType not found. 1486 * @throws { BusinessError } 12400001 - Application not found. 1487 * @throws { BusinessError } 12400005 - The size of authorization list reaches the upper limit. 1488 * @syscap SystemCapability.Account.AppAccount 1489 * @since 9 1490 */ 1491 setAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean): Promise<void>; 1492 1493 /** 1494 * Checks the oauth token visibility of the specified authentication type for a third-party application. 1495 * <p> 1496 * Only the owner of the application account has the permission to call this method. 1497 * 1498 * @param { string } name - Indicates the account name of your application or third-party applications. 1499 * @param { string } authType - Indicates the authentication type. 1500 * @param { string } bundleName - Indicates the bundle name of the third-party application. 1501 * @param { AsyncCallback<boolean> } callback - Asynchronous callback interface. Returns the bool value of visibility. 1502 * @syscap SystemCapability.Account.AppAccount 1503 * @since 8 1504 * @deprecated since 9 1505 * @useinstead appAccount.AppAccountManager#checkAuthTokenVisibility 1506 */ 1507 checkOAuthTokenVisibility( 1508 name: string, 1509 authType: string, 1510 bundleName: string, 1511 callback: AsyncCallback<boolean> 1512 ): void; 1513 1514 /** 1515 * Checks the oauth token visibility of the specified authentication type for a third-party application. 1516 * <p> 1517 * Only the owner of the application account has the permission to call this method. 1518 * 1519 * @param { string } name - Indicates the account name of your application or third-party applications. 1520 * @param { string } authType - Indicates the authentication type. 1521 * @param { string } bundleName - Indicates the bundle name of the third-party application. 1522 * @returns { Promise<boolean> } Returns the bool value of visibility. 1523 * @syscap SystemCapability.Account.AppAccount 1524 * @since 8 1525 * @deprecated since 9 1526 * @useinstead appAccount.AppAccountManager#checkAuthTokenVisibility 1527 */ 1528 checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): Promise<boolean>; 1529 1530 /** 1531 * Checks the auth token visibility of the specified authentication type for a third-party application. 1532 * <p> 1533 * Only the owner of the application account has the permission to call this method. 1534 * 1535 * @param { string } name - Indicates the account name of your application or third-party applications. 1536 * @param { string } authType - Indicates the authentication type. 1537 * @param { string } bundleName - Indicates the bundle name of the third-party application. 1538 * @param { AsyncCallback<boolean> } callback - Asynchronous callback interface. 1539 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1540 * <br> 2. Incorrect parameter types. 1541 * @throws { BusinessError } 12300001 - System service exception. 1542 * @throws { BusinessError } 12300002 - Invalid name, authType or bundleName. 1543 * @throws { BusinessError } 12300003 - Account not found. 1544 * @throws { BusinessError } 12300107 - AuthType not found. 1545 * @syscap SystemCapability.Account.AppAccount 1546 * @since 9 1547 */ 1548 checkAuthTokenVisibility( 1549 name: string, 1550 authType: string, 1551 bundleName: string, 1552 callback: AsyncCallback<boolean> 1553 ): void; 1554 1555 /** 1556 * Checks the auth token visibility of the specified authentication type for a third-party application. 1557 * <p> 1558 * Only the owner of the application account has the permission to call this method. 1559 * 1560 * @param { string } name - Indicates the account name of your application or third-party applications. 1561 * @param { string } authType - Indicates the authentication type. 1562 * @param { string } bundleName - Indicates the bundle name of the third-party application. 1563 * @returns { Promise<boolean> } Returns the bool value of visibility. 1564 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1565 * <br> 2. Incorrect parameter types. 1566 * @throws { BusinessError } 12300001 - System service exception. 1567 * @throws { BusinessError } 12300002 - Invalid name, authType or bundleName. 1568 * @throws { BusinessError } 12300003 - Account not found. 1569 * @throws { BusinessError } 12300107 - AuthType not found. 1570 * @syscap SystemCapability.Account.AppAccount 1571 * @since 9 1572 */ 1573 checkAuthTokenVisibility(name: string, authType: string, bundleName: string): Promise<boolean>; 1574 1575 /** 1576 * Gets all oauth tokens visible to the caller application. 1577 * 1578 * @param { string } name - Indicates the account name of your application or third-party applications. 1579 * @param { string } owner - Indicates the account owner of your application or third-party applications. 1580 * @param { AsyncCallback<Array<OAuthTokenInfo>> } callback - Asynchronous callback interface. 1581 * @syscap SystemCapability.Account.AppAccount 1582 * @since 8 1583 * @deprecated since 9 1584 * @useinstead appAccount.AppAccountManager#getAllAuthTokens 1585 */ 1586 getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback<Array<OAuthTokenInfo>>): void; 1587 1588 /** 1589 * Gets all oauth tokens visible to the caller application. 1590 * 1591 * @param { string } name - Indicates the account name of your application or third-party applications. 1592 * @param { string } owner - Indicates the account owner of your application or third-party applications. 1593 * @returns { Promise<Array<OAuthTokenInfo>> } Returns a list of oauth tokens visible to the caller application. 1594 * @syscap SystemCapability.Account.AppAccount 1595 * @since 8 1596 * @deprecated since 9 1597 * @useinstead appAccount.AppAccountManager#getAllAuthTokens 1598 */ 1599 getAllOAuthTokens(name: string, owner: string): Promise<Array<OAuthTokenInfo>>; 1600 1601 /** 1602 * Gets all auth tokens visible to the caller application. 1603 * 1604 * @param { string } name - Indicates the account name of your application or third-party applications. 1605 * @param { string } owner - Indicates the account owner of your application or third-party applications. 1606 * @param { AsyncCallback<Array<AuthTokenInfo>> } callback - Asynchronous callback interface. 1607 * Returns a list of auth tokens visible to the caller application. 1608 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1609 * <br> 2. Incorrect parameter types. 1610 * @throws { BusinessError } 12300001 - System service exception. 1611 * @throws { BusinessError } 12300002 - Invalid name or owner. 1612 * @throws { BusinessError } 12300003 - Account not found. 1613 * @syscap SystemCapability.Account.AppAccount 1614 * @since 9 1615 */ 1616 getAllAuthTokens(name: string, owner: string, callback: AsyncCallback<Array<AuthTokenInfo>>): void; 1617 1618 /** 1619 * Gets all auth tokens visible to the caller application. 1620 * 1621 * @param { string } name - Indicates the account name of your application or third-party applications. 1622 * @param { string } owner - Indicates the account owner of your application or third-party applications. 1623 * @returns { Promise<Array<AuthTokenInfo>> } Returns a list of auth tokens visible to the caller application. 1624 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1625 * <br> 2. Incorrect parameter types. 1626 * @throws { BusinessError } 12300001 - System service exception. 1627 * @throws { BusinessError } 12300002 - Invalid name or owner. 1628 * @throws { BusinessError } 12300003 - Account not found. 1629 * @syscap SystemCapability.Account.AppAccount 1630 * @since 9 1631 */ 1632 getAllAuthTokens(name: string, owner: string): Promise<Array<AuthTokenInfo>>; 1633 1634 /** 1635 * Gets the open authorization list with a specified authentication type for a particular application account. 1636 * <p> 1637 * Only the owner of the application account has the permission to call this method. 1638 * 1639 * @param { string } name - Indicates the account name of your application. 1640 * @param { string } authType - Indicates the authentication type. 1641 * @param { AsyncCallback<Array<string>> } callback - Asynchronous callback interface. 1642 * Returns the open authorization list of the specified authentication type. 1643 * @syscap SystemCapability.Account.AppAccount 1644 * @since 8 1645 * @deprecated since 9 1646 * @useinstead appAccount.AppAccountManager#getAuthList 1647 */ 1648 getOAuthList(name: string, authType: string, callback: AsyncCallback<Array<string>>): void; 1649 1650 /** 1651 * Gets the open authorization list with a specified authentication type for a particular application account. 1652 * <p> 1653 * Only the owner of the application account has the permission to call this method. 1654 * 1655 * @param { string } name - Indicates the account name of your application. 1656 * @param { string } authType - Indicates the authentication type. 1657 * @returns { Promise<Array<string>> } Returns the open authorization list of the specified authentication type. 1658 * @syscap SystemCapability.Account.AppAccount 1659 * @since 8 1660 * @deprecated since 9 1661 * @useinstead appAccount.AppAccountManager#getAuthList 1662 */ 1663 getOAuthList(name: string, authType: string): Promise<Array<string>>; 1664 1665 /** 1666 * Gets the open authorization list with a specified authentication type for a particular application account. 1667 * <p> 1668 * Only the owner of the application account has the permission to call this method. 1669 * 1670 * @param { string } name - Indicates the account name of your application. 1671 * @param { string } authType - Indicates the authentication type. 1672 * @param { AsyncCallback<Array<string>> } callback - Asynchronous callback interface. 1673 * Returns the open authorization list of the specified authentication type. 1674 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1675 * <br> 2. Incorrect parameter types. 1676 * @throws { BusinessError } 12300001 - System service exception. 1677 * @throws { BusinessError } 12300002 - Invalid name or authType. 1678 * @throws { BusinessError } 12300003 - Account not found. 1679 * @throws { BusinessError } 12300107 - AuthType not found. 1680 * @syscap SystemCapability.Account.AppAccount 1681 * @since 9 1682 */ 1683 getAuthList(name: string, authType: string, callback: AsyncCallback<Array<string>>): void; 1684 1685 /** 1686 * Gets the open authorization list with a specified authentication type for a particular application account. 1687 * <p> 1688 * Only the owner of the application account has the permission to call this method. 1689 * 1690 * @param { string } name - Indicates the account name of your application. 1691 * @param { string } authType - Indicates the authentication type. 1692 * @returns { Promise<Array<string>> } Returns the open authorization list of the specified authentication type. 1693 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1694 * <br> 2. Incorrect parameter types. 1695 * @throws { BusinessError } 12300001 - System service exception. 1696 * @throws { BusinessError } 12300002 - Invalid name or authType. 1697 * @throws { BusinessError } 12300003 - Account not found. 1698 * @throws { BusinessError } 12300107 - AuthType not found. 1699 * @syscap SystemCapability.Account.AppAccount 1700 * @since 9 1701 */ 1702 getAuthList(name: string, authType: string): Promise<Array<string>>; 1703 1704 /** 1705 * Gets the authenticator callback with the specified session id. 1706 * <p> 1707 * Only the owner of the authenticator has the permission to call this method. 1708 * 1709 * @param { string } sessionId - Indicates the id of a authentication session. 1710 * @param { AsyncCallback<AuthenticatorCallback> } callback - Asynchronous callback interface. 1711 * Returns the authenticator callback related to the session id. 1712 * @syscap SystemCapability.Account.AppAccount 1713 * @since 8 1714 * @deprecated since 9 1715 * @useinstead appAccount.AppAccountManager#getAuthCallback 1716 */ 1717 getAuthenticatorCallback(sessionId: string, callback: AsyncCallback<AuthenticatorCallback>): void; 1718 1719 /** 1720 * Gets the authenticator callback with the specified session id. 1721 * <p> 1722 * Only the owner of the authenticator has the permission to call this method. 1723 * 1724 * @param { string } sessionId - Indicates the id of a authentication session. 1725 * @returns { Promise<AuthenticatorCallback> } Returns the authenticator callback related to the session id. 1726 * @syscap SystemCapability.Account.AppAccount 1727 * @since 8 1728 * @deprecated since 9 1729 * @useinstead appAccount.AppAccountManager#getAuthCallback 1730 */ 1731 getAuthenticatorCallback(sessionId: string): Promise<AuthenticatorCallback>; 1732 1733 /** 1734 * Obtains the authenticator callback with the specified session id. 1735 * <p> 1736 * Only the owner of the authenticator has the permission to call this method. 1737 * 1738 * @param { string } sessionId - Indicates the id of a authentication session. 1739 * @param { AsyncCallback<AuthCallback> } callback - Asynchronous callback interface. 1740 * Returns the authenticator callback related to the session id. 1741 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1742 * <br> 2. Incorrect parameter types. 1743 * @throws { BusinessError } 12300001 - System service exception. 1744 * @throws { BusinessError } 12300002 - Invalid sessionId. 1745 * @throws { BusinessError } 12300108 - Session not found. 1746 * @syscap SystemCapability.Account.AppAccount 1747 * @since 9 1748 */ 1749 getAuthCallback(sessionId: string, callback: AsyncCallback<AuthCallback>): void; 1750 1751 /** 1752 * Obtains the authenticator callback with the specified session id. 1753 * <p> 1754 * Only the owner of the authenticator has the permission to call this method. 1755 * 1756 * @param { string } sessionId - Indicates the id of a authentication session. 1757 * @returns { Promise<AuthCallback> } Returns the authenticator callback related to the session id. 1758 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1759 * <br> 2. Incorrect parameter types. 1760 * @throws { BusinessError } 12300001 - System service exception. 1761 * @throws { BusinessError } 12300002 - Invalid sessionId. 1762 * @throws { BusinessError } 12300108 - Session not found. 1763 * @syscap SystemCapability.Account.AppAccount 1764 * @since 9 1765 */ 1766 getAuthCallback(sessionId: string): Promise<AuthCallback>; 1767 1768 /** 1769 * Gets the authenticator information of an application account. 1770 * 1771 * @param { string } owner - Indicates the account owner of your application or third-party applications. 1772 * @param { AsyncCallback<AuthenticatorInfo> } callback - Asynchronous callback interface. 1773 * Returns the authenticator information of the application account. 1774 * @syscap SystemCapability.Account.AppAccount 1775 * @since 8 1776 * @deprecated since 9 1777 * @useinstead appAccount.AppAccountManager#queryAuthenticatorInfo 1778 */ 1779 getAuthenticatorInfo(owner: string, callback: AsyncCallback<AuthenticatorInfo>): void; 1780 1781 /** 1782 * Gets the authenticator information of an application account. 1783 * 1784 * @param { string } owner - Indicates the account owner of your application or third-party applications. 1785 * @returns { Promise<AuthenticatorInfo> } Returns the authenticator information of the application account. 1786 * @syscap SystemCapability.Account.AppAccount 1787 * @since 8 1788 * @deprecated since 9 1789 * @useinstead appAccount.AppAccountManager#queryAuthenticatorInfo 1790 */ 1791 getAuthenticatorInfo(owner: string): Promise<AuthenticatorInfo>; 1792 1793 /** 1794 * Queries the authenticator information of an application account. 1795 * 1796 * @param { string } owner - Indicates the account owner of your application or third-party applications. 1797 * @param { AsyncCallback<AuthenticatorInfo> } callback - Asynchronous callback interface. 1798 * Returns the authenticator information of the application account. 1799 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1800 * <br> 2. Incorrect parameter types. 1801 * @throws { BusinessError } 12300001 - System service exception. 1802 * @throws { BusinessError } 12300002 - Invalid owner. 1803 * @throws { BusinessError } 12300113 - Authenticator service not found. 1804 * @syscap SystemCapability.Account.AppAccount 1805 * @since 9 1806 */ 1807 queryAuthenticatorInfo(owner: string, callback: AsyncCallback<AuthenticatorInfo>): void; 1808 1809 /** 1810 * Queries the authenticator information of an application account. 1811 * 1812 * @param { string } owner - Indicates the account owner of your application or third-party applications. 1813 * @returns { Promise<AuthenticatorInfo> } Returns the authenticator information of the application account. 1814 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1815 * <br> 2. Incorrect parameter types. 1816 * @throws { BusinessError } 12300001 - System service exception. 1817 * @throws { BusinessError } 12300002 - Invalid owner. 1818 * @throws { BusinessError } 12300113 - Authenticator service not found. 1819 * @syscap SystemCapability.Account.AppAccount 1820 * @since 9 1821 */ 1822 queryAuthenticatorInfo(owner: string): Promise<AuthenticatorInfo>; 1823 1824 /** 1825 * Checks whether a particular account has all specified labels. 1826 * 1827 * @param { string } name - Indicates the account name. 1828 * @param { string } owner - Indicates the account owner. 1829 * @param { Array<string> } labels - Indicates an array of labels to check. 1830 * @param { AsyncCallback<boolean> } callback - Asynchronous callback interface. 1831 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1832 * <br> 2. Incorrect parameter types. 1833 * @throws { BusinessError } 12300001 - System service exception. 1834 * @throws { BusinessError } 12300002 - Invalid name, owner or labels. 1835 * @throws { BusinessError } 12300003 - Account not found. 1836 * @throws { BusinessError } 12300010 - Account service busy. 1837 * @throws { BusinessError } 12300113 - Authenticator service not found. 1838 * @throws { BusinessError } 12300114 - Authenticator service exception. 1839 * @syscap SystemCapability.Account.AppAccount 1840 * @since 9 1841 */ 1842 checkAccountLabels(name: string, owner: string, labels: Array<string>, callback: AsyncCallback<boolean>): void; 1843 1844 /** 1845 * Checks whether a particular account has all specified labels. 1846 * 1847 * @param { string } name - Indicates the account name. 1848 * @param { string } owner - Indicates the account owner. 1849 * @param { Array<string> } labels - Indicates an array of labels to check. 1850 * @returns { Promise<boolean> } The promise returned by the function. 1851 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1852 * <br> 2. Incorrect parameter types. 1853 * @throws { BusinessError } 12300001 - System service exception. 1854 * @throws { BusinessError } 12300002 - Invalid name, owner or labels. 1855 * @throws { BusinessError } 12300003 - Account not found. 1856 * @throws { BusinessError } 12300010 - Account service busy. 1857 * @throws { BusinessError } 12300113 - Authenticator service not found. 1858 * @throws { BusinessError } 12300114 - Authenticator service exception. 1859 * @syscap SystemCapability.Account.AppAccount 1860 * @since 9 1861 */ 1862 checkAccountLabels(name: string, owner: string, labels: Array<string>): Promise<boolean>; 1863 1864 /** 1865 * Deletes the credential of the specified application account. 1866 * 1867 * @param { string } name - Indicates the account name. 1868 * @param { string } credentialType - Indicates the type of the credential to delete. 1869 * @param { AsyncCallback<void> } callback - Asynchronous callback interface. 1870 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1871 * <br> 2. Incorrect parameter types. 1872 * @throws { BusinessError } 12300001 - System service exception. 1873 * @throws { BusinessError } 12300002 - Invalid name or credentialType. 1874 * @throws { BusinessError } 12300003 - Account not found. 1875 * @throws { BusinessError } 12300102 - Credential not found. 1876 * @syscap SystemCapability.Account.AppAccount 1877 * @since 9 1878 */ 1879 deleteCredential(name: string, credentialType: string, callback: AsyncCallback<void>): void; 1880 1881 /** 1882 * Deletes the credential of the specified application account. 1883 * 1884 * @param { string } name - Indicates the account name. 1885 * @param { string } credentialType - Indicates the type of the credential to delete. 1886 * @returns { Promise<void> } The promise returned by the function. 1887 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1888 * <br> 2. Incorrect parameter types. 1889 * @throws { BusinessError } 12300001 - System service exception. 1890 * @throws { BusinessError } 12300002 - Invalid name or credentialType. 1891 * @throws { BusinessError } 12300003 - Account not found. 1892 * @throws { BusinessError } 12300102 - Credential not found. 1893 * @syscap SystemCapability.Account.AppAccount 1894 * @since 9 1895 */ 1896 deleteCredential(name: string, credentialType: string): Promise<void>; 1897 1898 /** 1899 * Selects a list of accounts that satisfied with the specified options. 1900 * 1901 * @param { SelectAccountsOptions } options - Indicates the options for selecting account. 1902 * @param { AsyncCallback<Array<AppAccountInfo>> } callback - Asynchronous callback interface. 1903 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1904 * <br> 2. Incorrect parameter types. 1905 * @throws { BusinessError } 12300001 - System service exception. 1906 * @throws { BusinessError } 12300002 - Invalid options. 1907 * @throws { BusinessError } 12300010 - Account service busy. 1908 * @throws { BusinessError } 12300114 - Authenticator service exception. 1909 * @syscap SystemCapability.Account.AppAccount 1910 * @since 9 1911 */ 1912 selectAccountsByOptions(options: SelectAccountsOptions, callback: AsyncCallback<Array<AppAccountInfo>>): void; 1913 1914 /** 1915 * Selects a list of accounts that satisfied with the specified options. 1916 * 1917 * @param { SelectAccountsOptions } options - Indicates the options for selecting account. 1918 * @returns { Promise<Array<AppAccountInfo>> } Returns a list of accounts. 1919 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1920 * <br> 2. Incorrect parameter types. 1921 * @throws { BusinessError } 12300001 - System service exception. 1922 * @throws { BusinessError } 12300002 - Invalid options. 1923 * @throws { BusinessError } 12300010 - Account service busy. 1924 * @throws { BusinessError } 12300114 - Authenticator service exception. 1925 * @syscap SystemCapability.Account.AppAccount 1926 * @since 9 1927 */ 1928 selectAccountsByOptions(options: SelectAccountsOptions): Promise<Array<AppAccountInfo>>; 1929 1930 /** 1931 * Verifies the credential to ensure the user is the owner of the specified account. 1932 * 1933 * @param { string } name - Indicates the account name. 1934 * @param { string } owner - Indicates the account owner. 1935 * @param { AuthCallback } callback - Indicates the authenticator callback. 1936 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1937 * <br> 2. Incorrect parameter types. 1938 * @throws { BusinessError } 12300001 - System service exception. 1939 * @throws { BusinessError } 12300002 - Invalid name or owner. 1940 * @throws { BusinessError } 12300003 - Account not found. 1941 * @throws { BusinessError } 12300010 - Account service busy. 1942 * @throws { BusinessError } 12300113 - Authenticator service not found. 1943 * @throws { BusinessError } 12300114 - Authenticator service exception. 1944 * @syscap SystemCapability.Account.AppAccount 1945 * @since 9 1946 */ 1947 verifyCredential(name: string, owner: string, callback: AuthCallback): void; 1948 /** 1949 * Verifies the credential to ensure the user is the owner of the specified account. 1950 * 1951 * @param { string } name - Indicates the account name. 1952 * @param { string } owner - Indicates the account owner. 1953 * @param { VerifyCredentialOptions } options - Indicates the options for verifying credential. 1954 * @param { AuthCallback } callback - Indicates the authenticator callback. 1955 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1956 * <br> 2. Incorrect parameter types. 1957 * @throws { BusinessError } 12300001 - System service exception. 1958 * @throws { BusinessError } 12300002 - Invalid name, owner or options. 1959 * @throws { BusinessError } 12300003 - Account not found. 1960 * @throws { BusinessError } 12300010 - Account service busy. 1961 * @throws { BusinessError } 12300113 - Authenticator service not found. 1962 * @throws { BusinessError } 12300114 - Authenticator service exception. 1963 * @syscap SystemCapability.Account.AppAccount 1964 * @since 9 1965 */ 1966 verifyCredential(name: string, owner: string, options: VerifyCredentialOptions, callback: AuthCallback): void; 1967 1968 /** 1969 * Sets properties for the specified account authenticator. 1970 * <p> 1971 * If the authenticator supports setting its properties, 1972 * the caller will normally be redirected to an Ability specified by Want for property setting. 1973 * 1974 * @param { string } owner - Indicates the owner of authenticator. 1975 * @param { AuthCallback } callback - Indicates the authenticator callback. 1976 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1977 * <br> 2. Incorrect parameter types. 1978 * @throws { BusinessError } 12300001 - System service exception. 1979 * @throws { BusinessError } 12300002 - Invalid owner. 1980 * @throws { BusinessError } 12300010 - Account service busy. 1981 * @throws { BusinessError } 12300113 - Authenticator service not found. 1982 * @throws { BusinessError } 12300114 - Authenticator service exception. 1983 * @syscap SystemCapability.Account.AppAccount 1984 * @since 9 1985 */ 1986 setAuthenticatorProperties(owner: string, callback: AuthCallback): void; 1987 /** 1988 * Sets properties for the specified account authenticator. 1989 * <p> 1990 * If the authenticator supports setting its properties, 1991 * the caller will normally be redirected to an Ability specified by Want for property setting. 1992 * 1993 * @param { string } owner - Indicates the owner of authenticator. 1994 * @param { SetPropertiesOptions } options - Indicates the options for setting properties. 1995 * @param { AuthCallback } callback - Indicates the authenticator callback. 1996 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1997 * <br> 2. Incorrect parameter types. 1998 * @throws { BusinessError } 12300001 - System service exception. 1999 * @throws { BusinessError } 12300002 - Invalid owner or options. 2000 * @throws { BusinessError } 12300010 - Account service busy. 2001 * @throws { BusinessError } 12300113 - Authenticator service not found. 2002 * @throws { BusinessError } 12300114 - Authenticator service exception. 2003 * @syscap SystemCapability.Account.AppAccount 2004 * @since 9 2005 */ 2006 setAuthenticatorProperties(owner: string, options: SetPropertiesOptions, callback: AuthCallback): void; 2007 } 2008 2009 /** 2010 * Provides basic information of an application account, including the account owner and name. 2011 * 2012 * @interface AppAccountInfo 2013 * @syscap SystemCapability.Account.AppAccount 2014 * @since 7 2015 */ 2016 interface AppAccountInfo { 2017 /** 2018 * The owner an application account. 2019 * 2020 * @type { string } 2021 * @syscap SystemCapability.Account.AppAccount 2022 * @since 7 2023 */ 2024 owner: string; 2025 2026 /** 2027 * The name an application account. 2028 * 2029 * @type { string } 2030 * @syscap SystemCapability.Account.AppAccount 2031 * @since 7 2032 */ 2033 name: string; 2034 } 2035 2036 /** 2037 * Provides basic information of an oauth token, including the authentication type and token value. 2038 * 2039 * @interface OAuthTokenInfo 2040 * @syscap SystemCapability.Account.AppAccount 2041 * @since 8 2042 * @deprecated since 9 2043 * @useinstead appAccount.AuthTokenInfo 2044 */ 2045 interface OAuthTokenInfo { 2046 /** 2047 * The authentication type. 2048 * 2049 * @type { string } 2050 * @syscap SystemCapability.Account.AppAccount 2051 * @since 8 2052 * @deprecated since 9 2053 */ 2054 authType: string; 2055 2056 /** 2057 * The token value. 2058 * 2059 * @type { string } 2060 * @syscap SystemCapability.Account.AppAccount 2061 * @since 8 2062 * @deprecated since 9 2063 */ 2064 token: string; 2065 } 2066 2067 /** 2068 * Provides basic information of an auth token, including the authentication type and token value. 2069 * 2070 * @interface AuthTokenInfo 2071 * @syscap SystemCapability.Account.AppAccount 2072 * @since 9 2073 */ 2074 interface AuthTokenInfo { 2075 /** 2076 * The authentication type. 2077 * 2078 * @type { string } 2079 * @syscap SystemCapability.Account.AppAccount 2080 * @since 9 2081 */ 2082 authType: string; 2083 2084 /** 2085 * The token value. 2086 * 2087 * @type { string } 2088 * @syscap SystemCapability.Account.AppAccount 2089 * @since 9 2090 */ 2091 token: string; 2092 2093 /** 2094 * The account to which the token belongs. 2095 * 2096 * @type { ?AppAccountInfo } 2097 * @syscap SystemCapability.Account.AppAccount 2098 * @since 9 2099 */ 2100 account?: AppAccountInfo; 2101 } 2102 2103 /** 2104 * Provides basic information of an authenticator, including the authenticator owner, icon id and label id. 2105 * 2106 * @interface AuthenticatorInfo 2107 * @syscap SystemCapability.Account.AppAccount 2108 * @since 8 2109 */ 2110 interface AuthenticatorInfo { 2111 /** 2112 * The owner of an authenticator. 2113 * 2114 * @type { string } 2115 * @syscap SystemCapability.Account.AppAccount 2116 * @since 8 2117 */ 2118 owner: string; 2119 2120 /** 2121 * The icon id of an authenticator. 2122 * 2123 * @type { number } 2124 * @syscap SystemCapability.Account.AppAccount 2125 * @since 8 2126 */ 2127 iconId: number; 2128 2129 /** 2130 * The label id of an authenticator. 2131 * 2132 * @type { number } 2133 * @syscap SystemCapability.Account.AppAccount 2134 * @since 8 2135 */ 2136 labelId: number; 2137 } 2138 2139 /** 2140 * Provides the definition of the authentication result. 2141 * 2142 * @interface AuthResult 2143 * @syscap SystemCapability.Account.AppAccount 2144 * @since 9 2145 */ 2146 interface AuthResult { 2147 /** 2148 * The account information. 2149 * 2150 * @type { ?AppAccountInfo } 2151 * @syscap SystemCapability.Account.AppAccount 2152 * @since 9 2153 */ 2154 account?: AppAccountInfo; 2155 2156 /** 2157 * The token information. 2158 * 2159 * @type { ?AuthTokenInfo } 2160 * @syscap SystemCapability.Account.AppAccount 2161 * @since 9 2162 */ 2163 tokenInfo?: AuthTokenInfo; 2164 } 2165 2166 /** 2167 * Provides the available options for creating an account. 2168 * 2169 * @interface CreateAccountOptions 2170 * @syscap SystemCapability.Account.AppAccount 2171 * @since 9 2172 */ 2173 interface CreateAccountOptions { 2174 /** 2175 * The custom data for creating an account, 2176 * which can be further modified by function setCustomData. 2177 * 2178 * @type { ?Record<string, string> } 2179 * @syscap SystemCapability.Account.AppAccount 2180 * @since 9 2181 */ 2182 customData?: Record<string, string>; 2183 } 2184 2185 /** 2186 * Provides the available options for creating an account implicitly. 2187 * 2188 * @interface CreateAccountImplicitlyOptions 2189 * @syscap SystemCapability.Account.AppAccount 2190 * @since 9 2191 */ 2192 interface CreateAccountImplicitlyOptions { 2193 /** 2194 * The required labels for creating an account. 2195 * 2196 * @type { ?Array<string> } 2197 * @syscap SystemCapability.Account.AppAccount 2198 * @since 9 2199 */ 2200 requiredLabels?: Array<string>; 2201 2202 /** 2203 * The authentication type. 2204 * 2205 * @type { ?string } 2206 * @syscap SystemCapability.Account.AppAccount 2207 * @since 9 2208 */ 2209 authType?: string; 2210 2211 /** 2212 * The authenticator-specific parameters. 2213 * The list of reserved parameter name: 2214 * 1. Constants.KEY_CALLER_BUNDLE_NAME; 2215 * The above parameters are set by the appAccount management service and can be used for identify the caller. 2216 * 2217 * @type { ?Record<string, Object> } 2218 * @syscap SystemCapability.Account.AppAccount 2219 * @since 9 2220 */ 2221 parameters?: Record<string, Object>; 2222 } 2223 2224 /** 2225 * Provides the available options for selecting accounts. 2226 * 2227 * @interface SelectAccountsOptions 2228 * @syscap SystemCapability.Account.AppAccount 2229 * @since 9 2230 */ 2231 interface SelectAccountsOptions { 2232 /** 2233 * The list of accounts allowed to be selected. 2234 * 2235 * @type { ?Array<AppAccountInfo> } 2236 * @syscap SystemCapability.Account.AppAccount 2237 * @since 9 2238 */ 2239 allowedAccounts?: Array<AppAccountInfo>; 2240 2241 /** 2242 * The list of account owners, whose accounts allowed to be selected. 2243 * 2244 * @type { ?Array<string> } 2245 * @syscap SystemCapability.Account.AppAccount 2246 * @since 9 2247 */ 2248 allowedOwners?: Array<string>; 2249 2250 /** 2251 * The labels required for the selected accounts. 2252 * 2253 * @type { ?Array<string> } 2254 * @syscap SystemCapability.Account.AppAccount 2255 * @since 9 2256 */ 2257 requiredLabels?: Array<string>; 2258 } 2259 2260 /** 2261 * Provides the available options for verifying credential. 2262 * 2263 * @interface VerifyCredentialOptions 2264 * @syscap SystemCapability.Account.AppAccount 2265 * @since 9 2266 */ 2267 interface VerifyCredentialOptions { 2268 /** 2269 * The credential type to be verified. 2270 * 2271 * @type { ?string } 2272 * @syscap SystemCapability.Account.AppAccount 2273 * @since 9 2274 */ 2275 credentialType?: string; 2276 2277 /** 2278 * The credential to be verified. 2279 * 2280 * @type { ?string } 2281 * @syscap SystemCapability.Account.AppAccount 2282 * @since 9 2283 */ 2284 credential?: string; 2285 2286 /** 2287 * The authenticator-specific parameters. 2288 * The list of reserved parameter name: 2289 * 1. Constants.KEY_CALLER_BUNDLE_NAME; 2290 * The above parameters are set by the appAccount management service and can be used for identify the caller. 2291 * 2292 * @type { ?Record<string, Object> } 2293 * @syscap SystemCapability.Account.AppAccount 2294 * @since 9 2295 */ 2296 parameters?: Record<string, Object>; 2297 } 2298 2299 /** 2300 * Provides the available options for setting properties. 2301 * 2302 * @interface SetPropertiesOptions 2303 * @syscap SystemCapability.Account.AppAccount 2304 * @since 9 2305 */ 2306 interface SetPropertiesOptions { 2307 /** 2308 * The properties to be set. 2309 * 2310 * @type { ?Record<string, Object> } 2311 * @syscap SystemCapability.Account.AppAccount 2312 * @since 9 2313 */ 2314 properties?: Record<string, Object>; 2315 2316 /** 2317 * The authenticator-specific parameters. 2318 * The list of reserved parameter name: 2319 * 1. Constants.KEY_CALLER_BUNDLE_NAME; 2320 * The above parameters are set by the appAccount management service and can be used for identify the caller. 2321 * 2322 * @type { ?Record<string, Object> } 2323 * @syscap SystemCapability.Account.AppAccount 2324 * @since 9 2325 */ 2326 parameters?: Record<string, Object>; 2327 } 2328 2329 /** 2330 * Provides constants definition. 2331 * 2332 * @enum { string } Constants 2333 * @syscap SystemCapability.Account.AppAccount 2334 * @since 8 2335 */ 2336 enum Constants { 2337 /** 2338 * Indicates the action for adding account implicitly. 2339 * 2340 * @syscap SystemCapability.Account.AppAccount 2341 * @since 8 2342 * @deprecated since 9 2343 * @useinstead appAccount.Constants#ACTION_CREATE_ACCOUNT_IMPLICITLY 2344 */ 2345 ACTION_ADD_ACCOUNT_IMPLICITLY = 'addAccountImplicitly', 2346 2347 /** 2348 * Indicates the action for authenticating. 2349 * 2350 * @syscap SystemCapability.Account.AppAccount 2351 * @since 8 2352 * @deprecated since 9 2353 * @useinstead appAccount.Constants#ACTION_AUTH 2354 */ 2355 ACTION_AUTHENTICATE = 'authenticate', 2356 2357 /** 2358 * Indicates the action for creating account implicitly. 2359 * 2360 * @syscap SystemCapability.Account.AppAccount 2361 * @since 9 2362 */ 2363 ACTION_CREATE_ACCOUNT_IMPLICITLY = 'createAccountImplicitly', 2364 2365 /** 2366 * Indicates the action for authenticating. 2367 * 2368 * @syscap SystemCapability.Account.AppAccount 2369 * @since 9 2370 */ 2371 ACTION_AUTH = 'auth', 2372 2373 /** 2374 * Indicates the action for verifying credential. 2375 * 2376 * @syscap SystemCapability.Account.AppAccount 2377 * @since 9 2378 */ 2379 ACTION_VERIFY_CREDENTIAL = 'verifyCredential', 2380 2381 /** 2382 * Indicates the action for set authenticator properties. 2383 * 2384 * @syscap SystemCapability.Account.AppAccount 2385 * @since 9 2386 */ 2387 ACTION_SET_AUTHENTICATOR_PROPERTIES = 'setAuthenticatorProperties', 2388 2389 /** 2390 * Indicates the key of name. 2391 * 2392 * @syscap SystemCapability.Account.AppAccount 2393 * @since 8 2394 */ 2395 KEY_NAME = 'name', 2396 2397 /** 2398 * Indicates the key of owner. 2399 * 2400 * @syscap SystemCapability.Account.AppAccount 2401 * @since 8 2402 */ 2403 KEY_OWNER = 'owner', 2404 2405 /** 2406 * Indicates the key of token. 2407 * 2408 * @syscap SystemCapability.Account.AppAccount 2409 * @since 8 2410 */ 2411 KEY_TOKEN = 'token', 2412 2413 /** 2414 * Indicates the key of action. 2415 * 2416 * @syscap SystemCapability.Account.AppAccount 2417 * @since 8 2418 */ 2419 KEY_ACTION = 'action', 2420 2421 /** 2422 * Indicates the key of authentication type. 2423 * 2424 * @syscap SystemCapability.Account.AppAccount 2425 * @since 8 2426 */ 2427 KEY_AUTH_TYPE = 'authType', 2428 2429 /** 2430 * Indicates the key of session id. 2431 * 2432 * @syscap SystemCapability.Account.AppAccount 2433 * @since 8 2434 */ 2435 KEY_SESSION_ID = 'sessionId', 2436 2437 /** 2438 * Indicates the key of caller pid. 2439 * 2440 * @syscap SystemCapability.Account.AppAccount 2441 * @since 8 2442 */ 2443 KEY_CALLER_PID = 'callerPid', 2444 2445 /** 2446 * Indicates the key of caller uid. 2447 * 2448 * @syscap SystemCapability.Account.AppAccount 2449 * @since 8 2450 */ 2451 KEY_CALLER_UID = 'callerUid', 2452 2453 /** 2454 * Indicates the key of caller bundle name. 2455 * 2456 * @syscap SystemCapability.Account.AppAccount 2457 * @since 8 2458 */ 2459 KEY_CALLER_BUNDLE_NAME = 'callerBundleName', 2460 2461 /** 2462 * Indicates the key of required labels. 2463 * 2464 * @syscap SystemCapability.Account.AppAccount 2465 * @since 9 2466 */ 2467 KEY_REQUIRED_LABELS = 'requiredLabels', 2468 2469 /** 2470 * Indicates the key of boolean result. 2471 * 2472 * @syscap SystemCapability.Account.AppAccount 2473 * @since 9 2474 */ 2475 KEY_BOOLEAN_RESULT = 'booleanResult' 2476 } 2477 2478 /** 2479 * Provides result code definition. 2480 * 2481 * @enum { number } ResultCode 2482 * @syscap SystemCapability.Account.AppAccount 2483 * @since 8 2484 * @deprecated since 9 2485 */ 2486 enum ResultCode { 2487 /** 2488 * Indicates the success result. 2489 * 2490 * @syscap SystemCapability.Account.AppAccount 2491 * @since 8 2492 * @deprecated since 9 2493 */ 2494 SUCCESS = 0, 2495 2496 /** 2497 * Indicates the result of account not exist. 2498 * 2499 * @syscap SystemCapability.Account.AppAccount 2500 * @since 8 2501 * @deprecated since 9 2502 */ 2503 ERROR_ACCOUNT_NOT_EXIST = 10001, 2504 2505 /** 2506 * Indicates the result of account service exception. 2507 * 2508 * @syscap SystemCapability.Account.AppAccount 2509 * @since 8 2510 * @deprecated since 9 2511 */ 2512 ERROR_APP_ACCOUNT_SERVICE_EXCEPTION = 10002, 2513 2514 /** 2515 * Indicates the result of password is invalid. 2516 * 2517 * @syscap SystemCapability.Account.AppAccount 2518 * @since 8 2519 * @deprecated since 9 2520 */ 2521 ERROR_INVALID_PASSWORD = 10003, 2522 2523 /** 2524 * Indicates the result of request is invalid. 2525 * 2526 * @syscap SystemCapability.Account.AppAccount 2527 * @since 8 2528 * @deprecated since 9 2529 */ 2530 ERROR_INVALID_REQUEST = 10004, 2531 2532 /** 2533 * Indicates the result of response is invalid. 2534 * 2535 * @syscap SystemCapability.Account.AppAccount 2536 * @since 8 2537 * @deprecated since 9 2538 */ 2539 ERROR_INVALID_RESPONSE = 10005, 2540 2541 /** 2542 * Indicates the result of network exception. 2543 * 2544 * @syscap SystemCapability.Account.AppAccount 2545 * @since 8 2546 * @deprecated since 9 2547 */ 2548 ERROR_NETWORK_EXCEPTION = 10006, 2549 2550 /** 2551 * Indicates the result of network exception. 2552 * 2553 * @syscap SystemCapability.Account.AppAccount 2554 * @since 8 2555 * @deprecated since 9 2556 */ 2557 ERROR_OAUTH_AUTHENTICATOR_NOT_EXIST = 10007, 2558 2559 /** 2560 * Indicates the result of auth has been canceled. 2561 * 2562 * @syscap SystemCapability.Account.AppAccount 2563 * @since 8 2564 * @deprecated since 9 2565 */ 2566 ERROR_OAUTH_CANCELED = 10008, 2567 2568 /** 2569 * Indicates the result of auth list is too large. 2570 * 2571 * @syscap SystemCapability.Account.AppAccount 2572 * @since 8 2573 * @deprecated since 9 2574 */ 2575 ERROR_OAUTH_LIST_TOO_LARGE = 10009, 2576 2577 /** 2578 * Indicates the result of auth service is busy. 2579 * 2580 * @syscap SystemCapability.Account.AppAccount 2581 * @since 8 2582 * @deprecated since 9 2583 */ 2584 ERROR_OAUTH_SERVICE_BUSY = 10010, 2585 2586 /** 2587 * Indicates the result of auth service exception. 2588 * 2589 * @syscap SystemCapability.Account.AppAccount 2590 * @since 8 2591 * @deprecated since 9 2592 */ 2593 ERROR_OAUTH_SERVICE_EXCEPTION = 10011, 2594 2595 /** 2596 * Indicates the result of auth session is not exist. 2597 * 2598 * @syscap SystemCapability.Account.AppAccount 2599 * @since 8 2600 * @deprecated since 9 2601 */ 2602 ERROR_OAUTH_SESSION_NOT_EXIST = 10012, 2603 2604 /** 2605 * Indicates the result of auth timeout. 2606 * 2607 * @syscap SystemCapability.Account.AppAccount 2608 * @since 8 2609 * @deprecated since 9 2610 */ 2611 ERROR_OAUTH_TIMEOUT = 10013, 2612 2613 /** 2614 * Indicates the result of token is not exist. 2615 * 2616 * @syscap SystemCapability.Account.AppAccount 2617 * @since 8 2618 * @deprecated since 9 2619 */ 2620 ERROR_OAUTH_TOKEN_NOT_EXIST = 10014, 2621 2622 /** 2623 * Indicates the result of token is too many. 2624 * 2625 * @syscap SystemCapability.Account.AppAccount 2626 * @since 8 2627 * @deprecated since 9 2628 */ 2629 ERROR_OAUTH_TOKEN_TOO_MANY = 10015, 2630 2631 /** 2632 * Indicates the result of not supported action. 2633 * 2634 * @syscap SystemCapability.Account.AppAccount 2635 * @since 8 2636 * @deprecated since 9 2637 */ 2638 ERROR_OAUTH_UNSUPPORT_ACTION = 10016, 2639 2640 /** 2641 * Indicates the result of not supported auth type. 2642 * 2643 * @syscap SystemCapability.Account.AppAccount 2644 * @since 8 2645 * @deprecated since 9 2646 */ 2647 ERROR_OAUTH_UNSUPPORT_AUTH_TYPE = 10017, 2648 2649 /** 2650 * Indicates the result of permission denied. 2651 * 2652 * @syscap SystemCapability.Account.AppAccount 2653 * @since 8 2654 * @deprecated since 9 2655 */ 2656 ERROR_PERMISSION_DENIED = 10018 2657 } 2658 2659 /** 2660 * Provides methods for authenticator callback. 2661 * 2662 * @interface AuthenticatorCallback 2663 * @syscap SystemCapability.Account.AppAccount 2664 * @since 8 2665 * @deprecated since 9 2666 * @useinstead AppAccount.AuthCallback 2667 */ 2668 interface AuthenticatorCallback { 2669 /** 2670 * Notifies the client of the authentication result. 2671 * 2672 * @syscap SystemCapability.Account.AppAccount 2673 * @since 8 2674 * @deprecated since 9 2675 */ 2676 onResult: (code: number, result: { [key: string]: any }) => void; 2677 2678 /** 2679 * Notifies the client that the authentication request need to be redirected. 2680 * 2681 * @syscap SystemCapability.Account.AppAccount 2682 * @since 8 2683 * @deprecated since 9 2684 */ 2685 onRequestRedirected: (request: Want) => void; 2686 } 2687 2688 /** 2689 * Provides methods for authentication callback. 2690 * 2691 * @interface AuthCallback 2692 * @syscap SystemCapability.Account.AppAccount 2693 * @since 9 2694 */ 2695 interface AuthCallback { 2696 /** 2697 * Notifies the client of the authentication result. 2698 * 2699 * @syscap SystemCapability.Account.AppAccount 2700 * @since 9 2701 */ 2702 onResult: (code: number, result?: AuthResult) => void; 2703 2704 /** 2705 * Notifies the client that the authentication request need to be redirected. 2706 * 2707 * @syscap SystemCapability.Account.AppAccount 2708 * @since 9 2709 */ 2710 onRequestRedirected: (request: Want) => void; 2711 2712 /** 2713 * Notifies the client that the request is continued. 2714 * 2715 * @syscap SystemCapability.Account.AppAccount 2716 * @since 9 2717 */ 2718 onRequestContinued?: () => void; 2719 } 2720 2721 /** 2722 * Provides methods for authenticator. 2723 * 2724 * @syscap SystemCapability.Account.AppAccount 2725 * @since 8 2726 * @name Authenticator 2727 */ 2728 class Authenticator { 2729 /** 2730 * Adds an application account of a specified owner implicitly. 2731 * 2732 * @param { string } authType - Indicates the authentication type. 2733 * @param { string } callerBundleName - Indicates the caller bundle name. 2734 * @param { object } options - Indicates the authenticator-specific options for the request. 2735 * @param { AuthenticatorCallback } callback - Indicates the authenticator callback. 2736 * @syscap SystemCapability.Account.AppAccount 2737 * @since 8 2738 * @deprecated since 9 2739 * @useinstead appAccount.Authenticator#createAccountImplicitly 2740 */ 2741 addAccountImplicitly( 2742 authType: string, 2743 callerBundleName: string, 2744 options: { [key: string]: any }, 2745 callback: AuthenticatorCallback 2746 ): void; 2747 2748 /** 2749 * Creates an application account of a specified owner implicitly. 2750 * 2751 * @param { CreateAccountImplicitlyOptions } options - Indicates the authenticator-specific options for the request. 2752 * @param { AuthCallback } callback - Indicates the authenticator callback. 2753 * @syscap SystemCapability.Account.AppAccount 2754 * @since 9 2755 */ 2756 createAccountImplicitly(options: CreateAccountImplicitlyOptions, callback: AuthCallback): void; 2757 2758 /** 2759 * Authenticates an application account to get an oauth token. 2760 * 2761 * @param { string } name - Indicates the account name. 2762 * @param { string } authType - Indicates the authentication type. 2763 * @param { string } callerBundleName - Indicates the caller bundle name. 2764 * @param { object } options - Indicates the authenticator-specific options for the request. 2765 * @param { AuthenticatorCallback } callback - Indicates the authenticator callback. 2766 * @syscap SystemCapability.Account.AppAccount 2767 * @since 8 2768 * @deprecated since 9 2769 * @useinstead appAccount.Authenticator#auth 2770 */ 2771 authenticate( 2772 name: string, 2773 authType: string, 2774 callerBundleName: string, 2775 options: { [key: string]: any }, 2776 callback: AuthenticatorCallback 2777 ): void; 2778 2779 /** 2780 * Authenticates an application account to get an oauth token. 2781 * 2782 * @param { string } name - Indicates the account name. 2783 * @param { string } authType - Indicates the authentication type. 2784 * @param { Record<string, Object> } options - Indicates the authenticator-specific options for the request. 2785 * @param { AuthCallback } callback - Indicates the authenticator callback. 2786 * @syscap SystemCapability.Account.AppAccount 2787 * @since 9 2788 */ 2789 auth(name: string, authType: string, options: Record<string, Object>, callback: AuthCallback): void; 2790 2791 /** 2792 * Verifies the credential to ensure the user is the owner of the specified application account. 2793 * <p> 2794 * The credential can be provided in the options, otherwise an Ability will normally be returned, 2795 * which can be started by the caller to further verify credential. 2796 * 2797 * @param { string } name - Indicates the name of the application account. 2798 * @param { VerifyCredentialOptions } options - Indicates the options for verifying credential. 2799 * @param { AuthCallback } callback - Indicates the authenticator callback. 2800 * @syscap SystemCapability.Account.AppAccount 2801 * @since 9 2802 */ 2803 verifyCredential(name: string, options: VerifyCredentialOptions, callback: AuthCallback): void; 2804 2805 /** 2806 * Sets properties for the authenticator. 2807 * 2808 * @param { SetPropertiesOptions } options - Indicates the options for setting properties. 2809 * @param { AuthCallback } callback - Indicates the authenticator callback. 2810 * @syscap SystemCapability.Account.AppAccount 2811 * @since 9 2812 */ 2813 setProperties(options: SetPropertiesOptions, callback: AuthCallback): void; 2814 2815 /** 2816 * Checks whether a particular account has all specified labels. 2817 * 2818 * @param { string } name - Indicates the account name. 2819 * @param { Array<string> } labels - Indicates an array of labels to check. 2820 * @param { AuthCallback } callback - Indicates the authenticator callback. 2821 * @syscap SystemCapability.Account.AppAccount 2822 * @since 9 2823 */ 2824 checkAccountLabels(name: string, labels: Array<string>, callback: AuthCallback): void; 2825 2826 /** 2827 * Checks whether the specified account can be removed. 2828 * 2829 * @param { string } name - Indicates the account name. 2830 * @param { AuthCallback } callback - Indicates the authenticator callback. 2831 * @syscap SystemCapability.Account.AppAccount 2832 * @since 9 2833 */ 2834 checkAccountRemovable(name: string, callback: AuthCallback): void; 2835 2836 /** 2837 * Gets the remote object of the authenticator for remote procedure call. 2838 * 2839 * @returns { rpc.RemoteObject } Returns a remote object. 2840 * @syscap SystemCapability.Account.AppAccount 2841 * @since 9 2842 */ 2843 getRemoteObject(): rpc.RemoteObject; 2844 } 2845} 2846 2847export default appAccount; 2848