Skip to content

BarkClient

github-actions[bot] edited this page Dec 5, 2023 · 38 revisions

Class: BarkClient

A class to communicate with Bark server

Table of contents

Constructors

Methods

Constructors

constructor

new BarkClient(serverAddress?): BarkClient

Parameters

Name Type Default value
serverAddress string "https://api.day.app"

Returns

BarkClient

Defined in

src/lib/BarkClient.ts:20

Methods

checkIv

checkIv(iv): void

Check if iv is legal when using encrypted push

Parameters

Name Type Description
iv string iv

Returns

void

Throws

BarkEncryptionError when iv is illegal

Defined in

src/lib/BarkClient.ts:265


checkKey

checkKey(algorithm, key): void

Check if key is legal when using encrypted push

Parameters

Name Type Description
algorithm BarkEncryptedPushAlgorithm which algorithm to use
key string key

Returns

void

Throws

BarkEncryptionError when key is illegal

Defined in

src/lib/BarkClient.ts:225


cryptoJsModeAndKeySizeProducer

cryptoJsModeAndKeySizeProducer(algorithm): Object

Produces the CryptoJS mode and key size based on the provided algorithm.

Parameters

Name Type Description
algorithm BarkEncryptedPushAlgorithm The BarkEncryptedPushAlgorithm to extract mode and key size from.

Returns

Object

An object containing the mode (CBC or ECB) and keySize (128, 192, or 256).

Name Type
keySize number
mode BlockCipherMode

Throws

if the algorithm does not have a valid key size or CryptoJS mode.

Defined in

src/lib/BarkClient.ts:156


health

health(): Promise<void>

Check if the Bark server is healthy

Returns

Promise<void>

nothing if the Bark server is healthy

See

Healthz

Throws

BarkResponseError if the Bark server is unhealthy

Defined in

src/lib/BarkClient.ts:30


info

info(): Promise<BarkInfoResponse>

Get info of Bark server

Returns

Promise<BarkInfoResponse>

BarkInfoResponse info of the Bark server

See

Info

Throws

BarkResponseError if the Bark server does not respond normally

Defined in

src/lib/BarkClient.ts:44


miscellaneousFunctionErrorProducer

miscellaneousFunctionErrorProducer(e): BarkResponseError

An error producing function used by miscellaneous function

Parameters

Name Type Description
e unknown error

Returns

BarkResponseError

BarkResponseError

Defined in

src/lib/BarkClient.ts:198


ping

ping(): Promise<void>

Check if the Bark server is running

Returns

Promise<void>

nothing if the Bark server is running

See

Ping

Throws

BarkResponseError if the Bark server is not running

Defined in

src/lib/BarkClient.ts:74


push

push(message): Promise<void>

Push a message to Bark APP

Parameters

Name Type Description
message BarkMessage bark message

Returns

Promise<void>

nothing if message is sent successfully

See

API V2

Throws

BarkResponseError if message is sent unsuccessfully

Defined in

src/lib/BarkClient.ts:89


pushEncrypted

pushEncrypted(deviceKey, message, algorithm, key, iv): Promise<void>

Push a message to Bark APP with encryption

When using encrypted push, you do not need set device key in BarkMessage

Parameters

Name Type Description
deviceKey string device key
message BarkMessage bark message, whose device key is unneeded
algorithm BarkEncryptedPushAlgorithm which algorithm to use
key string key
iv string iv

Returns

Promise<void>

nothing if message is sent successfully

See

Encryption

Throws

BarkResponseError if message is sent unsuccessfully

Defined in

src/lib/BarkClient.ts:111


pushErrorProducer

pushErrorProducer(e): BarkResponseError

An error producing function used by push function

Parameters

Name Type Description
e unknown error

Returns

BarkResponseError

BarkResponseError

Defined in

src/lib/BarkClient.ts:279