Class: Client
client.Client
Client
is a class-based interface for managing a Lattice device.
Constructorsโ
constructorโ
โข new Client(params
)
Parametersโ
Name | Type | Description |
---|---|---|
params | Object | Parameters are passed as an object. |
params.baseUrl? | string | The base URL of the signing server. |
params.deviceId? | string | The ID of the connected Lattice |
params.name? | string | The name of the client. |
params.privKey? | string | Buffer | The private key of the client. |
params.retryCount? | number | Number of times to retry a request if it fails. |
params.skipRetryOnWrongWallet? | boolean | If true we will not retry if we get a wrong wallet error code |
params.stateData? | string | User can pass in previous state data to rehydrate connected session |
params.timeout? | number | The time to wait for a response before cancelling. |
Defined inโ
Propertiesโ
activeWalletsโ
โข activeWallets: ActiveWallets
Information about the current wallet. Should be null unless we know a wallet is present
Defined inโ
baseUrlโ
โข baseUrl: string
The base of the remote url to which the SDK sends requests.
Defined inโ
isPairedโ
โข isPaired: boolean
Is the Lattice paired with this Client.
Defined inโ
timeoutโ
โข timeout: number
The time to wait for a response before cancelling.
Defined inโ
Lattice Methodsโ
addKvRecordsโ
โธ addKvRecords(__namedParameters
): Promise
<Buffer
>
Takes in a set of key-value records and sends a request to add them to the Lattice.
Parametersโ
Name | Type |
---|---|
__namedParameters | AddKvRecordsRequestParams |
Returnsโ
Promise
<Buffer
>
Defined inโ
connectโ
โธ connect(deviceId
): Promise
<any
>
Attempt to contact a device based on its deviceId
. The response should include an ephemeral
public key, which is used to pair with the device in a later request.
Parametersโ
Name | Type |
---|---|
deviceId | string |
Returnsโ
Promise
<any
>
Defined inโ
fetchEncryptedDataโ
โธ fetchEncryptedData(params
): Promise
<Buffer
>
Fetch a record of encrypted data from the Lattice. Must specify a data type. Returns a Buffer containing data formatted according to the specified type.
Parametersโ
Name | Type |
---|---|
params | FetchEncDataRequest |
Returnsโ
Promise
<Buffer
>
Defined inโ
getAddressesโ
โธ getAddresses(__namedParameters
): Promise
<string
[] | Buffer
[]>
Takes a starting path and a number to get the addresses associated with the active wallet.
Parametersโ
Name | Type |
---|---|
__namedParameters | GetAddressesRequestParams |
Returnsโ
Promise
<string
[] | Buffer
[]>
Defined inโ
getKvRecordsโ
โธ getKvRecords(__namedParameters
): Promise
<GetKvRecordsData
>
Fetches a list of key-value records from the Lattice.
Parametersโ
Name | Type |
---|---|
__namedParameters | GetKvRecordsRequestParams |
Returnsโ
Promise
<GetKvRecordsData
>
Defined inโ
pairโ
โธ pair(pairingSecret
): Promise
<any
>
If a pairing secret is provided, pair
uses it to sign a hash of the public key, name, and
pairing secret. It then sends the name and signature to the device. If no pairing secret is
provided, pair
sends a zero-length name buffer to the device.
Parametersโ
Name | Type |
---|---|
pairingSecret | string |
Returnsโ
Promise
<any
>
Defined inโ
removeKvRecordsโ
โธ removeKvRecords(__namedParameters
): Promise
<Buffer
>
Takes in an array of ids and sends a request to remove them from the Lattice.
Parametersโ
Name | Type |
---|---|
__namedParameters | RemoveKvRecordsRequestParams |
Returnsโ
Promise
<Buffer
>
Defined inโ
signโ
โธ sign(__namedParameters
): Promise
<SignData
>
Builds and sends a request for signing to the Lattice.
Parametersโ
Name | Type |
---|---|
__namedParameters | SignRequestParams |
Returnsโ
Promise
<SignData
>
Defined inโ
Other Methodsโ
fetchActiveWalletโ
โธ fetchActiveWallet(): Promise
<ActiveWallets
>
Fetch the active wallet in the Lattice.
Returnsโ
Promise
<ActiveWallets
>
Defined inโ
getActiveWalletโ
โธ getActiveWallet(): Wallet
Get the active wallet
Returnsโ
Defined inโ
getAppNameโ
โธ getAppName(): string
Get the pairing name for this client instance
Returnsโ
string
Defined inโ
getDeviceIdโ
โธ getDeviceId(): string
Get the deviceId
for this client instance
Returnsโ
string
Defined inโ
hasActiveWalletโ
โธ hasActiveWallet(): boolean
Check if the user has an active wallet
Returnsโ
boolean
Defined inโ
mutateโ
โธ mutate(__namedParameters
): void
Handles the mutation of Client state in the primary functions.
Parametersโ
Name | Type |
---|---|
__namedParameters | Object |
__namedParameters.activeWallets? | ActiveWallets |
__namedParameters.deviceId? | string |
__namedParameters.ephemeralPub? | Buffer |
__namedParameters.fwVersion? | Buffer |
__namedParameters.isPaired? | boolean |
__namedParameters.url? | string |
Returnsโ
void