目录

SharedCredential

Overview

A credential which can be shared between different apps.

Constructor

Constructor

Description

SharedCredential(jsonObject)

Constructs a SharedCredential object from a JSON object. The attribute name of the JSON object is the same as that of SharedCredential.

Attribute

Attribute

Type

Description

owner

Subclass of AppIdentity.

Credential owner. This attribute is read-only.

type

int

Credential type. This attribute is read-only. The options are as follows:

  • SharedCredential.PASSWORD 0
  • SharedCredential.TOKEN 1
  • SharedCredential.FEDERATION 2

username

String

User name, which can contain a maximum of 128 characters. This attribute is read-only.

content

ArrayBuffer

Password, token, and federation information, which can contain a maximum of 16,384 characters. The information can be obtained by calling the getContent() method.

displayName

String

Display name, which can contain a maximum of 128 characters.

avatarUrl

String

URL of a user's avatar, which can contain a maximum of 16,384 characters.

tag

String

Tag of a credential (defined by you), which can contain a maximum of 1024 characters.

syncAble

Bool

Indicates whether a credential can be synchronized between devices. During synchronization, sensitive information in the credential is encrypted using password technologies. Huawei will not obtain the credential content. This method is reserved. In this version, this parameter can be set but does not take effect. In versions released later, the parameter setting will take effect to support credential synchronization between devices.

userAuth

Bool

Indicates whether user authentication is enabled to verify the user's lock screen password or fingerprint when they try to obtain the credential content. This attribute is read-only.

sharedWith

AppIdentity[]

App or website with which the credentials are shared. If credentials are not shared, you do not need to set this parameter.

timeCreated

long

Time when a credential is created, which is a UNIX time. This attribute is read-only.

timeUpdated

long

Time when a credential is updated the last time, which is a UNIX time. This attribute is read-only.

timeLastUsed

long

Time when a credential is used the last time, which is a UNIX time. This attribute is read-only.

Constant

Constant

Description

PASSWORD

Password credential. The value is 0.

TOKEN

Token credential. The value is 1.

FEDERATION

Federated authentication credential. The value is 2.

Method

Method

Description

Parameter Type

Return Value

getContent()

Obtains the credential content.

-

Promise of ArrayBuffer type.

getContent()

Obtains the credential content.

[h2]Syntax

SharedCredential.getContent().then(function(contentBuffer) { ... } )

[h2]Parameter

None

[h2]Returns

Promise which is parsed as ArrayBuffer.

[h2]Example

navigator.sharedCredentials.find([]).then((credentials)=>{
for (var credential of credentials) {
credential.getContent().then((content)=>{
// handle content buffer
//ConvertToString(content)
})
}
})