1/* 2 * Copyright (c) 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 } from './basic'; 17 18/** 19 * User authentication 20 * @namespace userAuth 21 * @syscap SystemCapability.UserIAM.UserAuth.Core 22 * @since 6 23 */ 24declare namespace userAuth { 25 /** 26 * Enum for authentication result. 27 * @enum {number} 28 * @syscap SystemCapability.UserIAM.UserAuth.Core 29 * @since 6 30 * @deprecated since 8 31 * @useinstead ohos.userIAM.userAuth.ResultCode 32 */ 33 export enum AuthenticationResult { 34 /** 35 * Indicates that the device does not support authentication. 36 * @syscap SystemCapability.UserIAM.UserAuth.Core 37 * @since 6 38 * @deprecated since 8 39 */ 40 NO_SUPPORT = -1, 41 42 /** 43 * Indicates that authentication is success. 44 * @syscap SystemCapability.UserIAM.UserAuth.Core 45 * @since 6 46 * @deprecated since 8 47 */ 48 SUCCESS = 0, 49 50 /** 51 * Indicates the authenticator fails to identify user. 52 * @syscap SystemCapability.UserIAM.UserAuth.Core 53 * @since 6 54 * @deprecated since 8 55 */ 56 COMPARE_FAILURE = 1, 57 58 /** 59 * Indicates that authentication has been canceled. 60 * @syscap SystemCapability.UserIAM.UserAuth.Core 61 * @since 6 62 * @deprecated since 8 63 */ 64 CANCELED = 2, 65 66 /** 67 * Indicates that authentication has timed out. 68 * @syscap SystemCapability.UserIAM.UserAuth.Core 69 * @since 6 70 * @deprecated since 8 71 */ 72 TIMEOUT = 3, 73 74 /** 75 * Indicates a failure to open the camera. 76 * @syscap SystemCapability.UserIAM.UserAuth.Core 77 * @since 6 78 * @deprecated since 8 79 */ 80 CAMERA_FAIL = 4, 81 82 /** 83 * Indicates that the authentication task is busy. Wait for a few seconds and try again. 84 * @syscap SystemCapability.UserIAM.UserAuth.Core 85 * @since 6 86 * @deprecated since 8 87 */ 88 BUSY = 5, 89 90 /** 91 * Indicates incorrect parameters. 92 * @syscap SystemCapability.UserIAM.UserAuth.Core 93 * @since 6 94 * @deprecated since 8 95 */ 96 INVALID_PARAMETERS = 6, 97 98 /** 99 * Indicates that the authenticator is locked. 100 * @syscap SystemCapability.UserIAM.UserAuth.Core 101 * @since 6 102 * @deprecated since 8 103 */ 104 LOCKED = 7, 105 106 /** 107 * Indicates that the user has not enrolled the authenticator. 108 * @syscap SystemCapability.UserIAM.UserAuth.Core 109 * @since 6 110 * @deprecated since 8 111 */ 112 NOT_ENROLLED = 8, 113 114 /** 115 * Indicates other errors. 116 * @syscap SystemCapability.UserIAM.UserAuth.Core 117 * @since 6 118 * @deprecated since 8 119 */ 120 GENERAL_ERROR = 100, 121 } 122 123 /** 124 * Auth types 125 * @since 6 126 * @deprecated since 8 127 */ 128 type AuthType = "ALL" | "FACE_ONLY"; 129 130 /** 131 * Secure levels 132 * @since 6 133 * @deprecated since 8 134 */ 135 type SecureLevel = "S1" | "S2" | "S3" | "S4"; 136 137 /** 138 * Used to initiate authentication. 139 * @interface Authenticator 140 * @syscap SystemCapability.UserIAM.UserAuth.Core 141 * @since 6 142 * @deprecated since 8 143 */ 144 interface Authenticator { 145 /** 146 * Execute authentication. 147 * @permission ohos.permission.ACCESS_BIOMETRIC 148 * @param type Indicates the authentication type. 149 * @param level Indicates the security level. 150 * @returns Returns authentication result, which is specified by AuthenticationResult. 151 * @syscap SystemCapability.UserIAM.UserAuth.Core 152 * @since 6 153 * @deprecated since 8 154 */ 155 execute(type: AuthType, level: SecureLevel, callback: AsyncCallback<number>): void; 156 execute(type: AuthType, level: SecureLevel): Promise<number>; 157 } 158 159 /** 160 * Get Authenticator instance. 161 * @returns Returns an Authenticator. 162 * @syscap SystemCapability.UserIAM.UserAuth.Core 163 * @deprecated since 8 164 */ 165 function getAuthenticator(): Authenticator; 166 167 /** 168 * User authentication. 169 * @syscap SystemCapability.UserIAM.UserAuth.Core 170 * @since 8 171 * @deprecated since 9 172 * @useinstead ohos.userIAM.userAuth.AuthInstance 173 */ 174 class UserAuth { 175 /** 176 * Constructor to get the UserAuth class instance. 177 * @returns Returns the UserAuth class instance. 178 * @syscap SystemCapability.UserIAM.UserAuth.Core 179 * @since 8 180 * @deprecated since 9 181 * @useinstead ohos.userIAM.userAuth.getAuthInstance 182 */ 183 constructor(); 184 185 /** 186 * Get version information. 187 * @permission ohos.permission.ACCESS_BIOMETRIC 188 * @returns Returns version information. 189 * @syscap SystemCapability.UserIAM.UserAuth.Core 190 * @since 8 191 * @deprecated since 9 192 * @useinstead ohos.userIAM.userAuth.getVersion 193 */ 194 getVersion(): number; 195 196 /** 197 * Check whether the authentication capability is available. 198 * @permission ohos.permission.ACCESS_BIOMETRIC 199 * @param authType Credential type for authentication. 200 * @param authTrustLevel Trust level of authentication result. 201 * @returns Returns a check result, which is specified by getAvailableStatus, the value of number is related to the ResultCode enum, **201** is check permission failed. 202 * @syscap SystemCapability.UserIAM.UserAuth.Core 203 * @since 8 204 * @deprecated since 9 205 * @useinstead ohos.userIAM.userAuth.getAvailableStatus 206 */ 207 getAvailableStatus(authType: UserAuthType, authTrustLevel: AuthTrustLevel): number; 208 209 /** 210 * Executes authentication. 211 * @permission ohos.permission.ACCESS_BIOMETRIC 212 * @param challenge Pass in challenge value. 213 * @param authType Type of authentication. 214 * @param authTrustLevel Trust level of authentication result. 215 * @param callback Return result and acquireInfo through callback, the value of result code is related to the ResultCode enum, **201** is check permission failed. 216 * @returns Returns ContextId for cancel. 217 * @syscap SystemCapability.UserIAM.UserAuth.Core 218 * @since 8 219 * @deprecated since 9 220 * @useinstead ohos.userIAM.userAuth.AuthInstance.start 221 */ 222 auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array; 223 224 /** 225 * Cancel authentication with ContextID. 226 * @permission ohos.permission.ACCESS_BIOMETRIC 227 * @param contextID Cancel authentication and pass in ContextID. 228 * @returns Returns a number value indicating whether Cancel authentication was successful, the value of number is related to the ResultCode enum, **201** is check permission failed. 229 * @syscap SystemCapability.UserIAM.UserAuth.Core 230 * @since 8 231 * @deprecated since 9 232 * @useinstead ohos.userIAM.userAuth.AuthInstance.cancel 233 */ 234 cancelAuth(contextID: Uint8Array): number; 235 } 236 237 /** 238 * Asynchronous callback of authentication operation. 239 * @interface IUserAuthCallback 240 * @syscap SystemCapability.UserIAM.UserAuth.Core 241 * @since 8 242 * @deprecated since 9 243 * @useinstead ohos.userIAM.userAuth.AuthEvent 244 */ 245 interface IUserAuthCallback { 246 /** 247 * The authentication result code is returned through the callback. 248 * If the authentication is passed, the authentication token is returned in extraInfo, 249 * If the authentication fails, the remaining authentication times are returned in extraInfo, 250 * If the authentication executor is locked, the freezing time is returned in extraInfo. 251 * @param result Authentication result code, the value of result code is related to the ResultCode enum, **201** is check permission failed. 252 * @param extraInfo Pass the specific information for different situation. 253 * @syscap SystemCapability.UserIAM.UserAuth.Core 254 * @since 8 255 * @deprecated since 9 256 * @useinstead ohos.userIAM.userAuth.AuthEvent.callback 257 */ 258 onResult: (result: number, extraInfo: AuthResult) => void; 259 260 /** 261 * During an authentication, the TipsCode is returned through the callback. 262 * @param module The executor type for authentication. 263 * @param acquire The tip code for different authentication executor. 264 * @param extraInfo Reserved parameter. 265 * @syscap SystemCapability.UserIAM.UserAuth.Core 266 * @since 8 267 * @deprecated since 9 268 * @useinstead ohos.userIAM.userAuth.AuthEvent.callback 269 */ 270 onAcquireInfo ?: (module: number, acquire: number, extraInfo: any) => void; 271 } 272 273 /** 274 * Authentication result: authentication token, remaining authentication times, freezing time. 275 * @typedef AuthResult 276 * @syscap SystemCapability.UserIAM.UserAuth.Core 277 * @since 8 278 * @deprecated since 9 279 * @useinstead ohos.userIAM.userAuth.AuthResultInfo 280 */ 281 interface AuthResult { 282 /** 283 * The authentication result if the authentication is passed. 284 * @type {Uint8Array} 285 * @since 8 286 */ 287 token ?: Uint8Array; 288 289 /** 290 * The remaining authentication times if the authentication fails. 291 * @type {number} 292 * @since 8 293 */ 294 remainTimes ?: number; 295 296 /** 297 * The freezing time if the authentication executor is locked. 298 * @type {number} 299 * @since 8 300 */ 301 freezingTime ?: number; 302 } 303 304 /** 305 * Enum for operation result. 306 * @enum {number} 307 * @syscap SystemCapability.UserIAM.UserAuth.Core 308 * @since 8 309 * @deprecated since 9 310 * @useinstead ohos.userIAM.userAuth.UserAuthResultCode 311 */ 312 enum ResultCode { 313 /** 314 * Indicates that the result is success or ability is supported. 315 * @syscap SystemCapability.UserIAM.UserAuth.Core 316 * @since 8 317 * @deprecated since 9 318 */ 319 SUCCESS = 0, 320 321 /** 322 * Indicates that authentication failed. 323 * @syscap SystemCapability.UserIAM.UserAuth.Core 324 * @since 8 325 * @deprecated since 9 326 */ 327 FAIL = 1, 328 329 /** 330 * Indicates other errors. 331 * @syscap SystemCapability.UserIAM.UserAuth.Core 332 * @since 8 333 * @deprecated since 9 334 */ 335 GENERAL_ERROR = 2, 336 337 /** 338 * Indicates that this operation has been canceled. 339 * @syscap SystemCapability.UserIAM.UserAuth.Core 340 * @since 8 341 * @deprecated since 9 342 */ 343 CANCELED = 3, 344 345 /** 346 * Indicates that this operation has timed out. 347 * @syscap SystemCapability.UserIAM.UserAuth.Core 348 * @since 8 349 * @deprecated since 9 350 */ 351 TIMEOUT = 4, 352 353 /** 354 * Indicates that this authentication type is not supported. 355 * @syscap SystemCapability.UserIAM.UserAuth.Core 356 * @since 8 357 * @deprecated since 9 358 */ 359 TYPE_NOT_SUPPORT = 5, 360 361 /** 362 * Indicates that the authentication trust level is not supported. 363 * @syscap SystemCapability.UserIAM.UserAuth.Core 364 * @since 8 365 * @deprecated since 9 366 */ 367 TRUST_LEVEL_NOT_SUPPORT = 6, 368 369 /** 370 * Indicates that the authentication task is busy. Wait for a few seconds and try again. 371 * @syscap SystemCapability.UserIAM.UserAuth.Core 372 * @since 8 373 * @deprecated since 9 374 */ 375 BUSY = 7, 376 377 /** 378 * Indicates incorrect parameters. 379 * @syscap SystemCapability.UserIAM.UserAuth.Core 380 * @since 8 381 * @deprecated since 9 382 */ 383 INVALID_PARAMETERS = 8, 384 385 /** 386 * Indicates that the authenticator is locked. 387 * @syscap SystemCapability.UserIAM.UserAuth.Core 388 * @since 8 389 * @deprecated since 9 390 */ 391 LOCKED = 9, 392 393 /** 394 * Indicates that the user has not enrolled the authenticator. 395 * @syscap SystemCapability.UserIAM.UserAuth.Core 396 * @since 8 397 * @deprecated since 9 398 */ 399 NOT_ENROLLED = 10 400 } 401 402 /** 403 * The enumeration of prompt codes in the process of face authentication. 404 * @enum {number} 405 * @syscap SystemCapability.UserIAM.UserAuth.Core 406 * @since 8 407 */ 408 enum FaceTips { 409 /** 410 * Indicates that the obtained facial image is too bright due to high illumination. 411 * @syscap SystemCapability.UserIAM.UserAuth.Core 412 * @since 8 413 */ 414 FACE_AUTH_TIP_TOO_BRIGHT = 1, 415 416 /** 417 * Indicates that the obtained facial image is too dark due to low illumination. 418 * @syscap SystemCapability.UserIAM.UserAuth.Core 419 * @since 8 420 */ 421 FACE_AUTH_TIP_TOO_DARK = 2, 422 423 /** 424 * Indicates that the face is too close to the device. 425 * @syscap SystemCapability.UserIAM.UserAuth.Core 426 * @since 8 427 */ 428 FACE_AUTH_TIP_TOO_CLOSE = 3, 429 430 /** 431 * Indicates that the face is too far away from the device. 432 * @syscap SystemCapability.UserIAM.UserAuth.Core 433 * @since 8 434 */ 435 FACE_AUTH_TIP_TOO_FAR = 4, 436 437 /** 438 * Indicates that the device is too high, and that only the upper part of the face is captured. 439 * @syscap SystemCapability.UserIAM.UserAuth.Core 440 * @since 8 441 */ 442 FACE_AUTH_TIP_TOO_HIGH = 5, 443 444 /** 445 * Indicates that the device is too low, and that only the lower part of the face is captured. 446 * @syscap SystemCapability.UserIAM.UserAuth.Core 447 * @since 8 448 */ 449 FACE_AUTH_TIP_TOO_LOW = 6, 450 451 /** 452 * Indicates that the device is deviated to the right, and that only the right part of the face is captured. 453 * @syscap SystemCapability.UserIAM.UserAuth.Core 454 * @since 8 455 */ 456 FACE_AUTH_TIP_TOO_RIGHT = 7, 457 458 /** 459 * Indicates that the device is deviated to the left, and that only the left part of the face is captured. 460 * @syscap SystemCapability.UserIAM.UserAuth.Core 461 * @since 8 462 */ 463 FACE_AUTH_TIP_TOO_LEFT = 8, 464 465 /** 466 * Indicates that the face moves too fast during facial information collection. 467 * @syscap SystemCapability.UserIAM.UserAuth.Core 468 * @since 8 469 */ 470 FACE_AUTH_TIP_TOO_MUCH_MOTION = 9, 471 472 /** 473 * Indicates that the face is not facing the device. 474 * @syscap SystemCapability.UserIAM.UserAuth.Core 475 * @since 8 476 */ 477 FACE_AUTH_TIP_POOR_GAZE = 10, 478 479 /** 480 * Indicates that no face is detected. 481 * @syscap SystemCapability.UserIAM.UserAuth.Core 482 * @since 8 483 */ 484 FACE_AUTH_TIP_NOT_DETECTED = 11, 485 } 486 487 /** 488 * The enumeration of prompt codes in the process of fingerprint authentication. 489 * @enum {number} 490 * @syscap SystemCapability.UserIAM.UserAuth.Core 491 * @since 8 492 */ 493 enum FingerprintTips { 494 /** 495 * Indicates that the image acquired is good. 496 * @syscap SystemCapability.UserIAM.UserAuth.Core 497 * @since 8 498 */ 499 FINGERPRINT_AUTH_TIP_GOOD = 0, 500 501 /** 502 * Indicates that the fingerprint image is too noisy due to suspected or detected dirt on sensor. 503 * @syscap SystemCapability.UserIAM.UserAuth.Core 504 * @since 8 505 */ 506 FINGERPRINT_AUTH_TIP_DIRTY = 1, 507 508 /** 509 * Indicates that the fingerprint image is too noisy to process due to a detected condition. 510 * @syscap SystemCapability.UserIAM.UserAuth.Core 511 * @since 8 512 */ 513 FINGERPRINT_AUTH_TIP_INSUFFICIENT = 2, 514 515 /** 516 * Indicates that only a partial fingerprint image is detected. 517 * @syscap SystemCapability.UserIAM.UserAuth.Core 518 * @since 8 519 */ 520 FINGERPRINT_AUTH_TIP_PARTIAL = 3, 521 522 /** 523 * Indicates that the fingerprint image is incomplete due to quick motion. 524 * @syscap SystemCapability.UserIAM.UserAuth.Core 525 * @since 8 526 */ 527 FINGERPRINT_AUTH_TIP_TOO_FAST = 4, 528 529 /** 530 * Indicates that the fingerprint image is unreadable due to lack of motion. 531 * @syscap SystemCapability.UserIAM.UserAuth.Core 532 * @since 8 533 */ 534 FINGERPRINT_AUTH_TIP_TOO_SLOW = 5 535 } 536 537 /** 538 * Credential type for authentication. 539 * @enum {number} 540 * @syscap SystemCapability.UserIAM.UserAuth.Core 541 * @since 8 542 */ 543 enum UserAuthType { 544 /** 545 * Authentication type face. 546 * @syscap SystemCapability.UserIAM.UserAuth.Core 547 * @since 8 548 */ 549 FACE = 2, 550 551 /** 552 * Authentication type fingerprint. 553 * @syscap SystemCapability.UserIAM.UserAuth.Core 554 * @since 8 555 */ 556 FINGERPRINT = 4 557 } 558 559 /** 560 * Trust level of authentication results. 561 * @enum {number} 562 * @syscap SystemCapability.UserIAM.UserAuth.Core 563 * @since 8 564 */ 565 enum AuthTrustLevel { 566 /** 567 * Authentication result trusted level 1. 568 * @syscap SystemCapability.UserIAM.UserAuth.Core 569 * @since 8 570 */ 571 ATL1 = 10000, 572 573 /** 574 * Authentication result trusted level 2. 575 * @syscap SystemCapability.UserIAM.UserAuth.Core 576 * @since 8 577 */ 578 ATL2 = 20000, 579 580 /** 581 * Authentication result trusted level 3. 582 * @syscap SystemCapability.UserIAM.UserAuth.Core 583 * @since 8 584 */ 585 ATL3 = 30000, 586 587 /** 588 * Authentication result trusted level 4. 589 * @syscap SystemCapability.UserIAM.UserAuth.Core 590 * @since 8 591 */ 592 ATL4 = 40000 593 } 594 595 /** 596 * Authentication events. 597 * @since 9 598 */ 599 type AuthEventKey = "result" | "tip"; 600 601 /** 602 * Return information of Authentication events. 603 * @syscap SystemCapability.UserIAM.UserAuth.Core 604 * @since 9 605 */ 606 type EventInfo = AuthResultInfo | TipInfo; 607 608 /** 609 * Asynchronous callback of authentication event. 610 * @interface AuthEvent 611 * @syscap SystemCapability.UserIAM.UserAuth.Core 612 * @since 9 613 */ 614 interface AuthEvent { 615 /** 616 * The authentication event callback. 617 * @param result Event info. 618 * @syscap SystemCapability.UserIAM.UserAuth.Core 619 * @since 9 620 */ 621 callback(result: EventInfo): void; 622 } 623 624 /** 625 * Authentication result information. 626 * @typedef AuthResultInfo 627 * @syscap SystemCapability.UserIAM.UserAuth.Core 628 * @since 9 629 */ 630 interface AuthResultInfo { 631 /** 632 * The authentication result. 633 * @type {number} 634 * @since 9 635 */ 636 result: number; 637 638 /** 639 * The authentication token if the authentication is passed. 640 * @type {Uint8Array} 641 * @since 9 642 */ 643 token ?: Uint8Array; 644 645 /** 646 * The remaining authentication attempts if the authentication fails. 647 * @type {number} 648 * @since 9 649 */ 650 remainAttempts ?: number; 651 652 /** 653 * The lockout duration if the authentication executor is locked. 654 * @type {number} 655 * @since 9 656 */ 657 lockoutDuration ?: number; 658 } 659 660 /** 661 * Authentication tip info. 662 * @typedef TipInfo 663 * @syscap SystemCapability.UserIAM.UserAuth.Core 664 * @since 9 665 */ 666 interface TipInfo { 667 /** 668 * The authentication module of sending tip information. 669 * @type {number} 670 * @since 9 671 */ 672 module: number; 673 674 /** 675 * Tip information, used to prompt the business to perform some operations. 676 * @type {number} 677 * @since 9 678 */ 679 tip: number; 680 } 681 682 /** 683 * Authentication instance, used to initiate a complete authentication. 684 * @interface AuthInstance 685 * @syscap SystemCapability.UserIAM.UserAuth.Core 686 * @since 9 687 */ 688 interface AuthInstance { 689 /** 690 * Turn on authentication event listening. 691 * @param name Event name. 692 * @param callback Event information return. 693 * @throws { BusinessError } 401 - Incorrect parameters. 694 * @throws { BusinessError } 12500002 - General operation error. 695 * @syscap SystemCapability.UserIAM.UserAuth.Core 696 * @since since 9 697 */ 698 on: (name: AuthEventKey, callback: AuthEvent) => void; 699 700 /** 701 * Turn off authentication event listening. 702 * @param name Event name. 703 * @throws { BusinessError } 401 - Incorrect parameters. 704 * @throws { BusinessError } 12500002 - General operation error. 705 * @syscap SystemCapability.UserIAM.UserAuth.Core 706 * @since since 9 707 */ 708 off: (name: AuthEventKey) => void; 709 710 /** 711 * Start this authentication, an instance can only perform authentication once. 712 * @permission ohos.permission.ACCESS_BIOMETRIC 713 * @throws { BusinessError } 201 - Permission verification failed. 714 * @throws { BusinessError } 401 - Incorrect parameters. 715 * @throws { BusinessError } 12500001 - Authentication failed. 716 * @throws { BusinessError } 12500002 - General operation error. 717 * @throws { BusinessError } 12500003 - The operation is canceled. 718 * @throws { BusinessError } 12500004 - The operation is time-out. 719 * @throws { BusinessError } 12500005 - The authentication type is not supported. 720 * @throws { BusinessError } 12500006 - The authentication trust level is not supported. 721 * @throws { BusinessError } 12500007 - The authentication task is busy. 722 * @throws { BusinessError } 12500009 - The authenticator is locked. 723 * @throws { BusinessError } 12500010 - The type of credential has not been enrolled. 724 * @syscap SystemCapability.UserIAM.UserAuth.Core 725 * @since since 9 726 */ 727 start: () => void; 728 729 /** 730 * Cancel this authentication. 731 * @permission ohos.permission.ACCESS_BIOMETRIC 732 * @throws { BusinessError } 201 - Permission verification failed. 733 * @throws { BusinessError } 401 - Incorrect parameters. 734 * @throws { BusinessError } 12500002 - General operation error. 735 * @syscap SystemCapability.UserIAM.UserAuth.Core 736 * @since since 9 737 */ 738 cancel: () => void; 739 } 740 741 /** 742 * Check whether the authentication capability is available. 743 * @permission ohos.permission.ACCESS_BIOMETRIC 744 * @param authType Credential type for authentication. 745 * @param authTrustLevel Trust level of authentication result. 746 * @throws { BusinessError } 201 - Permission verification failed. 747 * @throws { BusinessError } 401 - Incorrect parameters. 748 * @throws { BusinessError } 12500002 - General operation error. 749 * @throws { BusinessError } 12500005 - The authentication type is not supported. 750 * @throws { BusinessError } 12500006 - The authentication trust level is not supported. 751 * @throws { BusinessError } 12500010 - The type of credential has not been enrolled. 752 * @syscap SystemCapability.UserIAM.UserAuth.Core 753 * @since 9 754 */ 755 function getAvailableStatus(authType: UserAuthType, authTrustLevel: AuthTrustLevel): void; 756 757 /** 758 * Get Authentication instance. 759 * @param challenge Pass in challenge value. 760 * @param authType Credential type for authentication. 761 * @param authTrustLevel Trust level of authentication result. 762 * @returns Returns an authentication instance. 763 * @throws { BusinessError } 401 - Incorrect parameters. 764 * @throws { BusinessError } 12500002 - General operation error. 765 * @throws { BusinessError } 12500005 - The authentication type is not supported. 766 * @throws { BusinessError } 12500006 - The authentication trust level is not supported. 767 * @syscap SystemCapability.UserIAM.UserAuth.Core 768 * @since 9 769 */ 770 function getAuthInstance(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLevel): AuthInstance; 771 772 /** 773 * Enum for operation result. 774 * @enum {number} 775 * @syscap SystemCapability.UserIAM.UserAuth.Core 776 * @since 9 777 */ 778 enum UserAuthResultCode { 779 /** 780 * Indicates that the result is success or ability is supported. 781 * @syscap SystemCapability.UserIAM.UserAuth.Core 782 * @since 9 783 */ 784 SUCCESS = 12500000, 785 786 /** 787 * Indicates that the authentication result is failed. 788 * @syscap SystemCapability.UserIAM.UserAuth.Core 789 * @since 9 790 */ 791 FAIL = 12500001, 792 793 /** 794 * Indicates other errors. 795 * @syscap SystemCapability.UserIAM.UserAuth.Core 796 * @since 9 797 */ 798 GENERAL_ERROR = 12500002, 799 800 /** 801 * Indicates that this operation is canceled. 802 * @syscap SystemCapability.UserIAM.UserAuth.Core 803 * @since 9 804 */ 805 CANCELED = 12500003, 806 807 /** 808 * Indicates that this operation is time-out. 809 * @syscap SystemCapability.UserIAM.UserAuth.Core 810 * @since 9 811 */ 812 TIMEOUT = 12500004, 813 814 /** 815 * Indicates that this authentication type is not supported. 816 * @syscap SystemCapability.UserIAM.UserAuth.Core 817 * @since 9 818 */ 819 TYPE_NOT_SUPPORT = 12500005, 820 821 /** 822 * Indicates that the authentication trust level is not supported. 823 * @syscap SystemCapability.UserIAM.UserAuth.Core 824 * @since 9 825 */ 826 TRUST_LEVEL_NOT_SUPPORT = 12500006, 827 828 /** 829 * Indicates that the authentication task is busy. Wait for a few seconds and try again. 830 * @syscap SystemCapability.UserIAM.UserAuth.Core 831 * @since 9 832 */ 833 BUSY = 12500007, 834 835 /** 836 * Indicates that the authenticator is locked. 837 * @syscap SystemCapability.UserIAM.UserAuth.Core 838 * @since 9 839 */ 840 LOCKED = 12500009, 841 842 /** 843 * Indicates that the user has not enrolled the authenticator. 844 * @syscap SystemCapability.UserIAM.UserAuth.Core 845 * @since 9 846 */ 847 NOT_ENROLLED = 12500010 848 } 849} 850 851export default userAuth; 852