@hiveio/dhive 1.2.3 → 1.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dhive.d.ts CHANGED
@@ -517,6 +517,7 @@ declare module 'dhive/chain/misc' {
517
517
 
518
518
  }
519
519
  declare module 'dhive/chain/serializer' {
520
+ /// <reference types="node" />
520
521
  /**
521
522
  * @file Hive protocol serialization.
522
523
  * @author Johan Nordberg <code@johan-nordberg.com>
@@ -551,7 +552,6 @@ declare module 'dhive/chain/serializer' {
551
552
  * You acknowledge that this software is not designed, licensed or intended for use
552
553
  * in the design, construction, operation or maintenance of any military facility.
553
554
  */
554
- /// <reference types="node" />
555
555
  import * as ByteBuffer from 'bytebuffer';
556
556
  import { PublicKey } from 'dhive/crypto';
557
557
  import { Asset } from 'dhive/chain/asset';
@@ -567,6 +567,9 @@ declare module 'dhive/chain/serializer' {
567
567
  Binary: (size?: number | undefined) => (buffer: ByteBuffer, data: HexBuffer | Buffer) => void;
568
568
  Boolean: (buffer: ByteBuffer, data: boolean) => void;
569
569
  Date: (buffer: ByteBuffer, data: string) => void;
570
+ EncryptedMemo: (buffer: ByteBuffer, data: {
571
+ [key: string]: any;
572
+ }) => void;
570
573
  FlatMap: (keySerializer: Serializer, valueSerializer: Serializer) => (buffer: ByteBuffer, data: [any, any][]) => void;
571
574
  Int16: (buffer: ByteBuffer, data: number) => void;
572
575
  Int32: (buffer: ByteBuffer, data: number) => void;
@@ -590,7 +593,7 @@ declare module 'dhive/chain/serializer' {
590
593
  UInt32: (buffer: ByteBuffer, data: number) => void;
591
594
  UInt64: (buffer: ByteBuffer, data: number) => void;
592
595
  UInt8: (buffer: ByteBuffer, data: number) => void;
593
- Void: (buffer: ByteBuffer) => never;
596
+ Void: () => never;
594
597
  };
595
598
 
596
599
  }
@@ -684,6 +687,7 @@ declare module 'dhive/crypto' {
684
687
  * in the design, construction, operation or maintenance of any military facility.
685
688
  */
686
689
  /// <reference types="node" />
690
+ import * as ByteBuffer from 'bytebuffer';
687
691
  import { SignedTransaction, Transaction } from 'dhive/chain/transaction';
688
692
  /**
689
693
  * Network id used in WIF-encoding.
@@ -693,9 +697,13 @@ declare module 'dhive/crypto' {
693
697
  * ECDSA (secp256k1) public key.
694
698
  */
695
699
  export class PublicKey {
696
- readonly key: Buffer;
700
+ readonly key: any;
697
701
  readonly prefix: string;
698
- constructor(key: Buffer, prefix?: string);
702
+ readonly uncompressed: Buffer;
703
+ constructor(key: any, prefix?: string);
704
+ static fromBuffer(key: ByteBuffer): {
705
+ key: ByteBuffer;
706
+ };
699
707
  /**
700
708
  * Create a new instance from a WIF-encoded key.
701
709
  */
@@ -729,6 +737,7 @@ declare module 'dhive/crypto' {
729
737
  */
730
738
  export class PrivateKey {
731
739
  private key;
740
+ secret: Buffer;
732
741
  constructor(key: Buffer);
733
742
  /**
734
743
  * Convenience to create a new instance from WIF string or buffer.
@@ -746,6 +755,7 @@ declare module 'dhive/crypto' {
746
755
  * Create key from username and password.
747
756
  */
748
757
  static fromLogin(username: string, password: string, role?: KeyRole): PrivateKey;
758
+ multiply(pub: any): Buffer;
749
759
  /**
750
760
  * Sign message.
751
761
  * @param message 32-byte message.
@@ -764,6 +774,10 @@ declare module 'dhive/crypto' {
764
774
  * to get the full encoded key you need to explicitly call {@link toString}.
765
775
  */
766
776
  inspect(): string;
777
+ /**
778
+ * Get shared secret for memo cryptography
779
+ */
780
+ get_shared_secret(public_key: PublicKey): Buffer;
767
781
  }
768
782
  /**
769
783
  * ECDSA (secp256k1) signature.
@@ -1895,7 +1909,7 @@ declare module 'dhive/utils' {
1895
1909
  hbd_interest_rate?: number;
1896
1910
  url?: string;
1897
1911
  }
1898
- export function buildWitnessUpdateOp(owner: string, props: WitnessProps): WitnessSetPropertiesOperation;
1912
+ export const buildWitnessUpdateOp: (owner: string, props: WitnessProps) => WitnessSetPropertiesOperation;
1899
1913
  export const operationOrders: {
1900
1914
  vote: number;
1901
1915
  comment: number;
@@ -2923,6 +2937,53 @@ declare module 'dhive/client' {
2923
2937
  updateOperations(rebrandedApi: any): void;
2924
2938
  }
2925
2939
 
2940
+ }
2941
+ declare module 'dhive/chain/deserializer' {
2942
+ /// <reference types="node" />
2943
+ import * as ByteBuffer from 'bytebuffer';
2944
+ export type Deserializer = (buffer: ByteBuffer) => void;
2945
+ export const types: {
2946
+ EncryptedMemoD: (buf: Buffer | ByteBuffer) => {};
2947
+ };
2948
+
2949
+ }
2950
+ declare module 'dhive/helpers/aes' {
2951
+ import { PrivateKey, PublicKey } from 'dhive/crypto';
2952
+ /**
2953
+ * Spec: http://peakd.com/steem/@dantheman/how-to-encrypt-a-memo-when-transferring-steem
2954
+ * @throws {Error|TypeError} - "Invalid Key, ..."
2955
+ * @param {PrivateKey} private_key - required and used for decryption
2956
+ * @param {PublicKey} public_key - required and used to calcualte the shared secret
2957
+ * @param message - message to be encrypted
2958
+ * @param {string} [nonce = uniqueNonce()] - assigned a random unique uint64
2959
+ *
2960
+ * @return {object}
2961
+ * @property {string} nonce - random or unique uint64, provides entropy when re-using the same private/public keys.
2962
+ * @property {Buffer} message - Plain text message
2963
+ * @property {number} checksum - shared secret checksum
2964
+ */
2965
+ export function encrypt(private_key: PrivateKey, public_key: PublicKey, message: any, nonce: any): any;
2966
+ /**
2967
+ * Spec: http://peakd.com/steem/@dantheman/how-to-encrypt-a-memo-when-transferring-steem
2968
+ * @arg {PrivateKey} private_key - required and used for decryption
2969
+ * @arg {PublicKey} public_key - required and used to calcualte the shared secret
2970
+ * @arg {string} nonce - random or unique uint64, provides entropy when re-using the same private/public keys.
2971
+ * @arg {Buffer} message - Encrypted or plain text message
2972
+ * @arg {number} checksum - shared secret checksum
2973
+ * @throws {Error|TypeError} - "Invalid Key, ..."
2974
+ * @return {Buffer} - message
2975
+ */
2976
+ export function decrypt(private_key: PrivateKey, public_key: PublicKey, nonce: any, message: any, checksum: number): string;
2977
+
2978
+ }
2979
+ declare module 'dhive/memo' {
2980
+ import { PrivateKey, PublicKey } from 'dhive/crypto'; function encode(private_key: PrivateKey | string, public_key: PublicKey | string, memo: string, testNonce?: number): string; function decode(private_key: PrivateKey | string, memo: any): any;
2981
+ export const Memo: {
2982
+ decode: typeof decode;
2983
+ encode: typeof encode;
2984
+ };
2985
+ export {};
2986
+
2926
2987
  }
2927
2988
  declare module 'dhive' {
2928
2989
  /**
@@ -2973,9 +3034,12 @@ declare module 'dhive' {
2973
3034
  export * from 'dhive/chain/misc';
2974
3035
  export * from 'dhive/chain/operation';
2975
3036
  export * from 'dhive/chain/serializer';
3037
+ export * from 'dhive/chain/deserializer';
2976
3038
  export * from 'dhive/chain/transaction';
3039
+ export * from 'dhive/chain/hivemind';
2977
3040
  export * from 'dhive/client';
2978
3041
  export * from 'dhive/crypto';
3042
+ export * from 'dhive/memo';
2979
3043
 
2980
3044
  }
2981
3045
  declare module 'dhive/index-browser' {