-
Notifications
You must be signed in to change notification settings - Fork 0
BarkClient
A class to communicate with Bark server
- checkIv
- checkKey
- cryptoJsModeAndKeySizeProducer
- health
- info
- miscellaneousFunctionErrorProducer
- ping
- push
- pushEncrypted
- pushErrorProducer
• new BarkClient(serverAddress?
): BarkClient
Name | Type | Default value |
---|---|---|
serverAddress |
string |
"https://api.day.app" |
▸ checkIv(iv
): void
Check if iv is legal when using encrypted push
Name | Type | Description |
---|---|---|
iv |
string |
iv |
void
Throws
BarkEncryptionError when iv is illegal
▸ checkKey(algorithm
, key
): void
Check if key is legal when using encrypted push
Name | Type | Description |
---|---|---|
algorithm |
BarkEncryptedPushAlgorithm |
which algorithm to use |
key |
string |
key |
void
Throws
BarkEncryptionError when key is illegal
▸ cryptoJsModeAndKeySizeProducer(algorithm
): Object
Produces the CryptoJS mode and key size based on the provided algorithm.
Name | Type | Description |
---|---|---|
algorithm |
BarkEncryptedPushAlgorithm |
The BarkEncryptedPushAlgorithm to extract mode and key size from. |
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.
▸ health(): Promise
<void
>
Check if the Bark server is healthy
Promise
<void
>
nothing if the Bark server is healthy
See
Throws
BarkResponseError if the Bark server is unhealthy
▸ info(): Promise
<BarkInfoResponse
>
Get info of Bark server
Promise
<BarkInfoResponse
>
BarkInfoResponse info of the Bark server
See
Throws
BarkResponseError if the Bark server does not respond normally
▸ miscellaneousFunctionErrorProducer(e
): BarkResponseError
An error producing function used by miscellaneous function
Name | Type | Description |
---|---|---|
e |
unknown |
error |
▸ ping(): Promise
<void
>
Check if the Bark server is running
Promise
<void
>
nothing if the Bark server is running
See
Throws
BarkResponseError if the Bark server is not running
▸ push(message
): Promise
<void
>
Push a message to Bark APP
Name | Type | Description |
---|---|---|
message |
BarkMessage |
bark message |
Promise
<void
>
nothing if message is sent successfully
See
Throws
BarkResponseError if message is sent unsuccessfully
▸ 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
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 |
Promise
<void
>
nothing if message is sent successfully
See
Throws
BarkResponseError if message is sent unsuccessfully
▸ pushErrorProducer(e
): BarkResponseError
An error producing function used by push function
Name | Type | Description |
---|---|---|
e |
unknown |
error |