@cubexch/client
Advanced tools
Comparing version 1.1.13 to 1.1.14
@@ -162,5 +162,19 @@ export declare const protobufPackage = "trade"; | ||
* `cube.xyz` and the current unix epoch in seconds interpreted at a | ||
* little-endian 64-bit number. For example: | ||
* little-endian 64-bit number. | ||
* | ||
* Implementation notes: | ||
* - The signature is base-64 encoded with the 'standard' alphabet and | ||
* padding. | ||
* | ||
* ``` | ||
* ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ | ||
* ``` | ||
* - The timestamp should be encoded as 8-byte little-endian (array of bytes) | ||
* - The secret key should be decoded from a hex string into a 32-byte array of | ||
* bytes | ||
* | ||
* #### Rust | ||
* | ||
* ```rust compile_fail | ||
* use base64::Engine; | ||
* use hmac::{Hmac, Mac, NewMac}; | ||
@@ -171,6 +185,3 @@ * use std::time::SystemTime; | ||
* | ||
* let timestamp = SystemTime::now() | ||
* .duration_since(SystemTime::UNIX_EPOCH) | ||
* .expect("clock went backwords") | ||
* .as_secs(); | ||
* let timestamp: u64 = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_secs(); | ||
* | ||
@@ -182,4 +193,19 @@ * let mut mac = Hmac::<sha2::Sha256>::new_from_slice( | ||
* mac.update(×tamp.to_le_bytes()); | ||
* let signature = <[u8; 32]>::from(mac.finalize().into_bytes()); | ||
* let signature_bytes = <[u8; 32]>::from(mac.finalize().into_bytes()); | ||
* let signature = base64::general_purpose::STANDARD.encode(signature_bytes); | ||
* ``` | ||
* | ||
* #### Typescript | ||
* ``` | ||
* import { createHmac } from 'crypto'; | ||
* const secretKey = "cafecafecafecafecafecafecafecafecafecafecafecafecafecafecafecafe"; | ||
* const timestampSecs = Math.floor(Date.now() / 1000); | ||
* const timestampBytes = Buffer.alloc(8); | ||
* timestampBytes.writeBigInt64LE(BigInt(timestampSecs)); | ||
* | ||
* const signature = createHmac('sha256', Buffer.from(secretKey, 'hex')) | ||
* .update(`cube.xyz`) | ||
* .update(timestampBytes) | ||
* .digest('base64'); | ||
* ``` | ||
*/ | ||
@@ -189,3 +215,3 @@ export interface Credentials { | ||
accessKeyId: string; | ||
/** HMAC signature */ | ||
/** HMAC signature, base-64 encoded */ | ||
signature: string; | ||
@@ -652,2 +678,3 @@ /** Timestamp in seconds */ | ||
latestTransactTime: bigint; | ||
readOnly: boolean; | ||
} | ||
@@ -654,0 +681,0 @@ /** A resting order. Sent on bootstrap in `RestingOrders`. */ |
{ | ||
"name": "@cubexch/client", | ||
"version": "1.1.13", | ||
"version": "1.1.14", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "build": "tsc" |
Sorry, the diff of this file is too big to display
379366
9358