未验证 提交 706c53c1 编写于 作者: O openharmony_ci 提交者: Gitee

!9510 [翻译完成】#I5NS5E

Merge pull request !9510 from Annie_wang/PR8545
# 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.
......@@ -154,7 +154,7 @@ Implicitly adds an app account based on the specified account owner, authenticat
}
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.addAccountImplicitly("LiSi", "readAge", {}, {
appAccountManager.addAccountImplicitly("com.example.ohos.accountjsdemo", "getSocialData", {}, {
onResult: onResultCallback,
onRequestRedirected: onRequestRedirectedCallback
});
......@@ -321,7 +321,8 @@ Enables an app account to access an app with the given bundle name. This API use
**Example**
```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');
}).catch((err) => {
console.log("enableAppAccess err: " + JSON.stringify(err));
......@@ -334,7 +335,7 @@ checkAppAccountSyncEnable(name: string, callback: AsyncCallback<boolean>):
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
......@@ -361,7 +362,7 @@ checkAppAccountSyncEnable(name: string): Promise<boolean>
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
......@@ -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.
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC (available only to system applications)
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
**System capability**: SystemCapability.Account.AppAccount
......@@ -537,7 +538,7 @@ setAppAccountSyncEnable(name: string, isEnable: boolean): Promise<void>
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
......@@ -585,7 +586,8 @@ Sets data to be associated with an app account. This API uses an asynchronous ca
**Example**
```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));
});
```
......@@ -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(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
**Example**
```js
const appAccountManager = account.createAppAccountManager();
const appAccountManager = account_appAccount.createAppAccountManager();
const selfBundle = "com.example.actsgetallaaccounts";
appAccountManager.getAllAccounts(selfBundle, (err, data)=>{
console.debug("getAllAccounts err:" + JSON.stringify(err));
......@@ -929,7 +960,7 @@ Subscribes to the account change events of the specified account owners. This AP
**Example**
```js
const appAccountManager = account.createAppAccountManager();
const appAccountManager = account_appAccount.createAppAccountManager();
function changeOnCallback(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
**Example**
```js
const appAccountManager = account.createAppAccountManager();
const appAccountManager = account_appAccount.createAppAccountManager();
function changeOnCallback(data){
console.debug("receive change data:" + JSON.stringify(data));
appAccountManager.off('change', function(){
......@@ -1010,7 +1041,7 @@ Authenticates an app account to obtain an Open Authorization (OAuth) token. This
}
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.authenticate("LiSi", "com.example.ohos.accountjsdemo", "readAge", {}, {
appAccountManager.authenticate("LiSi", "com.example.ohos.accountjsdemo", "getSocialData", {}, {
onResult: onResultCallback,
onRequestRedirected: onRequestRedirectedCallback
});
......@@ -1037,7 +1068,7 @@ Obtains the OAuth token of an app account based on the specified authentication
```js
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 token: ' + data);
});
......@@ -1069,7 +1100,7 @@ Obtains the OAuth token of an app account based on the specified authentication
```js
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);
}).catch((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
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx", (err) => {
appAccountManager.setOAuthToken("LiSi", "getSocialData", "xxxx", (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
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx").then(() => {
appAccountManager.setOAuthToken("LiSi", "getSocialData", "xxxx").then(() => {
console.log('setOAuthToken successfully');
}).catch((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
```js
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));
});
```
......@@ -1189,7 +1220,7 @@ Deletes the specified OAuth token for an app account. This API uses a promise to
```js
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');
}).catch((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
```js
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));
});
```
......@@ -1250,7 +1281,7 @@ Sets the visibility of an OAuth token to an app. This API uses a promise to retu
```js
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');
}).catch((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
```js
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 isVisible: ' + data);
});
......@@ -1310,7 +1341,7 @@ Checks whether an OAuth token is visible to an app. This API uses a promise to r
```js
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);
}).catch((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
```js
const appAccountManager = account_appAccount.createAppAccountManager();
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) => {
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
```js
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 data: ' + JSON.stringify(data));
});
......@@ -1426,7 +1457,7 @@ Obtains a list of authorized OAuth tokens of an app account. This API uses a pro
```js
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));
}).catch((err) => {
console.log("getOAuthList err: " + JSON.stringify(err));
......@@ -1462,9 +1493,9 @@ Obtains the authenticator callback for an authentication session. This API uses
}
var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi",
[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"};
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
**Example**
```js
import featureAbility from '@ohos.ability.featureAbility';
const appAccountManager = account_appAccount.createAppAccountManager();
featureAbility.getWant().then((want) => {
var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID];
appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi",
[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"};
callback.OnResult(account_appAccount.ResultCode.SUCCESS, result);
callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
}).catch((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
| Name | Type | Mandatory | Description |
| ---------- | ---------------------------- | ----- | ---------------- |
| 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. |
**Example**
......@@ -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 | 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**
......@@ -1702,7 +1735,8 @@ Checks whether an app account has specific labels. This API uses an asynchronous
```js
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 err: " + JSON.stringify(err));
});
......@@ -1734,7 +1768,8 @@ Checks whether an app account has specific labels. This API uses a promise to re
```js
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));
}).catch((err) => {
console.log("checkAccountLabels err: " + JSON.stringify(err));
......@@ -1944,7 +1979,7 @@ Defines app account information.
| Name | Type | Mandatory | Description |
| ----- | ------ | ---- | ----------- |
| 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>
......@@ -1967,8 +2002,8 @@ Defines OAuth authenticator information.
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ---------- |
| owner | string | Yes | Owner of the authenticator. The value is the bundle name of the app.|
| iconId | string | Yes | ID of the authenticator icon. |
| labelId | string | Yes | ID of the authenticator label. |
| iconId | number | Yes | ID of the authenticator icon. |
| labelId | number | Yes | ID of the authenticator label. |
## SelectAccountsOptions<sup>9+</sup>
......@@ -2082,9 +2117,9 @@ Called to return the result of an authentication request.
appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi",
[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"};
callback.OnResult(account_appAccount.ResultCode.SUCCESS, result);
callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
}).catch((err) => {
console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
});
......@@ -2137,7 +2172,7 @@ Called to continue to process the request.
const appAccountManager = account_appAccount.createAppAccountManager();
var sessionId = "1234";
appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
callback.OnRequestContinued();
callback.onRequestContinued();
}).catch((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
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
......@@ -2264,7 +2299,7 @@ Obtains the remote object of an authenticator. This API cannot be overloaded.
callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
}
verifyCredential(name: string, options: VerifyCredentialOptions, callback: AuthenticatorCallback) {
verifyCredential(name, options, callback) {
callback.onRequestRedirected({
bundleName: "com.example.ohos.accountjsdemo",
abilityName: "com.example.ohos.accountjsdemo.VerifyAbility",
......@@ -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, {});
}
checkAccountLabels(name: string, labels: Array<string>, callback: AuthenticatorCallback) {
checkAccountLabels(name, labels, callback) {
var result = {[account_appAccount.Constants.KEY_BOOLEAN_RESULT]: false};
callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
}
......
......@@ -19,6 +19,8 @@ getDistributedAccountAbility(): DistributedAccountAbility
Obtains a **DistributedAccountAbility** instance.
**System capability**: SystemCapability.Account.OsAccount
- Return value
| Type| Description|
| -------- | -------- |
......
# 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>
> 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.
```js
const accountManager = account_osAccount.getAccountManager();
var createIocalId;
osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
createIocalId = osAccountInfo.localId;
});
accountManager.removeOsAccount(createIocalId, (err)=>{
console.log("removeOsAccount err:" + JSON.stringify(err));
accountManager.createOsAccount("testAccountName", account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo) => {
accountManager.removeOsAccount(osAccountInfo.localId, (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.
```js
const accountManager = account_osAccount.getAccountManager();
var createIocalId;
osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
createIocalId = osAccountInfo.localId;
});
createIocalId = osAccount.localId;
accountManager.removeOsAccount(createIocalId).then(() => {
console.log('removeOsAccount Success');
}).catch(() => {
console.log("removeOsAccount err: " + JSON.stringify(err));
accountManager.createOsAccount("testAccountName", account_osAccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
accountManager.removeOsAccount(osAccountInfo.localId).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.
```js
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 osAccountInfo:" + JSON.stringify(osAccountInfo));
});
......@@ -1132,7 +1127,7 @@ This is a system API and cannot be called by third-party applications.
```js
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));
}).catch((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.
```js
const accountManager = account_osAccount.getAccountManager();
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 osAccountInfo:" + JSON.stringify(osAccountInfo));
});
......@@ -1200,7 +1195,7 @@ This is a system API and cannot be called by third-party applications.
```js
const accountManager = account_osAccount.getAccountManager();
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));
}).catch((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.
"Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y"+
"q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo"+
"+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg=="
osAccountManager.setOsAccountProfilePhoto(localId, photo, (err)=>{
accountManager.setOsAccountProfilePhoto(localId, photo, (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.
**Example**
```js
const accountManager = account_osAccount.getAccountManager();
var testUid = 1000000;
osAccountManager.getBundleIdFromUid(testUid,(err,bundleId)=>{
accountManager.getBundleIdFromUid(testUid, (err, bundleId) => {
console.info("getBundleIdFromUid errInfo:" + JSON.stringify(err));
console.info("getBundleIdFromUid bundleId:" + JSON.stringify(bundleId));
});
......@@ -1796,10 +1792,13 @@ This is a system API and cannot be called by third-party applications.
**Example**
```js
const accountManager = account_osAccount.getAccountManager();
var testUid = 1000000;
var bundleIdInfo = await osAccountManager.getBundleIdFromUid(testUid).catch((err)=>{
console.info("getBundleIdFromUid errInfo:" + JSON.stringify(err));})
console.info("getBundleIdFromUid bundleId:" + JSON.stringify(bundleIdInfo));
accountManager.getBundleIdFromUid(testUid).then((result) => {
console.info("getBundleIdFromUid bundleId:" + JSON.stringify(result));
}).catch((err)=>{
console.info("getBundleIdFromUid errInfo:" + JSON.stringify(err));
});
```
### isMainOsAccount<sup>9+</sup>
......@@ -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.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
**System capability**: SystemCapability.Account.OsAccount
**Parameters**
......@@ -1821,7 +1822,8 @@ This is a system API and cannot be called by third-party applications.
**Example**
```js
osAccountManager.isMainOsAccount((err,result)=>{
const accountManager = account_osAccount.getAccountManager();
accountManager.isMainOsAccount((err,result)=>{
console.info("isMainOsAccount errInfo:" + JSON.stringify(err));
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
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
**Return value**
......@@ -1845,10 +1849,12 @@ This is a system API and cannot be called by third-party applications.
**Example**
```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 result:" + JSON.stringify(result));
```
### queryOsAccountConstraintSourceTypes<sup>9+</sup>
......@@ -1873,7 +1879,8 @@ This is a system API and cannot be called by third-party applications.
**Example**
```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 sourceTypeInfos:" + JSON.stringify(sourceTypeInfos));
});
......@@ -1907,27 +1914,33 @@ This is a system API and cannot be called by third-party applications.
**Example**
```js
var sourceTypeInfos = await osAccountManager.queryOsAccountConstraintSourceTypes(100, "constraint.wifi").catch((err)=>{
console.info("queryOsAccountConstraintSourceType errInfo:" + JSON.stringify(err));})
console.info("queryOsAccountConstraintSourceType sourceTypeInfos:" + JSON.stringify(sourceTypeInfos));
const accountManager = account_osAccount.getAccountManager();
accountManager.queryOsAccountConstraintSourceTypes(100, "constraint.wifi").then((result) => {
console.info("queryOsAccountConstraintSourceType sourceTypeInfos:" + JSON.stringify(result));
}).catch((err)=>{
console.info("queryOsAccountConstraintSourceType errInfo:" + JSON.stringify(err));
});
```
## UserAuth<sup>8+</sup>
Provides APIs for user authentication.
This is a system API and cannot be called by third-party applications.
### constructor<sup>8+</sup>
constructor()
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
**Example**
```js
let userAuth = new osAccount.UserAuth();
console.info('====>test for examples constructor success');
let userAuth = new account_osAccount.UserAuth();
```
......@@ -1949,17 +1962,16 @@ This is a system API and cannot be called by third-party applications.
**Example**
```js
let userAuth = new osAccount.UserAuth();
console.info('====>test for examples constructor success');
var version = userAuth.getVersion();
console.info('====>test for examples version is : ' + JSON.stringify(version));
let userAuth = new account_osAccount.UserAuth();
let version = userAuth.getVersion();
console.log("getVersion version = " + version);
```
### getAvailableStatus<sup>8+</sup>
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.
......@@ -1971,23 +1983,22 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description |
| --------------- | -----------------------------------------------| ---- | ------------------------- |
| authType | [AuthType](#AuthType<sup>8+</sup>) | Yes | Authentication credential type. |
| authTrustLevel | [AuthTrustLevel](#AuthTrustLevel<sup>8+</sup>) | Yes | Trust level of the authentication result.|
| authType | [AuthType](#authtype8) | Yes | Authentication credential type. |
| authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | Yes | Trust level of the authentication result.|
**Return value**
| Type | Description |
| :----- | :---------------------------------------- |
| number | Result code(#ResultCode<sup>8+</sup>).|
| number | [Result code](#resultcode8).|
**Example**
```js
let userAuth = new osAccount.UserAuth();
let authType = osAccount.AuthType.PIN;
let authTrustLevel = osAccount.AuthTrustLevel.ATL1;
console.info('====>test for examples constructor success');
let availableStatus = userAuth.getAvailableStatus(authType, authTrustLevel);
console.info('====>test for examples AvailabeStatus is : ' + JSON.stringify(availableStatus));
let userAuth = new account_osAccount.UserAuth();
let authType = account_osAccount.AuthType.PIN;
let authTrustLevel = account_osAccount.AuthTrustLevel.ATL1;
let status = userAuth.getAvailableStatus(authType, authTrustLevel);
console.log("getAvailableStatus status = " + status);
```
### getProperty<sup>8+</sup>
......@@ -2006,26 +2017,30 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------------------------------- | ---- | ---------------------------------- |
| request | [GetPropertyRequest](#GetPropertyRequest<sup>8+</sup>) | 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. |
| request | [GetPropertyRequest](#getpropertyrequest8) | Yes | Request information, including the authentication credential type and property list.|
| callback | AsyncCallback&lt;[ExecutorProperty](#executorproperty8)&gt; | Yes | Callback invoked to return the executor property obtained. |
**Example**
```js
let userAuth = new osAccount.UserAuth();
let authType = osAccount.AuthType.PIN;
let keys = new Array();
keys[0] = osAccount.GetPropertyType.AUTH_SUB_TYPE;
keys[1] = osAccount.GetPropertyType.REMAIN_TIMES;
keys[2] = osAccount.GetPropertyType.FREEZING_TIME;
let getPropertyRequest = {authType, keys};
userAuth.getProperty(getPropertyRequest,function (propReq) {
console.log("====>test for examples getallAuthInfo AsyncCallback = " + JSON.stringify(propReq));
})
let userAuth = new account_osAccount.UserAuth();
let keys = [
account_osAccount.GetPropertyType.AUTH_SUB_TYPE,
account_osAccount.GetPropertyType.REMAIN_TIMES,
account_osAccount.GetPropertyType.FREEZING_TIME
];
let request = {
authType: account_osAccount.AuthType.PIN,
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(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.
......@@ -2039,31 +2054,36 @@ This is a system API and cannot be called by third-party applications.
| 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**
| Type | Description |
| :---------------------------------------------------------------- | :-------------------------------------------------- |
| Promise&lt;[ExecutorProperty](#ExecutorProperty<sup>8+</sup>)&gt; | Promise used to return the executor property obtained.|
**Example**
```js
let userAuth = new osAccount.UserAuth();
let authType = osAccount.AuthType.PIN;
let keys = new Array();
keys[0] = osAccount.GetPropertyType.AUTH_SUB_TYPE;
keys[1] = osAccount.GetPropertyType.REMAIN_TIMES;
keys[2] = osAccount.GetPropertyType.FREEZING_TIME;
let getPropertyRequest = {authType, keys};
userAuth.getProperty(getPropertyRequest).then((propReq) => {
console.log("====>test for examples getallAuthInfo AsyncCallback = " + JSON.stringify(propReq));
| Promise&lt;[ExecutorProperty](#executorproperty8)&gt; | Promise used to return the executor property obtained.|
**Example**
```js
let userAuth = new account_osAccount.UserAuth();
let keys = [
account_osAccount.GetPropertyType.AUTH_SUB_TYPE,
account_osAccount.GetPropertyType.REMAIN_TIMES,
account_osAccount.GetPropertyType.FREEZING_TIME
];
let request = {
authType: account_osAccount.AuthType.PIN,
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(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.
......@@ -2077,24 +2097,26 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------------- | ---- | ---------------------------------------------------------------------- |
| request | [SetPropertyRequest](#SetPropertyRequest<sup>8+</sup>)| 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>).|
| 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](#resultcode8).|
**Example**
```js
let userAuth = new osAccount.UserAuth();
let authType = osAccount.AuthType.PIN;
let key = osAccount.SetPropertyType.INIT_ALGORITHM;
let setInfo = new Uint8Array();
let setPropertyRequest = {authType, key, setInfo};
userAuth.setProperty(setPropertyRequest,function (setProp) {
console.log("====>test for examples setProperty AsyncCallback = " + JSON.stringify(setProp));
let userAuth = new account_osAccount.UserAuth();
let request = {
authType: account_osAccount.AuthType.PIN,
key: account_osAccount.SetPropertyType.INIT_ALGORITHM,
setInfo: new Uint8Array([0])
};
userAuth.setProperty(request, (err, result) => {
console.log("setProperty error = " + JSON.stringify(err));
console.log("setProperty result = " + JSON.stringify(result));
});
```
### 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.
......@@ -2108,23 +2130,26 @@ This is a system API and cannot be called by third-party applications.
| 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**
| 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**
```js
let userAuth = new osAccount.UserAuth();
let authType = osAccount.AuthType.PIN;
let key = osAccount.SetPropertyType.INIT_ALGORITHM;
let setInfo = new Uint8Array();
let setPropertyRequest = {authType, key, setInfo};
userAuth.setProperty(setPropertyRequest).then((setProp) => {
console.log("====>test for examples setProperty AsyncCallback = " + JSON.stringify(setProp));
let userAuth = new account_osAccount.UserAuth();
let request = {
authType: account_osAccount.AuthType.PIN,
key: account_osAccount.SetPropertyType.INIT_ALGORITHM,
setInfo: new Uint8Array([0])
};
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.
| Name | Type | Mandatory| Description |
| --------------- | ---------------------------------------------------- | --- | ------------------------------------ |
| challenge | Uint8Array | Yes | Challenge value, which is a random number used to improve security.|
| authType | [AuthType](#AuthType<sup>8+</sup>) | Yes | Authentication credential type. |
| authTrustLevel | [AuthTrustLevel](#AuthTrustLevel<sup>8+</sup>) | Yes | Trust level of the authentication result. |
| callback | [IUserAuthCallback](#IUserAuthCallback<sup>8+</sup>) | Yes | Callback invoked to return the authentication result and obtained information. |
| authType | [AuthType](#authtype8) | Yes | Authentication credential type. |
| authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | Yes | Trust level of the authentication result. |
| callback | [IUserAuthCallback](#iuserauthcallback8) | Yes | Callback invoked to return the authentication result and obtained information. |
**Return value**
......@@ -2158,22 +2183,15 @@ This is a system API and cannot be called by third-party applications.
**Example**
```js
let userAuth = new osAccount.UserAuth();
let authType = osAccount.AuthType.PIN;
let challenge = 1;
let authTrustLevel = osAccount.AuthTrustLevel.ATL1;
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));
}
let userAuth = new account_osAccount.UserAuth();
let challenge = new Uint8Array([0]);
let authType = account_osAccount.AuthType.PIN;
let authTrustLevel = account_osAccount.AuthTrustLevel.ATL1;
userAuth.auth(challenge, authType, authTrustLevel, {
onResult: function(result,extraInfo){
console.log("auth result = " + result);
console.log("auth extraInfo = " + JSON.stringify(extraInfo));
}
});
```
......@@ -2195,9 +2213,9 @@ This is a system API and cannot be called by third-party applications.
| --------------- | ---------------------------------------------------- | --- | ------------------------------------ |
| userId | number | Yes | User ID. |
| challenge | Uint8Array | Yes | Challenge value, which is a random number used to improve security. |
| authType | [AuthType](#AuthType<sup>8+</sup>) | Yes | Authentication credential type. |
| authTrustLevel | [AuthTrustLevel](#AuthTrustLevel<sup>8+</sup>) | Yes | Trust level of the authentication result. |
| callback | [IUserAuthCallback](#IUserAuthCallback<sup>8+</sup>) | Yes | Callback invoked to return the authentication result and obtained information. |
| authType | [AuthType](#authtype8) | Yes | Authentication credential type. |
| authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | Yes | Trust level of the authentication result. |
| callback | [IUserAuthCallback](#iuserauthcallback8) | Yes | Callback invoked to return the authentication result and obtained information. |
**Return value**
......@@ -2208,23 +2226,16 @@ This is a system API and cannot be called by third-party applications.
**Example**
```js
let userAuth = new osAccount.UserAuth();
let authType = osAccount.AuthType.PIN;
let challenge = 1;
let authTrustLevel = osAccount.AuthTrustLevel.ATL1;
let userAuth = new account_osAccount.UserAuth();
let userID = 100;
let onresult = {
authresult: null,
authextr: null,
}
let challenge = new Uint8Array([0]);
let authType = account_osAccount.AuthType.PIN;
let authTrustLevel = account_osAccount.AuthTrustLevel.ATL1;
userAuth.authUser(userID, challenge, authType, authTrustLevel, {
onResult: function(result,extraInfo){
console.log("====>test for examples authUser result = " + result);
onresult.authresult = result;
console.log("====>test for examples authUser extraInfo = " + JSON.stringify(extraInfo));
onresult.authextr = extraInfo;
console.info('====>test for examples authUser onResult = ' + JSON.stringify(onresult));
}
onResult: function(result,extraInfo){
console.log("authUser result = " + result);
console.log("authUser extraInfo = " + JSON.stringify(extraInfo));
}
});
```
......@@ -2250,20 +2261,28 @@ This is a system API and cannot be called by third-party applications.
| Type | Description |
| :----- | :-------------------------------------------------------- |
| number | [Result code](#ResultCode<sup>8+</sup>).|
| number | [Result code](#resultcode8).|
**Example**
```js
let userAuth = new osAccount.UserAuth();
let contextID = null;
let cancelAuthresult = null;
cancelAuthresult = userAuth.cancelAuth(contextID);
console.log("====>test for examples cancelAuthresult result = " + JSON.stringify(cancelAuthresult));
let userAuth = new account_osAccount.UserAuth();
let pinAuth = new account_osAccount.PINAuth();
let challenge = new Uint8Array([0]);
let contextID = userAuth.auth(challenge, account_osAccount.AuthType.PIN, account_osAccount.AuthTrustLevel.ATL1, {
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>
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>
......@@ -2271,12 +2290,13 @@ constructor()
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
**Example**
```js
var pinAuth = new osAccount.PINAuth();
console.info('====>test for examples constructor success');
let pinAuth = new account_osAccount.PINAuth();
```
### registerInputer
......@@ -2295,7 +2315,7 @@ This is a system API and cannot be called by third-party applications.
| 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**
......@@ -2305,20 +2325,14 @@ This is a system API and cannot be called by third-party applications.
**Example**
```js
var pinAuth = new osAccount.PINAuth();
var GetAuthSubType = 0;
var AuthSubType = osAccount.AuthSubType.PIN_SIX;
var Inputerdata = [0,1,3];
var registerresult = pinAuth.registerInputer({
onGetData: (GetAuthSubType, IInputData) => {
if (GetAuthSubType == 0) {
IInputData.onSetData(AuthSubType, Inputerdata)
} else {
IInputData.onSetData(GetAuthSubType, Inputerdata);
}
let pinAuth = new account_osAccount.PINAuth();
let password = new Uint8Array([0, 0, 0, 0, 0]);
let result = pinAuth.registerInputer({
onGetData: (pinSubType, callback) => {
callback.onSetData(pinSubType, password);
}
})
console.log("====>test for examples RegisterInputer result is: " + registerresult);
});
console.log("registerInputer result = " + result);
```
### unregisterInputer
......@@ -2335,13 +2349,15 @@ This is a system API and cannot be called by third-party applications.
**Example**
```js
var pinAuth = new osAccount.PinAuth();
let pinAuth = new account_osAccount.PINAuth();
pinAuth.unregisterInputer();
```
## 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>
......@@ -2349,12 +2365,13 @@ constructor()
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
**Example**
```js
var userIDM = new osAccount.UserIdentityManager();
console.info('====>test for examples constructor success');
let userIDM = new account_osAccount.UserIdentityManager();
```
### openSession<sup>8+</sup>
......@@ -2373,23 +2390,14 @@ This is a system API and cannot be called by third-party applications.
| 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**
```js
var userIDM = new osAccount.UserIdentityManager();
var challenge;
userIDM.openSession(function(err, data){
try{
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));
}
let userIDM = new account_osAccount.UserIdentityManager();
userIDM.openSession((err, challenge) => {
console.log("openSession error = " + JSON.stringify(err));
console.log("openSession challenge = " + JSON.stringify(challenge));
});
```
......@@ -2409,27 +2417,16 @@ This is a system API and cannot be called by third-party applications.
| 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**
```js
var userIDM = new osAccount.UserIdentityManager();
var challenge;
userIDM.openSession().then((data) => {
try{
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(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));
})
let userIDM = new account_osAccount.UserIdentityManager();
userIDM.openSession().then((challenge) => {
console.info("openSession challenge = " + JSON.stringify(challenge));
}).catch((err) => {
console.info("openSession error = " + JSON.stringify(err));
});
```
### addCredential<sup>8+</sup>
......@@ -2448,31 +2445,32 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description |
| --------------- | ------------------------------------------------ | --- | -------------------------------- |
| credentialInfo | [CredentialInfo](#CredentialInfo<sup>8+</sup>) | Yes | Credential information to add. |
| callback | [IIdmCallback](#IIdmCallback<sup>8+</sup>) | Yes | Callback invoked to return the result and obtained information. |
| credentialInfo | [CredentialInfo](#credentialinfo8) | Yes | Credential information to add. |
| callback | [IIdmCallback](#iidmcallback8) | Yes | Callback invoked to return the result and obtained information. |
**Example**
```js
var userIDM = new osAccount.UserIdentityManager();
let CredentialInfo = null;
let onresult = {
addCredresult: null,
credentialId: null,
}
userIDM.addCredential(CredentialInfo, {
onResult: function(result,extraInfo){
console.info('====>test for examples aaaaaaaaaaaaa');
console.info("====>test for examples addCredential result = " + result);
console.info("====>test for examples addCredential extraInfo = " + JSON.stringify(extraInfo));
console.log(result)
onresult.addCredresult= result;
if(extraInfo != undefined) {
onresult.credentialId = extraInfo.credentialId
} else {
onresult.credentialId = null;
}
let password = new Uint8Array([0, 0, 0, 0, 0, 0]);
let pinAuth = new account_osAccount.PINAuth();
pinAuth.registerInputer({
onGetData: (pinSubType, callback) => {
callback.onSetData(pinSubType, password);
}
});
let credentialInfo = {
credType: account_osAccount.AuthType.PIN,
credSubType: account_osAccount.AuthSubType.PIN_SIX,
token: null
};
let userIDM = new account_osAccount.UserIdentityManager();
userIDM.openSession((err, challenge) => {
userIDM.addCredential(credentialInfo, {
onResult: (result, extraInfo) => {
console.log("updateCredential result = " + result);
console.log("updateCredential extraInfo = " + extraInfo);
}
})
});
});
```
### updateCredential<sup>8+</sup>
......@@ -2491,30 +2489,41 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description |
| --------------- | ------------------------------------------------- | --- | -------------------------------- |
| credentialInfo | [CredentialInfo](#CredentialInfo<sup>8+</sup>) | Yes | New credential information. |
| callback | [IIdmCallback](#IIdmCallback<sup>8+</sup>) | Yes | Callback invoked to return the result and obtained information. |
**Example**
```js
var userIDM = new osAccount.UserIdentityManager();
let CredentialInfo = null;
let onresult = {
addCredresult: null,
credentialId: null,
}
userIDM.updateCredential(CredentialInfo, {
onResult: function(result,extraInfo){
console.log("====>test for examples faceDemo updateCredential result = " + result)
onresult.updateCredresult = result
console.log("====>test for examples faceDemo updateCredential credentialId = " + extraInfo.credentialId)
if(extraInfo != undefined) {
onresult.CredentialId = extraInfo.credentialId
} else {
onresult.CredentialId = null;
| credentialInfo | [CredentialInfo](#credentialinfo8) | Yes | New credential information. |
| callback | [IIdmCallback](#iidmcallback8) | Yes | Callback invoked to return the result and obtained information. |
**Example**
```js
let userIDM = new account_osAccount.UserIdentityManager();
let userAuth = new account_osAccount.UserAuth();
let pinAuth = new account_osAccount.PINAuth();
let password = new Uint8Array([0, 0, 0, 0, 0, 0]);
let credentialInfo = {
credType: account_osAccount.AuthType.PIN,
credSubType: account_osAccount.AuthSubType.PIN_SIX,
token: null
};
pinAuth.registerInputer({
onGetData: (pinSubType, callback) => {
callback.onSetData(pinSubType, password);
}
});
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>
......@@ -2531,7 +2540,7 @@ This is a system API and cannot be called by third-party applications.
**Example**
```js
var userIDM = new osAccount.UserIdentityManager();
let userIDM = new account_osAccount.UserIdentityManager();
userIDM.closeSession();
```
......@@ -2557,13 +2566,14 @@ This is a system API and cannot be called by third-party applications.
| Type | Description |
| :----- | :-------------------------------------------------------- |
| number | [Result code](#ResultCode<sup>8+</sup>).|
| number | [Result code](#resultcode8) indicating whether the operation is successful.|
**Example**
```js
var userIDM = new osAccount.UserIdentityManager();
let challenge = 1;
let cancelresult = userIDM.cancel(challenge);
let userIDM = new account_osAccount.UserIdentityManager();
let challenge = new Uint8Array([0]);
let result = userIDM.cancel(challenge);
console.log("cancel result: " + result);
```
### delUser<sup>8+</sup>
......@@ -2583,28 +2593,18 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------ | --- | ------------------------- |
| 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**
```js
var userIDM = new osAccount.UserIdentityManager();
let onresult = {
delUserresult: null,
CredentialId: null,
}
let token = null;
let userIDM = new account_osAccount.UserIdentityManager();
let token = new Uint8Array([0]);
userIDM.delUser(token, {
onResult: function(result,extraInfo){
console.log("====>test for examples delUser result = " + result)
onresult.delUserresult = result
if(extraInfo != undefined) {
onresult.CredentialId = extraInfo.credentialId
} else {
onresult.CredentialId = null;
}
console.info('====>test for examples publicdelUser delUser = ' + JSON.stringify(onresult));
}
})
onResult: (result, extraInfo) => {
console.log("delUser result = " + result);
console.log("delUser extraInfo = " + JSON.stringify(extraInfo));
}
});
```
### delCred<sup>8+</sup>
......@@ -2625,35 +2625,24 @@ This is a system API and cannot be called by third-party applications.
| --------------- | ----------------------------------------------- | --- | ---------------------------|
| credentialId | Uint8Array | Yes | Credential ID. |
| 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**
```js
var userIDM = new osAccount.UserIdentityManager();
let onresult = {
delUserresult: null,
CredentialId: null,
}
let credentialId = 1;
let token = null;
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));
}
})
let userIDM = new account_osAccount.UserIdentityManager();
let credentialId = new Uint8Array([0]);
let token = new Uint8Array([0]);
userIDM.delCred(credentialId, token, {
onResult: (result, extraInfo) => {
console.log("delCred result = " + result);
console.log("delCred extraInfo = " + JSON.stringify(extraInfo));
}
});
```
### 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.
......@@ -2661,22 +2650,50 @@ This is a system API and cannot be called by third-party applications.
**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**
| 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](#AuthType<sup>8+</sup>) | No | Authentication credential type. |
| authType | [AuthType](#authtype8) | Yes | 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**
```js
var userIDM = new osAccount.UserIdentityManager();
var authType = osAccount.AuthType.PIN;
userIDM.getAuthInfo(authType, function (authInfo) {
console.log("====>test for examples getAuthInfo AsyncCallback = " + JSON.stringify(authInfo))
})
let userIDM = new account_osAccount.UserIdentityManager();
userIDM.getAuthInfo(account_osAccount.AuthType.PIN, (err, result) => {
console.log("getAuthInfo err = " + JSON.stringify(err));
console.log("getAuthInfo result = " + JSON.stringify(result));
});
```
### getAuthInfo<sup>8+</sup>
......@@ -2689,37 +2706,42 @@ This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount
**Required permissions**: ohos.permission.MANAGE_USER_IDM
**Required permissions**: ohos.permission.USE_USER_IDM
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------- | ---- | -------- |
| authType | [AuthType](#AuthType<sup>8+</sup>) | No | Authentication credential type.|
| authType | [AuthType](#authtype8) | No | Authentication credential type.|
**Return value**
| 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**
```js
var userIDM = new osAccount.UserIdentityManager();
var authType = osAccount.AuthType.PIN;
userIDM.getAuthInfo(authType).then((authInfo) => {
console.log("====>test for examples getAuthInfo AsyncCallback = " + JSON.stringify(authInfo))
})
let userIDM = new account_osAccount.UserIdentityManager();
userIDM.getAuthInfo(account_osAccount.AuthType.PIN).then((result) => {
console.log("getAuthInfo result = " + JSON.stringify(result))
}).catch((err) => {
console.log("getAuthInfo error = " + JSON.stringify(err));
});
```
## IInputData<sup>8+</sup>
Provides callbacks for PIN operations.
This is a system API and cannot be called by third-party applications.
### onSetData<sup>8+</sup>
onSetData: (pinSubType: AuthSubType, data: Uint8Array) => void;
This is a system API and cannot be called by third-party applications.
Called to set data.
**System capability**: SystemCapability.Account.OsAccount
......@@ -2728,85 +2750,78 @@ Called to set data.
| 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.|
**Example**
```js
console.log("====>test for examples onCreate start ");
var pinAuth = new osAccount.PINAuth();
var GetAuthSubType = 0;
var AuthSubType = osAccount.AuthSubType.PIN_SIX;
console.log("====>test for examples GetAuthSubType " + GetAuthSubType);
console.log("====>test for examples AuthSubType " + AuthSubType);
var Inputerdata = [0,1,3];
var registerresult = pinAuth.registerInputer({
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);
let password = new Uint8Array([0, 0, 0, 0, 0, 0]);
let passwordNumber = new Uint8Array([1, 2, 3, 4]);
let inputer = {
onGetData: (pinSubType, callback) => {
if (pinSubType == account_osAccount.AuthSubType.PIN_NUMBER) {
callback.onSetData(pinSubType, passwordNumber);
} else {
callback.onSetData(pinSubType, password);
}
}
};
```
## IInputer<sup>8+</sup>
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: (callback: IInputData) => void;
onGetData: (pinSubType: AuthSubType, callback: IInputData) => void;
Called to obtain data.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | --------------------------------------- | ---- | --------------- |
| callback | [IInputData](#IInputData<sup>8+</sup>) | Yes | Called to input the PIN.|
**Example**
```js
console.log("====>test for examples onCreate start ");
var pinAuth = new osAccount.PINAuth();
var GetAuthSubType = 0;
var AuthSubType = osAccount.AuthSubType.PIN_SIX;
console.log("====>test for examples GetAuthSubType " + GetAuthSubType);
console.log("====>test for examples AuthSubType " + AuthSubType);
var Inputerdata = [0,1,3];
var registerresult = pinAuth.registerInputer({
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);
| callback | [IInputData](#iinputdata8) | Yes | Called to input the PIN.|
**Example**
```js
let password = new Uint8Array([0, 0, 0, 0, 0, 0]);
let passwordNumber = new Uint8Array([1, 2, 3, 4]);
let inputer = {
onGetData: (pinSubType, callback) => {
if (pinSubType == account_osAccount.AuthSubType.PIN_NUMBER) {
callback.onSetData(pinSubType, passwordNumber);
} else {
callback.onSetData(pinSubType, password);
}
}
};
let pinAuth = new account_osAccount.PINAuth();
let result = pinAuth.registerInputer(inputer);
console.log("registerInputer result: " + result);
```
## IUserAuthCallback<sup>8+</sup>
Provides callbacks for user authentication.
This is a system API and cannot be called by third-party applications.
### onResult<sup>8+</sup>
onResult: (result: number, extraInfo: AuthResult) => void;
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
**Parameters**
......@@ -2814,27 +2829,16 @@ Called to return the authentication result code.
| Name | Type | Mandatory| Description |
| --------- | --------------------------------------- | ---- | ------------------- |
| 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**
```js
let userAuth = new osAccount.UserAuth();
let authType = osAccount.AuthType.PIN;
let challenge = 1;
let authTrustLevel = osAccount.AuthTrustLevel.ATL1;
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));
}
});
let authCallback = {
onResult: (result, extraInfo) => {
console.log("auth result = " + result);
console.log("auth extraInfo = " + JSON.stringify(extraInfo));
}
};
```
### onAcquireInfo?<sup>8+</sup>
......@@ -2857,45 +2861,28 @@ This is a system API and cannot be called by third-party applications.
**Example**
```js
let userAuth = new osAccount.UserAuth();
let authType = osAccount.AuthType.PIN;
let challenge = 1;
let authTrustLevel = osAccount.AuthTrustLevel.ATL1;
let onresult = {
authresult: null,
authextr: null,
}
let onacquireinfo = {
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));
}
});
let authCallback = {
onResult: (result, extraInfo) => {
console.log("auth result = " + result)
console.log("auth extraInfo = " + JSON.stringify(extraInfo));
},
onAcquireInfo: (module, acquire, extraInfo) => {
console.log("auth module = " + module);
console.log("auth acquire = " + acquire);
console.info('auth extraInfo = ' + JSON.stringify(extraInfo));
}
};
```
## IIdmCallback<sup>8+</sup>
Provides callbacks for IDM.
This is a system API and cannot be called by third-party applications.
### onResult<sup>8+</sup>
onResult: (result: number, extraInfo: AuthResult) => void;
onResult: (result: number, extraInfo: RequestResult) => void;
Called to return the authentication result code.
......@@ -2908,29 +2895,16 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description |
| --------- | --------------------------------------- | ---- | ----------------------- |
| 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**
```js
var userIDM = new osAccount.UserIdentityManager();
let CredentialInfo = null;
let onresult = {
addCredresult: null,
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));
}
})
var idmCallback = {
onResult: (result, extraInfo) => {
console.log("callback result = " + result)
console.info('callback extraInfo = ' + JSON.stringify(extraInfo));
}
};
```
### onAcquireInfo?<sup>8+</sup>
......@@ -2953,73 +2927,58 @@ This is a system API and cannot be called by third-party applications.
**Example**
```js
var userIDM = new osAccount.UserIdentityManager();
let CredentialInfo = null;
let onresult = {
addCredresult: null,
credentialId: null,
}
let onacquireinfo = {
updateCredmodule : null,
updateCredacquire : null,
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)
}
})
let idmCallback = {
onResult: (result, extraInfo) => {
console.log("callback result = " + result)
console.log("callback onResult = " + JSON.stringify(extraInfo));
},
onAcquireInfo: (module, acquire, extraInfo) => {
console.log("callback module = " + module);
console.log("callback acquire = " + acquire);
console.log('callback onacquireinfo = ' + JSON.stringify(extraInfo));
}
};
```
## GetPropertyRequest<sup>8+</sup>
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
| Name | Type | Mandatory | Description |
| -------- | ------------------------------------------------------------- | ----- | ----------------------- |
| authType | [AuthType](#AuthType<sup>8+</sup>) | Yes | Authentication credential type. |
| keys | Array&lt;[GetPropertyType](#GetPropertyType<sup>8+</sup>)&gt; | Yes | An array of the types of the properties to obtain.|
| authType | [AuthType](#authtype8) | Yes | Authentication credential type. |
| keys | Array&lt;[GetPropertyType](#getpropertytype8)&gt; | Yes | An array of the types of the properties to obtain.|
## SetPropertyRequest<sup>8+</sup>
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
| Name | Type | Mandatory | Description |
| -------- | ------------------------------------------------ | ----- | -------------------- |
| authType | [AuthType](#AuthType<sup>8+</sup>) | Yes | Authentication credential type. |
| keys | [SetPropertyType](#SetPropertyType<sup>8+</sup>) | Yes | Type of the property to be set.|
| authType | [AuthType](#authtype8) | Yes | Authentication credential type. |
| key | [SetPropertyType](#setpropertytype8) | Yes | Type of the property to set.|
| setInfo | Uint8Array | Yes | Information to set. |
## ExecutorProperty<sup>8+</sup>
Defines the executor property.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory | Description |
| ------------ | ---------------------------------------- | ----- | ----------------- |
| 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. |
| freezingTime | number | No | Freezing time. |
......@@ -3027,6 +2986,8 @@ Defines the executor property.
Defines the authentication result information.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory | Description |
......@@ -3039,18 +3000,22 @@ Defines the authentication result information.
Defines the credential information.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory | Description |
| ------------ | ---------------------------------------- | ----- | ----------------- |
| credType | [AuthType](#AuthType<sup>8+</sup>) | Yes | Authentication credential type. |
| credSubType | [AuthSubType](#AuthSubType<sup>8+</sup>) | Yes | Credential subtype. |
| credType | [AuthType](#authtype8) | Yes | Authentication credential type. |
| credSubType | [AuthSubType](#authsubtype8) | Yes | Authentication credential subtype. |
| token | Uint8Array | Yes | Authentication token. |
## RequestResult<sup>8+</sup>
Defines the request result information.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory | Description |
......@@ -3061,24 +3026,28 @@ Defines the request result information.
Defines enrolled credential information.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory | Description |
| ------------ | ---------------------------------------- | ----- | ------------------- |
| credentialId | Uint8Array | Yes | Credential ID. |
| authType | [AuthType](#AuthType<sup>8+</sup>) | Yes | Authentication credential type. |
| authSubType | [AuthSubType](#AuthSubType<sup>8+</sup>) | Yes | Credential subtype.|
| templateId | Uint8Array | Yes | Credential template ID. |
| authType | [AuthType](#authtype8) | Yes | Authentication credential type. |
| authSubType | [AuthSubType](#authsubtype8) | Yes | Credential subtype.|
| templateId | Uint8Array | Yes | Authentication credential template ID. |
## GetPropertyType<sup>8+</sup>
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
| Name | Default Value| Description |
| ------------- | ------ | --------- |
| AUTH_SUB_TYPE | 1 | Authentication subtype.|
| AUTH_SUB_TYPE | 1 | Authentication credential subtype.|
| REMAIN_TIMES | 2 | Remaining time. |
| FREEZING_TIME | 3 | Freezing time. |
......@@ -3086,6 +3055,8 @@ Enumerates the types of the properties to obtain.
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
| Name | Default Value| Description |
......@@ -3094,7 +3065,9 @@ Enumerates the types of the properties to set.
## 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
......@@ -3105,7 +3078,9 @@ Enumerates the credential types.
## 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
......@@ -3121,6 +3096,8 @@ Enumerates the credential subtypes.
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
| Name | Default Value| Description |
......@@ -3134,28 +3111,32 @@ Enumerates the trust levels of the authentication result.
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
| Name | Default Value| Description |
| --------- | ------ | ------------------------ |
| FACE_AUTH | 1 | Information obtained from the face authentication module.|
| FACE_AUTH | 1 | Face authentication module.|
## ResultCode<sup>8+</sup>
Enumerates the authentication result codes.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Account.OsAccount
| 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. |
| GENERAL_ERROR | 2 | Other errors. |
| CANCELED | 3 | The authentication is canceled. |
| TIMEOUT | 4 | The authentication timed out. |
| TYPE_NOT_SUPPORT | 5 | The authentication credential type 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. |
| LOCKED | 9 | The authentication executor is locked. |
| NOT_ENROLLED | 10 | The authentication executor is not enrolled. |
......@@ -3164,6 +3145,8 @@ Enumerates the authentication result codes.
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
| Name | Default Value| Description |
......@@ -3184,6 +3167,8 @@ Enumerates the tip codes for facial 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
| Name | Default Value| Description |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册