diff --git a/zh-cn/application-dev/reference/apis/js-apis-osAccount.md b/zh-cn/application-dev/reference/apis/js-apis-osAccount.md index 4e0465e809a0ce71c95130aacc88d58bc3707260..ffedac9eb368d5deb17fc638f97132bfe73c213a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-osAccount.md +++ b/zh-cn/application-dev/reference/apis/js-apis-osAccount.md @@ -4441,7 +4441,9 @@ auth(domainAccountInfo: DomainAccountInfo, credential: Uint8Array, callback: IUs getAccountInfo: (domain, accountName, callback) => {}, getAuthStatusInfo: (domainAccountInfo, callback) => {}, bindAccount: (domainAccountInfo, localId, callback) => {}, - unbindAccount: (domainAccountInfo, callback) => {} + unbindAccount: (domainAccountInfo, callback) => {}, + isAccountTokenValid: (domainAccountInfo, callback) => {}, + getAccessToken: (options, callback) => {} } account_osAccount.DomainAccountManager.registerPlugin(plugin); let userAuth = new account_osAccount.UserAuth(); @@ -4494,7 +4496,9 @@ authWithPopup(domainAccountInfo: DomainAccountInfo, callback: IUserAuthCallback) getAccountInfo: (domain, accountName, callback) => {}, getAuthStatusInfo: (domainAccountInfo, callback) => {}, bindAccount: (domainAccountInfo, localId, callback) => {}, - unbindAccount: (domainAccountInfo, callback) => {} + unbindAccount: (domainAccountInfo, callback) => {}, + isAccountTokenValid: (domainAccountInfo, callback) => {}, + getAccessToken: (options, callback) => {} } account_osAccount.DomainAccountManager.registerPlugin(plugin) ``` @@ -4534,7 +4538,9 @@ authWithToken(domainAccountInfo: DomainAccountInfo, token: Uint8Array, callback: getAccountInfo: (domain, accountName, callback) => {}, getAuthStatusInfo: (domainAccountInfo, callback) => {}, bindAccount: (domainAccountInfo, localId, callback) => {}, - unbindAccount: (domainAccountInfo, callback) => {} + unbindAccount: (domainAccountInfo, callback) => {}, + isAccountTokenValid: (domainAccountInfo, callback) => {}, + getAccessToken: (options, callback) => {} } account_osAccount.DomainAccountManager.registerPlugin(plugin) ``` @@ -4576,7 +4582,9 @@ getAccountInfo(domain: string, accountName: string, callback: AsyncCallback<D }, getAuthStatusInfo: (domainAccountInfo, callback) => {}, bindAccount: (domainAccountInfo, localId, callback) => {}, - unbindAccount: (domainAccountInfo, callback) => {} + unbindAccount: (domainAccountInfo, callback) => {}, + isAccountTokenValid: (domainAccountInfo, callback) => {}, + getAccessToken: (options, callback) => {} } account_osAccount.DomainAccountManager.registerPlugin(plugin) ``` @@ -4614,7 +4622,9 @@ getAuthStatusInfo(domainAccountInfo: DomainAccountInfo, callback: AsyncCallback& }) }, bindAccount: (domainAccountInfo, localId, callback) => {}, - unbindAccount: (domainAccountInfo, callback) => {} + unbindAccount: (domainAccountInfo, callback) => {}, + isAccountTokenValid: (domainAccountInfo, callback) => {}, + getAccessToken: (options, callback) => {} } account_osAccount.DomainAccountManager.registerPlugin(plugin) ``` @@ -4649,7 +4659,9 @@ bindAccount(domainAccountInfo: DomainAccountInfo, localId: number, callback: Asy // notify binding result callback({code: 0}) }, - unbindAccount: (domainAccountInfo, callback) => {} + unbindAccount: (domainAccountInfo, callback) => {}, + isAccountTokenValid: (domainAccountInfo, callback) => {}, + getAccessToken: (options, callback) => {} } account_osAccount.DomainAccountManager.registerPlugin(plugin) ``` @@ -4684,6 +4696,84 @@ unbindAccount(domainAccountInfo: DomainAccountInfo, callback: AsyncCallback<v // mock unbinding operation // notify unbinding result callback({code: 0}) + }, + isAccountTokenValid: (domainAccountInfo, callback) => {}, + getAccessToken: (options, callback) => {} + } + account_osAccount.DomainAccountManager.registerPlugin(plugin) + ``` + +### isAccountTokenValid10+ + +isAccountTokenValid(domainAccountInfo: DomainAccountInfo, token: Uint8Array, callback: AsyncCallback<boolean>): void + +检查指定的域帐号令牌是否有效。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | --------------------------------------- | ---- | --------------- | +| domainAccountInfo | [DomainAccountInfo](#domainaccountinfo8) | 是 | 指示域帐号信息。| +| token | Uint8Array | 是 | 指示域帐号令牌。 | +| callback | AsyncCallback<boolean> | 是 | 指示检查结果回调。| + +**示例:** + ```js + let plugin = { + auth: (domainAccountInfo, credential, callback) => {}, + authWithPopup: (domainAccountInfo, callback) => {}, + authWithToken: (domainAccountInfo, callback) => {}, + getAccountInfo: (domain, accountName, callback) => {}, + getAuthStatusInfo: (domainAccountInfo, callback) => {}, + bindAccount: (domainAccountInfo, localId, callback) => {}, + unbindAccount: (domainAccountInfo, callback) => {}, + isAccountTokenValid: (domainAccountInfo, callback) => { + // mock checking operation + // notify checking result + callback({code: 0}, true); + }, + getAccessToken: (options, callback) => {} + } + account_osAccount.DomainAccountManager.registerPlugin(plugin) + ``` + +### getAccessToken10+ + +getAccessToken(options: GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>): void + +根据指定的选项获取域访问令牌。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | --------------------------------------- | ---- | --------------- | +| options | [GetDomainAccessTokenOptions](#getdomainaccesstokenoptions10) | 是 | 指示获取域访问令牌的选项。| +| callback | AsyncCallback<Uint8Array> | 是 | 指示结果回调。| + +**示例:** + ```js + let plugin = { + auth: (domainAccountInfo, credential, callback) => {}, + authWithPopup: (domainAccountInfo, callback) => {}, + authWithToken: (domainAccountInfo, callback) => {}, + getAccountInfo: (domain, accountName, callback) => {}, + getAuthStatusInfo: (domainAccountInfo, callback) => {}, + bindAccount: (domainAccountInfo, localId, callback) => {}, + unbindAccount: (domainAccountInfo, callback) => {}, + isAccountTokenValid: (domainAccountInfo, callback) => {}, + getAccessToken: (options, callback) => { + // mock getting operation + let token = new Uint8Array([0]); + // notify result + callback({code: 0}, token); } } account_osAccount.DomainAccountManager.registerPlugin(plugin) @@ -5003,6 +5093,107 @@ hasAccount(domainAccountInfo: DomainAccountInfo): Promise<boolean> } ``` +### updateAccountToken10+ + +updateAccountToken(domainAccountInfo: DomainAccountInfo, token: Uint8Array, callback: AsyncCallback<void>): void; + +更新指定域帐号的令牌,空令牌表示目标域帐号的令牌失效。使用callback异步回调。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.Account.OsAccount + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | --------------------------------------- | ---- | --------------- | +| domainAccountInfo | [DomainAccountInfo](#domainaccountinfo8) | 是 | 指示域帐号信息。| +| token | Uint8Array | 是 | 指示域帐号的令牌。| +| callback | AsyncCallback<void> | 是 | 回调函数。如果更新成功,err为null,否则为错误对象。| + +**错误码:** + +| 错误码ID | 错误信息 | +| -------- | --------------------------- | +| 12300001 | System service exception. | +| 12300002 | Invalid token. | +| 12300003 | Account not found. | + +**示例:** + ```js + let domainAccountInfo = { + domain: "CHINA", + accountName: "zhangsan", + accountId: "123456" + } + let token = new Uint8Array([0]) + try { + account_osAccount.DomainAccountManager.updateAccountToken(domainAccountInfo, token, (err) => { + if (err != null) { + console.log("updateAccountToken failed, error: " + JSON.stringify(err)); + } else { + console.log("updateAccountToken successfully"); + } + }) + } catch (err) { + console.log('updateAccountToken exception = ' + JSON.stringify(err)); + } + ``` + +### updateAccountToken10+ + +updateAccountToken(domainAccountInfo: DomainAccountInfo, token: Uint8Array): Promise<void> + +更新指定域帐号的令牌,空令牌表示目标域帐号的令牌失效。使用Promise异步回调。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.Account.OsAccount + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | --------------------------------------- | ---- | --------------- | +| domainAccountInfo | [DomainAccountInfo](#domainaccountinfo8) | 是 | 指示域帐号信息。| +| token | Uint8Array | 是 | 指示域帐号的令牌。| + +**返回值:** + +| 类型 | 说明 | +| :------------------------ | ----------------------- | +| Promise<void> | Promise对象,无返回结果的Promise对象。 | + +**错误码:** + +| 错误码ID | 错误信息 | +| -------- | --------------------------- | +| 12300001 | System service exception. | +| 12300002 | Invalid token. | +| 12300003 | Account not found. | + +**示例:** + ```js + let domainAccountInfo = { + domain: "CHINA", + accountName: "zhangsan", + accountId: "123456" + } + let token = new Uint8Array([0]) + try { + account_osAccount.DomainAccountManager.updateAccountToken(domainAccountInfo, token).then(() => { + console.log("updateAccountToken successfully"); + }).catch((err) => { + console.log("updateAccountToken failed, error: " + JSON.stringify(err)); + }); + } catch (err) { + console.log('updateAccountToken exception = ' + JSON.stringify(err)); + } + ``` + ## UserIdentityManager8+ 获取用户身份管理类。 @@ -6086,3 +6277,18 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void; | ----------- | ------ | ---- | ---------- | | remainTimes | number | 是 | 剩余次数 | | freezingTime | number | 是 | 冻结时间 | + +## GetDomainAccessTokenOptions10+ + +表示获取域访问令牌的选项。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount。 + +| 名称 | 类型 | 必填 | 说明 | +| ----------- | ------ | ---- | ---------- | +| domainAccountInfo | [DomainAccountInfo](#domainaccountinfo8) | 是 | 域帐号的信息 | +| domainAccountToken | Uint8Array | 是 | 域帐号的令牌 | +| businessParams | { [key: string]: object } | 是 | 业务参数,由业务方根据请求协议自定义 | +| callerUid | number | 是 | 调用方唯一标识符 |