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