Skip to main content

Class: Client

client.Client

Client is a class-based interface for managing a Lattice device.

Constructorsโ€‹

constructorโ€‹

โ€ข new Client(params)

Parametersโ€‹

NameTypeDescription
paramsObjectParameters are passed as an object.
params.baseUrl?stringThe base URL of the signing server.
params.deviceId?stringThe ID of the connected Lattice
params.name?stringThe name of the client.
params.privKey?string | BufferThe private key of the client.
params.retryCount?numberNumber of times to retry a request if it fails.
params.skipRetryOnWrongWallet?booleanIf true we will not retry if we get a wrong wallet error code
params.stateData?stringUser can pass in previous state data to rehydrate connected session
params.timeout?numberThe time to wait for a response before cancelling.

Defined inโ€‹

src/client.ts:59

Propertiesโ€‹

activeWalletsโ€‹

โ€ข activeWallets: ActiveWallets

Information about the current wallet. Should be null unless we know a wallet is present

Defined inโ€‹

src/client.ts:52


baseUrlโ€‹

โ€ข baseUrl: string

The base of the remote url to which the SDK sends requests.

Defined inโ€‹

src/client.ts:36


isPairedโ€‹

โ€ข isPaired: boolean

Is the Lattice paired with this Client.

Defined inโ€‹

src/client.ts:32


timeoutโ€‹

โ€ข timeout: number

The time to wait for a response before cancelling.

Defined inโ€‹

src/client.ts:34

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โ€‹

NameType
__namedParametersAddKvRecordsRequestParams

Returnsโ€‹

Promise<Buffer>

Defined inโ€‹

src/client.ts:207


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โ€‹

NameType
deviceIdstring

Returnsโ€‹

Promise<any>

Defined inโ€‹

src/client.ts:157


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โ€‹

NameType
paramsFetchEncDataRequest

Returnsโ€‹

Promise<Buffer>

Defined inโ€‹

src/client.ts:244


getAddressesโ€‹

โ–ธ getAddresses(__namedParameters): Promise<string[] | Buffer[]>

Takes a starting path and a number to get the addresses associated with the active wallet.

Parametersโ€‹

NameType
__namedParametersGetAddressesRequestParams

Returnsโ€‹

Promise<string[] | Buffer[]>

Defined inโ€‹

src/client.ts:175


getKvRecordsโ€‹

โ–ธ getKvRecords(__namedParameters): Promise<GetKvRecordsData>

Fetches a list of key-value records from the Lattice.

Parametersโ€‹

NameType
__namedParametersGetKvRecordsRequestParams

Returnsโ€‹

Promise<GetKvRecordsData>

Defined inโ€‹

src/client.ts:219


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โ€‹

NameType
pairingSecretstring

Returnsโ€‹

Promise<any>

Defined inโ€‹

src/client.ts:167


removeKvRecordsโ€‹

โ–ธ removeKvRecords(__namedParameters): Promise<Buffer>

Takes in an array of ids and sends a request to remove them from the Lattice.

Parametersโ€‹

NameType
__namedParametersRemoveKvRecordsRequestParams

Returnsโ€‹

Promise<Buffer>

Defined inโ€‹

src/client.ts:231


signโ€‹

โ–ธ sign(__namedParameters): Promise<SignData>

Builds and sends a request for signing to the Lattice.

Parametersโ€‹

NameType
__namedParametersSignRequestParams

Returnsโ€‹

Promise<SignData>

Defined inโ€‹

src/client.ts:187


Other Methodsโ€‹

fetchActiveWalletโ€‹

โ–ธ fetchActiveWallet(): Promise<ActiveWallets>

Fetch the active wallet in the Lattice.

Returnsโ€‹

Promise<ActiveWallets>

Defined inโ€‹

src/client.ts:199


getActiveWalletโ€‹

โ–ธ getActiveWallet(): Wallet

Get the active wallet

Returnsโ€‹

Wallet

Defined inโ€‹

src/client.ts:251


getAppNameโ€‹

โ–ธ getAppName(): string

Get the pairing name for this client instance

Returnsโ€‹

string

Defined inโ€‹

src/client.ts:117


getDeviceIdโ€‹

โ–ธ getDeviceId(): string

Get the deviceId for this client instance

Returnsโ€‹

string

Defined inโ€‹

src/client.ts:124


hasActiveWalletโ€‹

โ–ธ hasActiveWallet(): boolean

Check if the user has an active wallet

Returnsโ€‹

boolean

Defined inโ€‹

src/client.ts:268


mutateโ€‹

โ–ธ mutate(__namedParameters): void

Handles the mutation of Client state in the primary functions.

Parametersโ€‹

NameType
__namedParametersObject
__namedParameters.activeWallets?ActiveWallets
__namedParameters.deviceId?string
__namedParameters.ephemeralPub?Buffer
__namedParameters.fwVersion?Buffer
__namedParameters.isPaired?boolean
__namedParameters.url?string

Returnsโ€‹

void

Defined inโ€‹

src/client.ts:320