diff --git a/api/@ohos.ability.wantConstant.d.ts b/api/@ohos.ability.wantConstant.d.ts index c0b1cc914c9152cf9a6000715cd2366be197dabc..15ce6b7a38b7e0742efabde7e282d361b7686d59 100644 --- a/api/@ohos.ability.wantConstant.d.ts +++ b/api/@ohos.ability.wantConstant.d.ts @@ -213,9 +213,18 @@ declare namespace wantConstant { * Indicates the action of providing oauth service. * * @since 8 + * @deprecated since 9 + * @useinstead wantConstant.Action#ACTION_APP_ACCOUNT_AUTH */ ACTION_APP_ACCOUNT_OAUTH = "ohos.account.appAccount.action.oauth", + /** + * Indicates the action of providing auth service. + * + * @since 9 + */ + ACTION_APP_ACCOUNT_AUTH = "account.appAccount.action.auth", + /** * Indicates the action of an application downloaded from the application market. * diff --git a/api/@ohos.account.appAccount.d.ts b/api/@ohos.account.appAccount.d.ts index de8c4c0c8ef3b4fe013ac1f0ce482e8739bfa9ec..c1c808ad92bd76176f2a1a85d9a7947be5cdde77 100644 --- a/api/@ohos.account.appAccount.d.ts +++ b/api/@ohos.account.appAccount.d.ts @@ -19,74 +19,127 @@ import rpc from './@ohos.rpc' /** * This module provides the capability to manage application accounts. - * - * @since 7 * @syscap SystemCapability.Account.AppAccount + * @since 7 */ declare namespace appAccount { /** * Obtains the AppAccountManager instance. - * @since 7 + * @returns Returns the instance of the AppAccountManager. * @syscap SystemCapability.Account.AppAccount - * @return Returns the instance of the AppAccountManager. + * @since 7 */ function createAppAccountManager(): AppAccountManager; /** * Provides methods for managing application accounts. * @name AppAccountManager - * @since 7 * @syscap SystemCapability.Account.AppAccount + * @since 7 */ interface AppAccountManager { /** * Adds the account name and extra information of this application to the account management service. *

* Only the owner of the application account has the permission to call this method. - * - * @since 7 * @param name Indicates the name of the application account to add. * @param extraInfo Indicates the extra information of the application account to add. * The extra information cannot be sensitive information of the application account. - * @return void. + * @returns void. + * @since 7 + * @deprecated since 9 + * @useinstead appAccount.AppAccountManager#createAccount */ addAccount(name: string, callback: AsyncCallback): void; addAccount(name: string, extraInfo: string, callback: AsyncCallback): void; addAccount(name: string, extraInfo?: string): Promise; + /** + * Creates the account name and extra information of this application to the account management service. + *

+ * Only the owner of the application account has the permission to call this method. + * @param name Indicates the name of the application account to add. + * @param options Indicates the extra information of the application account to add. + * The extra information cannot be sensitive information of the application account. + * @returns void. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid name or options. + * @throws {BusinessError} 12300008 - the account indicated by name already exist. + * @throws {BusinessError} 12300011 - the account number has reached the upper limit. + * @since 9 + */ + createAccount(name: string, callback: AsyncCallback): void; + createAccount(name: string, options: CreateAccountOptions, callback: AsyncCallback): void; + createAccount(name: string, options?: CreateAccountOptions): Promise; + /** * Adds an application account of a specified owner implicitly. - * - * @since 8 * @param owner Indicates the account owner of your application or third-party applications. * @param authType Indicates the authentication type. * @param options Indicates the authenticator-specific options for the request. * @param callback Indicates the authenticator callback. - * @return void. + * @returns void. + * @since 8 + * @deprecated since 9 + * @useinstead appAccount.AppAccountManager#createAccountImplicitly */ addAccountImplicitly(owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void; + /** + * Creates an application account of a specified owner implicitly. + * @param owner Indicates the account owner of your application or third-party applications. + * @param options Indicates the authenticator-specific options for the request. + * @param callback Indicates the authenticator callback. + * @returns void. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid owner or options. + * @throws {BusinessError} 12300011 - the account number has reached the upper limit. + * @throws {BusinessError} 12400002 - the account authenticator service does not exist. + * @since 9 + */ + createAccountImplicitly(owner: string, callback: AuthCallback): void; + createAccountImplicitly(owner: string, options: CreateAccountImplicitlyOptions, callback: AuthCallback): void; + /** * Deletes an application account from the account management service. *

* Only the owner of the application account has the permission to call this method. - * - * @since 7 * @param name Indicates the name of the application account to delete. - * @return void. + * @returns void. + * @since 7 + * @deprecated since 9 + * @useinstead appAccount.AppAccountManager#removeAccount */ deleteAccount(name: string, callback: AsyncCallback): void; deleteAccount(name: string): Promise; + /** + * Removes an application account from the account management service. + *

+ * Only the owner of the application account has the permission to call this method. + * @param name Indicates the name of the application account to delete. + * @returns void. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid name. + * @throws {BusinessError} 12300003 - the account indicated by name dose not exist. + * @since 9 + */ + removeAccount(name: string, callback: AsyncCallback): void; + removeAccount(name: string): Promise; + /** * Disables a third-party application with the specified bundle name from * accessing the given application account. - * - * @since 7 * @param name Indicates the name of the application account to disable access from * the third-party application. * @param bundleName Indicates the bundle name of the third-party application. - * @return void. + * @returns void. + * @since 7 + * @deprecated since 9 + * @useinstead appAccount.AppAccountManager#setAppAccess */ disableAppAccess(name: string, bundleName: string, callback: AsyncCallback): void; disableAppAccess(name: string, bundleName: string): Promise; @@ -94,23 +147,45 @@ declare namespace appAccount { /** * Enables a third-party application with the specified bundle name to access the given application * account for data query and listening. - * - * @since 7 * @param name Indicates the name of the application account. * @param bundleName Indicates the bundle name of the third-party application. - * @return void. + * @returns void. + * @since 7 + * @deprecated since 9 + * @useinstead appAccount.AppAccountManager#setAppAccess */ enableAppAccess(name: string, bundleName: string, callback: AsyncCallback): void; enableAppAccess(name: string, bundleName: string): Promise; + /** + * Sets a third-party application with the specified bundle name to access the given application + * account for data query and listening. + * @param name Indicates the name of the application account. + * @param bundleName Indicates the bundle name of the third-party application. + * @param isAccessible Indicates the accessibility flag, true for accessible, false for inaccessible. + * @returns void. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid name or bundlename. + * @throws {BusinessError} 12300003 - the account indicated by localId dose not exist. + * @throws {BusinessError} 12400001 - the application indicated by bundlename does not exist. + * @since 9 + */ + setAppAccess(name: string, bundleName: string, isAccessible: boolean, callback: AsyncCallback): void; + setAppAccess(name: string, bundleName: string, isAccessible: boolean): Promise; + /** * Checks whether a third-party application with the specified bundle name is allowed to access * the given application account for data query and listening. - * - * @since 9 * @param name Indicates the name of the application account. * @param bundleName Indicates the bundle name of the third-party application. - * @return void. + * @returns void. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid name or bundlename. + * @throws {BusinessError} 12300003 - the account indicated by localId dose not exist. + * @throws {BusinessError} 12400001 - the application indicated by bundlename does not exist. + * @since 9 */ checkAppAccess(name: string, bundleName: string, callback: AsyncCallback): void; checkAppAccess(name: string, bundleName: string): Promise; @@ -119,45 +194,83 @@ declare namespace appAccount { * Checks whether a specified application account allows application data synchronization. *

* If the same OHOS account has logged in to multiple devices, these devices constitute a super device - * through the distributed networking. On the networked devices, you can call this method to check + * through the distributed networking. On the connected devices, you can call this method to check * whether application data can be synchronized. *

- * - * @since 7 - * @param name Indicates the name of the application account. - * @return Returns {@code true} if application data synchronization is allowed; returns {@code false} otherwise. * @permission ohos.permission.DISTRIBUTED_DATASYNC. + * @param name Indicates the name of the application account. + * @returns Returns {@code true} if application data synchronization is allowed; returns {@code false} otherwise. + * @since 7 + * @deprecated since 9 + * @useinstead appAccount.AppAccountManager#checkDataSyncEnabled */ checkAppAccountSyncEnable(name: string, callback: AsyncCallback): void; checkAppAccountSyncEnable(name: string): Promise; + /** + * Checks whether application data synchronization is enabled for the specified account. + *

+ * If the same OHOS account has logged in to multiple devices, these devices constitute a super device + * through the distributed networking. On the connected devices, you can call this method to check + * whether application data can be synchronized. + *

+ * @permission ohos.permission.DISTRIBUTED_DATASYNC. + * @param name Indicates the name of the application account. + * @returns Returns {@code true} if application data synchronization is allowed; returns {@code false} otherwise. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid name. + * @throws {BusinessError} 12300003 - the account indicated by localId dose not exist. + * @since 9 + */ + checkDataSyncEnabled(name: string, callback: AsyncCallback): void; + checkDataSyncEnabled(name: string): Promise; + /** * Sets the credential for this application account. - * - * @since 7 * @param name Indicates the name of the application account. * @param credentialType Indicates the type of the credential to set. * @param credential Indicates the credential to set. - * @return void. + * @returns void. + * @since 7 + * @deprecated since 9 + * @useinstead appAccount.AppAccountManager#setCredential */ setAccountCredential(name: string, credentialType: string, credential: string, callback: AsyncCallback): void; setAccountCredential(name: string, credentialType: string, credential: string): Promise; + /** + * Sets the credential for this application account. + * @param name Indicates the name of the application account. + * @param credentialType Indicates the type of the credential to set. + * @param credential Indicates the credential to set. + * @returns void. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid name or credentialType. + * @throws {BusinessError} 12300003 - the account indicated by localId dose not exist. + * @since 9 + */ + setCredential(name: string, credentialType: string, credential: string, + callback: AsyncCallback): void; + setCredential(name: string, credentialType: string, credential: string): Promise; + /** * Sets extra information for this application account. *

* You can call this method when you forget the extra information of your application account or * need to modify the extra information. - * - * @since 7 * @param name Indicates the name of the application account. * @param extraInfo Indicates the extra information to set. - * @return void. + * @returns void. + * @since 7 + * @deprecated since 9 */ setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback): void; setAccountExtraInfo(name: string, extraInfo: string): Promise; - + /** * Sets whether a specified application account allows application data synchronization. *

@@ -173,28 +286,75 @@ declare namespace appAccount { * Application data that can be synchronized: application account name, token, * and data associated with this application account *

- * - * @since 7 + * @permission ohos.permission.DISTRIBUTED_DATASYNC. * @param name Indicates the name of the application account. * @param isEnable Specifies whether to allow application data synchronization. - * @return void. - * @permission ohos.permission.DISTRIBUTED_DATASYNC. + * @returns void. + * @since 7 + * @deprecated since 9 + * @useinstead appAccount.AppAccountManager#setDataSyncEnabled */ setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback): void; setAppAccountSyncEnable(name: string, isEnable: boolean): Promise; + /** + * Sets whether a specified application account enables application data synchronization. + *

+ * If the same OHOS account has logged in to multiple devices, these devices constitute a super device + * through the distributed networking. On the networked devices, you can call this method to set whether to + * enable cross-device data synchronization. If synchronization is enabled, application data can be synchronized + * among these devices in the event of any changes related to the application account. + * If synchronization is not enabled, the application data is stored only on the local device. + *

+ * Application account-related changes: adding or deleting an application account, setting extra + * information (such as updating a token), and setting data associated with this application account + *

+ * Application data that can be synchronized: application account name, token, + * and data associated with this application account + *

+ * @permission ohos.permission.DISTRIBUTED_DATASYNC. + * @param name Indicates the name of the application account. + * @param isEnabled Specifies whether to enable application data synchronization. + * @returns void. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid name. + * @throws {BusinessError} 12300003 - the account indicated by name dose not exist. + * @since 9 + */ + setDataSyncEnabled(name: string, isEnabled: boolean, callback: AsyncCallback): void; + setDataSyncEnabled(name: string, isEnabled: boolean): Promise; + /** * Sets data associated with this application account. - * - * @since 7 * @param name Indicates the name of the application account. * @param key Indicates the key of the data to set. The key can be customized. * @param value Indicates the value of the data to set. - * @return void. + * @returns void. + * @since 7 + * @deprecated since 9 + * @useinstead appAccount.AppAccountManager#setCustomData */ setAssociatedData(name: string, key: string, value: string, callback: AsyncCallback): void; setAssociatedData(name: string, key: string, value: string): Promise; + /** + * Sets data associated with this application account. + * @param name Indicates the name of the application account. + * @param key Indicates the key of the data to set. The key can be customized. + * @param value Indicates the value of the data to set. + * @returns void. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid name, key or value. + * @throws {BusinessError} 12300003 - the account indicated by name dose not exist. + * @throws {BusinessError} 12400008 - the number of customized data has reached the upper limit. + * @since 9 + */ + setCustomData(name: string, key: string, value: string, callback: AsyncCallback): void; + setCustomData(name: string, key: string, value: string): Promise; + /** * Obtains information about all accessible accounts. *

@@ -204,14 +364,34 @@ declare namespace appAccount { *

  • Accounts of third-party applications. To obtain such information, * your application must have gained authorization from the third-party applications.
  • * - * - * @since 7 - * @return Returns a list of application accounts. * @permission ohos.permission.GET_ALL_APP_ACCOUNTS. + * @returns Returns a list of application accounts. + * @since 7 + * @deprecated since 9 + * @useinstead appAccount.AppAccountManager#getAllAccounts */ getAllAccessibleAccounts(callback: AsyncCallback>): void; getAllAccessibleAccounts(): Promise>; + /** + * Obtains information about all accessible accounts. + *

    + * This method applies to the following accounts: + *

    + * @permission ohos.permission.GET_ALL_APP_ACCOUNTS. + * @returns Returns a list of application accounts. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @since 9 + */ + getAllAccounts(callback: AsyncCallback>): void; + getAllAccounts(): Promise>; + /** * Obtains information about all accounts of a specified account owner. *

    @@ -221,274 +401,567 @@ declare namespace appAccount { *

  • Accounts of third-party applications. To obtain such information, * your application must have gained authorization from the third-party applications.
  • * - * - * @since 7 - * @param owner Indicates the account owner of your application or third-party applications. - * @return Returns a list of application accounts. * @permission ohos.permission.GET_ALL_APP_ACCOUNTS. + * @param owner Indicates the account owner of your application or third-party applications. + * @returns Returns a list of application accounts. + * @since 7 + * @deprecated since 9 + * @useinstead appAccount.AppAccountManager#getAccountsByOwner */ getAllAccounts(owner: string, callback: AsyncCallback>): void; getAllAccounts(owner: string): Promise>; + /** + * Gets information about all accounts of a specified account owner. + *

    + * This method applies to the following accounts: + *

      + *
    • Accounts of this application.
    • + *
    • Accounts of third-party applications. To obtain such information, + * your application must have gained authorization from the third-party applications.
    • + *
    + * @permission ohos.permission.GET_ALL_APP_ACCOUNTS. + * @param owner Indicates the account owner of your application or third-party applications. + * @returns Returns a list of application accounts. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid owner. + * @throws {BusinessError} 12300003 - the account indicated by owner dose not exist. + * @since 9 + */ + getAccountsByOwner(owner: string, callback: AsyncCallback>): void; + getAccountsByOwner(owner: string): Promise>; + /** * Obtains the credential of this application account. - * - * @since 7 * @param name Indicates the name of the application account. * @param credentialType Indicates the type of the credential to obtain. - * @return Returns the credential of the application account. + * @returns Returns the credential of the application account. + * @since 7 + * @deprecated since 9 + * @useinstead appAccount.AppAccountManager#getCredential */ getAccountCredential(name: string, credentialType: string, callback: AsyncCallback): void; getAccountCredential(name: string, credentialType: string): Promise; + /** + * Obtains the credential of this application account. + * @param name Indicates the name of the application account. + * @param credentialType Indicates the type of the credential to obtain. + * @returns Returns the credential of the application account. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid name or credentialType. + * @throws {BusinessError} 12300003 - the account indicated by name dose not exist. + * @throws {BusinessError} 12300019 - credential does not exist. + * @since 9 + */ + getCredential(name: string, credentialType: string, callback: AsyncCallback): void; + getCredential(name: string, credentialType: string): Promise; + /** * Obtains extra information of this application account. - * - * @since 7 * @param name Indicates the name of the application account. - * @return Returns the extra information of the account; returns {@code null} in other scenarios, + * @returns Returns the extra information of the account; returns {@code null} in other scenarios, * for example, if the account does not exist. + * @since 7 + * @deprecated since 9 */ getAccountExtraInfo(name: string, callback: AsyncCallback): void; getAccountExtraInfo(name: string): Promise; /** * Obtains data associated with this application account. - * - * @since 7 * @param name Indicates the name of the application account. * @param key Indicates the key of the data to obtain. - * @return Returns the associated data of the application account. + * @returns Returns the associated data of the application account. + * @since 7 + * @deprecated since 9 + * @useinstead appAccount.AppAccountManager#getCustomData */ getAssociatedData(name: string, key: string, callback: AsyncCallback): void; getAssociatedData(name: string, key: string): Promise; /** - * Obtains data associated with the specified account synchronously. - * + * Obtains data associated with this application account. + * @param name Indicates the name of the application account. + * @param key Indicates the key of the data to obtain. + * @returns Returns the associated data of the application account. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid name or key. + * @throws {BusinessError} 12300003 - the account indicated by name dose not exist. + * @throws {BusinessError} 12400009 - the customData does not exist. * @since 9 + */ + getCustomData(name: string, key: string, callback: AsyncCallback): void; + getCustomData(name: string, key: string): Promise; + + /** + * Obtains data associated with the specified account synchronously. * @param name Indicates the name of the application account. * @param key Indicates the key of the data to obtain. - * @return Returns the associated data of the application account. + * @returns Returns the associated data of the application account. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid name or key. + * @throws {BusinessError} 12300003 - the account indicated by name dose not exist. + * @since 9 */ - getAssociatedDataSync(name: string, key: string): string; + getCustomDataSync(name: string, key: string): string; /** * Subscribes to the change events of accounts of the specified owners. *

    * When the account owner updates the account, the subscriber will receive a notification * about the account change event. - * - * @since 7 * @param owners Indicates the account owners, which are specified * by {@link AppAccount#AppAccount(String name, String owner)}. - * @return void + * @returns void + * @since 7 + * @deprecated since 9 + * @useinstead appAccount.AppAccountManager#on */ on(type: 'change', owners: Array, callback: Callback>): void; + /** + * Subscribes to the change events of accounts of the specified owners. + *

    + * When the account owner updates the account, the subscriber will receive a notification + * about the account change event. + * @param owners Indicates the account owners, which are specified + * by {@link AppAccount#AppAccount(String name, String owner)}. + * @returns void + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid type or owners. + * @throws {BusinessError} 12300003 - the account indicated by owners dose not exist. + * @throws {BusinessError} 12300005 - the listener has been registered. + * @since 9 + */ + on(type: 'accountChange', owners: Array, callback: Callback>): void; + /** * Unsubscribes from account events. - * + * @returns void * @since 7 - * @return void + * @deprecated since 9 + * @useinstead appAccount.AppAccountManager#off */ off(type: 'change', callback?: Callback>): void; + /** + * Unsubscribes from account events. + * @returns void + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid type. + * @throws {BusinessError} 12300005 - the listener has been registered. + * @since 9 + */ + off(type: 'accountChange', callback?: Callback>): void; + /** * Authenticates an application account to get an oauth token. - * - * @since 8 * @param name Indicates the account name of your application or third-party applications. * @param owner Indicates the account owner of your application or third-party applications. * @param authType Indicates the authentication type. * @param options Indicates the authenticator-specific options for the request. * @param callback Indicates the authenticator callback. - * @return void. + * @returns void. + * @since 8 + * @deprecated since 9 + * @useinstead appAccount.AppAccountManager#auth */ authenticate(name: string, owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void; + /** + * Authenticates an application account to get an auth token. + * @param name Indicates the account name of your application or third-party applications. + * @param owner Indicates the account owner of your application or third-party applications. + * @param authType Indicates the authentication type. + * @param options Indicates the authenticator-specific options for the request. + * @param callback Indicates the authenticator callback. + * @returns void. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid name, owner, authType or options. + * @throws {BusinessError} 12300003 - the account indicated by owner dose not exist. + * @throws {BusinessError} 12300016 - authentication timeout. + * @throws {BusinessError} 12300017 - authentication service is busy. + * @throws {BusinessError} 12300018 - authentication service is locked. + * @throws {BusinessError} 12400001 - the application indicated by name does not exist. + * @since 9 + */ + auth(name: string, owner: string, authType: string, callback: AuthCallback): void; + auth(name: string, owner: string, authType: string, options: {[key:string]: Object}, callback: AuthCallback): void; + /** * Gets an oauth token with the specified authentication type from a particular application account. - * - * @since 8 * @param name Indicates the account name of your application or third-party applications. * @param owner Indicates the account owner of your application or third-party applications. * @param authType Indicates the authentication type. - * @return Returns an oauth token. + * @returns Returns an oauth token. + * @since 8 + * @deprecated since 9 + * @useinstead appAccount.AppAccountManager#getAuthToken */ getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCallback): void; getOAuthToken(name: string, owner: string, authType: string): Promise; + /** + * Gets an auth token with the specified authentication type from a particular application account. + * @param name Indicates the account name of your application or third-party applications. + * @param owner Indicates the account owner of your application or third-party applications. + * @param authType Indicates the authentication type. + * @returns Returns an auth token. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid name, owner or authType. + * @throws {BusinessError} 12300003 - the account indicated by owner dose not exist. + * @throws {BusinessError} 12300015 - the authType is not supported on current device. + * @throws {BusinessError} 12400001 - the application indicated by name does not exist. + * @since 9 + */ + getAuthToken(name: string, owner: string, authType: string, callback: AsyncCallback): void; + getAuthToken(name: string, owner: string, authType: string): Promise; + /** * Sets an oauth token with the specified authentication type for a particular account. *

    * Only the owner of the application account has the permission to call this method. - * - * @since 8 * @param name Indicates the account name of your application. * @param authType Indicates the authentication type. * @param token Indicates the oauth token. - * @return void. + * @returns void. + * @since 8 + * @deprecated since 9 + * @useinstead appAccount.AppAccountManager#setAuthToken */ setOAuthToken(name: string, authType: string, token: string, callback: AsyncCallback): void; setOAuthToken(name: string, authType: string, token: string): Promise; + /** + * Sets an auth token with the specified authentication type for a particular account. + *

    + * Only the owner of the application account has the permission to call this method. + * @param name Indicates the account name of your application. + * @param authType Indicates the authentication type. + * @param token Indicates the auth token. + * @returns void. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid name, owner, authType or token. + * @throws {BusinessError} 12300003 - the account indicated by name dose not exist. + * @throws {BusinessError} 12300015 - the authType is not supported on current device. + * @throws {BusinessError} 12300019 - credential does not exist. + * @throws {BusinessError} 12400007 - the number of token has reached the upper limit. + * @since 9 + */ + setAuthToken(name: string, authType: string, token: string, callback: AsyncCallback): void; + setAuthToken(name: string, authType: string, token: string): Promise; + /** * Deletes an oauth token for the specified application account. *

    * Only tokens visible to the caller application can be deleted. - * - * @since 8 * @param name Indicates the account name of your application or third-party applications. * @param owner Indicates the account owner of your application or third-party applications. * @param authType Indicates the authentication type. * @param token Indicates the oauth token. - * @return void. + * @returns void. + * @since 8 + * @deprecated since 9 + * @useinstead appAccount.AppAccountManager#deleteAuthToken */ deleteOAuthToken(name: string, owner: string, authType: string, token: string, callback: AsyncCallback): void; deleteOAuthToken(name: string, owner: string, authType: string, token: string): Promise; + /** + * Deletes an auth token for the specified application account. + *

    + * Only tokens visible to the caller application can be deleted. + * @param name Indicates the account name of your application or third-party applications. + * @param owner Indicates the account owner of your application or third-party applications. + * @param authType Indicates the authentication type. + * @param token Indicates the auth token. + * @returns void. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid name, owner, authType or token. + * @throws {BusinessError} 12300003 - the account indicated by name dose not exist. + * @throws {BusinessError} 12300015 - the authType is not supported on current device. + * @throws {BusinessError} 12300019 - credential does not exist. + * @since 9 + */ + deleteAuthToken(name: string, owner: string, authType: string, token: string, callback: AsyncCallback): void; + deleteAuthToken(name: string, owner: string, authType: string, token: string): Promise; + /** * Sets the oauth token visibility of the specified authentication type to a third-party application. *

    * Only the owner of the application account has the permission to call this method. - * - * @since 8 * @param name Indicates the account name of your application. * @param authType Indicates the authentication type. * @param bundleName Indicates the bundle name of the third-party application. * @param isVisible Indicates the bool value of visibility. - * @return void. + * @returns void. + * @since 8 + * @deprecated since 9 + * @useinstead appAccount.AppAccountManager#setAuthTokenVisibility */ setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean, callback: AsyncCallback): void; setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean): Promise; + /** + * Sets the auth token visibility of the specified authentication type to a third-party application. + *

    + * Only the owner of the application account has the permission to call this method. + * @param name Indicates the account name of your application. + * @param authType Indicates the authentication type. + * @param bundleName Indicates the bundle name of the third-party application. + * @param isVisible Indicates the bool value of visibility. + * @returns void. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid name, authType or bundleName. + * @throws {BusinessError} 12300003 - the account indicated by name dose not exist. + * @throws {BusinessError} 12300015 - the authType is not supported on current device. + * @throws {BusinessError} 12300019 - credential does not exist. + * @since 9 + */ + setAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean, callback: AsyncCallback): void; + setAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean): Promise; + /** * Checks the oauth token visibility of the specified authentication type for a third-party application. *

    * Only the owner of the application account has the permission to call this method. - * - * @since 8 * @param name Indicates the account name of your application or third-party applications. * @param authType Indicates the authentication type. * @param bundleName Indicates the bundle name of the third-party application. - * @return Returns the bool value of visibility. + * @returns Returns the bool value of visibility. + * @since 8 + * @deprecated since 9 + * @useinstead appAccount.AppAccountManager#checkAuthTokenVisibility */ checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, callback: AsyncCallback): void; checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): Promise; + /** + * Checks the auth token visibility of the specified authentication type for a third-party application. + *

    + * Only the owner of the application account has the permission to call this method. + * @param name Indicates the account name of your application or third-party applications. + * @param authType Indicates the authentication type. + * @param bundleName Indicates the bundle name of the third-party application. + * @returns Returns the bool value of visibility. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid name, authType or bundleName. + * @throws {BusinessError} 12300003 - the account indicated by name dose not exist. + * @throws {BusinessError} 12300015 - the authType is not supported on current device. + * @throws {BusinessError} 12300019 - credential does not exist. + * @since 9 + */ + checkAuthTokenVisibility(name: string, authType: string, bundleName: string, callback: AsyncCallback): void; + checkAuthTokenVisibility(name: string, authType: string, bundleName: string): Promise; + /** * Gets all oauth tokens visible to the caller application. - * - * @since 8 * @param name Indicates the account name of your application or third-party applications. * @param owner Indicates the account owner of your application or third-party applications. - * @return Returns a list of oauth tokens visible to the caller application. + * @returns Returns a list of oauth tokens visible to the caller application. + * @since 8 + * @deprecated since 9 + * @useinstead appAccount.AppAccountManager#getAllAuthTokens */ getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback>): void; getAllOAuthTokens(name: string, owner: string): Promise>; + /** + * Gets all auth tokens visible to the caller application. + * @param name Indicates the account name of your application or third-party applications. + * @param owner Indicates the account owner of your application or third-party applications. + * @returns Returns a list of auth tokens visible to the caller application. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid name or owner. + * @throws {BusinessError} 12300003 - the account indicated by name dose not exist. + * @since 9 + */ + getAllAuthTokens(name: string, owner: string, callback: AsyncCallback>): void; + getAllAuthTokens(name: string, owner: string): Promise>; + /** * Gets the open authorization list with a specified authentication type for a paticular application account. *

    * Only the owner of the application account has the permission to call this method. - * - * @since 8 * @param name Indicates the account name of your application. * @param authType Indicates the authentication type. - * @return Returns the open authorization list of the specified authentication type. + * @returns Returns the open authorization list of the specified authentication type. + * @since 8 + * @deprecated since 9 + * @useinstead appAccount.AppAccountManager#getAuthList */ getOAuthList(name: string, authType: string, callback: AsyncCallback>): void; getOAuthList(name: string, authType: string): Promise>; + /** + * Gets the open authorization list with a specified authentication type for a paticular application account. + *

    + * Only the owner of the application account has the permission to call this method. + * @param name Indicates the account name of your application. + * @param authType Indicates the authentication type. + * @returns Returns the open authorization list of the specified authentication type. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid name or authType. + * @throws {BusinessError} 12300003 - the account indicated by name dose not exist. + * @throws {BusinessError} 12300015 - the authType is not supported on current device. + * @throws {BusinessError} 12300019 - credential does not exist. + * @since 9 + */ + getAuthList(name: string, authType: string, callback: AsyncCallback>): void; + getAuthList(name: string, authType: string): Promise>; + /** * Gets the authenticator callback with the specified session id. *

    * Only the owner of the authenticator has the permission to call this method. - * - * @since 8 * @param sessionId Indicates the id of a authentication session. - * @return Returns the authenticator callback related to the session id. + * @returns Returns the authenticator callback related to the session id. + * @since 8 + * @deprecated since 9 + * @useinstead appAccount.AppAccountManager#getAuthCallback */ getAuthenticatorCallback(sessionId: string, callback: AsyncCallback): void; getAuthenticatorCallback(sessionId: string): Promise; + /** + * Obtains the authenticator callback with the specified session id. + *

    + * Only the owner of the authenticator has the permission to call this method. + * @param sessionId Indicates the id of a authentication session. + * @returns Returns the authenticator callback related to the session id. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12400005 - the session indicated by sessionId does not exist. + * @since 9 + */ + getAuthCallback(sessionId: string, callback: AsyncCallback): void; + getAuthCallback(sessionId: string): Promise; + /** * Gets the authenticator information of an application account. - * - * @since 8 * @param owner Indicates the account owner of your application or third-party applications. - * @return Returns the authenticator information of the application account. + * @returns Returns the authenticator information of the application account. + * @since 8 + * @deprecated since 9 + * @useinstead appAccount.AppAccountManager#queryAuthenticatorInfo */ getAuthenticatorInfo(owner: string, callback: AsyncCallback): void; getAuthenticatorInfo(owner: string): Promise; /** - * Checks whether a paticular account has all specified labels. - * + * Queries the authenticator information of an application account. + * @param owner Indicates the account owner of your application or third-party applications. + * @returns Returns the authenticator information of the application account. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid owner. + * @throws {BusinessError} 12300003 - the account indicated by owner dose not exist. * @since 9 + */ + queryAuthenticatorInfo(owner: string, callback: AsyncCallback): void; + queryAuthenticatorInfo(owner: string): Promise; + + /** + * Checks whether a paticular account has all specified labels. * @param name Indicates the account name. * @param owner Indicates the account owner. * @param labels Indicates an array of labels to check. - * @return boolean + * @returns boolean + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid name or owner. + * @throws {BusinessError} 12300003 - the account indicated by owner dose not exist. + * @throws {BusinessError} 12400001 - the application indicated by name does not exist. + * @since 9 */ checkAccountLabels(name: string, owner: string, labels: Array, callback: AsyncCallback): void; checkAccountLabels(name: string, owner: string, labels: Array): Promise; /** * Deletes the credential of the specified application account. - * - * @since 9 * @param name Indicates the account name. * @param credentialType Indicates the type of the credential to delete. - * @return void. + * @returns void. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid name or credentialType. + * @throws {BusinessError} 12300019 - credential does not exist. + * @throws {BusinessError} 12400001 - the application indicated by name does not exist. + * since 9 */ - deleteAccountCredential(name: string, credentialType: string, callback: AsyncCallback): void; - deleteAccountCredential(name: string, credentialType: string): Promise; + deleteCredential(name: string, credentialType: string, callback: AsyncCallback): void; + deleteCredential(name: string, credentialType: string): Promise; /** * Selects a list of accounts that satisfied with the specified options. - * - * @since 9 * @param options Indicates the options for selecting account. - * @return Returns a list of accounts. + * @returns Returns a list of accounts. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid options. + * @since 9 */ - selectAccountsByOptions(options: SelectAccountsOptions, callback: AsyncCallback>); + selectAccountsByOptions(options: SelectAccountsOptions, callback: AsyncCallback>): void; selectAccountsByOptions(options: SelectAccountsOptions): Promise>; /** * Verifies the credential to ensure the user is the owner of the specified account. - * - * @since 9 * @param name Indicates the account name. * @param owner Indicates the account owner. * @param options Indicates the options for verifying credential. * @param callback Indicates the authenticator callback. - * @return void. + * @returns void. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid name, owner or options. + * @throws {BusinessError} 12300003 - the account indicated by owner dose not exist. + * @throws {BusinessError} 12400001 - the application indicated by name does not exist. + * @throws {BusinessError} 12400002 - he account authenticator service does not exist. + * @since 9 */ - verifyCredential(name: string, owner: string, callback: AuthenticatorCallback): void; - verifyCredential(name: string, owner: string, options: VerifyCredentialOptions, callback: AuthenticatorCallback): void; + verifyCredential(name: string, owner: string, callback: AuthCallback): void; + verifyCredential(name: string, owner: string, options: VerifyCredentialOptions, callback: AuthCallback): void; /** * Sets properties for the specified account authenticator. *

    * If the authenticator supports setting its properties, * the caller will normally be redirected to an Ability specified by Want for property setting. - * - * @since 9 * @param owner Indicates the owner of authenticator. * @param callback Indicates the authenticator callback. - * @return void. + * @returns void. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid owner or options. + * @throws {BusinessError} 12300003 - the account indicated by owner dose not exist. + * @throws {BusinessError} 12400002 - the account authenticator service does not exist. + * @since 9 */ - setAuthenticatorProperties(owner: string, callback: AuthenticatorCallback): void; - setAuthenticatorProperties(owner: string, options: SetPropertiesOptions, callback: AuthenticatorCallback): void; + setAuthenticatorProperties(owner: string, callback: AuthCallback): void; + setAuthenticatorProperties(owner: string, options: SetPropertiesOptions, callback: AuthCallback): void; } /** * Provides basic information of an application account, including the account owner and name. * @name AppAccountInfo - * @since 7 * @syscap SystemCapability.Account.AppAccount + * @since 7 */ interface AppAccountInfo { /** @@ -505,8 +978,10 @@ declare namespace appAccount { /** * Provides basic information of an oauth token, including the authentication type and token value. * @name OAuthTokenInfo - * @since 8 * @syscap SystemCapability.Account.AppAccount + * @since 8 + * @deprecated since 9 + * @useinstead appAccount.AuthTokenInfo */ interface OAuthTokenInfo { /** @@ -529,13 +1004,39 @@ declare namespace appAccount { * @since 9 */ account?: AppAccountInfo; - } + } + + /** + * Provides basic information of an auth token, including the authentication type and token value. + * @name AuthTokenInfo + * @syscap SystemCapability.Account.AppAccount + * @since 9 + */ + interface AuthTokenInfo { + /** + * The authentication type. + * @since 9 + */ + authType: string; + + /** + * The token value. + * @since 9 + */ + token: string; + + /** + * The account to which the token belongs. + * @since 9 + */ + account?: AppAccountInfo; + } /** * Provides basic information of an authenticator, including the authenticator owner, icon id and label id. * @name AuthenticatorInfo - * @since 8 * @syscap SystemCapability.Account.AppAccount + * @since 8 */ interface AuthenticatorInfo { /** @@ -554,81 +1055,163 @@ declare namespace appAccount { labelId: number; } + /** + * Provides the definition of the authentication result. + * @name AuthResult + * @syscap SystemCapability.Account.AppAccount + * @since 9 + */ + interface AuthResult { + /** + * The account infomation. + * @since 9 + */ + account?: AppAccountInfo; + + /** + * The token information. + * @since 9 + */ + tokenInfo?: AuthTokenInfo; + } + + /** + * Provides the available options for creating an account. + * @name CreateAccountOptions + * @syscap SystemCapability.Account.AppAccount + * @since 9 + */ + interface CreateAccountOptions { + /** + * The custom data for creating an account, + * which can be further modified by function setCustomData. + * @since 9 + */ + customData?: {[key: string]: string}; + } + + /** + * Provides the available options for creating an account implicitly. + * @name CreateAccountImplicitlyOptions + * @syscap SystemCapability.Account.AppAccount + * + * @since 9 + */ + interface CreateAccountImplicitlyOptions { + /** + * The required labels for creating an account. + * @since 9 + */ + requiredLabels?: Array; + + /** + * The authentication type. + * @since 9 + */ + authType?: string; + + /** + * The authenticator-specific parameters. + * The list of reserved parameter name: + * 1. Constants.KEY_CALLER_BUNDLE_NAME; + * The above parameters are set by the appAccount management service and can be used for identify the caller. + * @since 9 + */ + parameters?: {[key:string]: Object}; + } + /** * Provides the available options for selecting accounts. * @name SelectAccountsOptions - * @since 9 * @syscap SystemCapability.Account.AppAccount + * @since 9 */ interface SelectAccountsOptions { /** * The list of accounts allowed to be selected. + * @since 9 */ - allowedAccounts?: Array, + allowedAccounts?: Array; /** * The list of account owners, whose accounts allowed to be selected. + * @since 9 */ - allowedOwners?: Array, + allowedOwners?: Array; /** * The labels required for the selected accounts. + * @since 9 */ - requiredLabels?: Array + requiredLabels?: Array; } /** * Provides the available options for verifying credential. * @name VerifyCredentialOptions - * @since 9 * @syscap SystemCapability.Account.AppAccount + * @since 9 */ interface VerifyCredentialOptions { /** * The credentail type to be verified. + * @since 9 */ - credentialType?: string, + credentialType?: string; /** * The credential to be verified. + * @since 9 */ - credential?: string, + credential?: string; /** * The authenticator-specific parameters. + * The list of reserved parameter name: + * 1. Constants.KEY_CALLER_BUNDLE_NAME; + * The above parameters are set by the appAccount management service and can be used for identify the caller. + * @since 9 */ - parameters?: {[key:string]: Object} + parameters?: {[key:string]: Object}; } /** * Provides the available options for setting properties. * @name SetPropertiesOptions - * @since 9 * @syscap SystemCapability.Account.AppAccount + * @since 9 */ - interface SetPropertiesOptions { + interface SetPropertiesOptions { /** * The properties to be set. + * @since 9 */ - properties?: {[key: string]: Object}, + properties?: {[key: string]: Object}; /** * The authenticator-specific parameters. + * The list of reserved parameter name: + * 1. Constants.KEY_CALLER_BUNDLE_NAME; + * The above parameters are set by the appAccount management service and can be used for identify the caller. + * + * @since 9 */ - parameters?: {[key: string]: Object} + parameters?: {[key: string]: Object}; } /** * Provides constants definition. * @name Constants - * @since 8 * @syscap SystemCapability.Account.AppAccount + * @since 8 */ enum Constants { /** * Indicates the action for adding account implicitly. * * @since 8 + * @deprecated since 9 + * @useinstead appAccount.Constants#ACTION_CREATE_ACCOUNT_IMPLICITLY */ ACTION_ADD_ACCOUNT_IMPLICITLY = "addAccountImplicitly", @@ -636,9 +1219,39 @@ declare namespace appAccount { * Indicates the action for authenticating. * * @since 8 + * @deprecated since 9 + * @useinstead appAccount.Constants#ACTION_AUTH */ ACTION_AUTHENTICATE = "authenticate", + /** + * Indicates the action for creating account implicitly. + * + * @since 9 + */ + ACTION_CREATE_ACCOUNT_IMPLICITLY = "createAccountImplicitly", + + /** + * Indicates the action for authenticating. + * + * @since 9 + */ + ACTION_AUTH = "auth", + + /** + * Indicates the action for verifying credential. + * + * @since 9 + */ + ACTION_VERIFY_CREDENTIAL = "verifyCredential", + + /** + * Indicates the action for set authenticator properties. + * + * @since 9 + */ + ACTION_SET_AUTHENTICATOR_PROPERTIES = "setAuthenticatorProperties", + /** * Indicates the key of name. * @@ -720,8 +1333,9 @@ declare namespace appAccount { /** * Provides result code definition. * @name ResultCode - * @since 8 * @syscap SystemCapability.Account.AppAccount + * @since 8 + * @deprecated since 9 */ enum ResultCode { SUCCESS = 0, @@ -748,34 +1362,66 @@ declare namespace appAccount { /** * Provides methods for authenticator callback. * @name AuthenticatorCallback - * @since 8 * @syscap SystemCapability.Account.AppAccount + * @since 8 + * @deprecated since 9 + * @useinstead AppAccount.AuthCallback + * */ interface AuthenticatorCallback { /** * Notifies the client of the authentication result. - * - * @since 8 * @param code Indicates the result code. * @param result Indicates the authentication result. - * @return void. + * @returns void. + * @since 8 */ onResult: (code: number, result: {[key: string]: any}) => void; /** * Notifies the client that the authentication request need to be redirected. - * + * @param request Indicates the request information to be redirected. + * @returns void. * @since 8 + */ + onRequestRedirected: (request: Want) => void; + + /** + * Notifies the client that the request is continued. + * @returns void. + * @since 9 + */ + onRequestContinued?: () => void; + } + + /** + * Provides methods for authentication callback. + * @name AuthCallback + * @syscap SystemCapability.Account.AppAccount + * @since 9 + */ + interface AuthCallback { + /** + * Notifies the client of the authentication result. + * @param code Indicates the result code. + * @param result Indicates the authentication result. + * @returns void. + * @since 9 + */ + onResult: (code: number, result?: AuthResult) => void; + + /** + * Notifies the client that the authentication request need to be redirected. * @param request Indicates the request information to be redirected. - * @return void. + * @returns void. + * @since 9 */ onRequestRedirected: (request: Want) => void; /** * Notifies the client that the request is continued. - * + * @returns void. * @since 9 - * @return void. */ onRequestContinued?: () => void; } @@ -783,85 +1429,98 @@ declare namespace appAccount { /** * Provides methods for authenticator. * @name Authenticator - * @since 8 * @syscap SystemCapability.Account.AppAccount + * @since 8 */ class Authenticator { /** * Adds an application account of a specified owner implicitly. - * - * @since 8 * @param authType Indicates the authentication type. * @param callerBundleName Indicates the caller bundle name. * @param options Indicates the authenticator-specific options for the request. * @param callback Indicates the authenticator callback. - * @return void. + * @returns void. + * @since 8 */ addAccountImplicitly(authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void; + /** + * Creates an application account of a specified owner implicitly. + * @param options Indicates the authenticator-specific options for the request. + * @param callback Indicates the authenticator callback. + * @returns void. + * @since 9 + */ + createAccountImplicitly(options: CreateAccountImplicitlyOptions, callback: AuthCallback): void; + /** * Authenticates an application account to get an oauth token. - * - * @since 8 * @param name Indicates the account name. * @param authType Indicates the authentication type. * @param callerBundleName Indicates the caller bundle name. * @param options Indicates the authenticator-specific options for the request. * @param callback Indicates the authenticator callback. - * @return void. + * @returns void. + * @since 8 */ authenticate(name: string, authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void; /** + * Authenticates an application account to get an oauth token. + * @param name Indicates the account name. + * @param authType Indicates the authentication type. + * @param options Indicates the authenticator-specific options for the request. + * @param callback Indicates the authenticator callback. + * @returns void. + * @since 9 + */ + auth(name: string, authType: string, options: {[key:string]: Object}, callback: AuthCallback): void; + + /** * Verifies the credential to ensure the user is the owner of the specified application account. *

    * The credential can be provided in the options, otherwise an Ability will normally be returned, * which can be started by the caller to further verify credential. - * - * @since 9 * @param name Indicates the name of the application account. * @param options Indicates the options for verifying credential. * @param callback Indicates the authenticator callback. - * @return void. + * @returns void. + * @since 9 */ - verifyCredential(name: string, options: VerifyCredentialOptions, callback: AuthenticatorCallback): void; + verifyCredential(name: string, options: VerifyCredentialOptions, callback: AuthCallback): void; /** * Sets properties for the authenticator. - * - * @since 9 * @param options Indicates the options for setting properties. * @param callback Indicates the authenticator callback. - * @return void. + * @returns void. + * @since 9 */ - setProperties(options: SetPropertiesOptions, callback: AuthenticatorCallback): void; + setProperties(options: SetPropertiesOptions, callback: AuthCallback): void; /** - * Checks whether a paticular account has all specified labels. - * - * @since 9 + * Checks whether a particular account has all specified labels. * @param name Indicates the account name. * @param labels Indicates an array of labels to check. * @param callback Indicates the authenticator callback. - * @return void. + * @returns void. + * @since 9 */ - checkAccountLabels(name: string, labels: Array, callback: AuthenticatorCallback): void; + checkAccountLabels(name: string, labels: Array, callback: AuthCallback): void; /** * Checks whether the specified account can be removed. - * - * @since 9 * @param name Indicates the account name. * @param callback Indicates the authenticator callback. - * @return void. + * @returns void. + * @since 9 */ - isAccountRemovable(name: string, callback: AuthenticatorCallback): void; + isAccountRemovable(name: string, callback: AuthCallback): void; /** * Gets the remote object of the authenticator for remote procedure call. - * + * @returns Returns a remote object. * @since 9 - * @return Returns a remote object. */ getRemoteObject(): rpc.RemoteObject; } diff --git a/api/@ohos.account.distributedAccount.d.ts b/api/@ohos.account.distributedAccount.d.ts index ae809f7f65391286b6b70347c0f596fe43235370..3e3b41439a0e946fb2ed98c435a39123283fd218 100644 --- a/api/@ohos.account.distributedAccount.d.ts +++ b/api/@ohos.account.distributedAccount.d.ts @@ -17,75 +17,121 @@ import {AsyncCallback} from './basic' /** * This module provides the capability to manage distributed accounts. - * - * @since 7 * @syscap SystemCapability.Account.OsAccount + * @since 7 */ declare namespace distributedAccount { /** * Get the ability of the distributed account. - * @since 7 - * @syscap SystemCapability.Account.OsAccount * @permission N/A - * @return Ability to manage operations of distributed account. + * @syscap SystemCapability.Account.OsAccount + * @returns Ability to manage operations of distributed account. + * @since 7 */ function getDistributedAccountAbility(): DistributedAccountAbility; /** * Defines distributed account functions and interfaces. - * * @name DistributedAccountAbility - * @since 7 - * @syscap SystemCapability.Account.OsAccount * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS + * @syscap SystemCapability.Account.OsAccount + * @since 7 */ interface DistributedAccountAbility { /** * Queries the distributed information of the current OS account. - * - * @since 7 - * @return The distributed information of the current OS account. * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.DISTRIBUTED_DATASYNC + * @returns The distributed information of the current OS account. + * @since 7 + * @deprecated since 9 + * @useinstead distributedAccount.DistributedAccountAbility#getOsAccountDistributedInfo */ queryOsAccountDistributedInfo(callback: AsyncCallback): void; queryOsAccountDistributedInfo(): Promise; + /** + * Gets the distributed information of the current OS account. + * @permission ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS or ohos.permission.GET_DISTRIBUTED_ACCOUNTS or ohos.permission.DISTRIBUTED_DATASYNC. + * @returns The distributed information of the current OS account. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @since 9 + */ + getOsAccountDistributedInfo(callback: AsyncCallback): void; + getOsAccountDistributedInfo(): Promise; + /** * Updates the distributed information of the OS account. - * - * @since 7 - * @param accountInfo Indicates the information of the OS account used for a distributed system. - * @return void * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @param accountInfo Indicates the information of the OS account used for a distributed system. + * @returns void + * @since 7 + * @deprecated since 9 + * @useinstead distributedAccount.DistributedAccountAbility#setOsAccountDistributedInfo */ updateOsAccountDistributedInfo(accountInfo: DistributedInfo, callback: AsyncCallback): void; updateOsAccountDistributedInfo(accountInfo: DistributedInfo): Promise; + + /** + * Sets the distributed information of the OS account. + * @permission ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS. + * @param accountInfo Indicates the information of the OS account used for a distributed system. + * @returns void + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid accountInfo. + * @since 9 + */ + setOsAccountDistributedInfo(accountInfo: DistributedInfo, callback: AsyncCallback): void; + setOsAccountDistributedInfo(accountInfo: DistributedInfo): Promise; } /** * Provides the distributed information of the OS account. * * @name DistributedInfo - * @since 7 - * @syscap SystemCapability.Account.OsAccount * @permission N/A + * @syscap SystemCapability.Account.OsAccount + * @since 7 */ interface DistributedInfo { /** * The name in the distributed information of the OS account. + * + * @since 7 */ name: string; /** * The ID in the distributed information of the OS account. + * + * @since 7 */ id: string; /** * The event string in the distributed information of the OS account. - */ + * + * @since 7 + */ event: string; + /** + * The nickname in the distributed information of the OS account. + * + * @since 9 + */ + nickname?: string; + + /** + * The avatar in the distributed information of the OS account. + * + * @since 9 + */ + avatar?: string; + /** * The scalable data in the distributed information of the OS account. */ diff --git a/api/@ohos.account.osAccount.d.ts b/api/@ohos.account.osAccount.d.ts index edd26230e6cb1267e1ded811fc4f610e76668f0a..92a81d4b44d572743e76639447886445cdae8e48 100644 --- a/api/@ohos.account.osAccount.d.ts +++ b/api/@ohos.account.osAccount.d.ts @@ -18,24 +18,23 @@ import { AsyncCallback, Callback } from './basic'; /** * This module provides the capability to manage os accounts. - * - * @since 7 * @syscap SystemCapability.Account.OsAccount + * @since 7 */ declare namespace osAccount { /** * Obtains the AccountManager instance. - * @since 7 + * @returns Returns the instance of the AccountManager. * @syscap SystemCapability.Account.OsAccount - * @return Returns the instance of the AccountManager. + * @since 7 */ function getAccountManager(): AccountManager; /** * Provides abilities for you to manage and perform operations on your OS accounts. * @name AccountManager - * @since 7 * @syscap SystemCapability.Account.OsAccount + * @since 7 */ interface AccountManager { /** @@ -45,39 +44,72 @@ declare namespace osAccount { * to run in the foreground. Then, the OS account originally running in the foreground will be * switched to the background. *

    - * @since 7 - * @param localId Indicates the local ID of the OS account. - * @return void. * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION. + * @param localId Indicates the local ID of the OS account. + * @returns void. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid localId. + * @throws {BusinessError} 12300003 - the account indicated by localId dose not exist. + * @throws {BusinessError} 12300003 - the account indicated by localId has been activated. + * @throws {BusinessError} 12300010 - account service is busy. * @systemapi Hide this for inner system use. + * @since 7 */ activateOsAccount(localId: number, callback: AsyncCallback): void; activateOsAccount(localId: number): Promise; /** * Checks whether the function of supporting multiple OS accounts is enabled. - * + * @returns Returns {@code true} if this function is enabled; returns {@code false} otherwise. * @since 7 - * @return Returns {@code true} if this function is enabled; returns {@code false} otherwise. + * @deprecated since 9 + * @useinstead osAccount.AccountManager#checkMultiOsAccountEnabled */ isMultiOsAccountEnable(callback: AsyncCallback): void; isMultiOsAccountEnable(): Promise; + /** + * Checks whether the function of supporting multiple OS accounts is enabled. + * @returns void + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @since 9 + */ + checkMultiOsAccountEnabled(callback: AsyncCallback): void; + checkMultiOsAccountEnabled(): Promise; + /** * Checks whether an OS account is activated based on its local ID. - * - * @since 7 - * @param localId Indicates the local ID of the OS account. - * @return Returns {@code true} if the OS account is activated; returns {@code false} otherwise. * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + * @param localId Indicates the local ID of the OS account. + * @returns Returns {@code true} if the OS account is activated; returns {@code false} otherwise. + * @since 7 + * @deprecated since 9 + * @useinstead osAccount.AccountManager#checkOsAccountActivated */ isOsAccountActived(localId: number, callback: AsyncCallback): void; isOsAccountActived(localId: number): Promise; + /** + * Checks whether an OS account is activated based on its local ID. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @param localId Indicates the local ID of the OS account. + * @returns void + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid localId. + * @throws {BusinessError} 12300003 - the account indicated by localId dose not exist. + * @since 9 + */ + checkOsAccountActivated(localId: number, callback: AsyncCallback): void; + checkOsAccountActivated(localId: number): Promise; + /** * Checks whether a constraint has been enabled for an OS account based on its local ID. - * - * @since 7 + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. * @param localId Indicates the local ID of the OS account. * @param constraint Indicates the constraint to check. The value can be: *
      @@ -89,59 +121,114 @@ declare namespace osAccount { *
    • {@code constraint.unknown.sources.install} - Indicates the constraint on installing applications * from unknown sources.
    • *
    - * @return Returns {@code true} if the constraint has been enabled for the OS account; + * @returns Returns {@code true} if the constraint has been enabled for the OS account; * returns {@code false} otherwise. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @since 7 + * @deprecated since 9 + * @useinstead osAccount.AccountManager#checkConstraintEnabled */ isOsAccountConstraintEnable(localId: number, constraint: string, callback: AsyncCallback): void; isOsAccountConstraintEnable(localId: number, constraint: string): Promise; + /** + * Checks whether a constraint has been enabled for an OS account based on its local ID. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @param localId Indicates the local ID of the OS account. + * @param constraint Indicates the constraint to check. The value can be: + *
      + *
    • {@code constraint.wifi.set} - Indicates the constraint on configuring the Wi-Fi access point. + *
    • + *
    • {@code constraint.sms.use} - Indicates the constraint on sending and receiving short messages. + *
    • + *
    • {@code constraint.calls.outgoing} - Indicates the constraint on making calls.
    • + *
    • {@code constraint.unknown.sources.install} - Indicates the constraint on installing applications + * from unknown sources.
    • + *
    + * @returns Returns {@code true} if the constraint has been enabled for the OS account; + * returns {@code false} otherwise. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid localId or constraint. + * @throws {BusinessError} 12300003 - the account indicated by localId dose not exist. + * @throws {BusinessError} 12300004 - the localId indicates restricted account. + * @since 9 + */ + checkConstraintEnabled(localId: number, constraint: string, callback: AsyncCallback): void; + checkConstraintEnabled(localId: number, constraint: string): Promise; + /** * Checks whether this OS account is a test OS account. - * + * @returns Returns {@code true} if this OS account is a test OS account; returns {@code false} otherwise. * @since 7 - * @return Returns {@code true} if this OS account is a test OS account; returns {@code false} otherwise. + * @deprecated since 9 + * @useinstead osAccount.AccountManager#checkOsAccountTestable */ isTestOsAccount(callback: AsyncCallback): void; isTestOsAccount(): Promise; /** - * Checks whether this OS account has been verified. - * - * @since 7 - * @return Returns {@code true} if the OS account has been verified successfully; - * returns {@code false} otherwise. + * Checks whether current OS account is testable. + * @returns Returns {@code true} if this account is testable; returns {@code false} otherwise. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @since 9 */ - isOsAccountVerified(callback: AsyncCallback): void; + checkOsAccountTestable(callback: AsyncCallback): void; + checkOsAccountTestable(): Promise; /** * Checks whether an OS account has been verified based on its local ID. - * - * @since 7 - * @param localId Indicates the local ID of the OS account. - * @return Returns {@code true} if the OS account has been verified successfully; - * returns {@code false} otherwise. * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS. + * @param localId Indicates the local ID of the OS account. + * @returns Returns {@code true} if the OS account has been verified successfully; + * returns {@code false} otherwise. + * @since 7 + * @deprecated since 9 + * @useinstead osAccount.AccountManager#checkOsAccountVerified + * */ + isOsAccountVerified(callback: AsyncCallback): void; isOsAccountVerified(localId: number, callback: AsyncCallback): void; isOsAccountVerified(localId?: number): Promise; /** - * Removes an OS account based on its local ID. - * - * @since 7 + * Checks whether an OS account has been verified based on its ID. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS. * @param localId Indicates the local ID of the OS account. - * @return void. + * @returns Returns {@code true} if the OS account has been verified successfully; + * returns {@code false} otherwise. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid localId. + * @throws {BusinessError} 12300003 - the account indicated by localId dose not exist. + * @since 9 + */ + checkOsAccountVerified(callback: AsyncCallback): void; + checkOsAccountVerified(localId: number, callback: AsyncCallback): void; + checkOsAccountVerified(localId?: number): Promise; + + /** + * Removes an OS account based on its local ID. * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @param localId Indicates the local ID of the OS account. + * @returns void. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid localId. + * @throws {BusinessError} 12300003 - the account indicated by localId dose not exist. + * @throws {BusinessError} 12300004 - the localId indicates restricted account. * @systemapi Hide this for inner system use. + * @since 7 */ removeOsAccount(localId: number, callback: AsyncCallback): void; removeOsAccount(localId: number): Promise; /** * Sets constraints for an OS account based on its local ID. - * - * @since 7 + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. * @param localId Indicates the local ID of the OS account. * @param constraints Indicates the constraints to set for the OS account. The value can be: *
      @@ -154,9 +241,15 @@ declare namespace osAccount { * from unknown sources. *
    * @param enable Specifies whether to enable the constraint. - * @return void. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @returns void. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid localId or constraints. + * @throws {BusinessError} 12300003 - the account indicated by localId dose not exist. + * @throws {BusinessError} 12300004 - the localId indicates restricted account. * @systemapi Hide this for inner system use. + * @since 7 */ setOsAccountConstraints(localId: number, constraints: Array, enable: boolean, callback: AsyncCallback): void; @@ -164,158 +257,284 @@ declare namespace osAccount { /** * Sets the local name for an OS account based on its local ID. - * - * @since 7 + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. * @param localId Indicates the local ID of the OS account. * @param localName Indicates the local name to set for the OS account. - * @return void. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @returns void. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid localId or localName. + * @throws {BusinessError} 12300003 - the account indicated by localId dose not exist. + * @throws {BusinessError} 12300004 - the localId indicates restricted account. * @systemapi Hide this for inner system use. + * @since 7 */ setOsAccountName(localId: number, localName: string, callback: AsyncCallback): void; setOsAccountName(localId: number, localName: string): Promise; /** * Obtains the number of all OS accounts created on a device. - * - * @since 7 - * @return Returns the number of created OS accounts. * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @returns Returns the number of created OS accounts. + * @since 7 + * @deprecated since 9 + * @useinstead osAccount.AccountManager#getOsAccountCount */ getCreatedOsAccountsCount(callback: AsyncCallback): void; getCreatedOsAccountsCount(): Promise; + /** + * Obtains the number of all OS accounts created on a device. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @returns Returns the number of created OS accounts. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @since 9 + */ + getOsAccountCount(callback: AsyncCallback): void; + getOsAccountCount(): Promise; + /** * Obtains the local ID of an OS account from the current process UID. - * + * @returns Returns the local ID of the OS account. * @since 7 - * @return Returns the local ID of the OS account. + * @deprecated since 9 + * @useinstead osAccount.AccountManager#queryOsAccountLocalIdFromProcess */ getOsAccountLocalIdFromProcess(callback: AsyncCallback): void; getOsAccountLocalIdFromProcess(): Promise; /** - * Queries the local ID of an OS account from the process UID. - * - * @since 7 + * Queries the local ID of an OS account from the current process UID. + * @returns Returns the local ID of the OS account. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @since 9 + */ + queryOsAccountLocalIdFromProcess(callback: AsyncCallback): void; + queryOsAccountLocalIdFromProcess(): Promise; + + /** + * Gets the local ID of an OS account from the process UID * @param uid Indicates the process UID. - * @return Returns the local ID of the OS account. + * @returns Returns the local ID of the OS account. + * @since 7 + * @deprecated since 9 + * @useinstead osAccount.AccountManager#queryOsAccountLocalIdFromUid */ getOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback): void; getOsAccountLocalIdFromUid(uid: number): Promise; + /** + * Queries the local ID of an OS account from the process UID. + * @param uid Indicates the process UID. + * @returns Returns the local ID of the OS account. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid uid. + * @since 9 + */ + queryOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback): void; + queryOsAccountLocalIdFromUid(uid: number): Promise; + /** * Queries the local ID of an OS account which is bound to the specified domain account - * - * @since 8 - * @param domainInfo Indicates the domain account info. - * @return Returns the local ID of the OS account. * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @param domainInfo Indicates the domain account info. + * @returns Returns the local ID of the OS account. + * @since 8 + * @deprecated since 9 + * @useinstead osAccount.AccountManager#queryOsAccountLocalIdFromDomain */ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCallback): void; getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise; /** - * Queries the maximum number of OS accounts that can be created on a device. + * Queries the ID of an account which is bound to the specified domain account * - * @since 7 - * @return Returns the maximum number of OS accounts that can be created. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @param domainInfo Indicates the domain account info. + * @returns Returns the local ID of the OS account. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid domainInfo. + * @since 9 + */ + queryOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCallback): void; + queryOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise; + + /** + * Queries the maximum number of OS accounts that can be created on a device. + * @returns Returns the maximum number of OS accounts that can be created. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. * @systemapi Hide this for inner system use. + * @since 7 */ queryMaxOsAccountNumber(callback: AsyncCallback): void; queryMaxOsAccountNumber(): Promise; /** * Obtains all constraints of an OS account based on its local ID. - * - * @since 7 - * @param localId Indicates the local ID of the OS account. - * @return Returns a list of constraints. * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @param localId Indicates the local ID of the OS account. + * @returns Returns a list of constraints. + * @since 7 + * @deprecated since 9 + * @useinstead osAccount.AccountManager#getOsAccountConstraints */ getOsAccountAllConstraints(localId: number, callback: AsyncCallback>): void; getOsAccountAllConstraints(localId: number): Promise>; + /** + * Obtains all constraints of an account based on its ID. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @param localId Indicates the local ID of the OS account. + * @returns Returns a list of constraints. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid localId. + * @throws {BusinessError} 12300003 - the account indicated by localId dose not exist. + * @throws {BusinessError} 12300004 - the localId indicates restricted account. + * @since 9 + */ + getOsAccountConstraints(localId: number, callback: AsyncCallback>): void; + getOsAccountConstraints(localId: number): Promise>; + /** * Queries the list of all the OS accounts that have been created in the system. - * - * @since 7 - * @return Returns a list of OS accounts. - * @systemapi Hide this for inner system use. * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @returns Returns a list of OS accounts. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @systemapi Hide this for inner system use. + * @since 7 */ queryAllCreatedOsAccounts(callback: AsyncCallback>): void; queryAllCreatedOsAccounts(): Promise>; /** * Queries the id list of all activated OS accounts. - * + * @returns Returns a id list of OS accounts. * @since 8 - * @return Returns a id list of OS accounts. + * @deprecated since 9 + * @useinstead osAccount.AccountManager#getActivatedOsAccountIds */ queryActivatedOsAccountIds(callback: AsyncCallback>): void; queryActivatedOsAccountIds(): Promise>; + /** + * Gets the id list of all activated accounts. + * @returns Returns a id list of OS accounts. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @since 9 + */ + getActivatedOsAccountIds(callback: AsyncCallback>): void; + getActivatedOsAccountIds(): Promise>; + /** * Creates an OS account using the local name and account type. - * - * @since 7 + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. * @param localName Indicates the local name of the OS account to create. * @param type Indicates the type of the OS account to create. * {@link OsAccountType} specifies the account types available in the system. - * @return Returns information about the created OS account; returns {@code null} if the creation fails. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @returns Returns information about the created OS account; returns {@code null} if the creation fails. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid localName. + * @throws {BusinessError} 12300003 - the account indicated by localId dose not exist. * @systemapi Hide this for inner system use. + * @since 7 */ createOsAccount(localName: string, type: OsAccountType, callback: AsyncCallback): void; createOsAccount(localName: string, type: OsAccountType): Promise; /** - * Creates an OS account using the account type and domain account info - * - * @since 8 + * Creates an OS account using the account type and domain account info. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. * @param type Indicates the type of the OS account to create. * {@link OsAccountType} specifies the account types available in the system. * @param domainInfo Indicates the domain account info. - * @return Returns information about the created OS account; returns {@code null} if the creation fails. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @returns Returns information about the created OS account; returns {@code null} if the creation fails. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid type or domainInfo. * @systemapi Hide this for inner system use. + * @since 8 */ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, callback: AsyncCallback): void; createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo): Promise; /** * Queries information about the current OS account. - * - * @since 7 - * @return Returns information about the current OS account; returns {@code null} if the query fails. * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @returns Returns information about the current OS account; returns {@code null} if the query fails. + * @since 7 + * @deprecated since 9 + * @useinstead osAccount.AccountManager#getCurrentOsAccount */ queryCurrentOsAccount(callback: AsyncCallback): void; queryCurrentOsAccount(): Promise; + /** + * Gets information about the current OS account. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @returns Returns information about the current OS account; returns {@code null} if the query fails. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @since 9 + */ + getCurrentOsAccount(callback: AsyncCallback): void; + getCurrentOsAccount(): Promise; + /** * Queries OS account information based on the local ID. * - * @since 7 - * @param localId Indicates the local ID of the OS account. - * @return Returns the OS account information; returns {@code null} if the query fails. * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION. + * @param localId Indicates the local ID of the OS account. + * @returns Returns the OS account information; returns {@code null} if the query fails. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid localId. + * @throws {BusinessError} 12300003 - the account indicated by localId dose not exist. * @systemapi Hide this for inner system use. + * @since 7 */ queryOsAccountById(localId: number, callback: AsyncCallback): void; queryOsAccountById(localId: number): Promise; /** * Obtains the type of this OS account from the current process. - * - * @since 7 - * @return Returns the OS account type. The value can be {@link OsAccountType#ADMIN}, + * @returns Returns the OS account type. The value can be {@link OsAccountType#ADMIN}, * {@link OsAccountType#NORMAL}, and {@link OsAccountType#GUEST}. + * @since 7 + * @deprecated since 9 + * @useinstead osAccount.AccountManager#getOsAccountType */ getOsAccountTypeFromProcess(callback: AsyncCallback): void; getOsAccountTypeFromProcess(): Promise; + /** + * Obtains the type of this OS account from the current process. + * @returns Returns the OS account type. The value can be {@link OsAccountType#ADMIN}, + * {@link OsAccountType#NORMAL}, and {@link OsAccountType#GUEST}. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @since 9 + */ + getOsAccountType(callback: AsyncCallback): void; + getOsAccountType(): Promise; + /** * Obtains the distributed virtual device ID (DVID). *

    @@ -324,117 +543,184 @@ declare namespace osAccount { * The same application running on different devices obtains the same DVID, whereas different applications * obtain different DVIDs. *

    - * - * @since 7 - * @return Returns the DVID if obtained; returns an empty string if no OHOS account has logged in. * @permission ohos.permission.DISTRIBUTED_DATASYNC or ohos.permission.MANAGE_LOCAL_ACCOUNTS + * @returns Returns the DVID if obtained; returns an empty string if no OHOS account has logged in. + * @since 7 + * @deprecated since 9 + * @useinstead osAccount.AccountManager#queryDistributedVirtualDeviceId */ getDistributedVirtualDeviceId(callback: AsyncCallback): void; getDistributedVirtualDeviceId(): Promise; + /** + * Queries the distributed virtual device ID (DVID). + *

    + * If the same OHOS account has logged in to multiple devices, these devices constitute a super device + * through the distributed networking. On the networked devices, you can call this method to obtain the DVIDs. + * The same application running on different devices obtains the same DVID, whereas different applications + * obtain different DVIDs. + *

    + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @returns Returns the DVID if obtained; returns an empty string if no OHOS account has logged in. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @since 9 + */ + queryDistributedVirtualDeviceId(callback: AsyncCallback): void; + queryDistributedVirtualDeviceId(): Promise; + /** * Obtains the profile photo of an OS account based on its local ID. - * - * @since 7 + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. * @param localId Indicates the local ID of the OS account. - * @return Returns the profile photo if obtained; + * @returns Returns the profile photo if obtained; * returns {@code null} if the profile photo fails to be obtained. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid localId. + * @throws {BusinessError} 12300003 - the account indicated by localId dose not exist. * @systemapi Hide this for inner system use. + * @since 7 */ getOsAccountProfilePhoto(localId: number, callback: AsyncCallback): void; getOsAccountProfilePhoto(localId: number): Promise; /** * Sets the profile photo for an OS account based on its local ID. - * - * @since 7 + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. * @param localId Indicates the local ID of the OS account. * @param photo Indicates the profile photo to set for the OS account. - * @return void. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @returns void. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid localId or photo. + * @throws {BusinessError} 12300003 - the account indicated by localId dose not exist. * @systemapi Hide this for inner system use. + * @since 7 */ setOsAccountProfilePhoto(localId: number, photo: string, callback: AsyncCallback): void; setOsAccountProfilePhoto(localId: number, photo: string): Promise; /** * Obtain localId according to serial number - * - * @since 8 * @param serialNumber Indicates serial number. - * @return localId. + * @returns localId. + * @since 8 + * @deprecated since 9 + * @useinstead osAccount.AccountManager#queryOsAccountLocalIdBySerialNumber */ getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback): void; getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise; + /** + * Queries account ID according to serial number + * @param serialNumber Indicates serial number. + * @returns localId. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @since 9 + */ + queryOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback): void; + queryOsAccountLocalIdBySerialNumber(serialNumber: number): Promise; + /** * Obtain serial number according to localId. - * - * @since 8 * @param localId Indicates the local ID of the OS account. - * @return serial number. + * @returns serial number. + * @since 8 + * @deprecated since 9 + * @useinstead osAccount.AccountManager#querySerialNumberByOsAccountLocalId */ getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback): void; getSerialNumberByOsAccountLocalId(localId: number): Promise; /** - * Subscribes to the change events of OS accounts. + * Queries serial number according to account ID. + * @param localId Indicates the local ID of the OS account. + * @returns serial number. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid localId. + * @throws {BusinessError} 12300003 - the account indicated by localId dose not exist. + * @since 9 + */ + querySerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback): void; + querySerialNumberByOsAccountLocalId(localId: number): Promise; + + /** + * Subscribes to the change events of accounts. *

    * When user change the account, the subscriber will receive a notification * about the account change event. - * - * @since 7 + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION * @param type Event type. * @param name Indicates the name of subscriber. - * @return void. - * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION + * @returns void. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300005 - the listener has been registered. * @systemapi Hide this for inner system use. + * @since 7 */ on(type: 'activate' | 'activating', name: string, callback: Callback): void; /** * Unsubscribes from account events. - * - * @since 7 + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION * @param type Event type. * @param name Indicates the name of subscriber. - * @return void. - * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION + * @returns void. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300006 - the listener has not been registered. * @systemapi Hide this for inner system use. + * @since 7 */ off(type: 'activate' | 'activating', name: string, callback?: Callback): void; /** * Obtain bundle id from uid. - * - * @since 9 * @param uid Indicates the target uid. - * @return bundle id. + * @returns bundle id. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid uid. * @systemapi Hide this for inner system use. + * @since 9 */ getBundleIdFromUid(uid: number, callback: AsyncCallback): void; getBundleIdFromUid(uid: number): Promise; /** - * Check whether current process belongs to the main os account - * - * @since 9 - * @return Returns {@code true} if current process belongs to the main os account; + * Check whether current process belongs to the main account. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @returns Returns {@code true} if current process belongs to the main os account; * returns {@code false} otherwise. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. * @systemapi Hide this for inner system use. + * @since 9 */ isMainOsAccount(callback: AsyncCallback): void; isMainOsAccount(): Promise; /** - * Query the constraint source type list of the os account - * - * @since 9 - * @return Returns the constraint source type infos of the os account; + * Query the constraint source type list of the OS account. * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @returns Returns the constraint source type infos of the os account; + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid name or constraint. + * @throws {BusinessError} 12300003 - the account indicated by localId dose not exist. * @systemapi Hide this for inner system use. + * @since 9 */ queryOsAccountConstraintSourceTypes(localId: number, constraint: string, callback: AsyncCallback>): void; queryOsAccountConstraintSourceTypes(localId: number, constraint: string): Promise>; @@ -443,15 +729,15 @@ declare namespace osAccount { /** * Provides information about OS accounts, including the local ID, local name, and type of an OS account. * @name OsAccountInfo - * @since 7 * @syscap SystemCapability.Account.OsAccount + * @since 7 */ interface OsAccountInfo { /** * The local ID of an OS account. * @since 7 */ - localId: number; + localId: number; /** * The local name of an OS account. @@ -523,7 +809,7 @@ declare namespace osAccount { * Domain account info. * @since 8 */ - domainInfo: DomainAccountInfo; + domainInfo: DomainAccountInfo; } interface DomainAccountInfo { @@ -543,8 +829,8 @@ declare namespace osAccount { /** * Enumerates OS account types. * @name OsAccountType - * @since 7 * @syscap SystemCapability.Account.OsAccount + * @since 7 */ enum OsAccountType { /** @@ -566,155 +852,184 @@ declare namespace osAccount { /** * Provides the abilities for user authentication. * @name UserAuth - * @since 8 * @syscap SystemCapability.Account.OsAccount + * @since 8 */ class UserAuth { /** * Constructor to get the UserAuth class instance. - * - * @since 8 - * @return Returns the UserAuth class instance. + * @returns Returns the UserAuth class instance. * @systemapi Hide this for inner system use. + * @since 8 */ constructor(); /** * Gets version information. - * - * @since 8 - * @return Returns the version information. + * @returns Returns the version information. * @systemapi Hide this for inner system use. + * @since 8 */ getVersion(): number; /** * Checks whether the authentication capability is available. - * - * @since 8 + * @permission ohos.permission.ACCESS_USER_AUTH_INTERNAL * @param authType Indicates the credential type for authentication. * @param authTrustLevel Indicates the trust level of authentication result. - * @return Returns a status result. - * @permission ohos.permission.ACCESS_USER_AUTH_INTERNAL + * @returns Returns a status result. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid authType or authTrustLevel. + * @throws {BusinessError} 12300014 - the authTrustLevel is not supported on current device + * @throws {BusinessError} 12300015 - the authType is not supported on current device. * @systemapi Hide this for inner system use. + * @since 8 */ getAvailableStatus(authType: AuthType, authTrustLevel: AuthTrustLevel): number; /** * Gets the property based on the specified request information. - * - * @since 8 - * @param request Indicates the request information, including authentication type, and property type list. - * @return Returns an executor property. * @permission ohos.permission.ACCESS_USER_AUTH_INTERNAL + * @param request Indicates the request information, including authentication type, and property type list. + * @returns Returns an executor property. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid request. * @systemapi Hide this for inner system use. + * @since 8 */ getProperty(request: GetPropertyRequest, callback: AsyncCallback): void; getProperty(request: GetPropertyRequest): Promise; /** * Sets property that can be used to initialize algorithms. - * - * @since 8 - * @param request Indicates the request information, including authentication type and the key-value to be set. - * @return Returns a number value indicating whether the property setting was successful. * @permission ohos.permission.ACCESS_USER_AUTH_INTERNAL + * @param request Indicates the request information, including authentication type and the key-value to be set. + * @returns Returns a number value indicating whether the property setting was successful. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid request. * @systemapi Hide this for inner system use. + * @since 8 */ setProperty(request: SetPropertyRequest, callback: AsyncCallback): void; setProperty(request: SetPropertyRequest): Promise; /** * Executes authentication. - * - * @since 8 + * @permission ohos.permission.ACCESS_USER_AUTH_INTERNAL * @param challenge Indicates the challenge value. * @param authType Indicates the authentication type. * @param authTrustLevel Indicates the trust level of authentication result. * @param callback Indicates the callback to get result and acquireInfo. - * @return Returns a context ID for cancellation. - * @permission ohos.permission.ACCESS_USER_AUTH_INTERNAL + * @returns Returns a context ID for cancellation. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid challenge, authType or authTrustLevel. + * @throws {BusinessError} 12300014 - the authTrustLevel is not supported on current device + * @throws {BusinessError} 12300015 - the authType is not supported on current device. + * @throws {BusinessError} 12300016 - authentication timeout. + * @throws {BusinessError} 12300017 - authentication service is busy. + * @throws {BusinessError} 12300018 - authentication service is locked. + * @throws {BusinessError} 12300019 - the credential does not exist. * @systemapi Hide this for inner system use. + * @since 8 */ auth(challenge: Uint8Array, authType: AuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array; /** * Executes user authentication. - * - * @since 8 + * @permission ohos.permission.ACCESS_USER_AUTH_INTERNAL * @param userId Indicates the user identification. * @param challenge Indicates the challenge value. * @param authType Indicates the authentication type. * @param authTrustLevel Indicates the trust level of authentication result. * @param callback Indicates the callback to get result and acquireInfo. - * @return Returns a context ID for cancellation. - * @permission ohos.permission.ACCESS_USER_AUTH_INTERNAL + * @returns Returns a context ID for cancellation. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid userId, challenge, authType or authTrustLevel. + * @throws {BusinessError} 12300003 - the account indicated by userId dose not exist. + * @throws {BusinessError} 12300014 - the authTrustLevel is not supported on current device + * @throws {BusinessError} 12300015 - the authType is not supported on current device. + * @throws {BusinessError} 12300016 - authentication timeout. + * @throws {BusinessError} 12300017 - authentication service is busy. + * @throws {BusinessError} 12300018 - authentication service is locked. + * @throws {BusinessError} 12300019 - the credential does not exist. * @systemapi Hide this for inner system use. + * @since 8 */ authUser(userId: number, challenge: Uint8Array, authType: AuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array; /** * Cancels authentication with context ID. - * - * @since 8 - * @param contextID Indicates the authentication context ID. - * @return Returns a number indicating whether the cancellation was successful. * @permission ohos.permission.ACCESS_USER_AUTH_INTERNAL + * @param contextID Indicates the authentication context ID. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid contexId. * @systemapi Hide this for inner system use. + * @since 8 */ - cancelAuth(contextID: Uint8Array): number; + cancelAuth(contextID: Uint8Array): void; } /** * Provides the abilities for Pin code authentication. - * * @name PINAuth - * @since 8 * @syscap SystemCapability.Account.OsAccount + * @since 8 */ class PINAuth { /** * Constructor to get the PINAuth class instance. - * - * @since 8 - * @return Returns the PINAuth class instance. + * @returns Returns the PINAuth class instance. * @systemapi Hide this for inner system use. + * @since 8 */ constructor(); /** * Register inputer. - * - * @param inputer Indicates the password input box callback - * @return boolean Indicates the registration succeeded or failed. * @permission ohos.permission.ACCESS_PIN_AUTH + * @param inputer Indicates the password input box callback + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300007 - PIN inputer has been registered. * @systemapi Hide this for inner system use. + * @since 8 */ - registerInputer(inputer: IInputer): boolean; + registerInputer(inputer: IInputer): void; /** * Unregister inputer. - * * @permission ohos.permission.ACCESS_PIN_AUTH * @systemapi Hide this for inner system use. + * @since 8 */ unregisterInputer(): void; } /** * Provides the abilities for managing user identity. - * * @name UserIdentityManager - * @since 8 * @syscap SystemCapability.Account.OsAccount + * @since 8 */ class UserIdentityManager { /** * Constructor to get the UserIdentityManager class instance. - * - * @since 8 - * @return Returns the UserIdentityManager class instance. + * @returns Returns the UserIdentityManager class instance. * @systemapi Hide this for inner system use. + * @since 8 */ constructor(); @@ -723,11 +1038,13 @@ declare namespace osAccount { *

    * Start an IDM operation to obtain challenge value. * A challenge value of 0 indicates that opensession failed. - * - * @since 8 - * @return Returns a challenge value. * @permission ohos.permission.MANAGE_USER_IDM + * @returns Returns a challenge value. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. * @systemapi Hide this for inner system use. + * @since 8 */ openSession(callback: AsyncCallback): void; openSession(): Promise; @@ -738,80 +1055,101 @@ declare namespace osAccount { * Add user credential information, pass in credential addition method and credential information * (credential type, subclass, if adding user's non password credentials, pass in password authentication token), * and get the result / acquireinfo callback. - * - * @since 8 + * @permission ohos.permission.MANAGE_USER_IDM * @param credentialInfo Indicates the credential information. * @param callback Indicates the callback to get results and acquireInfo. - * @permission ohos.permission.MANAGE_USER_IDM + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid credentialInfo. * @systemapi Hide this for inner system use. + * @since 8 */ addCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void; /** * Updates credential. - * - * @since 8 + * @permission ohos.permission.MANAGE_USER_IDM * @param credentialInfo Indicates the credential information. * @param callback Indicates the callback to get results and acquireInfo. - * @permission ohos.permission.MANAGE_USER_IDM + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid credentialInfo. * @systemapi Hide this for inner system use. + * @since 8 */ updateCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void; /** * Closes session. *

    - * End an IDM operation. - * - * @since 8 + * End an IDM operation. * @permission ohos.permission.MANAGE_USER_IDM * @systemapi Hide this for inner system use. + * @since 8 */ closeSession(): void; /** * Cancels entry with a challenge value. - * - * @since 8 - * @param challenge Indicates the challenge value. - * @return Returns a number indicating whether the cancellation was successful. * @permission ohos.permission.MANAGE_USER_IDM + * @param challenge Indicates the challenge value. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid challenge. * @systemapi Hide this for inner system use. + * @since 8 */ - cancel(challenge: Uint8Array): number; + cancel(challenge: Uint8Array): void; /** * Deletes the user with the authentication token. - * - * @since 8 + * @permission ohos.permission.MANAGE_USER_IDM * @param token Indicates the authentication token. * @param callback Indicates the callback to get the deletion result. - * @permission ohos.permission.MANAGE_USER_IDM + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid token. * @systemapi Hide this for inner system use. + * @since 8 */ delUser(token: Uint8Array, callback: IIdmCallback): void; /** * Deletes the user credential information. - * - * @since 8 + * @permission ohos.permission.MANAGE_USER_IDM * @param credentialId Indicates the credential index. * @param token Indicates the authentication token. * @param callback Indicates the callback to get the deletion result. - * @permission ohos.permission.MANAGE_USER_IDM + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid credentialId or token. * @systemapi Hide this for inner system use. + * @since 8 */ delCred(credentialId: Uint8Array, token: Uint8Array, callback: IIdmCallback): void; /** * Gets authentication information. - * - * @since 8 + * @permission ohos.permission.USE_USER_IDM * @param authType Indicates the authentication type. * @param callback Indicates the callback to get all registered credential information of * the specified type for the current user. - * @permission ohos.permission.USE_USER_IDM + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid authType. + * @throws {BusinessError} 12300015 - the authType is not supported on current device. + * @throws {BusinessError} 12300016 - authentication timeout. + * @throws {BusinessError} 12300017 - authentication service is busy. + * @throws {BusinessError} 12300018 - authentication service is locked. + * @throws {BusinessError} 12300019 - the credential does not exist. * @systemapi Hide this for inner system use. + * @since 8 */ getAuthInfo(callback: AsyncCallback>): void; getAuthInfo(authType: AuthType, callback: AsyncCallback>): void; @@ -822,102 +1160,96 @@ declare namespace osAccount { * Password data callback. * * @name IInputData - * @since 8 * @syscap SystemCapability.Account.OsAccount * @systemapi Hide this for inner system use. + * @since 8 */ interface IInputData { /** * Notifies to set data. - * - * @since 8 * @param pinSubType Indicates the credential subtype for authentication. * @param data Indicates the data to set. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 12300002 - invalid pinSubType. * @systemapi Hide this for inner system use. + * @since 8 */ onSetData: (pinSubType: AuthSubType, data: Uint8Array) => void; } /** * Password input box callback. - * * @name IInputer - * @since 8 * @syscap SystemCapability.Account.OsAccount * @systemapi Hide this for inner system use. + * @since 8 */ interface IInputer { /** * Notifies to get data. - * - * @since 8 * @param pinSubType Indicates the credential subtype for authentication. * @param callback Indicates the password data callback. * @systemapi Hide this for inner system use. + * @since 8 */ onGetData: (pinSubType: AuthSubType, callback: IInputData) => void; } /** * User authentication callback. - * * @name IUserAuthCallback - * @since 8 * @syscap SystemCapability.Account.OsAccount * @systemapi Hide this for inner system use. + * @since 8 */ interface IUserAuthCallback { /** * The authentication result code is returned through the callback. - * - * @since 8 * @param result Indicates the authentication result code. * @param extraInfo Indicates the specific information for different situation. * If the authentication is passed, the authentication token is returned in extrainfo, * If the authentication fails, the remaining authentication times are returned in extrainfo, * If the authentication executor is locked, the freezing time is returned in extrainfo. * @systemapi Hide this for inner system use. + * @since 8 */ onResult: (result: number, extraInfo: AuthResult) => void; /** * During an authentication, the TipsCode is returned through the callback. - * - * @since 8 * @param module Indicates the executor type for authentication. * @param acquire Indicates the tip code for different authentication executor. * @param extraInfo reserved parameter. * @systemapi Hide this for inner system use. + * @since 8 */ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void; } /** * Identity manager callback. - * * @name IIdmCallback - * @since 8 * @syscap SystemCapability.Account.OsAccount * @systemapi Hide this for inner system use. + * @since 8 */ interface IIdmCallback { /** * The authentication result code is returned through the callback. - * - * @since 8 * @param result Indicates the authentication result code. * @param extraInfo pass the specific information for different situation. * @systemapi Hide this for inner system use. + * @since 8 */ onResult: (result: number, extraInfo: RequestResult) => void; /** * During an authentication, the TipsCode is returned through the callback. - * @since 8 * @param module Indicates the executor type for authentication. * @param acquire Indicates the tip code for different authentication executor. * @param extraInfo reserved parameter. * @systemapi Hide this for inner system use. + * @since 8 */ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void; } @@ -926,9 +1258,9 @@ declare namespace osAccount { * Provides the information of the get property request. * * @name GetPropertyRequest - * @since 8 * @syscap SystemCapability.Account.OsAccount * @systemapi Hide this for inner system use. + * @since 8 */ interface GetPropertyRequest { /** @@ -944,11 +1276,10 @@ declare namespace osAccount { /** * Provides the information of the set property request. - * * @name SetPropertyRequest - * @since 8 * @syscap SystemCapability.Account.OsAccount * @systemapi Hide this for inner system use. + * @since 8 */ interface SetPropertyRequest { /** @@ -969,11 +1300,10 @@ declare namespace osAccount { /** * Provides the property of executor. - * * @name ExecutorProperty - * @since 8 * @syscap SystemCapability.Account.OsAccount * @systemapi Hide this for inner system use. + * @since 8 */ interface ExecutorProperty { /** @@ -999,11 +1329,10 @@ declare namespace osAccount { /** * Indicates the information of authentication result. - * * @name AuthResult - * @since 8 * @syscap SystemCapability.Account.OsAccount * @systemapi Hide this for inner system use. + * @since 8 */ interface AuthResult { /** @@ -1024,11 +1353,10 @@ declare namespace osAccount { /** * Indicates the information of credential. - * * @name CredentialInfo - * @since 8 * @syscap SystemCapability.Account.OsAccount * @systemapi Hide this for inner system use. + * @since 8 */ interface CredentialInfo { /** @@ -1049,11 +1377,10 @@ declare namespace osAccount { /** * Indicates the information of request result. - * * @name RequestResult - * @since 8 * @syscap SystemCapability.Account.OsAccount * @systemapi Hide this for inner system use. + * @since 8 */ interface RequestResult { /** @@ -1064,11 +1391,10 @@ declare namespace osAccount { /** * Indicates the information of enrolled credential. - * * @name EnrolledCredInfo - * @since 8 * @syscap SystemCapability.Account.OsAccount * @systemapi Hide this for inner system use. + * @since 8 */ interface EnrolledCredInfo { /** @@ -1094,11 +1420,10 @@ declare namespace osAccount { /** * Indicates the property type to get. - * * @name GetPropertyType - * @since 8 * @syscap SystemCapability.Account.OsAccount * @systemapi Hide this for inner system use. + * @since 8 */ enum GetPropertyType { /** @@ -1121,9 +1446,9 @@ declare namespace osAccount { * Indicates the property type to set. * * @name SetPropertyType - * @since 8 * @syscap SystemCapability.Account.OsAccount * @systemapi Hide this for inner system use. + * @since 8 */ enum SetPropertyType { /** @@ -1134,11 +1459,10 @@ declare namespace osAccount { /** * Indicates the credential type for authentication. - * * @name AuthType - * @since 8 * @syscap SystemCapability.Account.OsAccount * @systemapi Hide this for inner system use. + * @since 8 */ enum AuthType { /** @@ -1154,11 +1478,10 @@ declare namespace osAccount { /** * Indicates the credential subtype for authentication. - * * @name AuthSubType - * @since 8 * @syscap SystemCapability.Account.OsAccount * @systemapi Hide this for inner system use. + * @since 8 */ enum AuthSubType { /** @@ -1189,11 +1512,10 @@ declare namespace osAccount { /** * Indicates the trusted level of authentication results. - * * @name AuthTrustLevel - * @since 8 * @syscap SystemCapability.Account.OsAccount * @systemapi Hide this for inner system use. + * @since 8 */ enum AuthTrustLevel { /** @@ -1219,11 +1541,10 @@ declare namespace osAccount { /** * Indicates the module of acquired information. - * * @name Module - * @since 8 * @syscap SystemCapability.Account.OsAccount * @systemapi Hide this for inner system use. + * @since 8 */ enum Module { /** @@ -1234,11 +1555,10 @@ declare namespace osAccount { /** * Indicates the enumeration of authentication result code. - * * @name ResultCode - * @since 8 * @syscap SystemCapability.Account.OsAccount * @systemapi Hide this for inner system use. + * @since 8 */ enum ResultCode { /** @@ -1299,11 +1619,10 @@ declare namespace osAccount { /** * Indicates the enumeration of prompt codes in the process of face authentication. - * * @name FaceTipsCode - * @since 8 * @syscap SystemCapability.Account.OsAccount * @systemapi Hide this for inner system use. + * @since 8 */ enum FaceTipsCode { /** @@ -1364,11 +1683,10 @@ declare namespace osAccount { /** * Indicates the enumeration of prompt codes in the process of fingerprint authentication. - * * @name FingerprintTips - * @since 8 * @syscap SystemCapability.Account.OsAccount * @systemapi Hide this for inner system use. + * @since 8 */ enum FingerprintTips { /** @@ -1404,11 +1722,10 @@ declare namespace osAccount { /** * Enumerates for constraint source types. - * * @name ConstraintSourceType - * @since 9 * @syscap SystemCapability.Account.OsAccount * @systemapi Hide this for inner system use. + * @since 9 */ enum ConstraintSourceType { /** @@ -1434,11 +1751,10 @@ declare namespace osAccount { /** * Provides information about the constraint source type info of an os account. - * * @name ConstraintSourceTypeInfo - * @since 9 * @syscap SystemCapability.Account.OsAccount * @systemapi Hide this for inner system use. + * @since 9 */ interface ConstraintSourceTypeInfo { /**