From 4817c383ab0d6cb09fcb9aabd2c52d241715cc7a Mon Sep 17 00:00:00 2001 From: wangyihui Date: Thu, 8 Dec 2022 15:29:47 +0800 Subject: [PATCH] add domain auth Signed-off-by: wangyihui Change-Id: I9adfa88329be083db9b163a27ff4142046a30463 --- .../reference/apis/js-apis-osAccount.md | 149 ++++++++++++++---- 1 file changed, 116 insertions(+), 33 deletions(-) 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 0c96d65afa..0eae3b284c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-osAccount.md +++ b/zh-cn/application-dev/reference/apis/js-apis-osAccount.md @@ -4243,7 +4243,7 @@ cancelAuth(contextID: Uint8Array): void; ## PINAuth8+ -Pin码认证功能基类。 +PIN码认证基类。 **系统接口:** 此接口为系统接口。 @@ -4251,7 +4251,7 @@ Pin码认证功能基类。 constructor() -创建Pin码认证的实例。 +创建PIN码认证的实例。 **系统接口:** 此接口为系统接口。 @@ -4280,17 +4280,12 @@ registerInputer(inputer: IInputer): void; | ----------| ----------------------- | --- | -------------------------- | | inputer | [IInputer](#iinputer8) | 是 | PIN码输入器,用于获取PIN码。 | -**返回值:** - -| 类型 | 说明 | -| :------ | :-------------------------------------------- | -| boolean | 返回布尔值,true表示注册成功,false表示注册失败。 | - **错误码:** | 错误码ID | 错误信息 | | -------- | --------------------------- | | 12300001 | System service exception. | +| 12300102 | Invalid inputer. | | 12300103 | Inputer already registered. | **示例:** @@ -4299,8 +4294,8 @@ registerInputer(inputer: IInputer): void; let password = new Uint8Array([0, 0, 0, 0, 0]); try { let result = pinAuth.registerInputer({ - onGetData: (pinSubType, callback) => { - callback.onSetData(pinSubType, password); + onGetData: (authSubType, callback) => { + callback.onSetData(authSubType, password); } }); console.log('registerInputer result = ' + result); @@ -4327,6 +4322,91 @@ unregisterInputer(): void; pinAuth.unregisterInputer(); ``` +### InputerManager 10+ + +凭据输入管理器。 + +### registerInputer10+ + +registerInputer(authType: AuthType, inputer: IInputer): void; + +注册凭据输入器。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.Account.OsAccount + +**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNAL 或 ohos.permission.MANAGE_USER_IDM + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----------| ----------------------- | --- | -------------------------- | +| authType | [AuthType](#authtype8) | 是 | 认证类型。 | +| inputer | [IInputer](#iinputer8) | 是 | 凭据输入器,用于获取凭据。 | + +**错误码:** + +| 错误码ID | 错误信息 | +| -------- | --------------------------- | +| 12300001 | System service exception. | +| 12300102 | Invalid authType or inputer. | +| 12300103 | The credential inputer has been registered. | +| 12300106 | Unsupported authType. | + +**示例:** + ```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, { + onGetData: (authSubType, callback) => { + callback.onSetData(authSubType, password); + } + }); + console.log('registerInputer success.'); + } catch (e) { + console.log('registerInputer exception = ' + JSON.stringify(e)); + } + ``` + +### unregisterInputer10+ + +unregisterInputer(authType: AuthType): void; + +解注册凭据输入器。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.Account.OsAccount + +**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNAL 或 ohos.permission.MANAGE_USER_IDM + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----------| ----------------------- | --- | -------------------------- | +| authType | [AuthType](#authtype8) | 是 | 认证类型。 | + +**错误码:** + +| 错误码ID | 错误信息 | +| -------- | --------------------------- | +| 12300002 | Invalid authType. | + +**示例:** + ```js + let inputerMgr = new account_osAccount.InputerManager(); + let authType = account_osAccount.AuthType.DOMAIN; + try { + inputerMgr.unregisterInputer(authType); + console.log('unregisterInputer success.'); + } catch(err) { + console.log("unregisterInputer err:" + JSON.stringify(err)); + } + ``` + ## UserIdentityManager8+ 获取用户身份管理类。 @@ -4456,8 +4536,8 @@ addCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void; let password = new Uint8Array([0, 0, 0, 0, 0, 0]); let pinAuth = new account_osAccount.PINAuth(); pinAuth.registerInputer({ - onGetData: (pinSubType, callback) => { - callback.onSetData(pinSubType, password); + onGetData: (authSubType, callback) => { + callback.onSetData(authSubType, password); } }); let credentialInfo = { @@ -4470,12 +4550,12 @@ addCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void; try { userIDM.addCredential(credentialInfo, { onResult: (result, extraInfo) => { - console.log('updateCredential result = ' + result); - console.log('updateCredential extraInfo = ' + extraInfo); + console.log('addCredential result = ' + result); + console.log('addCredential extraInfo = ' + extraInfo); } }); } catch (e) { - console.log('updateCredential exception = ' + JSON.stringify(e)); + console.log('addCredential exception = ' + JSON.stringify(e)); } }); ``` @@ -4520,8 +4600,8 @@ updateCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void; token: null }; pinAuth.registerInputer({ - onGetData: (pinSubType, callback) => { - callback.onSetData(pinSubType, password); + onGetData: (authSubType, callback) => { + callback.onSetData(authSubType, password); } }); userIDM.openSession((err, challenge) => { @@ -4820,7 +4900,7 @@ getAuthInfo(authType?: AuthType): Promise<Array<EnrolledCredInfo>>; ### onSetData8+ -onSetData: (pinSubType: AuthSubType, data: Uint8Array) => void; +onSetData: (authSubType: AuthSubType, data: Uint8Array) => void; **系统接口:** 此接口为系统接口。 @@ -4832,7 +4912,7 @@ onSetData: (pinSubType: AuthSubType, data: Uint8Array) => void; | 参数名 | 类型 | 必填 | 说明 | | ---------- | ---------------------------------------- | ---- | ----------------------------------------------- | -| pinSubType | [AuthSubType](#authsubtype8) | 是 | 用于认证的凭据子类型。 | +| authSubType | [AuthSubType](#authsubtype8) | 是 | 用于认证的凭据子类型。 | | data | Uint8Array | 是 | 要设置的数据是凭据,用来在认证、添加、修改凭据操作。 | **示例:** @@ -4840,11 +4920,11 @@ onSetData: (pinSubType: AuthSubType, data: Uint8Array) => void; let password = new Uint8Array([0, 0, 0, 0, 0, 0]); let passwordNumber = new Uint8Array([1, 2, 3, 4]); let inputer = { - onGetData: (pinSubType, callback) => { - if (pinSubType == account_osAccount.AuthSubType.PIN_NUMBER) { - callback.onSetData(pinSubType, passwordNumber); + onGetData: (authSubType, callback) => { + if (authSubType == account_osAccount.AuthSubType.PIN_NUMBER) { + callback.onSetData(authSubType, passwordNumber); } else { - callback.onSetData(pinSubType, password); + callback.onSetData(authSubType, password); } } }; @@ -4852,13 +4932,13 @@ onSetData: (pinSubType: AuthSubType, data: Uint8Array) => void; ## IInputer8+ -密码输入框回调。 +凭据输入器回调。 **系统接口:** 此接口为系统接口。 ### onGetData8+ -onGetData: (pinSubType: AuthSubType, callback: IInputData) => void; +onGetData: (authSubType: AuthSubType, callback: IInputData) => void; 通知获取数据。 @@ -4877,11 +4957,11 @@ onGetData: (pinSubType: AuthSubType, callback: IInputData) => void; let password = new Uint8Array([0, 0, 0, 0, 0, 0]); let passwordNumber = new Uint8Array([1, 2, 3, 4]); let inputer = { - onGetData: (pinSubType, callback) => { - if (pinSubType == account_osAccount.AuthSubType.PIN_NUMBER) { - callback.onSetData(pinSubType, passwordNumber); + onGetData: (authSubType, callback) => { + if (authSubType == account_osAccount.AuthSubType.PIN_NUMBER) { + callback.onSetData(authSubType, passwordNumber); } else { - callback.onSetData(pinSubType, password); + callback.onSetData(authSubType, password); } } }; @@ -5155,8 +5235,10 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void; | 名称 | 值 | 说明 | | ----- | ----- | ---------------- | -| PIN | 1 | 指示PIN认证类型。 | -| FACE | 2 | 指示脸部认证类型。| +| PIN | 1 | 表示PIN认证类型。 | +| FACE | 2 | 表示脸部认证类型。| +| FINGERPRINT10+ | 4 | 表示指纹认证类型。 | +| DOMAIN10+ | 1024 | 表示域认证类型。| ## AuthSubType8+ @@ -5171,8 +5253,9 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void; | PIN_SIX | 10000 | 表示6位凭证。 | | PIN_NUMBER | 10001 | 表示自定义数字凭证。 | | PIN_MIXED | 10002 | 表示自定义混合凭据。 | -| FACE_2D | 20000 | 指示2D 人脸凭证。 | -| FACE_3D | 20001 | 指示3D 人脸凭证。 | +| FACE_2D | 20000 | 表示2D 人脸凭证。 | +| FACE_3D | 20001 | 表示3D 人脸凭证。 | +| DOMAIN_MIXED10+ | 10240001 | 表示域认证混合凭证。 | ## AuthTrustLevel8+ -- GitLab