@ocap/util 1.27.16 → 1.28.0

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.
Files changed (54) hide show
  1. package/esm/bn.d.ts +8 -6
  2. package/esm/bn.js +11 -7
  3. package/esm/constant.d.ts +4 -1
  4. package/esm/constant.js +5 -1
  5. package/esm/create-sorted-list.d.ts +4 -1
  6. package/esm/create-sorted-list.js +8 -3
  7. package/esm/curve.d.ts +85 -55
  8. package/esm/curve.js +132 -127
  9. package/esm/error.d.ts +12 -9
  10. package/esm/error.js +24 -17
  11. package/esm/get-list-field.d.ts +4 -1
  12. package/esm/get-list-field.js +7 -2
  13. package/esm/get-related-addr.d.ts +4 -1
  14. package/esm/get-related-addr.js +5 -1
  15. package/esm/index.d.ts +47 -44
  16. package/esm/index.js +364 -469
  17. package/esm/lodash.d.ts +12 -0
  18. package/esm/md5.d.ts +4 -1
  19. package/esm/md5.js +7 -3
  20. package/esm/ready.d.ts +13 -9
  21. package/esm/ready.js +33 -36
  22. package/esm/retry.d.ts +16 -9
  23. package/esm/retry.js +26 -27
  24. package/esm/tsfixme.d.ts +3 -0
  25. package/esm/url.d.ts +16 -12
  26. package/esm/url.js +67 -92
  27. package/lib/_virtual/rolldown_runtime.js +29 -0
  28. package/lib/bn.d.ts +8 -6
  29. package/lib/bn.js +12 -12
  30. package/lib/constant.d.ts +4 -1
  31. package/lib/constant.js +6 -4
  32. package/lib/create-sorted-list.d.ts +4 -1
  33. package/lib/create-sorted-list.js +11 -10
  34. package/lib/curve.d.ts +84 -55
  35. package/lib/curve.js +139 -137
  36. package/lib/error.d.ts +12 -9
  37. package/lib/error.js +25 -21
  38. package/lib/get-list-field.d.ts +4 -1
  39. package/lib/get-list-field.js +9 -9
  40. package/lib/get-related-addr.d.ts +4 -1
  41. package/lib/get-related-addr.js +5 -4
  42. package/lib/index.d.ts +47 -44
  43. package/lib/index.js +386 -506
  44. package/lib/lodash.d.ts +12 -0
  45. package/lib/md5.d.ts +4 -1
  46. package/lib/md5.js +9 -10
  47. package/lib/ready.d.ts +13 -9
  48. package/lib/ready.js +34 -42
  49. package/lib/retry.d.ts +16 -9
  50. package/lib/retry.js +27 -30
  51. package/lib/tsfixme.d.ts +3 -0
  52. package/lib/url.d.ts +16 -12
  53. package/lib/url.js +69 -118
  54. package/package.json +23 -9
package/lib/index.d.ts CHANGED
@@ -1,22 +1,23 @@
1
- import type { LiteralUnion } from 'type-fest';
2
- import rightPad from 'lodash/padEnd';
3
- import leftPad from 'lodash/padStart';
4
- import { BN } from './bn';
5
- export declare const isBase58btc: (data: any) => boolean;
6
- export type BytesType = string | Buffer | Uint8Array;
7
- export type EncodingType = LiteralUnion<'hex' | 'base16' | 'base58' | 'base64' | 'Uint8Array' | 'buffer', string>;
8
- export type KeyPairType = {
9
- publicKey: BytesType;
10
- secretKey: BytesType;
1
+ import { BN } from "./bn.js";
2
+ import { LiteralUnion } from "type-fest";
3
+ import rightPad from "lodash/padEnd";
4
+ import leftPad from "lodash/padStart";
5
+
6
+ //#region src/index.d.ts
7
+ declare const isBase58btc: (data: any) => boolean;
8
+ type BytesType = string | Buffer | Uint8Array;
9
+ type EncodingType = LiteralUnion<'hex' | 'base16' | 'base58' | 'base64' | 'Uint8Array' | 'buffer', string>;
10
+ type KeyPairType = {
11
+ publicKey: BytesType;
12
+ secretKey: BytesType;
11
13
  };
12
- export { BN, leftPad, rightPad };
13
14
  /**
14
15
  * Returns a BN object, converts a number value to a BN
15
16
  * @param {string|number|BN} `arg` input a string number, hex string number, number, BigNumber or BN object
16
17
  * @return {BN} `output` BN object of the number
17
18
  * @throws if the argument is not an array, object that isn't a bignumber, not a string number or number
18
19
  */
19
- export declare const numberToBN: (arg: string | number | BN) => BN;
20
+ declare const numberToBN: (arg: string | number | BN) => BN;
20
21
  /**
21
22
  * Returns a `boolean` on whether or not the `string` starts with '0x'
22
23
  *
@@ -26,14 +27,14 @@ export declare const numberToBN: (arg: string | number | BN) => BN;
26
27
  * @return {Boolean} a boolean if it is or is not hex prefixed
27
28
  * @throws if the str input is not a string
28
29
  */
29
- export declare const isHexPrefixed: (str: string) => boolean;
30
+ declare const isHexPrefixed: (str: string) => boolean;
30
31
  /**
31
32
  * Removes '0x' from a given `String` if present
32
33
  *
33
34
  * @public
34
35
  * @static
35
36
  */
36
- export declare const stripHexPrefix: (str: string | any) => any;
37
+ declare const stripHexPrefix: (str: string | any) => any;
37
38
  /**
38
39
  * Returns true if object is BN, otherwise false
39
40
  *
@@ -43,7 +44,7 @@ export declare const stripHexPrefix: (str: string | any) => any;
43
44
  * @param {Object} object
44
45
  * @returns {Boolean}
45
46
  */
46
- export declare const isBN: (object: $TSFixMe) => boolean;
47
+ declare const isBN: (object: $TSFixMe) => boolean;
47
48
  /**
48
49
  * Returns true if object is BigNumber, otherwise false
49
50
  *
@@ -53,7 +54,7 @@ export declare const isBN: (object: $TSFixMe) => boolean;
53
54
  * @param {Object} object
54
55
  * @returns {Boolean}
55
56
  */
56
- export declare const isBigNumber: (object: $TSFixMe) => boolean;
57
+ declare const isBigNumber: (object: $TSFixMe) => boolean;
57
58
  /**
58
59
  * Check if string is HEX, requires a 0x in front
59
60
  *
@@ -63,7 +64,7 @@ export declare const isBigNumber: (object: $TSFixMe) => boolean;
63
64
  * @param {String} hex to be checked
64
65
  * @returns {Boolean}
65
66
  */
66
- export declare const isHexStrict: (hex: string) => boolean;
67
+ declare const isHexStrict: (hex: string) => boolean;
67
68
  /**
68
69
  * Check if string is HEX
69
70
  *
@@ -73,7 +74,7 @@ export declare const isHexStrict: (hex: string) => boolean;
73
74
  * @param {String} hex to be checked
74
75
  * @returns {Boolean}
75
76
  */
76
- export declare const isHex: (hex: string) => boolean;
77
+ declare const isHex: (hex: string) => boolean;
77
78
  /**
78
79
  * Takes an input and transforms it into an BN
79
80
  *
@@ -83,7 +84,7 @@ export declare const isHex: (hex: string) => boolean;
83
84
  * @param {Number|String|BN} num, string, HEX string or BN
84
85
  * @returns {BN} BN
85
86
  */
86
- export declare const toBN: (num: number | string | BN, base?: number | "hex") => BN;
87
+ declare const toBN: (num: number | string | BN, base?: number | "hex") => BN;
87
88
  /**
88
89
  * Should be called to get hex representation (prefixed by 0x) of utf8 string
89
90
  *
@@ -93,7 +94,7 @@ export declare const toBN: (num: number | string | BN, base?: number | "hex") =>
93
94
  * @param {String} str
94
95
  * @returns {String} hex representation of input string
95
96
  */
96
- export declare const utf8ToHex: (str: string) => string;
97
+ declare const utf8ToHex: (str: string) => string;
97
98
  /**
98
99
  * Should be called to get utf8 from it's hex representation
99
100
  *
@@ -103,7 +104,7 @@ export declare const utf8ToHex: (str: string) => string;
103
104
  * @param {String} hex
104
105
  * @returns {String} ascii string representation of hex value
105
106
  */
106
- export declare const hexToUtf8: (hex: string) => string;
107
+ declare const hexToUtf8: (hex: string) => string;
107
108
  /**
108
109
  * Converts value to number representation
109
110
  *
@@ -113,7 +114,7 @@ export declare const hexToUtf8: (hex: string) => string;
113
114
  * @param {String|Number|BN} value
114
115
  * @returns {Number}
115
116
  */
116
- export declare const hexToNumber: (value: string | number | BN) => number;
117
+ declare const hexToNumber: (value: string | number | BN) => number;
117
118
  /**
118
119
  * Converts value to hex representation
119
120
  *
@@ -123,7 +124,7 @@ export declare const hexToNumber: (value: string | number | BN) => number;
123
124
  * @param {String|Number|BN} value
124
125
  * @returns {String}
125
126
  */
126
- export declare const numberToHex: (value: $TSFixMe) => string;
127
+ declare const numberToHex: (value: $TSFixMe) => string;
127
128
  /**
128
129
  * Convert a byte array to a hex string
129
130
  * Note: Implementation from crypto-js
@@ -134,7 +135,7 @@ export declare const numberToHex: (value: $TSFixMe) => string;
134
135
  * @param {Array} bytes
135
136
  * @returns {String} the hex string
136
137
  */
137
- export declare const bytesToHex: (bytes: $TSFixMe) => string;
138
+ declare const bytesToHex: (bytes: $TSFixMe) => string;
138
139
  /**
139
140
  * Convert a hex string to a byte array
140
141
  * Note: Implementation from crypto-js
@@ -145,7 +146,7 @@ export declare const bytesToHex: (bytes: $TSFixMe) => string;
145
146
  * @param {String} hex
146
147
  * @returns {Array} the byte array
147
148
  */
148
- export declare const hexToBytes: (hex: $TSFixMe) => Array<any>;
149
+ declare const hexToBytes: (hex: $TSFixMe) => Array<any>;
149
150
  /**
150
151
  * Auto converts any given value into it's hex representation.
151
152
  * And even stringify objects before.
@@ -157,63 +158,65 @@ export declare const hexToBytes: (hex: $TSFixMe) => Array<any>;
157
158
  * @param {Boolean} returnType
158
159
  * @returns {String}
159
160
  */
160
- export declare const toHex: (value: string | number | boolean | BN | Uint8Array | Buffer | (number | {
161
- test: string;
161
+ declare const toHex: (value: string | number | boolean | BN | Uint8Array | Buffer | (number | {
162
+ test: string;
162
163
  })[] | {
163
- test: string;
164
+ test: string;
164
165
  }, returnType?: boolean) => string;
165
- export declare const numberToString: (arg: $TSFixMe) => any;
166
+ declare const numberToString: (arg: $TSFixMe) => any;
166
167
  /**
167
168
  * Format a big number to human readable number, such as 1_0000_0000_0000_000 => 1 Token
168
169
  */
169
- export declare const fromUnitToToken: (input: string | number | BN, decimal?: number, optionsInput?: $TSFixMe) => string;
170
+ declare const fromUnitToToken: (input: string | number | BN, decimal?: number, optionsInput?: $TSFixMe) => string;
170
171
  /**
171
172
  * Convert human readable token number to big number instance
172
173
  */
173
- export declare const fromTokenToUnit: (input: string | number, decimal?: number) => BN;
174
+ declare const fromTokenToUnit: (input: string | number, decimal?: number) => BN;
174
175
  /**
175
176
  * Validates if a value is an Uint8Array.
176
177
  */
177
- export declare function isUint8Array(value: $TSFixMe): boolean;
178
+ declare function isUint8Array(value: $TSFixMe): boolean;
178
179
  /**
179
180
  * Generate a random UUID
180
181
  */
181
- export declare function UUID(): string;
182
+ declare function UUID(): string;
182
183
  /**
183
184
  * Check if a string is valid UUID
184
185
  */
185
- export declare function isUUID(str: string): boolean;
186
+ declare function isUUID(str: string): boolean;
186
187
  /**
187
188
  * Convert input to Uint8Array on best effort, base64 node supported
188
189
  */
189
- export declare function toUint8Array(v: any): Uint8Array;
190
+ declare function toUint8Array(v: any): Uint8Array;
190
191
  /**
191
192
  * Convert input to Buffer on best effort, base64 not supported
192
193
  */
193
- export declare function toBuffer(v: any): Buffer;
194
+ declare function toBuffer(v: any): Buffer;
194
195
  /**
195
196
  * Convert input to base58btc format on best effort
196
197
  */
197
- export declare function toBase58(v: any): string;
198
+ declare function toBase58(v: any): string;
198
199
  /**
199
200
  * Decode base58 string
200
201
  */
201
- export declare function fromBase58(v: string): Buffer;
202
+ declare function fromBase58(v: string): Buffer;
202
203
  /**
203
204
  * Convert input to base64 format
204
205
  */
205
- export declare function toBase64(v: any, escape?: boolean): string;
206
+ declare function toBase64(v: any, escape?: boolean): string;
206
207
  /**
207
208
  * Decode base64(base64_url) string to buffer
208
209
  */
209
- export declare function fromBase64(v: string): Buffer;
210
+ declare function fromBase64(v: string): Buffer;
210
211
  /**
211
212
  * Convert did to address: remove `did:abt:` prefix
212
213
  */
213
- export declare function toAddress(did: string): string;
214
+ declare function toAddress(did: string): string;
214
215
  /**
215
216
  * Convert address to did: prepend `did:abt:` prefix
216
217
  */
217
- export declare function toDid(address: string): string;
218
- export declare function isSameDid(a: string, b: string): boolean;
219
- export declare function formatTxType(type: string): any;
218
+ declare function toDid(address: string): string;
219
+ declare function isSameDid(a: string, b: string): boolean;
220
+ declare function formatTxType(type: string): Capitalize<string>;
221
+ //#endregion
222
+ export { BN, BytesType, EncodingType, KeyPairType, UUID, bytesToHex, formatTxType, fromBase58, fromBase64, fromTokenToUnit, fromUnitToToken, hexToBytes, hexToNumber, hexToUtf8, isBN, isBase58btc, isBigNumber, isHex, isHexPrefixed, isHexStrict, isSameDid, isUUID, isUint8Array, leftPad, numberToBN, numberToHex, numberToString, rightPad, stripHexPrefix, toAddress, toBN, toBase58, toBase64, toBuffer, toDid, toHex, toUint8Array, utf8ToHex };