提交 2cc7fa84 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 aff329ec
# App Account Management # App Account Management
The **appAccount** module provides APIs for app account management. You can use the APIs to add, delete, query, modify, and authorize app accounts, write data to disks, and synchronize data. The **appAccount** module provides APIs for app account management. You can use the APIs to add, delete, query, modify, and authorize app accounts, write data to disks, and synchronize data.
...@@ -154,7 +154,7 @@ Implicitly adds an app account based on the specified account owner, authenticat ...@@ -154,7 +154,7 @@ Implicitly adds an app account based on the specified account owner, authenticat
} }
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.addAccountImplicitly("LiSi", "readAge", {}, { appAccountManager.addAccountImplicitly("com.example.ohos.accountjsdemo", "getSocialData", {}, {
onResult: onResultCallback, onResult: onResultCallback,
onRequestRedirected: onRequestRedirectedCallback onRequestRedirected: onRequestRedirectedCallback
}); });
...@@ -321,7 +321,8 @@ Enables an app account to access an app with the given bundle name. This API use ...@@ -321,7 +321,8 @@ Enables an app account to access an app with the given bundle name. This API use
**Example** **Example**
```js ```js
app_account_instance.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => { const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => {
console.log('enableAppAccess Success'); console.log('enableAppAccess Success');
}).catch((err) => { }).catch((err) => {
console.log("enableAppAccess err: " + JSON.stringify(err)); console.log("enableAppAccess err: " + JSON.stringify(err));
...@@ -334,7 +335,7 @@ checkAppAccountSyncEnable(name: string, callback: AsyncCallback&lt;boolean&gt;): ...@@ -334,7 +335,7 @@ checkAppAccountSyncEnable(name: string, callback: AsyncCallback&lt;boolean&gt;):
Checks whether an app account allows app data synchronization. This API uses an asynchronous callback to return the result. Checks whether an app account allows app data synchronization. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC (available only to system applications) **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
**System capability**: SystemCapability.Account.AppAccount **System capability**: SystemCapability.Account.AppAccount
...@@ -361,7 +362,7 @@ checkAppAccountSyncEnable(name: string): Promise&lt;boolean&gt; ...@@ -361,7 +362,7 @@ checkAppAccountSyncEnable(name: string): Promise&lt;boolean&gt;
Checks whether an app account allows app data synchronization. This API uses a promise to return the result. Checks whether an app account allows app data synchronization. This API uses a promise to return the result.
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC (available only to system applications) **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
**System capability**: SystemCapability.Account.AppAccount **System capability**: SystemCapability.Account.AppAccount
...@@ -510,7 +511,7 @@ setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback ...@@ -510,7 +511,7 @@ setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback
Sets whether to enable app data synchronization for an app account. This API uses an asynchronous callback to return the result. Sets whether to enable app data synchronization for an app account. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC (available only to system applications) **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
**System capability**: SystemCapability.Account.AppAccount **System capability**: SystemCapability.Account.AppAccount
...@@ -537,7 +538,7 @@ setAppAccountSyncEnable(name: string, isEnable: boolean): Promise&lt;void&gt; ...@@ -537,7 +538,7 @@ setAppAccountSyncEnable(name: string, isEnable: boolean): Promise&lt;void&gt;
Sets whether to enable app data synchronization for an app account. This API uses a promise to return the result. Sets whether to enable app data synchronization for an app account. This API uses a promise to return the result.
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC (available only to system applications) **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
**System capability**: SystemCapability.Account.AppAccount **System capability**: SystemCapability.Account.AppAccount
...@@ -585,7 +586,8 @@ Sets data to be associated with an app account. This API uses an asynchronous ca ...@@ -585,7 +586,8 @@ Sets data to be associated with an app account. This API uses an asynchronous ca
**Example** **Example**
```js ```js
app_account_instance.setAssociatedData("ZhangSan", "k001", "v001", (err) => { const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setAssociatedData("ZhangSan", "k001", "v001", (err) => {
console.log("setAssociatedData err: " + JSON.stringify(err)); console.log("setAssociatedData err: " + JSON.stringify(err));
}); });
``` ```
...@@ -795,6 +797,35 @@ Obtains data associated with an app account. This API uses a promise to return t ...@@ -795,6 +797,35 @@ Obtains data associated with an app account. This API uses a promise to return t
}); });
``` ```
### getAssociatedDataSync<sup>9+</sup>
getAssociatedDataSync(name: string, key: string): string;
Obtains the data associated with this app account. This API returns the result synchronously.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | --------- |
| name | string | Yes | Name of the target app account. |
| key | string | Yes | Key of the data to obtain.|
**Return value**
| Type | Description |
| :-------------------- | :-------------------- |
| string | Data obtained.|
**Example**
```js
const appAccountManager = account_appAccount.createAppAccountManager();
var backData = appAccountManager.getAssociatedDataSync("ZhangSan", "k001");
console.info("getAssociatedDataSync backData:" + JSON.stringify(backData));
```
### getAllAccessibleAccounts ### getAllAccessibleAccounts
getAllAccessibleAccounts(callback: AsyncCallback&lt;Array&lt;AppAccountInfo&gt;&gt;): void getAllAccessibleAccounts(callback: AsyncCallback&lt;Array&lt;AppAccountInfo&gt;&gt;): void
...@@ -868,7 +899,7 @@ Obtains information about all app accounts of the specified app. This API uses a ...@@ -868,7 +899,7 @@ Obtains information about all app accounts of the specified app. This API uses a
**Example** **Example**
```js ```js
const appAccountManager = account.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
const selfBundle = "com.example.actsgetallaaccounts"; const selfBundle = "com.example.actsgetallaaccounts";
appAccountManager.getAllAccounts(selfBundle, (err, data)=>{ appAccountManager.getAllAccounts(selfBundle, (err, data)=>{
console.debug("getAllAccounts err:" + JSON.stringify(err)); console.debug("getAllAccounts err:" + JSON.stringify(err));
...@@ -929,7 +960,7 @@ Subscribes to the account change events of the specified account owners. This AP ...@@ -929,7 +960,7 @@ Subscribes to the account change events of the specified account owners. This AP
**Example** **Example**
```js ```js
const appAccountManager = account.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
function changeOnCallback(data){ function changeOnCallback(data){
console.debug("receive change data:" + JSON.stringify(data)); console.debug("receive change data:" + JSON.stringify(data));
} }
...@@ -959,7 +990,7 @@ Unsubscribes from the account change events. This API uses an asynchronous callb ...@@ -959,7 +990,7 @@ Unsubscribes from the account change events. This API uses an asynchronous callb
**Example** **Example**
```js ```js
const appAccountManager = account.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
function changeOnCallback(data){ function changeOnCallback(data){
console.debug("receive change data:" + JSON.stringify(data)); console.debug("receive change data:" + JSON.stringify(data));
appAccountManager.off('change', function(){ appAccountManager.off('change', function(){
...@@ -1010,7 +1041,7 @@ Authenticates an app account to obtain an Open Authorization (OAuth) token. This ...@@ -1010,7 +1041,7 @@ Authenticates an app account to obtain an Open Authorization (OAuth) token. This
} }
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.authenticate("LiSi", "com.example.ohos.accountjsdemo", "readAge", {}, { appAccountManager.authenticate("LiSi", "com.example.ohos.accountjsdemo", "getSocialData", {}, {
onResult: onResultCallback, onResult: onResultCallback,
onRequestRedirected: onRequestRedirectedCallback onRequestRedirected: onRequestRedirectedCallback
}); });
...@@ -1037,7 +1068,7 @@ Obtains the OAuth token of an app account based on the specified authentication ...@@ -1037,7 +1068,7 @@ Obtains the OAuth token of an app account based on the specified authentication
```js ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", (err, data) => { appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "getSocialData", (err, data) => {
console.log('getOAuthToken err: ' + JSON.stringify(err)); console.log('getOAuthToken err: ' + JSON.stringify(err));
console.log('getOAuthToken token: ' + data); console.log('getOAuthToken token: ' + data);
}); });
...@@ -1069,7 +1100,7 @@ Obtains the OAuth token of an app account based on the specified authentication ...@@ -1069,7 +1100,7 @@ Obtains the OAuth token of an app account based on the specified authentication
```js ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge").then((data) => { appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "getSocialData").then((data) => {
console.log('getOAuthToken token: ' + data); console.log('getOAuthToken token: ' + data);
}).catch((err) => { }).catch((err) => {
console.log("getOAuthToken err: " + JSON.stringify(err)); console.log("getOAuthToken err: " + JSON.stringify(err));
...@@ -1097,7 +1128,7 @@ Sets an OAuth token for an app account. This API uses an asynchronous callback t ...@@ -1097,7 +1128,7 @@ Sets an OAuth token for an app account. This API uses an asynchronous callback t
```js ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx", (err) => { appAccountManager.setOAuthToken("LiSi", "getSocialData", "xxxx", (err) => {
console.log('setOAuthToken err: ' + JSON.stringify(err)); console.log('setOAuthToken err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -1128,7 +1159,7 @@ Sets an OAuth token for an app account. This API uses a promise to return the re ...@@ -1128,7 +1159,7 @@ Sets an OAuth token for an app account. This API uses a promise to return the re
```js ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx").then(() => { appAccountManager.setOAuthToken("LiSi", "getSocialData", "xxxx").then(() => {
console.log('setOAuthToken successfully'); console.log('setOAuthToken successfully');
}).catch((err) => { }).catch((err) => {
console.log('setOAuthToken err: ' + JSON.stringify(err)); console.log('setOAuthToken err: ' + JSON.stringify(err));
...@@ -1157,7 +1188,7 @@ Deletes the specified OAuth token for an app account. This API uses an asynchron ...@@ -1157,7 +1188,7 @@ Deletes the specified OAuth token for an app account. This API uses an asynchron
```js ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx", (err) => { appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "getSocialData", "xxxxx", (err) => {
console.log('deleteOAuthToken err: ' + JSON.stringify(err)); console.log('deleteOAuthToken err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -1189,7 +1220,7 @@ Deletes the specified OAuth token for an app account. This API uses a promise to ...@@ -1189,7 +1220,7 @@ Deletes the specified OAuth token for an app account. This API uses a promise to
```js ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx").then(() => { appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "getSocialData", "xxxxx").then(() => {
console.log('deleteOAuthToken successfully'); console.log('deleteOAuthToken successfully');
}).catch((err) => { }).catch((err) => {
console.log("deleteOAuthToken err: " + JSON.stringify(err)); console.log("deleteOAuthToken err: " + JSON.stringify(err));
...@@ -1218,7 +1249,7 @@ Sets the visibility of an OAuth token to an app. This API uses an asynchronous c ...@@ -1218,7 +1249,7 @@ Sets the visibility of an OAuth token to an app. This API uses an asynchronous c
```js ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err) => { appAccountManager.setOAuthTokenVisibility("LiSi", "getSocialData", "com.example.ohos.accountjsdemo", true, (err) => {
console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err)); console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -1250,7 +1281,7 @@ Sets the visibility of an OAuth token to an app. This API uses a promise to retu ...@@ -1250,7 +1281,7 @@ Sets the visibility of an OAuth token to an app. This API uses a promise to retu
```js ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then(() => { appAccountManager.setOAuthTokenVisibility("LiSi", "getSocialData", "com.example.ohos.accountjsdemo", true).then(() => {
console.log('setOAuthTokenVisibility successfully'); console.log('setOAuthTokenVisibility successfully');
}).catch((err) => { }).catch((err) => {
console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err)); console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err));
...@@ -1278,7 +1309,7 @@ Checks whether an OAuth token is visible to an app. This API uses an asynchronou ...@@ -1278,7 +1309,7 @@ Checks whether an OAuth token is visible to an app. This API uses an asynchronou
```js ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err, data) => { appAccountManager.checkOAuthTokenVisibility("LiSi", "getSocialData", "com.example.ohos.accountjsdemo", (err, data) => {
console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err)); console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err));
console.log('checkOAuthTokenVisibility isVisible: ' + data); console.log('checkOAuthTokenVisibility isVisible: ' + data);
}); });
...@@ -1310,7 +1341,7 @@ Checks whether an OAuth token is visible to an app. This API uses a promise to r ...@@ -1310,7 +1341,7 @@ Checks whether an OAuth token is visible to an app. This API uses a promise to r
```js ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then((data) => { appAccountManager.checkOAuthTokenVisibility("LiSi", "getSocialData", "com.example.ohos.accountjsdemo").then((data) => {
console.log('checkOAuthTokenVisibility isVisible: ' + data); console.log('checkOAuthTokenVisibility isVisible: ' + data);
}).catch((err) => { }).catch((err) => {
console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err)); console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err));
...@@ -1369,7 +1400,7 @@ Obtains all OAuth tokens visible to the caller for an app account. This API uses ...@@ -1369,7 +1400,7 @@ Obtains all OAuth tokens visible to the caller for an app account. This API uses
```js ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo").then((data) => { appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo").then((data) => {
console.log('getAllOAuthTokens data: ' + JSON.stringify(data)); console.log('getAllOAuthTokens data: ' + JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
console.log("getAllOAuthTokens err: " + JSON.stringify(err)); console.log("getAllOAuthTokens err: " + JSON.stringify(err));
}); });
...@@ -1395,7 +1426,7 @@ Obtains a list of authorized OAuth tokens of an app account. This API uses an as ...@@ -1395,7 +1426,7 @@ Obtains a list of authorized OAuth tokens of an app account. This API uses an as
```js ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge", (err, data) => { appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "getSocialData", (err, data) => {
console.log('getOAuthList err: ' + JSON.stringify(err)); console.log('getOAuthList err: ' + JSON.stringify(err));
console.log('getOAuthList data: ' + JSON.stringify(data)); console.log('getOAuthList data: ' + JSON.stringify(data));
}); });
...@@ -1426,7 +1457,7 @@ Obtains a list of authorized OAuth tokens of an app account. This API uses a pro ...@@ -1426,7 +1457,7 @@ Obtains a list of authorized OAuth tokens of an app account. This API uses a pro
```js ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge").then((data) => { appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "getSocialData").then((data) => {
console.log('getOAuthList data: ' + JSON.stringify(data)); console.log('getOAuthList data: ' + JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
console.log("getOAuthList err: " + JSON.stringify(err)); console.log("getOAuthList err: " + JSON.stringify(err));
...@@ -1462,9 +1493,9 @@ Obtains the authenticator callback for an authentication session. This API uses ...@@ -1462,9 +1493,9 @@ Obtains the authenticator callback for an authentication session. This API uses
} }
var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi", var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi",
[account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo", [account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo",
[account_appAccount.Constants.KEY_AUTH_TYPE]: "readAge", [account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData",
[account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"}; [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
callback.OnResult(account_appAccount.ResultCode.SUCCESS, result); callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
}); });
}); });
``` ```
...@@ -1492,15 +1523,17 @@ Obtains the authenticator callback for an authentication session. This API uses ...@@ -1492,15 +1523,17 @@ Obtains the authenticator callback for an authentication session. This API uses
**Example** **Example**
```js ```js
import featureAbility from '@ohos.ability.featureAbility';
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
featureAbility.getWant().then((want) => { featureAbility.getWant().then((want) => {
var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID]; var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID];
appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => { appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi", var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi",
[account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo", [account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo",
[account_appAccount.Constants.KEY_AUTH_TYPE]: "readAge", [account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData",
[account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"}; [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
callback.OnResult(account_appAccount.ResultCode.SUCCESS, result); callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
}).catch((err) => { }).catch((err) => {
console.log("getAuthenticatorCallback err: " + JSON.stringify(err)); console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
}); });
...@@ -1578,7 +1611,7 @@ Checks whether an app account is authorized to access an app. This API uses an a ...@@ -1578,7 +1611,7 @@ Checks whether an app account is authorized to access an app. This API uses an a
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---------- | ---------------------------- | ----- | ---------------- | | ---------- | ---------------------------- | ----- | ---------------- |
| name | string | Yes | Name of the target app account. | | name | string | Yes | Name of the target app account. |
| bundleName | string | Yes | Bundle name of the app to access.| | bundleName | string | Yes | Bundle name of the app to access. |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback invoked to return the result. | | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback invoked to return the result. |
**Example** **Example**
...@@ -1604,7 +1637,7 @@ Checks whether an app account is authorized to access an app. This API uses a pr ...@@ -1604,7 +1637,7 @@ Checks whether an app account is authorized to access an app. This API uses a pr
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---------- | ------ | ----- | ---------------- | | ---------- | ------ | ----- | ---------------- |
| name | string | Yes | Name of the target app account. | | name | string | Yes | Name of the target app account. |
| bundleName | string | Yes | Bundle name of the app to access.| | bundleName | string | Yes | Bundle name of the app to access. |
**Parameters** **Parameters**
...@@ -1702,7 +1735,8 @@ Checks whether an app account has specific labels. This API uses an asynchronous ...@@ -1702,7 +1735,8 @@ Checks whether an app account has specific labels. This API uses an asynchronous
```js ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.checkAccountLabels("zhangsan", "com.example.ohos.accountjsdemo", (err, data) => { var labels = ["student"];
appAccountManager.checkAccountLabels("zhangsan", "com.example.ohos.accountjsdemo", labels, (err, data) => {
console.log('checkAccountLabels: ' + JSON.stringify(data)); console.log('checkAccountLabels: ' + JSON.stringify(data));
console.log("checkAccountLabels err: " + JSON.stringify(err)); console.log("checkAccountLabels err: " + JSON.stringify(err));
}); });
...@@ -1734,7 +1768,8 @@ Checks whether an app account has specific labels. This API uses a promise to re ...@@ -1734,7 +1768,8 @@ Checks whether an app account has specific labels. This API uses a promise to re
```js ```js
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.checkAccountLabels("zhangsan", "com.example.ohos.accountjsdemo").then((data) => { var labels = ["student"];
appAccountManager.checkAccountLabels("zhangsan", "com.example.ohos.accountjsdemo", labels).then((data) => {
console.log('checkAccountLabels: ' + JSON.stringify(data)); console.log('checkAccountLabels: ' + JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
console.log("checkAccountLabels err: " + JSON.stringify(err)); console.log("checkAccountLabels err: " + JSON.stringify(err));
...@@ -1944,7 +1979,7 @@ Defines app account information. ...@@ -1944,7 +1979,7 @@ Defines app account information.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----- | ------ | ---- | ----------- | | ----- | ------ | ---- | ----------- |
| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.| | owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
| name | string | Yes | Name of the target app account. | | name | string | Yes | Name of the app account. |
## OAuthTokenInfo<sup>8+</sup> ## OAuthTokenInfo<sup>8+</sup>
...@@ -1967,8 +2002,8 @@ Defines OAuth authenticator information. ...@@ -1967,8 +2002,8 @@ Defines OAuth authenticator information.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ---------- | | ------- | ------ | ---- | ---------- |
| owner | string | Yes | Owner of the authenticator. The value is the bundle name of the app.| | owner | string | Yes | Owner of the authenticator. The value is the bundle name of the app.|
| iconId | string | Yes | ID of the authenticator icon. | | iconId | number | Yes | ID of the authenticator icon. |
| labelId | string | Yes | ID of the authenticator label. | | labelId | number | Yes | ID of the authenticator label. |
## SelectAccountsOptions<sup>9+</sup> ## SelectAccountsOptions<sup>9+</sup>
...@@ -2082,9 +2117,9 @@ Called to return the result of an authentication request. ...@@ -2082,9 +2117,9 @@ Called to return the result of an authentication request.
appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => { appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi", var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi",
[account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo", [account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo",
[account_appAccount.Constants.KEY_AUTH_TYPE]: "readAge", [account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData",
[account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"}; [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
callback.OnResult(account_appAccount.ResultCode.SUCCESS, result); callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
}).catch((err) => { }).catch((err) => {
console.log("getAuthenticatorCallback err: " + JSON.stringify(err)); console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
}); });
...@@ -2137,7 +2172,7 @@ Called to continue to process the request. ...@@ -2137,7 +2172,7 @@ Called to continue to process the request.
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
var sessionId = "1234"; var sessionId = "1234";
appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => { appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
callback.OnRequestContinued(); callback.onRequestContinued();
}).catch((err) => { }).catch((err) => {
console.log("getAuthenticatorCallback err: " + JSON.stringify(err)); console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
}); });
...@@ -2167,7 +2202,7 @@ Implicitly adds an app account based on the specified authentication type and op ...@@ -2167,7 +2202,7 @@ Implicitly adds an app account based on the specified authentication type and op
authenticate(name: string, authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void authenticate(name: string, authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void
Authenticates an app account to obtain the OAuth access token. This API uses an asynchronous callback to return the result. Authenticates an app account to obtain the OAuth token. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount **System capability**: SystemCapability.Account.AppAccount
...@@ -2264,7 +2299,7 @@ Obtains the remote object of an authenticator. This API cannot be overloaded. ...@@ -2264,7 +2299,7 @@ Obtains the remote object of an authenticator. This API cannot be overloaded.
callback.onResult(account_appAccount.ResultCode.SUCCESS, result); callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
} }
verifyCredential(name: string, options: VerifyCredentialOptions, callback: AuthenticatorCallback) { verifyCredential(name, options, callback) {
callback.onRequestRedirected({ callback.onRequestRedirected({
bundleName: "com.example.ohos.accountjsdemo", bundleName: "com.example.ohos.accountjsdemo",
abilityName: "com.example.ohos.accountjsdemo.VerifyAbility", abilityName: "com.example.ohos.accountjsdemo.VerifyAbility",
...@@ -2274,11 +2309,11 @@ Obtains the remote object of an authenticator. This API cannot be overloaded. ...@@ -2274,11 +2309,11 @@ Obtains the remote object of an authenticator. This API cannot be overloaded.
}); });
} }
setProperties(options: SetPropertiesOptions, callback: AuthenticatorCallback) { setProperties(options, callback) {
callback.onResult(account_appAccount.ResultCode.SUCCESS, {}); callback.onResult(account_appAccount.ResultCode.SUCCESS, {});
} }
checkAccountLabels(name: string, labels: Array<string>, callback: AuthenticatorCallback) { checkAccountLabels(name, labels, callback) {
var result = {[account_appAccount.Constants.KEY_BOOLEAN_RESULT]: false}; var result = {[account_appAccount.Constants.KEY_BOOLEAN_RESULT]: false};
callback.onResult(account_appAccount.ResultCode.SUCCESS, result); callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
} }
......
...@@ -19,6 +19,8 @@ getDistributedAccountAbility(): DistributedAccountAbility ...@@ -19,6 +19,8 @@ getDistributedAccountAbility(): DistributedAccountAbility
Obtains a **DistributedAccountAbility** instance. Obtains a **DistributedAccountAbility** instance.
**System capability**: SystemCapability.Account.OsAccount
- Return value - Return value
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
......
# OS Account Management # OS Account Management
The osAccount module provides basic capabilities for managing operating system (OS) accounts, including adding, deleting, querying, setting, subscribing to, and enabling an OS account, and storing OS account data to disks. The **osAccount** module provides basic capabilities for managing operating system (OS) accounts, including adding, deleting, querying, setting, subscribing to, and enabling an OS account, and storing OS account data to disks.
> **NOTE**<br> > **NOTE**<br>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -440,12 +440,10 @@ This is a system API and cannot be called by third-party applications. ...@@ -440,12 +440,10 @@ This is a system API and cannot be called by third-party applications.
```js ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var createIocalId; accountManager.createOsAccount("testAccountName", account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo) => {
osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ accountManager.removeOsAccount(osAccountInfo.localId, (err)=>{
createIocalId = osAccountInfo.localId; console.log("removeOsAccount err:" + JSON.stringify(err));
}); });
accountManager.removeOsAccount(createIocalId, (err)=>{
console.log("removeOsAccount err:" + JSON.stringify(err));
}); });
``` ```
...@@ -477,15 +475,12 @@ This is a system API and cannot be called by third-party applications. ...@@ -477,15 +475,12 @@ This is a system API and cannot be called by third-party applications.
```js ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var createIocalId; accountManager.createOsAccount("testAccountName", account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ accountManager.removeOsAccount(osAccountInfo.localId).then(() => {
createIocalId = osAccountInfo.localId; console.log('removeOsAccount Success');
}); }).catch(() => {
createIocalId = osAccount.localId; console.log("removeOsAccount err: " + JSON.stringify(err));
accountManager.removeOsAccount(createIocalId).then(() => { });
console.log('removeOsAccount Success');
}).catch(() => {
console.log("removeOsAccount err: " + JSON.stringify(err));
}); });
``` ```
...@@ -1097,7 +1092,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -1097,7 +1092,7 @@ This is a system API and cannot be called by third-party applications.
```js ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.createOsAccount("testName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ accountManager.createOsAccount("testName", account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
console.log("createOsAccount err:" + JSON.stringify(err)); console.log("createOsAccount err:" + JSON.stringify(err));
console.log("createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo)); console.log("createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo));
}); });
...@@ -1132,7 +1127,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -1132,7 +1127,7 @@ This is a system API and cannot be called by third-party applications.
```js ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
accountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL).then((accountInfo) => { accountManager.createOsAccount("testAccountName", account_osAccount.OsAccountType.NORMAL).then((accountInfo) => {
console.log("createOsAccount, accountInfo: " + JSON.stringify(accountInfo)); console.log("createOsAccount, accountInfo: " + JSON.stringify(accountInfo));
}).catch((err) => { }).catch((err) => {
console.log("createOsAccount err: " + JSON.stringify(err)); console.log("createOsAccount err: " + JSON.stringify(err));
...@@ -1164,7 +1159,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -1164,7 +1159,7 @@ This is a system API and cannot be called by third-party applications.
```js ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; var domainInfo = {domain: "testDomain", accountName: "testAccountName"};
accountManager.createOsAccountForDomain(osaccount.OsAccountType.NORMAL, domainInfo, (err, osAccountInfo)=>{ accountManager.createOsAccountForDomain(account_osAccount.OsAccountType.NORMAL, domainInfo, (err, osAccountInfo)=>{
console.log("createOsAccountForDomain err:" + JSON.stringify(err)); console.log("createOsAccountForDomain err:" + JSON.stringify(err));
console.log("createOsAccountForDomain osAccountInfo:" + JSON.stringify(osAccountInfo)); console.log("createOsAccountForDomain osAccountInfo:" + JSON.stringify(osAccountInfo));
}); });
...@@ -1200,7 +1195,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -1200,7 +1195,7 @@ This is a system API and cannot be called by third-party applications.
```js ```js
const accountManager = account_osAccount.getAccountManager(); const accountManager = account_osAccount.getAccountManager();
var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; var domainInfo = {domain: "testDomain", accountName: "testAccountName"};
accountManager.createOsAccountForDomain(osaccount.OsAccountType.NORMAL, domainInfo).then((accountInfo) => { accountManager.createOsAccountForDomain(account_osAccount.OsAccountType.NORMAL, domainInfo).then((accountInfo) => {
console.log("createOsAccountForDomain, account info: " + JSON.stringify(accountInfo)); console.log("createOsAccountForDomain, account info: " + JSON.stringify(accountInfo));
}).catch((err) => { }).catch((err) => {
console.log("createOsAccountForDomain err: " + JSON.stringify(err)); console.log("createOsAccountForDomain err: " + JSON.stringify(err));
...@@ -1523,7 +1518,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -1523,7 +1518,7 @@ This is a system API and cannot be called by third-party applications.
"Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y"+ "Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y"+
"q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo"+ "q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo"+
"+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg==" "+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg=="
osAccountManager.setOsAccountProfilePhoto(localId, photo, (err)=>{ accountManager.setOsAccountProfilePhoto(localId, photo, (err)=>{
console.log("setOsAccountProfilePhoto err:" + JSON.stringify(err)); console.log("setOsAccountProfilePhoto err:" + JSON.stringify(err));
}); });
``` ```
...@@ -1765,8 +1760,9 @@ This is a system API and cannot be called by third-party applications. ...@@ -1765,8 +1760,9 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
```js ```js
const accountManager = account_osAccount.getAccountManager();
var testUid = 1000000; var testUid = 1000000;
osAccountManager.getBundleIdFromUid(testUid,(err,bundleId)=>{ accountManager.getBundleIdFromUid(testUid, (err, bundleId) => {
console.info("getBundleIdFromUid errInfo:" + JSON.stringify(err)); console.info("getBundleIdFromUid errInfo:" + JSON.stringify(err));
console.info("getBundleIdFromUid bundleId:" + JSON.stringify(bundleId)); console.info("getBundleIdFromUid bundleId:" + JSON.stringify(bundleId));
}); });
...@@ -1796,10 +1792,13 @@ This is a system API and cannot be called by third-party applications. ...@@ -1796,10 +1792,13 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
```js ```js
const accountManager = account_osAccount.getAccountManager();
var testUid = 1000000; var testUid = 1000000;
var bundleIdInfo = await osAccountManager.getBundleIdFromUid(testUid).catch((err)=>{ accountManager.getBundleIdFromUid(testUid).then((result) => {
console.info("getBundleIdFromUid errInfo:" + JSON.stringify(err));}) console.info("getBundleIdFromUid bundleId:" + JSON.stringify(result));
console.info("getBundleIdFromUid bundleId:" + JSON.stringify(bundleIdInfo)); }).catch((err)=>{
console.info("getBundleIdFromUid errInfo:" + JSON.stringify(err));
});
``` ```
### isMainOsAccount<sup>9+</sup> ### isMainOsAccount<sup>9+</sup>
...@@ -1810,6 +1809,8 @@ Checks whether the current process belongs to the main OS account. This API uses ...@@ -1810,6 +1809,8 @@ Checks whether the current process belongs to the main OS account. This API uses
This is a system API and cannot be called by third-party applications. This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
**System capability**: SystemCapability.Account.OsAccount **System capability**: SystemCapability.Account.OsAccount
**Parameters** **Parameters**
...@@ -1821,7 +1822,8 @@ This is a system API and cannot be called by third-party applications. ...@@ -1821,7 +1822,8 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
```js ```js
osAccountManager.isMainOsAccount((err,result)=>{ const accountManager = account_osAccount.getAccountManager();
accountManager.isMainOsAccount((err,result)=>{
console.info("isMainOsAccount errInfo:" + JSON.stringify(err)); console.info("isMainOsAccount errInfo:" + JSON.stringify(err));
console.info("isMainOsAccount result:" + JSON.stringify(result)); console.info("isMainOsAccount result:" + JSON.stringify(result));
}); });
...@@ -1834,6 +1836,8 @@ Checks whether the current process belongs to the main OS account. This API uses ...@@ -1834,6 +1836,8 @@ Checks whether the current process belongs to the main OS account. This API uses
This is a system API and cannot be called by third-party applications. This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
**System capability**: SystemCapability.Account.OsAccount **System capability**: SystemCapability.Account.OsAccount
**Return value** **Return value**
...@@ -1845,10 +1849,12 @@ This is a system API and cannot be called by third-party applications. ...@@ -1845,10 +1849,12 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
```js ```js
var result = await osAccountManager.isMainOsAccount().catch((err)=>{ const accountManager = account_osAccount.getAccountManager();
accountManager.isMainOsAccount().then((result) => {
console.info("isMainOsAccount result:" + JSON.stringify(result));
}).catch((err)=>{
console.info("isMainOsAccount errInfo:" + JSON.stringify(err)); console.info("isMainOsAccount errInfo:" + JSON.stringify(err));
}); });
console.info("isMainOsAccount result:" + JSON.stringify(result));
``` ```
### queryOsAccountConstraintSourceTypes<sup>9+</sup> ### queryOsAccountConstraintSourceTypes<sup>9+</sup>
...@@ -1873,7 +1879,8 @@ This is a system API and cannot be called by third-party applications. ...@@ -1873,7 +1879,8 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
```js ```js
osAccountManager.queryOsAccountConstraintSourceTypes(100, "constraint.wifi",(err,sourceTypeInfos)=>{ const accountManager = account_osAccount.getAccountManager();
accountManager.queryOsAccountConstraintSourceTypes(100, "constraint.wifi",(err,sourceTypeInfos)=>{
console.info("queryOsAccountConstraintSourceType errInfo:" + JSON.stringify(err)); console.info("queryOsAccountConstraintSourceType errInfo:" + JSON.stringify(err));
console.info("queryOsAccountConstraintSourceType sourceTypeInfos:" + JSON.stringify(sourceTypeInfos)); console.info("queryOsAccountConstraintSourceType sourceTypeInfos:" + JSON.stringify(sourceTypeInfos));
}); });
...@@ -1907,27 +1914,33 @@ This is a system API and cannot be called by third-party applications. ...@@ -1907,27 +1914,33 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
```js ```js
var sourceTypeInfos = await osAccountManager.queryOsAccountConstraintSourceTypes(100, "constraint.wifi").catch((err)=>{ const accountManager = account_osAccount.getAccountManager();
console.info("queryOsAccountConstraintSourceType errInfo:" + JSON.stringify(err));}) accountManager.queryOsAccountConstraintSourceTypes(100, "constraint.wifi").then((result) => {
console.info("queryOsAccountConstraintSourceType sourceTypeInfos:" + JSON.stringify(sourceTypeInfos)); console.info("queryOsAccountConstraintSourceType sourceTypeInfos:" + JSON.stringify(result));
}).catch((err)=>{
console.info("queryOsAccountConstraintSourceType errInfo:" + JSON.stringify(err));
});
``` ```
## UserAuth<sup>8+</sup> ## UserAuth<sup>8+</sup>
Provides APIs for user authentication. Provides APIs for user authentication.
This is a system API and cannot be called by third-party applications.
### constructor<sup>8+</sup> ### constructor<sup>8+</sup>
constructor() constructor()
A constructor used to create an instance for user authentication. A constructor used to create an instance for user authentication.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount **System capability**: SystemCapability.Account.OsAccount
**Example** **Example**
```js ```js
let userAuth = new osAccount.UserAuth(); let userAuth = new account_osAccount.UserAuth();
console.info('====>test for examples constructor success');
``` ```
...@@ -1949,17 +1962,16 @@ This is a system API and cannot be called by third-party applications. ...@@ -1949,17 +1962,16 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
```js ```js
let userAuth = new osAccount.UserAuth(); let userAuth = new account_osAccount.UserAuth();
console.info('====>test for examples constructor success'); let version = userAuth.getVersion();
var version = userAuth.getVersion(); console.log("getVersion version = " + version);
console.info('====>test for examples version is : ' + JSON.stringify(version));
``` ```
### getAvailableStatus<sup>8+</sup> ### getAvailableStatus<sup>8+</sup>
getAvailableStatus(authType: AuthType, authTrustLevel: AuthTrustLevel): number; getAvailableStatus(authType: AuthType, authTrustLevel: AuthTrustLevel): number;
Checks whether the identity authentication function is available. Checks whether the identity authentication feature is available.
This is a system API and cannot be called by third-party applications. This is a system API and cannot be called by third-party applications.
...@@ -1971,23 +1983,22 @@ This is a system API and cannot be called by third-party applications. ...@@ -1971,23 +1983,22 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------------- | -----------------------------------------------| ---- | ------------------------- | | --------------- | -----------------------------------------------| ---- | ------------------------- |
| authType | [AuthType](#AuthType<sup>8+</sup>) | Yes | Authentication credential type. | | authType | [AuthType](#authtype8) | Yes | Authentication credential type. |
| authTrustLevel | [AuthTrustLevel](#AuthTrustLevel<sup>8+</sup>) | Yes | Trust level of the authentication result.| | authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | Yes | Trust level of the authentication result.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| :----- | :---------------------------------------- | | :----- | :---------------------------------------- |
| number | Result code(#ResultCode<sup>8+</sup>).| | number | [Result code](#resultcode8).|
**Example** **Example**
```js ```js
let userAuth = new osAccount.UserAuth(); let userAuth = new account_osAccount.UserAuth();
let authType = osAccount.AuthType.PIN; let authType = account_osAccount.AuthType.PIN;
let authTrustLevel = osAccount.AuthTrustLevel.ATL1; let authTrustLevel = account_osAccount.AuthTrustLevel.ATL1;
console.info('====>test for examples constructor success'); let status = userAuth.getAvailableStatus(authType, authTrustLevel);
let availableStatus = userAuth.getAvailableStatus(authType, authTrustLevel); console.log("getAvailableStatus status = " + status);
console.info('====>test for examples AvailabeStatus is : ' + JSON.stringify(availableStatus));
``` ```
### getProperty<sup>8+</sup> ### getProperty<sup>8+</sup>
...@@ -2006,26 +2017,30 @@ This is a system API and cannot be called by third-party applications. ...@@ -2006,26 +2017,30 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------------------------------- | ---- | ---------------------------------- | | -------- | ----------------------------------------------------------------------- | ---- | ---------------------------------- |
| request | [GetPropertyRequest](#GetPropertyRequest<sup>8+</sup>) | Yes | Request information, including the authentication credential type and property list.| | request | [GetPropertyRequest](#getpropertyrequest8) | Yes | Request information, including the authentication credential type and property list.|
| callback | AsyncCallback&lt;[ExecutorProperty](#ExecutorProperty<sup>8+</sup>)&gt; | Yes | Callback invoked to return the executor property obtained. | | callback | AsyncCallback&lt;[ExecutorProperty](#executorproperty8)&gt; | Yes | Callback invoked to return the executor property obtained. |
**Example** **Example**
```js ```js
let userAuth = new osAccount.UserAuth(); let userAuth = new account_osAccount.UserAuth();
let authType = osAccount.AuthType.PIN; let keys = [
let keys = new Array(); account_osAccount.GetPropertyType.AUTH_SUB_TYPE,
keys[0] = osAccount.GetPropertyType.AUTH_SUB_TYPE; account_osAccount.GetPropertyType.REMAIN_TIMES,
keys[1] = osAccount.GetPropertyType.REMAIN_TIMES; account_osAccount.GetPropertyType.FREEZING_TIME
keys[2] = osAccount.GetPropertyType.FREEZING_TIME; ];
let getPropertyRequest = {authType, keys}; let request = {
userAuth.getProperty(getPropertyRequest,function (propReq) { authType: account_osAccount.AuthType.PIN,
console.log("====>test for examples getallAuthInfo AsyncCallback = " + JSON.stringify(propReq)); keys: keys
}) };
userAuth.getProperty(request, (err, result) => {
console.log("getProperty err = " + JSON.stringify(err));
console.log("getProperty result = " + JSON.stringify(result));
});
``` ```
### getProperty<sup>8+</sup> ### getProperty<sup>8+</sup>
getProperty(request: GetPropertyRequest): Promise<ExecutorProperty>; getProperty(request: GetPropertyRequest): Promise&lt;ExecutorProperty&gt;;
Obtains the executor property based on the request. This API uses a promise to return the result. Obtains the executor property based on the request. This API uses a promise to return the result.
...@@ -2039,31 +2054,36 @@ This is a system API and cannot be called by third-party applications. ...@@ -2039,31 +2054,36 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------ | ---- | ---------------------------------- | | -------- | ------------------------------------------------------ | ---- | ---------------------------------- |
| request | [GetPropertyRequest](#GetPropertyRequest<sup>8+</sup>) | Yes | Request information, including the authentication credential type and property list.| | request | [GetPropertyRequest](#getpropertyrequest8) | Yes | Request information, including the authentication credential type and property list.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| :---------------------------------------------------------------- | :-------------------------------------------------- | | :---------------------------------------------------------------- | :-------------------------------------------------- |
| Promise&lt;[ExecutorProperty](#ExecutorProperty<sup>8+</sup>)&gt; | Promise used to return the executor property obtained.| | Promise&lt;[ExecutorProperty](#executorproperty8)&gt; | Promise used to return the executor property obtained.|
**Example** **Example**
```js ```js
let userAuth = new osAccount.UserAuth(); let userAuth = new account_osAccount.UserAuth();
let authType = osAccount.AuthType.PIN; let keys = [
let keys = new Array(); account_osAccount.GetPropertyType.AUTH_SUB_TYPE,
keys[0] = osAccount.GetPropertyType.AUTH_SUB_TYPE; account_osAccount.GetPropertyType.REMAIN_TIMES,
keys[1] = osAccount.GetPropertyType.REMAIN_TIMES; account_osAccount.GetPropertyType.FREEZING_TIME
keys[2] = osAccount.GetPropertyType.FREEZING_TIME; ];
let getPropertyRequest = {authType, keys}; let request = {
userAuth.getProperty(getPropertyRequest).then((propReq) => { authType: account_osAccount.AuthType.PIN,
console.log("====>test for examples getallAuthInfo AsyncCallback = " + JSON.stringify(propReq)); keys: keys
};
userAuth.getProperty(request).then((result) => {
console.log("getProperty result = " + JSON.stringify(result));
}).catch((err) => {
console.log("getProperty error = " + JSON.stringify(err));
}); });
``` ```
### setProperty<sup>8+</sup> ### setProperty<sup>8+</sup>
setProperty(request: SetPropertyRequest, callback: AsyncCallback<number>): void; setProperty(request: SetPropertyRequest, callback: AsyncCallback&lt;number&gt;): void;
Sets the property for the initialization algorithm. This API uses an asynchronous callback to return the result. Sets the property for the initialization algorithm. This API uses an asynchronous callback to return the result.
...@@ -2077,24 +2097,26 @@ This is a system API and cannot be called by third-party applications. ...@@ -2077,24 +2097,26 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------------- | ---- | ---------------------------------------------------------------------- | | -------- | ----------------------------------------------------- | ---- | ---------------------------------------------------------------------- |
| request | [SetPropertyRequest](#SetPropertyRequest<sup>8+</sup>)| Yes | Request information, including the authentication credential type and key value to set. | | request | [SetPropertyRequest](#setpropertyrequest8)| Yes | Request information, including the authentication credential type and key value to set. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the [result code](#ResultCode<sup>8+</sup>).| | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the [result](#resultcode8).|
**Example** **Example**
```js ```js
let userAuth = new osAccount.UserAuth(); let userAuth = new account_osAccount.UserAuth();
let authType = osAccount.AuthType.PIN; let request = {
let key = osAccount.SetPropertyType.INIT_ALGORITHM; authType: account_osAccount.AuthType.PIN,
let setInfo = new Uint8Array(); key: account_osAccount.SetPropertyType.INIT_ALGORITHM,
let setPropertyRequest = {authType, key, setInfo}; setInfo: new Uint8Array([0])
userAuth.setProperty(setPropertyRequest,function (setProp) { };
console.log("====>test for examples setProperty AsyncCallback = " + JSON.stringify(setProp)); userAuth.setProperty(request, (err, result) => {
console.log("setProperty error = " + JSON.stringify(err));
console.log("setProperty result = " + JSON.stringify(result));
}); });
``` ```
### setProperty<sup>8+</sup> ### setProperty<sup>8+</sup>
setProperty(request: SetPropertyRequest): Promise<number>; setProperty(request: SetPropertyRequest): Promise&lt;number&gt;;
Sets the property for the initialization algorithm. This API uses a promise to return the result. Sets the property for the initialization algorithm. This API uses a promise to return the result.
...@@ -2108,23 +2130,26 @@ This is a system API and cannot be called by third-party applications. ...@@ -2108,23 +2130,26 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------ | ---- | ---------------------------------------- | | -------- | ------------------------------------------------------ | ---- | ---------------------------------------- |
| request | [SetPropertyRequest](#SetPropertyRequest<sup>8+</sup>) | Yes | Request information, including the authentication credential type and the key value to set.| | request | [SetPropertyRequest](#setpropertyrequest8) | Yes | Request information, including the authentication credential type and the key value to set.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| :-------------------- | :-------------------------------------------------------------------------------------------- | | :-------------------- | :-------------------------------------------------------------------------------------------- |
| Promise&lt;number&gt; | Promise used to return the [result code](#ResultCode<sup>8+</sup>).| | Promise&lt;number&gt; | Promise used to return the [result](#resultcode8).|
**Example** **Example**
```js ```js
let userAuth = new osAccount.UserAuth(); let userAuth = new account_osAccount.UserAuth();
let authType = osAccount.AuthType.PIN; let request = {
let key = osAccount.SetPropertyType.INIT_ALGORITHM; authType: account_osAccount.AuthType.PIN,
let setInfo = new Uint8Array(); key: account_osAccount.SetPropertyType.INIT_ALGORITHM,
let setPropertyRequest = {authType, key, setInfo}; setInfo: new Uint8Array([0])
userAuth.setProperty(setPropertyRequest).then((setProp) => { };
console.log("====>test for examples setProperty AsyncCallback = " + JSON.stringify(setProp)); userAuth.setProperty(request).then((result) => {
console.log("setProperty result = " + JSON.stringify(result));
}).catch((err) => {
console.log("setProperty error = " + JSON.stringify(err));
}); });
``` ```
...@@ -2145,9 +2170,9 @@ This is a system API and cannot be called by third-party applications. ...@@ -2145,9 +2170,9 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------------- | ---------------------------------------------------- | --- | ------------------------------------ | | --------------- | ---------------------------------------------------- | --- | ------------------------------------ |
| challenge | Uint8Array | Yes | Challenge value, which is a random number used to improve security.| | challenge | Uint8Array | Yes | Challenge value, which is a random number used to improve security.|
| authType | [AuthType](#AuthType<sup>8+</sup>) | Yes | Authentication credential type. | | authType | [AuthType](#authtype8) | Yes | Authentication credential type. |
| authTrustLevel | [AuthTrustLevel](#AuthTrustLevel<sup>8+</sup>) | Yes | Trust level of the authentication result. | | authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | Yes | Trust level of the authentication result. |
| callback | [IUserAuthCallback](#IUserAuthCallback<sup>8+</sup>) | Yes | Callback invoked to return the authentication result and obtained information. | | callback | [IUserAuthCallback](#iuserauthcallback8) | Yes | Callback invoked to return the authentication result and obtained information. |
**Return value** **Return value**
...@@ -2158,22 +2183,15 @@ This is a system API and cannot be called by third-party applications. ...@@ -2158,22 +2183,15 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
```js ```js
let userAuth = new osAccount.UserAuth(); let userAuth = new account_osAccount.UserAuth();
let authType = osAccount.AuthType.PIN; let challenge = new Uint8Array([0]);
let challenge = 1; let authType = account_osAccount.AuthType.PIN;
let authTrustLevel = osAccount.AuthTrustLevel.ATL1; let authTrustLevel = account_osAccount.AuthTrustLevel.ATL1;
let onresult = { userAuth.auth(challenge, authType, authTrustLevel, {
authresult: null, onResult: function(result,extraInfo){
authextr: null, console.log("auth result = " + result);
} console.log("auth extraInfo = " + JSON.stringify(extraInfo));
userAuth.auth(challenge, authType,authTrustLevel,{ }
onResult: function(result,extraInfo){
console.log("====>test for examples auth result = " + result);
onresult.authresult = result;
console.log("====>test for examples auth extraInfo = " + JSON.stringify(extraInfo));
onresult.authextr = extraInfo;
console.info('====>test for examples auth onResult = ' + JSON.stringify(onresult));
}
}); });
``` ```
...@@ -2195,9 +2213,9 @@ This is a system API and cannot be called by third-party applications. ...@@ -2195,9 +2213,9 @@ This is a system API and cannot be called by third-party applications.
| --------------- | ---------------------------------------------------- | --- | ------------------------------------ | | --------------- | ---------------------------------------------------- | --- | ------------------------------------ |
| userId | number | Yes | User ID. | | userId | number | Yes | User ID. |
| challenge | Uint8Array | Yes | Challenge value, which is a random number used to improve security. | | challenge | Uint8Array | Yes | Challenge value, which is a random number used to improve security. |
| authType | [AuthType](#AuthType<sup>8+</sup>) | Yes | Authentication credential type. | | authType | [AuthType](#authtype8) | Yes | Authentication credential type. |
| authTrustLevel | [AuthTrustLevel](#AuthTrustLevel<sup>8+</sup>) | Yes | Trust level of the authentication result. | | authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | Yes | Trust level of the authentication result. |
| callback | [IUserAuthCallback](#IUserAuthCallback<sup>8+</sup>) | Yes | Callback invoked to return the authentication result and obtained information. | | callback | [IUserAuthCallback](#iuserauthcallback8) | Yes | Callback invoked to return the authentication result and obtained information. |
**Return value** **Return value**
...@@ -2208,23 +2226,16 @@ This is a system API and cannot be called by third-party applications. ...@@ -2208,23 +2226,16 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
```js ```js
let userAuth = new osAccount.UserAuth(); let userAuth = new account_osAccount.UserAuth();
let authType = osAccount.AuthType.PIN;
let challenge = 1;
let authTrustLevel = osAccount.AuthTrustLevel.ATL1;
let userID = 100; let userID = 100;
let onresult = { let challenge = new Uint8Array([0]);
authresult: null, let authType = account_osAccount.AuthType.PIN;
authextr: null, let authTrustLevel = account_osAccount.AuthTrustLevel.ATL1;
}
userAuth.authUser(userID, challenge, authType, authTrustLevel, { userAuth.authUser(userID, challenge, authType, authTrustLevel, {
onResult: function(result,extraInfo){ onResult: function(result,extraInfo){
console.log("====>test for examples authUser result = " + result); console.log("authUser result = " + result);
onresult.authresult = result; console.log("authUser extraInfo = " + JSON.stringify(extraInfo));
console.log("====>test for examples authUser extraInfo = " + JSON.stringify(extraInfo)); }
onresult.authextr = extraInfo;
console.info('====>test for examples authUser onResult = ' + JSON.stringify(onresult));
}
}); });
``` ```
...@@ -2250,20 +2261,28 @@ This is a system API and cannot be called by third-party applications. ...@@ -2250,20 +2261,28 @@ This is a system API and cannot be called by third-party applications.
| Type | Description | | Type | Description |
| :----- | :-------------------------------------------------------- | | :----- | :-------------------------------------------------------- |
| number | [Result code](#ResultCode<sup>8+</sup>).| | number | [Result code](#resultcode8).|
**Example** **Example**
```js ```js
let userAuth = new osAccount.UserAuth(); let userAuth = new account_osAccount.UserAuth();
let contextID = null; let pinAuth = new account_osAccount.PINAuth();
let cancelAuthresult = null; let challenge = new Uint8Array([0]);
cancelAuthresult = userAuth.cancelAuth(contextID); let contextID = userAuth.auth(challenge, account_osAccount.AuthType.PIN, account_osAccount.AuthTrustLevel.ATL1, {
console.log("====>test for examples cancelAuthresult result = " + JSON.stringify(cancelAuthresult)); onResult: (result, extraInfo) => {
console.log("auth result = " + result);
console.log("auth extraInfo = " + JSON.stringify(extraInfo));
}
});
let result = userAuth.cancelAuth(contextID);
console.log("cancelAuth result = " + result);
``` ```
## PINAuth<sup>8+</sup> ## PINAuth<sup>8+</sup>
Provides methods for PIN authentication. Provides APIs for PIN authentication.
This is a system API and cannot be called by third-party applications.
### constructor<sup>8+</sup> ### constructor<sup>8+</sup>
...@@ -2271,12 +2290,13 @@ constructor() ...@@ -2271,12 +2290,13 @@ constructor()
A constructor used to create an instance for PIN authentication. A constructor used to create an instance for PIN authentication.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount **System capability**: SystemCapability.Account.OsAccount
**Example** **Example**
```js ```js
var pinAuth = new osAccount.PINAuth(); let pinAuth = new account_osAccount.PINAuth();
console.info('====>test for examples constructor success');
``` ```
### registerInputer ### registerInputer
...@@ -2295,7 +2315,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -2295,7 +2315,7 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------| ----------------------------------- | --- | ------------------ | | ----------| ----------------------------------- | --- | ------------------ |
| inputer | [IInputer](#IInputer<sup>8+</sup>) | Yes | Callback invoked to obtain the PIN.| | inputer | [IInputer](#iinputer8) | Yes | Callback invoked to obtain the PIN.|
**Return value** **Return value**
...@@ -2305,20 +2325,14 @@ This is a system API and cannot be called by third-party applications. ...@@ -2305,20 +2325,14 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
```js ```js
var pinAuth = new osAccount.PINAuth(); let pinAuth = new account_osAccount.PINAuth();
var GetAuthSubType = 0; let password = new Uint8Array([0, 0, 0, 0, 0]);
var AuthSubType = osAccount.AuthSubType.PIN_SIX; let result = pinAuth.registerInputer({
var Inputerdata = [0,1,3]; onGetData: (pinSubType, callback) => {
var registerresult = pinAuth.registerInputer({ callback.onSetData(pinSubType, password);
onGetData: (GetAuthSubType, IInputData) => {
if (GetAuthSubType == 0) {
IInputData.onSetData(AuthSubType, Inputerdata)
} else {
IInputData.onSetData(GetAuthSubType, Inputerdata);
}
} }
}) });
console.log("====>test for examples RegisterInputer result is: " + registerresult); console.log("registerInputer result = " + result);
``` ```
### unregisterInputer ### unregisterInputer
...@@ -2335,13 +2349,15 @@ This is a system API and cannot be called by third-party applications. ...@@ -2335,13 +2349,15 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
```js ```js
var pinAuth = new osAccount.PinAuth(); let pinAuth = new account_osAccount.PINAuth();
pinAuth.unregisterInputer(); pinAuth.unregisterInputer();
``` ```
## UserIdentityManager<sup>8+</sup> ## UserIdentityManager<sup>8+</sup>
Provides methods for user identity management. Provides APIs for user identity management.
This is a system API and cannot be called by third-party applications.
### constructor<sup>8+</sup> ### constructor<sup>8+</sup>
...@@ -2349,12 +2365,13 @@ constructor() ...@@ -2349,12 +2365,13 @@ constructor()
A constructor used to create an instance for user authentication. A constructor used to create an instance for user authentication.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount **System capability**: SystemCapability.Account.OsAccount
**Example** **Example**
```js ```js
var userIDM = new osAccount.UserIdentityManager(); let userIDM = new account_osAccount.UserIdentityManager();
console.info('====>test for examples constructor success');
``` ```
### openSession<sup>8+</sup> ### openSession<sup>8+</sup>
...@@ -2373,23 +2390,14 @@ This is a system API and cannot be called by third-party applications. ...@@ -2373,23 +2390,14 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------- | ---- | -------------------------------- | | -------- | -------------------------------- | ---- | -------------------------------- |
| callback | AsyncCallback&lt;Uint8Array&gt; | Yes | Callback invoked to return the result. If **0** is returned, the operation failed. If the operation is successful, the challenge value (a non-zero value) will be returned.| | callback | AsyncCallback&lt;Uint8Array&gt; | Yes | Callback invoked to return the challenge value. If **0** is returned, the operation failed.|
**Example** **Example**
```js ```js
var userIDM = new osAccount.UserIdentityManager(); let userIDM = new account_osAccount.UserIdentityManager();
var challenge; userIDM.openSession((err, challenge) => {
userIDM.openSession(function(err, data){ console.log("openSession error = " + JSON.stringify(err));
try{ console.log("openSession challenge = " + JSON.stringify(challenge));
console.log("====>test for examples before get challenge");
console.log("====>test for examples + " + data);
challenge = data;
console.log("====>test for examples end ");
console.log("====>test for examples after get challenge");
}
catch(e) {
console.info('====>test for examples openSession error = ' + JSON.stringify(e));
}
}); });
``` ```
...@@ -2409,27 +2417,16 @@ This is a system API and cannot be called by third-party applications. ...@@ -2409,27 +2417,16 @@ This is a system API and cannot be called by third-party applications.
| Type | Description | | Type | Description |
| :------------------------ | :------------------------------------------------------- | | :------------------------ | :------------------------------------------------------- |
| Promise&lt;Uint8Array&gt; | Promise used to return the result. If **0** is returned, the operation failed. If the operation is successful, the challenge value (a non-zero value) will be returned.| | Promise&lt;Uint8Array&gt; | Promise used to return the challenge value. If **0** is returned, the operation failed.|
**Example** **Example**
```js ```js
var userIDM = new osAccount.UserIdentityManager(); let userIDM = new account_osAccount.UserIdentityManager();
var challenge; userIDM.openSession().then((challenge) => {
userIDM.openSession().then((data) => { console.info("openSession challenge = " + JSON.stringify(challenge));
try{ }).catch((err) => {
console.log("====>test for examples before get challenge"); console.info("openSession error = " + JSON.stringify(err));
console.log("====>test for examples + " + data); });
challenge = data;
console.log("====>test for examples end ");
console.log("====>test for examples after get challenge");
}
catch(err) {
console.info('====>test for examples faceDemo openSession error1 = ' + JSON.stringify(err));
}
})
.catch((err) => {
console.info('====>test for examples faceDemo openSession error2 = ' + JSON.stringify(err));
})
``` ```
### addCredential<sup>8+</sup> ### addCredential<sup>8+</sup>
...@@ -2448,31 +2445,32 @@ This is a system API and cannot be called by third-party applications. ...@@ -2448,31 +2445,32 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------------- | ------------------------------------------------ | --- | -------------------------------- | | --------------- | ------------------------------------------------ | --- | -------------------------------- |
| credentialInfo | [CredentialInfo](#CredentialInfo<sup>8+</sup>) | Yes | Credential information to add. | | credentialInfo | [CredentialInfo](#credentialinfo8) | Yes | Credential information to add. |
| callback | [IIdmCallback](#IIdmCallback<sup>8+</sup>) | Yes | Callback invoked to return the result and obtained information. | | callback | [IIdmCallback](#iidmcallback8) | Yes | Callback invoked to return the result and obtained information. |
**Example** **Example**
```js ```js
var userIDM = new osAccount.UserIdentityManager(); let password = new Uint8Array([0, 0, 0, 0, 0, 0]);
let CredentialInfo = null; let pinAuth = new account_osAccount.PINAuth();
let onresult = { pinAuth.registerInputer({
addCredresult: null, onGetData: (pinSubType, callback) => {
credentialId: null, callback.onSetData(pinSubType, password);
} }
userIDM.addCredential(CredentialInfo, { });
onResult: function(result,extraInfo){ let credentialInfo = {
console.info('====>test for examples aaaaaaaaaaaaa'); credType: account_osAccount.AuthType.PIN,
console.info("====>test for examples addCredential result = " + result); credSubType: account_osAccount.AuthSubType.PIN_SIX,
console.info("====>test for examples addCredential extraInfo = " + JSON.stringify(extraInfo)); token: null
console.log(result) };
onresult.addCredresult= result; let userIDM = new account_osAccount.UserIdentityManager();
if(extraInfo != undefined) { userIDM.openSession((err, challenge) => {
onresult.credentialId = extraInfo.credentialId userIDM.addCredential(credentialInfo, {
} else { onResult: (result, extraInfo) => {
onresult.credentialId = null; console.log("updateCredential result = " + result);
} console.log("updateCredential extraInfo = " + extraInfo);
} }
}) });
});
``` ```
### updateCredential<sup>8+</sup> ### updateCredential<sup>8+</sup>
...@@ -2491,30 +2489,41 @@ This is a system API and cannot be called by third-party applications. ...@@ -2491,30 +2489,41 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------------- | ------------------------------------------------- | --- | -------------------------------- | | --------------- | ------------------------------------------------- | --- | -------------------------------- |
| credentialInfo | [CredentialInfo](#CredentialInfo<sup>8+</sup>) | Yes | New credential information. | | credentialInfo | [CredentialInfo](#credentialinfo8) | Yes | New credential information. |
| callback | [IIdmCallback](#IIdmCallback<sup>8+</sup>) | Yes | Callback invoked to return the result and obtained information. | | callback | [IIdmCallback](#iidmcallback8) | Yes | Callback invoked to return the result and obtained information. |
**Example** **Example**
```js ```js
var userIDM = new osAccount.UserIdentityManager(); let userIDM = new account_osAccount.UserIdentityManager();
let CredentialInfo = null; let userAuth = new account_osAccount.UserAuth();
let onresult = { let pinAuth = new account_osAccount.PINAuth();
addCredresult: null, let password = new Uint8Array([0, 0, 0, 0, 0, 0]);
credentialId: null, let credentialInfo = {
} credType: account_osAccount.AuthType.PIN,
userIDM.updateCredential(CredentialInfo, { credSubType: account_osAccount.AuthSubType.PIN_SIX,
onResult: function(result,extraInfo){ token: null
console.log("====>test for examples faceDemo updateCredential result = " + result) };
onresult.updateCredresult = result pinAuth.registerInputer({
console.log("====>test for examples faceDemo updateCredential credentialId = " + extraInfo.credentialId) onGetData: (pinSubType, callback) => {
if(extraInfo != undefined) { callback.onSetData(pinSubType, password);
onresult.CredentialId = extraInfo.credentialId }
} else { });
onresult.CredentialId = null; userIDM.openSession((err, challenge) => {
userAuth.auth(challenge, credentialInfo.credType, account_osAccount.AuthTrustLevel.ATL1, {
onResult: (result, extraInfo) => {
if (result != account_osAccount.ResultCode.SUCCESS) {
return;
}
credentialInfo.token = extraInfo.token;
userIDM.updateCredential(credentialInfo, {
onResult: (result, extraInfo) => {
console.log("updateCredential result = " + result);
console.log("updateCredential extraInfo = " + extraInfo);
} }
console.info('====>test for examples publicupdateCred updateCredential onResult = ' + JSON.stringify(onresult)); });
} }
}) });
});
``` ```
### closeSession<sup>8+</sup> ### closeSession<sup>8+</sup>
...@@ -2531,7 +2540,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -2531,7 +2540,7 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
```js ```js
var userIDM = new osAccount.UserIdentityManager(); let userIDM = new account_osAccount.UserIdentityManager();
userIDM.closeSession(); userIDM.closeSession();
``` ```
...@@ -2557,13 +2566,14 @@ This is a system API and cannot be called by third-party applications. ...@@ -2557,13 +2566,14 @@ This is a system API and cannot be called by third-party applications.
| Type | Description | | Type | Description |
| :----- | :-------------------------------------------------------- | | :----- | :-------------------------------------------------------- |
| number | [Result code](#ResultCode<sup>8+</sup>).| | number | [Result code](#resultcode8) indicating whether the operation is successful.|
**Example** **Example**
```js ```js
var userIDM = new osAccount.UserIdentityManager(); let userIDM = new account_osAccount.UserIdentityManager();
let challenge = 1; let challenge = new Uint8Array([0]);
let cancelresult = userIDM.cancel(challenge); let result = userIDM.cancel(challenge);
console.log("cancel result: " + result);
``` ```
### delUser<sup>8+</sup> ### delUser<sup>8+</sup>
...@@ -2583,28 +2593,18 @@ This is a system API and cannot be called by third-party applications. ...@@ -2583,28 +2593,18 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------ | --- | ------------------------- | | -------- | ------------------------------------------ | --- | ------------------------- |
| token | Uint8Array | Yes | Authentication token. | | token | Uint8Array | Yes | Authentication token. |
| callback | [IIdmCallback](#IIdmCallback<sup>8+</sup>) | Yes | Callback invoked to return the result.| | callback | [IIdmCallback](#iidmcallback8) | Yes | Callback invoked to return the result.|
**Example** **Example**
```js ```js
var userIDM = new osAccount.UserIdentityManager(); let userIDM = new account_osAccount.UserIdentityManager();
let onresult = { let token = new Uint8Array([0]);
delUserresult: null,
CredentialId: null,
}
let token = null;
userIDM.delUser(token, { userIDM.delUser(token, {
onResult: function(result,extraInfo){ onResult: (result, extraInfo) => {
console.log("====>test for examples delUser result = " + result) console.log("delUser result = " + result);
onresult.delUserresult = result console.log("delUser extraInfo = " + JSON.stringify(extraInfo));
if(extraInfo != undefined) { }
onresult.CredentialId = extraInfo.credentialId });
} else {
onresult.CredentialId = null;
}
console.info('====>test for examples publicdelUser delUser = ' + JSON.stringify(onresult));
}
})
``` ```
### delCred<sup>8+</sup> ### delCred<sup>8+</sup>
...@@ -2625,35 +2625,24 @@ This is a system API and cannot be called by third-party applications. ...@@ -2625,35 +2625,24 @@ This is a system API and cannot be called by third-party applications.
| --------------- | ----------------------------------------------- | --- | ---------------------------| | --------------- | ----------------------------------------------- | --- | ---------------------------|
| credentialId | Uint8Array | Yes | Credential ID. | | credentialId | Uint8Array | Yes | Credential ID. |
| token | Uint8Array | Yes | Authentication token. | | token | Uint8Array | Yes | Authentication token. |
| callback | [IIdmCallback](#IIdmCallback<sup>8+</sup>) | Yes | Callback invoked to return the result.| | callback | [IIdmCallback](#iidmcallback8) | Yes | Callback invoked to return the result.|
**Example** **Example**
```js ```js
var userIDM = new osAccount.UserIdentityManager(); let userIDM = new account_osAccount.UserIdentityManager();
let onresult = { let credentialId = new Uint8Array([0]);
delUserresult: null, let token = new Uint8Array([0]);
CredentialId: null, userIDM.delCred(credentialId, token, {
} onResult: (result, extraInfo) => {
let credentialId = 1; console.log("delCred result = " + result);
let token = null; console.log("delCred extraInfo = " + JSON.stringify(extraInfo));
userIDM.delCred(credentialId, token,{ }
onResult: function(result,extraInfo){ });
console.log("====>test for examples delCred result = " + result)
onresult.delCredresult = result
console.log("====>test for examples delCred extraInfo = " + extraInfo)
if(extraInfo != undefined) {
onresult.CredentialId = extraInfo.credentialId
} else {
onresult.CredentialId = null;
}
console.log("====>test for examples delCred onresult = " + JSON.stringify(onresult));
}
})
``` ```
### getAuthInfo<sup>8+</sup> ### getAuthInfo<sup>8+</sup>
getAuthInfo(callback: AsyncCallback&lt;Array&lt;EnrolledCredInfo&gt;&gt;, authType?: AuthType): void; getAuthInfo(callback: AsyncCallback&lt;Array&lt;EnrolledCredInfo&gt;&gt;): void;
Obtains authentication information. This API uses asynchronous callback to return the result. Obtains authentication information. This API uses asynchronous callback to return the result.
...@@ -2661,22 +2650,50 @@ This is a system API and cannot be called by third-party applications. ...@@ -2661,22 +2650,50 @@ This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount **System capability**: SystemCapability.Account.OsAccount
**Required permissions**: ohos.permission.MANAGE_USER_IDM **Required permissions**: ohos.permission.USE_USER_IDM
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------------------------------------- | ---- | -------------------------------------------------- |
| callback | AsyncCallback&lt;Array&lt;[EnrolledCredInfo](#enrolledcredinfo8)&gt;&gt; | Yes | Callback invoked to return information about all enrolled credentials of the specified type.|
**Example**
```js
let userIDM = new account_osAccount.UserIdentityManager();
userIDM.getAuthInfo((err, result) => {
console.log("getAuthInfo err = " + JSON.stringify(err));
console.log("getAuthInfo result = " + JSON.stringify(result));
});
```
### getAuthInfo<sup>8+</sup>
getAuthInfo(authType: AuthType, callback: AsyncCallback&lt;Array&lt;EnrolledCredInfo&gt;&gt;): void;
Obtains authentication information of the specified type. This API uses an asynchronous callback to return the result.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount
**Required permissions**: ohos.permission.USE_USER_IDM
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------------------------- | ---- | -------------------------------------------------- | | -------- | -------------------------------------------------- | ---- | -------------------------------------------------- |
| callback | AsyncCallback&lt;Array&lt;[EnrolledCredInfo](#EnrolledCredInfo<sup>8+</sup>)&gt;&gt; | Yes | Callback invoked to return information about all enrolled credentials of the specified type of the user.| | authType | [AuthType](#authtype8) | Yes | Authentication credential type. |
| authType | [AuthType](#AuthType<sup>8+</sup>) | No | Authentication credential type. | | callback | AsyncCallback&lt;Array&lt;[EnrolledCredInfo](#enrolledcredinfo8)&gt;&gt; | Yes | Callback invoked to return information about all the user's enrolled credentials of the specified type.|
**Example** **Example**
```js ```js
var userIDM = new osAccount.UserIdentityManager(); let userIDM = new account_osAccount.UserIdentityManager();
var authType = osAccount.AuthType.PIN; userIDM.getAuthInfo(account_osAccount.AuthType.PIN, (err, result) => {
userIDM.getAuthInfo(authType, function (authInfo) { console.log("getAuthInfo err = " + JSON.stringify(err));
console.log("====>test for examples getAuthInfo AsyncCallback = " + JSON.stringify(authInfo)) console.log("getAuthInfo result = " + JSON.stringify(result));
}) });
``` ```
### getAuthInfo<sup>8+</sup> ### getAuthInfo<sup>8+</sup>
...@@ -2689,37 +2706,42 @@ This is a system API and cannot be called by third-party applications. ...@@ -2689,37 +2706,42 @@ This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount **System capability**: SystemCapability.Account.OsAccount
**Required permissions**: ohos.permission.MANAGE_USER_IDM **Required permissions**: ohos.permission.USE_USER_IDM
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------------- | ---- | -------- | | -------- | ----------------------------------- | ---- | -------- |
| authType | [AuthType](#AuthType<sup>8+</sup>) | No | Authentication credential type.| | authType | [AuthType](#authtype8) | No | Authentication credential type.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| :------------------------------------------- | :------------------------------------------------------------------------ | | :------------------------------------------- | :------------------------------------------------------------------------ |
| Promise&lt;Array&lt;[EnrolledCredInfo](#EnrolledCredInfo<sup>8+</sup>)&gt;&gt; | Promise used to return information about all enrolled credentials of the specified type of the user.| | Promise&lt;Array&lt;[EnrolledCredInfo](#enrolledcredinfo8)&gt;&gt; | Promise used to return information about all the user's enrolled credentials of the specified type.|
**Example** **Example**
```js ```js
var userIDM = new osAccount.UserIdentityManager(); let userIDM = new account_osAccount.UserIdentityManager();
var authType = osAccount.AuthType.PIN; userIDM.getAuthInfo(account_osAccount.AuthType.PIN).then((result) => {
userIDM.getAuthInfo(authType).then((authInfo) => { console.log("getAuthInfo result = " + JSON.stringify(result))
console.log("====>test for examples getAuthInfo AsyncCallback = " + JSON.stringify(authInfo)) }).catch((err) => {
}) console.log("getAuthInfo error = " + JSON.stringify(err));
});
``` ```
## IInputData<sup>8+</sup> ## IInputData<sup>8+</sup>
Provides callbacks for PIN operations. Provides callbacks for PIN operations.
This is a system API and cannot be called by third-party applications.
### onSetData<sup>8+</sup> ### onSetData<sup>8+</sup>
onSetData: (pinSubType: AuthSubType, data: Uint8Array) => void; onSetData: (pinSubType: AuthSubType, data: Uint8Array) => void;
This is a system API and cannot be called by third-party applications.
Called to set data. Called to set data.
**System capability**: SystemCapability.Account.OsAccount **System capability**: SystemCapability.Account.OsAccount
...@@ -2728,85 +2750,78 @@ Called to set data. ...@@ -2728,85 +2750,78 @@ Called to set data.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ---------------------------------------- | ---- | ----------------------------------------------- | | ---------- | ---------------------------------------- | ---- | ----------------------------------------------- |
| pinSubType | [AuthSubType](#AuthSubType<sup>8+</sup>) | Yes | Credential subtype. | | pinSubType | [AuthSubType](#authsubtype8) | Yes | Credential subtype. |
| data | Uint8Array | Yes | Data (credential) to set. The data is used for authentication and operations for adding and modifying credentials.| | data | Uint8Array | Yes | Data (credential) to set. The data is used for authentication and operations for adding and modifying credentials.|
**Example** **Example**
```js ```js
console.log("====>test for examples onCreate start "); let password = new Uint8Array([0, 0, 0, 0, 0, 0]);
var pinAuth = new osAccount.PINAuth(); let passwordNumber = new Uint8Array([1, 2, 3, 4]);
var GetAuthSubType = 0; let inputer = {
var AuthSubType = osAccount.AuthSubType.PIN_SIX; onGetData: (pinSubType, callback) => {
console.log("====>test for examples GetAuthSubType " + GetAuthSubType); if (pinSubType == account_osAccount.AuthSubType.PIN_NUMBER) {
console.log("====>test for examples AuthSubType " + AuthSubType); callback.onSetData(pinSubType, passwordNumber);
var Inputerdata = [0,1,3]; } else {
var registerresult = pinAuth.registerInputer({ callback.onSetData(pinSubType, password);
onGetData: (GetAuthSubType, IInputData) => { }
console.log("====>test for examples by GetAuthSubType " +GetAuthSubType ); }
if (GetAuthSubType == 0) { };
console.log("====>test for examples GetAuthSubType == 0 ");
IInputData.onSetData(AuthSubType, Inputerdata)
} else {
console.log("====>test for examples GetAuthSubType == 1 ");
IInputData.onSetData(GetAuthSubType, Inputerdata);
}
}
})
console.log("====>test for examples RegisterInputer result is: " + registerresult);
``` ```
## IInputer<sup>8+</sup> ## IInputer<sup>8+</sup>
Provides callbacks for the PIN input box. Provides callbacks for the PIN input box.
This is a system API and cannot be called by third-party applications.
### onGetData<sup>8+</sup> ### onGetData<sup>8+</sup>
onGetData: (callback: IInputData) => void; onGetData: (pinSubType: AuthSubType, callback: IInputData) => void;
Called to obtain data. Called to obtain data.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount **System capability**: SystemCapability.Account.OsAccount
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | --------------------------------------- | ---- | --------------- | | ---------- | --------------------------------------- | ---- | --------------- |
| callback | [IInputData](#IInputData<sup>8+</sup>) | Yes | Called to input the PIN.| | callback | [IInputData](#iinputdata8) | Yes | Called to input the PIN.|
**Example** **Example**
```js ```js
console.log("====>test for examples onCreate start "); let password = new Uint8Array([0, 0, 0, 0, 0, 0]);
var pinAuth = new osAccount.PINAuth(); let passwordNumber = new Uint8Array([1, 2, 3, 4]);
var GetAuthSubType = 0; let inputer = {
var AuthSubType = osAccount.AuthSubType.PIN_SIX; onGetData: (pinSubType, callback) => {
console.log("====>test for examples GetAuthSubType " + GetAuthSubType); if (pinSubType == account_osAccount.AuthSubType.PIN_NUMBER) {
console.log("====>test for examples AuthSubType " + AuthSubType); callback.onSetData(pinSubType, passwordNumber);
var Inputerdata = [0,1,3]; } else {
var registerresult = pinAuth.registerInputer({ callback.onSetData(pinSubType, password);
onGetData: (GetAuthSubType, IInputData) => { }
console.log("====>test for examples by GetAuthSubType " +GetAuthSubType ); }
if (GetAuthSubType == 0) { };
console.log("====>test for examples GetAuthSubType == 0 "); let pinAuth = new account_osAccount.PINAuth();
IInputData.onSetData(AuthSubType, Inputerdata) let result = pinAuth.registerInputer(inputer);
} else { console.log("registerInputer result: " + result);
console.log("====>test for examples GetAuthSubType == 1 ");
IInputData.onSetData(GetAuthSubType, Inputerdata);
}
}
})
console.log("====>test for examples RegisterInputer result is: " + registerresult);
``` ```
## IUserAuthCallback<sup>8+</sup> ## IUserAuthCallback<sup>8+</sup>
Provides callbacks for user authentication. Provides callbacks for user authentication.
This is a system API and cannot be called by third-party applications.
### onResult<sup>8+</sup> ### onResult<sup>8+</sup>
onResult: (result: number, extraInfo: AuthResult) => void; onResult: (result: number, extraInfo: AuthResult) => void;
Called to return the authentication result code. Called to return the authentication result code.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount **System capability**: SystemCapability.Account.OsAccount
**Parameters** **Parameters**
...@@ -2814,27 +2829,16 @@ Called to return the authentication result code. ...@@ -2814,27 +2829,16 @@ Called to return the authentication result code.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | --------------------------------------- | ---- | ------------------- | | --------- | --------------------------------------- | ---- | ------------------- |
| result | number | Yes | Authentication result code.| | result | number | Yes | Authentication result code.|
| extraInfo | [AuthResult](#AuthResult<sup>8+</sup>) | Yes | Specific authentication result information. If the authentication is successful, the authentication token is returned in **extrainfo**. If the authentication fails, the remaining authentication time is returned. If the authentication executor is locked, the freezing time is returned.| | extraInfo | [AuthResult](#authresult8) | Yes | Specific authentication result information. If the authentication is successful, the authentication token is returned in **extrainfo**. If the authentication fails, the remaining authentication time is returned. If the authentication executor is locked, the freezing time is returned.|
**Example** **Example**
```js ```js
let userAuth = new osAccount.UserAuth(); let authCallback = {
let authType = osAccount.AuthType.PIN; onResult: (result, extraInfo) => {
let challenge = 1; console.log("auth result = " + result);
let authTrustLevel = osAccount.AuthTrustLevel.ATL1; console.log("auth extraInfo = " + JSON.stringify(extraInfo));
let onresult = { }
authresult: null, };
authextr: null,
}
userAuth.auth(challenge, authType,authTrustLevel,{
onResult: function(result,extraInfo){
console.log("====>test for examples auth result = " + result);
onresult.authresult = result;
console.log("====>test for examples auth extraInfo = " + JSON.stringify(extraInfo));
onresult.authextr = extraInfo;
console.info('====>test for examples auth onResult = ' + JSON.stringify(onresult));
}
});
``` ```
### onAcquireInfo?<sup>8+</sup> ### onAcquireInfo?<sup>8+</sup>
...@@ -2857,45 +2861,28 @@ This is a system API and cannot be called by third-party applications. ...@@ -2857,45 +2861,28 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
```js ```js
let userAuth = new osAccount.UserAuth(); let authCallback = {
let authType = osAccount.AuthType.PIN; onResult: (result, extraInfo) => {
let challenge = 1; console.log("auth result = " + result)
let authTrustLevel = osAccount.AuthTrustLevel.ATL1; console.log("auth extraInfo = " + JSON.stringify(extraInfo));
let onresult = { },
authresult: null, onAcquireInfo: (module, acquire, extraInfo) => {
authextr: null, console.log("auth module = " + module);
} console.log("auth acquire = " + acquire);
let onacquireinfo = { console.info('auth extraInfo = ' + JSON.stringify(extraInfo));
authmodule : null, }
authacquire : null, };
authextr : null
}
userAuth.auth(challenge, authType,authTrustLevel,{
onResult: function(result,extraInfo){
console.log("====>test for examples auth result = " + result)
onresult.authresult = result
console.log("====>test for examples auth extraInfo = " + JSON.stringify(extraInfo));
onresult.authextr = extraInfo;
console.info('====>test for examples auth onResult = ' + JSON.stringify(onresult));
},
onAcquireInfo:function (modulea,acquire,extr){
console.info('====>test for examples publicauth auth onAcquireInfo in');
onacquireinfo.authmodule = modulea;
onacquireinfo.authacquire = acquire;
onacquireinfo.authextr = extr;
console.log("====>test for examples auth module = " + JSON.stringify(modulea));
console.info('====>test for examples publicauth auth onAcquireInfo = ' + JSON.stringify(onacquireinfo));
}
});
``` ```
## IIdmCallback<sup>8+</sup> ## IIdmCallback<sup>8+</sup>
Provides callbacks for IDM. Provides callbacks for IDM.
This is a system API and cannot be called by third-party applications.
### onResult<sup>8+</sup> ### onResult<sup>8+</sup>
onResult: (result: number, extraInfo: AuthResult) => void; onResult: (result: number, extraInfo: RequestResult) => void;
Called to return the authentication result code. Called to return the authentication result code.
...@@ -2908,29 +2895,16 @@ This is a system API and cannot be called by third-party applications. ...@@ -2908,29 +2895,16 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | --------------------------------------- | ---- | ----------------------- | | --------- | --------------------------------------- | ---- | ----------------------- |
| result | number | Yes | Authentication result code. | | result | number | Yes | Authentication result code. |
| extraInfo | [AuthResult](#AuthResult<sup>8+</sup>) | Yes | Specific information to be transferred.| | extraInfo | [AuthResult](#authresult8) | Yes | Specific information to be transferred.|
**Example** **Example**
```js ```js
var userIDM = new osAccount.UserIdentityManager(); var idmCallback = {
let CredentialInfo = null; onResult: (result, extraInfo) => {
let onresult = { console.log("callback result = " + result)
addCredresult: null, console.info('callback extraInfo = ' + JSON.stringify(extraInfo));
credentialId: null, }
} };
userIDM.updateCredential(CredentialInfo, {
onResult: function(result,extraInfo){
console.log("====>test for examples updateCredential result = " + result)
onresult.updateCredresult = result
console.log("====>test for examples updateCredential credentialId = " + extraInfo.credentialId)
if(extraInfo != undefined) {
onresult.CredentialId = extraInfo.credentialId
} else {
onresult.CredentialId = null;
}
console.info('====>test for examples publicupdateCred updateCredential onResult = ' + JSON.stringify(onresult));
}
})
``` ```
### onAcquireInfo?<sup>8+</sup> ### onAcquireInfo?<sup>8+</sup>
...@@ -2953,73 +2927,58 @@ This is a system API and cannot be called by third-party applications. ...@@ -2953,73 +2927,58 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
```js ```js
var userIDM = new osAccount.UserIdentityManager(); let idmCallback = {
let CredentialInfo = null; onResult: (result, extraInfo) => {
let onresult = { console.log("callback result = " + result)
addCredresult: null, console.log("callback onResult = " + JSON.stringify(extraInfo));
credentialId: null, },
} onAcquireInfo: (module, acquire, extraInfo) => {
let onacquireinfo = { console.log("callback module = " + module);
updateCredmodule : null, console.log("callback acquire = " + acquire);
updateCredacquire : null, console.log('callback onacquireinfo = ' + JSON.stringify(extraInfo));
updateCredextr : null }
} };
userIDM.updateCredential(CredentialInfo, {
onResult: function(result,extraInfo){
console.log("====>test for examples updateCredential result = " + result)
onresult.updateCredresult = result
console.log("====>test for examples updateCredential credentialId = " + extraInfo.credentialId)
if(extraInfo != undefined) {
onresult.CredentialId = extraInfo.credentialId
} else {
onresult.CredentialId = null;
}
console.info('====>test for examples publicupdateCred updateCredential onResult = ' + JSON.stringify(onresult));
},
onAcquireInfo:function (modulea,acquire,extr){
console.info('====>test for examples publicupdateCred updateCredential onAcquireInfo in ');
onacquireinfo.updateCredmodule = modulea
onacquireinfo.updateCredacquire = acquire
onacquireinfo.updateCredextr = extr
console.info('====>test for examples updateCredential onacquireinfo = ' + JSON.stringify(onacquireinfo));
console.log("====>test for examples updateCredential module = " + modulea)
}
})
``` ```
## GetPropertyRequest<sup>8+</sup> ## GetPropertyRequest<sup>8+</sup>
Defines the request for obtaining property information. Defines the request for obtaining property information.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount **System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------------------------------------- | ----- | ----------------------- | | -------- | ------------------------------------------------------------- | ----- | ----------------------- |
| authType | [AuthType](#AuthType<sup>8+</sup>) | Yes | Authentication credential type. | | authType | [AuthType](#authtype8) | Yes | Authentication credential type. |
| keys | Array&lt;[GetPropertyType](#GetPropertyType<sup>8+</sup>)&gt; | Yes | An array of the types of the properties to obtain.| | keys | Array&lt;[GetPropertyType](#getpropertytype8)&gt; | Yes | An array of the types of the properties to obtain.|
## SetPropertyRequest<sup>8+</sup> ## SetPropertyRequest<sup>8+</sup>
Defines the request for setting property information. Defines the request for setting property information.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount **System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------------------------ | ----- | -------------------- | | -------- | ------------------------------------------------ | ----- | -------------------- |
| authType | [AuthType](#AuthType<sup>8+</sup>) | Yes | Authentication credential type. | | authType | [AuthType](#authtype8) | Yes | Authentication credential type. |
| keys | [SetPropertyType](#SetPropertyType<sup>8+</sup>) | Yes | Type of the property to be set.| | key | [SetPropertyType](#setpropertytype8) | Yes | Type of the property to set.|
| setInfo | Uint8Array | Yes | Information to set. | | setInfo | Uint8Array | Yes | Information to set. |
## ExecutorProperty<sup>8+</sup> ## ExecutorProperty<sup>8+</sup>
Defines the executor property. Defines the executor property.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount **System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------------ | ---------------------------------------- | ----- | ----------------- | | ------------ | ---------------------------------------- | ----- | ----------------- |
| result | number | Yes | Result. | | result | number | Yes | Result. |
| authSubType | [AuthSubType](#AuthSubType<sup>8+</sup>) | Yes | Authentication credential subtype.| | authSubType | [AuthSubType](#authsubtype8) | Yes | Authentication credential subtype.|
| remainTimes | number | No | Remaining time. | | remainTimes | number | No | Remaining time. |
| freezingTime | number | No | Freezing time. | | freezingTime | number | No | Freezing time. |
...@@ -3027,6 +2986,8 @@ Defines the executor property. ...@@ -3027,6 +2986,8 @@ Defines the executor property.
Defines the authentication result information. Defines the authentication result information.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount **System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
...@@ -3039,18 +3000,22 @@ Defines the authentication result information. ...@@ -3039,18 +3000,22 @@ Defines the authentication result information.
Defines the credential information. Defines the credential information.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount **System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------------ | ---------------------------------------- | ----- | ----------------- | | ------------ | ---------------------------------------- | ----- | ----------------- |
| credType | [AuthType](#AuthType<sup>8+</sup>) | Yes | Authentication credential type. | | credType | [AuthType](#authtype8) | Yes | Authentication credential type. |
| credSubType | [AuthSubType](#AuthSubType<sup>8+</sup>) | Yes | Credential subtype. | | credSubType | [AuthSubType](#authsubtype8) | Yes | Authentication credential subtype. |
| token | Uint8Array | Yes | Authentication token. | | token | Uint8Array | Yes | Authentication token. |
## RequestResult<sup>8+</sup> ## RequestResult<sup>8+</sup>
Defines the request result information. Defines the request result information.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount **System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
...@@ -3061,24 +3026,28 @@ Defines the request result information. ...@@ -3061,24 +3026,28 @@ Defines the request result information.
Defines enrolled credential information. Defines enrolled credential information.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount **System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------------ | ---------------------------------------- | ----- | ------------------- | | ------------ | ---------------------------------------- | ----- | ------------------- |
| credentialId | Uint8Array | Yes | Credential ID. | | credentialId | Uint8Array | Yes | Credential ID. |
| authType | [AuthType](#AuthType<sup>8+</sup>) | Yes | Authentication credential type. | | authType | [AuthType](#authtype8) | Yes | Authentication credential type. |
| authSubType | [AuthSubType](#AuthSubType<sup>8+</sup>) | Yes | Credential subtype.| | authSubType | [AuthSubType](#authsubtype8) | Yes | Credential subtype.|
| templateId | Uint8Array | Yes | Credential template ID. | | templateId | Uint8Array | Yes | Authentication credential template ID. |
## GetPropertyType<sup>8+</sup> ## GetPropertyType<sup>8+</sup>
Enumerates the types of the properties to obtain. Enumerates the types of the properties to obtain.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount **System capability**: SystemCapability.Account.OsAccount
| Name | Default Value| Description | | Name | Default Value| Description |
| ------------- | ------ | --------- | | ------------- | ------ | --------- |
| AUTH_SUB_TYPE | 1 | Authentication subtype.| | AUTH_SUB_TYPE | 1 | Authentication credential subtype.|
| REMAIN_TIMES | 2 | Remaining time. | | REMAIN_TIMES | 2 | Remaining time. |
| FREEZING_TIME | 3 | Freezing time. | | FREEZING_TIME | 3 | Freezing time. |
...@@ -3086,6 +3055,8 @@ Enumerates the types of the properties to obtain. ...@@ -3086,6 +3055,8 @@ Enumerates the types of the properties to obtain.
Enumerates the types of the properties to set. Enumerates the types of the properties to set.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount **System capability**: SystemCapability.Account.OsAccount
| Name | Default Value| Description | | Name | Default Value| Description |
...@@ -3094,7 +3065,9 @@ Enumerates the types of the properties to set. ...@@ -3094,7 +3065,9 @@ Enumerates the types of the properties to set.
## AuthType<sup>8+</sup> ## AuthType<sup>8+</sup>
Enumerates the credential types. Enumerates the authentication credential types.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount **System capability**: SystemCapability.Account.OsAccount
...@@ -3105,7 +3078,9 @@ Enumerates the credential types. ...@@ -3105,7 +3078,9 @@ Enumerates the credential types.
## AuthSubType<sup>8+</sup> ## AuthSubType<sup>8+</sup>
Enumerates the credential subtypes. Enumerates the authentication credential subtypes.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount **System capability**: SystemCapability.Account.OsAccount
...@@ -3121,6 +3096,8 @@ Enumerates the credential subtypes. ...@@ -3121,6 +3096,8 @@ Enumerates the credential subtypes.
Enumerates the trust levels of the authentication result. Enumerates the trust levels of the authentication result.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount **System capability**: SystemCapability.Account.OsAccount
| Name | Default Value| Description | | Name | Default Value| Description |
...@@ -3134,28 +3111,32 @@ Enumerates the trust levels of the authentication result. ...@@ -3134,28 +3111,32 @@ Enumerates the trust levels of the authentication result.
Enumerates the modules from which information is obtained. Enumerates the modules from which information is obtained.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount **System capability**: SystemCapability.Account.OsAccount
| Name | Default Value| Description | | Name | Default Value| Description |
| --------- | ------ | ------------------------ | | --------- | ------ | ------------------------ |
| FACE_AUTH | 1 | Information obtained from the face authentication module.| | FACE_AUTH | 1 | Face authentication module.|
## ResultCode<sup>8+</sup> ## ResultCode<sup>8+</sup>
Enumerates the authentication result codes. Enumerates the authentication result codes.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount **System capability**: SystemCapability.Account.OsAccount
| Name | Default Value| Description | | Name | Default Value| Description |
| ----------------------- | ----- | ---------------------------------------- | | ----------------------- | ----- | ---------------------------------------- |
| SUCCESS | 0 | The authentication is successful or the authentication function is supported. | | SUCCESS | 0 | The authentication is successful or the authentication feature is supported. |
| FAIL | 1 | The authentication executor failed to identify the user. | | FAIL | 1 | The authentication executor failed to identify the user. |
| GENERAL_ERROR | 2 | Other errors. | | GENERAL_ERROR | 2 | Other errors. |
| CANCELED | 3 | The authentication is canceled. | | CANCELED | 3 | The authentication is canceled. |
| TIMEOUT | 4 | The authentication timed out. | | TIMEOUT | 4 | The authentication timed out. |
| TYPE_NOT_SUPPORT | 5 | The authentication credential type is not supported. | | TYPE_NOT_SUPPORT | 5 | The authentication credential type is not supported. |
| TRUST_LEVEL_NOT_SUPPORT | 6 | The authentication trust level is not supported. | | TRUST_LEVEL_NOT_SUPPORT | 6 | The authentication trust level is not supported. |
| BUSY | 7 | The authentication task is not available. Try again after a few seconds.| | BUSY | 7 | The authentication executor is busy. Try again after a few seconds.|
| INVALID_PARAMETERS | 8 | Incorrect parameters are detected. | | INVALID_PARAMETERS | 8 | Incorrect parameters are detected. |
| LOCKED | 9 | The authentication executor is locked. | | LOCKED | 9 | The authentication executor is locked. |
| NOT_ENROLLED | 10 | The authentication executor is not enrolled. | | NOT_ENROLLED | 10 | The authentication executor is not enrolled. |
...@@ -3164,6 +3145,8 @@ Enumerates the authentication result codes. ...@@ -3164,6 +3145,8 @@ Enumerates the authentication result codes.
Enumerates the tip codes for facial authentication. Enumerates the tip codes for facial authentication.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount **System capability**: SystemCapability.Account.OsAccount
| Name | Default Value| Description | | Name | Default Value| Description |
...@@ -3184,6 +3167,8 @@ Enumerates the tip codes for facial authentication. ...@@ -3184,6 +3167,8 @@ Enumerates the tip codes for facial authentication.
Enumerates the tip codes for fingerprint authentication. Enumerates the tip codes for fingerprint authentication.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount **System capability**: SystemCapability.Account.OsAccount
| Name | Default Value| Description | | Name | Default Value| Description |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册