diff --git a/zh-cn/application-dev/reference/apis/js-apis-appAccount.md b/zh-cn/application-dev/reference/apis/js-apis-appAccount.md index 1402054068f5548345dc872d6764d1c26b6bb06a..fe4b165080641d7dd7bb4208864a6846eaa8a247 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-appAccount.md +++ b/zh-cn/application-dev/reference/apis/js-apis-appAccount.md @@ -1114,8 +1114,6 @@ getAllAccounts(callback: AsyncCallback<Array<AppAccountInfo>>): void 获取所有可访问的应用帐号信息。使用callback异步回调。 -**需要权限:** ohos.permission.GET_ALL_APP_ACCOUNTS。 - **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -1153,8 +1151,6 @@ getAllAccounts(): Promise<Array<AppAccountInfo>> 获取所有可访问的应用帐号信息。使用Promise异步回调。 -**需要权限:** ohos.permission.GET_ALL_APP_ACCOUNTS。 - **系统能力:** SystemCapability.Account.AppAccount **返回值:** @@ -1190,8 +1186,6 @@ getAccountsByOwner(owner: string, callback: AsyncCallback<Array<AppAccount 根据应用帐号所有者获取调用方可访问的应用帐号列表。使用callback异步回调。 -**需要权限:** ohos.permission.GET_ALL_APP_ACCOUNTS。 - **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -1232,8 +1226,6 @@ getAccountsByOwner(owner: string): Promise<Array<AppAccountInfo>> 根据应用帐号所有者获取调用方可访问的应用帐号列表。使用Promise异步回调。 -**需要权限:** ohos.permission.GET_ALL_APP_ACCOUNTS。 - **系统能力:** SystemCapability.Account.AppAccount **参数:** @@ -1312,7 +1304,7 @@ on(type: 'accountChange', owners: Array<string>, callback: Callback<Arr ### off('accountChange')9+ -off(type: 'accountChange', callback?: Callback>): void +off(type: 'accountChange', callback?: Callback<Array<AppAccountInfo>>): void 取消订阅帐号信息变更事件。 @@ -1323,7 +1315,7 @@ off(type: 'accountChange', callback?: Callback>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------- | ---- | ------------ | | type | 'accountChange' | 是 | 事件回调类型,支持的事件为'accountChange',当帐号所有者更新帐号信息时,触发该事件。 | -| callback | Callback> | 否 | 回调函数,返回信息发生变更的应用帐号列表。 | +| callback | Callback<Array<[AppAccountInfo](#appaccountinfo)>> | 否 | 回调函数,返回信息发生变更的应用帐号列表。 | **错误码:** @@ -1337,7 +1329,7 @@ off(type: 'accountChange', callback?: Callback>): void ```js let appAccountManager = account_appAccount.createAppAccountManager(); - function changeOnCallback(data){ + function changeOnCallback(data) { console.log("receive change data:" + JSON.stringify(data)); } try{ @@ -3790,7 +3782,7 @@ on(type: 'change', owners: Array<string>, callback: Callback<Array<A ### off('change')(deprecated) -off(type: 'change', callback?: Callback>): void +off(type: 'change', callback?: Callback<Array<AppAccountInfo>>): void 取消订阅帐号信息变更事件。 @@ -3805,7 +3797,7 @@ off(type: 'change', callback?: Callback>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------- | ---- | ------------ | | type | 'change' | 是 | 事件回调类型,支持的事件为'change',当帐号所有者更新帐号信息时,触发该事件。 | -| callback | Callback> | 否 | 回调函数,返回信息发生变更的应用帐号列表。 | +| callback | Callback<Array<[AppAccountInfo](#appaccountinfo)>> | 否 | 回调函数,返回信息发生变更的应用帐号列表。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-osAccount.md b/zh-cn/application-dev/reference/apis/js-apis-osAccount.md index e1113330d00d86e527b5919099280af817b92ab5..146357e815263f8949623573b27529593c5f2a90 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-osAccount.md +++ b/zh-cn/application-dev/reference/apis/js-apis-osAccount.md @@ -4323,13 +4323,13 @@ unregisterInputer(): void; pinAuth.unregisterInputer(); ``` -### InputerManager 10+ +## InputerManager 9+ 凭据输入管理器。 -### registerInputer10+ +### registerInputer9+ -registerInputer(authType: AuthType, inputer: IInputer): void; +static registerInputer(authType: AuthType, inputer: IInputer): void 注册凭据输入器。 @@ -4357,11 +4357,10 @@ registerInputer(authType: AuthType, inputer: IInputer): void; **示例:** ```js - let inputerMgr = new account_osAccount.InputerManager(); let authType = account_osAccount.AuthType.DOMAIN; let password = new Uint8Array([0, 0, 0, 0, 0]); try { - inputerMgr.registerInputer(authType, { + account_osAccount.InputerManager.registerInputer(authType, { onGetData: (authSubType, callback) => { callback.onSetData(authSubType, password); } @@ -4372,9 +4371,9 @@ registerInputer(authType: AuthType, inputer: IInputer): void; } ``` -### unregisterInputer10+ +### unregisterInputer9+ -unregisterInputer(authType: AuthType): void; +static unregisterInputer(authType: AuthType): void 解注册凭据输入器。 @@ -4398,16 +4397,129 @@ unregisterInputer(authType: AuthType): void; **示例:** ```js - let inputerMgr = new account_osAccount.InputerManager(); let authType = account_osAccount.AuthType.DOMAIN; try { - inputerMgr.unregisterInputer(authType); + account_osAccount.InputerManager.unregisterInputer(authType); console.log('unregisterInputer success.'); } catch(err) { console.log("unregisterInputer err:" + JSON.stringify(err)); } ``` +## DomainPlugin9+ + +域插件,提供域帐号认证功能。 + +**系统接口:** 此接口为系统接口。 + +### auth9+ + +auth(domainAccountInfo: DomainAccountInfo, credential: Uint8Array, callback: IUserAuthCallback): void + +认证指定的域帐号。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | --------------------------------------- | ---- | --------------- | +| domainAccountInfo | [DomainAccountInfo](#domainaccountinfo8) | 是 | 指示域帐号信息。| +| credential | Uint8Array | 是 | 指示域帐号的凭据。| +| callback | [IUserAuthCallback](#iuserauthcallback8) | 是 | 指示认证结果回调。| + +**示例:** + ```js + let plugin = { + auth: (domainInfo, credential, callback) => { + // mock authentication + callback.onResult(0, {}); + } + } + account_osAccount.DomainAccountManager.registerPlugin(plugin); + let userAuth = new account_osAccount.UserAuth(); + let challenge = new Uint8Array([0]); + let authType = account_osAccount.AuthType.PIN; + let authTrustLevel = account_osAccount.AuthTrustLevel.ATL1; + try { + userAuth.auth(challenge, authType, authTrustLevel, { + onResult: (resultCode, authResult) => { + console.log('auth resultCode = ' + resultCode); + console.log('auth authResult = ' + JSON.stringify(authResult)); + } + }); + } catch (err) { + console.log('auth exception = ' + JSON.stringify(err)); + } + ``` + +## DomainAccountManager 9+ +域帐号管理器类。 + +### registerPlugin9+ + +static registerPlugin(plugin: DomainPlugin): void + +注册域插件。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.Account.OsAccount + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----------| ----------------------- | --- | -------------------------- | +| plugin | [DomainPlugin](#domainplugin9) | 是 | 指示域插件。 | + +**错误码:** + +| 错误码ID | 错误信息 | +| -------- | --------------------------- | +| 12300201 | The domain plugin has been registered. | + +**示例:** + ```js + let plugin = { + auth: (domainInfo, credential, callback) => { + // mock authentication + callback.onResult(0, {}); + } + } + try { + account_osAccount.DomainAccountManager.registerPlugin(plugin); + console.log('registerPlugin success.'); + } catch(err) { + console.log("registerPlugin err:" + JSON.stringify(err)); + } + ``` + +### unregisterPlugin9+ + +static unregisterPlugin(): void + +注销域插件。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.Account.OsAccount + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**示例:** + ```js + try { + account_osAccount.DomainAccountManager.unregisterPlugin(); + console.log('unregisterPlugin success.'); + } catch(err) { + console.log("unregisterPlugin err:" + JSON.stringify(err)); + } + ``` + ## UserIdentityManager8+ 获取用户身份管理类。