@satianurag/hiero-mirror-client 0.1.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.
- package/LICENSE +21 -0
- package/README.md +172 -0
- package/dist/index.cjs +2231 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1425 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +1425 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.d.ts +1425 -0
- package/dist/index.mjs +2218 -0
- package/dist/index.mjs.map +1 -0
- package/dist/utils.cjs +188 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +105 -0
- package/dist/utils.d.cts.map +1 -0
- package/dist/utils.d.mts +105 -0
- package/dist/utils.d.mts.map +1 -0
- package/dist/utils.d.ts +105 -0
- package/dist/utils.mjs +178 -0
- package/dist/utils.mjs.map +1 -0
- package/package.json +73 -0
package/dist/utils.d.cts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
//#region src/utils/encoding.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Cross-platform encoding utilities.
|
|
4
|
+
*
|
|
5
|
+
* No dependency on Node.js `Buffer` — uses Web-standard APIs only.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Base64-to-hex conversion.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* base64ToHex('SGVsbG8=') // → '48656c6c6f'
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
declare function base64ToHex(base64: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Hex-to-base64 conversion.
|
|
19
|
+
*
|
|
20
|
+
* Accepts optional 0x prefix.
|
|
21
|
+
*
|
|
22
|
+
* ```ts
|
|
23
|
+
* hexToBase64('48656c6c6f') // → 'SGVsbG8='
|
|
24
|
+
* hexToBase64('0x48656c6c6f') // → 'SGVsbG8='
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
declare function hexToBase64(hex: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Convert a Uint8Array to a hex string (lowercase, no prefix).
|
|
30
|
+
*/
|
|
31
|
+
declare function bytesToHex(bytes: Uint8Array): string;
|
|
32
|
+
/**
|
|
33
|
+
* Convert a hex string (with optional 0x prefix) to Uint8Array.
|
|
34
|
+
*/
|
|
35
|
+
declare function hexToBytes(hex: string): Uint8Array;
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/utils/timestamp.d.ts
|
|
38
|
+
/**
|
|
39
|
+
* HieroTimestamp — factory methods for Hedera/Hiero timestamps.
|
|
40
|
+
*
|
|
41
|
+
* Hedera timestamps use the format `seconds.nanoseconds`, e.g., `1710000000.123456789`.
|
|
42
|
+
*
|
|
43
|
+
* @packageDocumentation
|
|
44
|
+
*/
|
|
45
|
+
/**
|
|
46
|
+
* Represents a Hedera consensus timestamp as `seconds.nanoseconds`.
|
|
47
|
+
*/
|
|
48
|
+
interface HieroTimestamp {
|
|
49
|
+
/** Whole seconds since epoch. */
|
|
50
|
+
readonly seconds: bigint;
|
|
51
|
+
/** Nanosecond component (0–999,999,999). */
|
|
52
|
+
readonly nanos: number;
|
|
53
|
+
/** Full timestamp string: `<seconds>.<nanos padded to 9 digits>`. */
|
|
54
|
+
toString(): string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Creates a HieroTimestamp from a `seconds.nanos` string.
|
|
58
|
+
*
|
|
59
|
+
* ```ts
|
|
60
|
+
* const ts = fromString('1710000000.123456789');
|
|
61
|
+
* ts.seconds // 1710000000n
|
|
62
|
+
* ts.nanos // 123456789
|
|
63
|
+
* ts.toString() // '1710000000.123456789'
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
declare function fromString(timestamp: string): HieroTimestamp;
|
|
67
|
+
/**
|
|
68
|
+
* Creates a HieroTimestamp from a JavaScript `Date`.
|
|
69
|
+
*
|
|
70
|
+
* Note: JS Date only has millisecond precision. Nanoseconds below ms will be 0.
|
|
71
|
+
*
|
|
72
|
+
* ```ts
|
|
73
|
+
* const ts = fromDate(new Date('2024-03-10T00:00:00Z'));
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
declare function fromDate(date: Date): HieroTimestamp;
|
|
77
|
+
/**
|
|
78
|
+
* Creates a HieroTimestamp for the current moment.
|
|
79
|
+
*
|
|
80
|
+
* ```ts
|
|
81
|
+
* const ts = now();
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
declare function now(): HieroTimestamp;
|
|
85
|
+
/**
|
|
86
|
+
* Creates a HieroTimestamp from separate seconds and nanoseconds.
|
|
87
|
+
*
|
|
88
|
+
* ```ts
|
|
89
|
+
* const ts = fromParts(1710000000n, 123456789);
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
declare function fromParts(seconds: bigint, nanos: number): HieroTimestamp;
|
|
93
|
+
/**
|
|
94
|
+
* Converts a HieroTimestamp to a JavaScript Date.
|
|
95
|
+
*
|
|
96
|
+
* Note: sub-millisecond precision is lost.
|
|
97
|
+
*/
|
|
98
|
+
declare function toDate(timestamp: HieroTimestamp): Date;
|
|
99
|
+
/**
|
|
100
|
+
* Compares two timestamps. Returns -1, 0, or 1.
|
|
101
|
+
*/
|
|
102
|
+
declare function compare(a: HieroTimestamp, b: HieroTimestamp): -1 | 0 | 1;
|
|
103
|
+
//#endregion
|
|
104
|
+
export { type HieroTimestamp, base64ToHex, bytesToHex, compare, fromDate, fromParts, fromString, hexToBase64, hexToBytes, now, toDate };
|
|
105
|
+
//# sourceMappingURL=utils.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.cts","names":[],"sources":["../src/utils/encoding.ts","../src/utils/timestamp.ts"],"mappings":";;AAeA;;;;;AAiBA;;;;;AAeA;;;iBAhCgB,WAAA,CAAY,MAAA;;AAyC5B;;;;;;;;AC7CA;iBDqBgB,WAAA,CAAY,GAAA;;;;iBAeZ,UAAA,CAAW,KAAA,EAAO,UAAA;;;;iBASlB,UAAA,CAAW,GAAA,WAAc,UAAA;;;;AAzCzC;;;;;AAiBA;;;;UCrBiB,cAAA;EDoCD;EAAA,SClCL,OAAA;;WAEA,KAAA;EDgCiC;EC9B1C,QAAA;AAAA;;;;;;;AANF;;;;iBAmBgB,UAAA,CAAW,SAAA,WAAoB,cAAA;;;;;AAA/C;;;;;iBA0BgB,QAAA,CAAS,IAAA,EAAM,IAAA,GAAO,cAAA;;;;;;;;iBActB,GAAA,CAAA,GAAO,cAAA;AAAvB;;;;;AAWA;;AAXA,iBAWgB,SAAA,CAAU,OAAA,UAAiB,KAAA,WAAgB,cAAA;;;;;;iBAY3C,MAAA,CAAO,SAAA,EAAW,cAAA,GAAiB,IAAA;AAAnD;;;AAAA,iBAQgB,OAAA,CAAQ,CAAA,EAAG,cAAA,EAAgB,CAAA,EAAG,cAAA"}
|
package/dist/utils.d.mts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
//#region src/utils/encoding.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Cross-platform encoding utilities.
|
|
4
|
+
*
|
|
5
|
+
* No dependency on Node.js `Buffer` — uses Web-standard APIs only.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Base64-to-hex conversion.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* base64ToHex('SGVsbG8=') // → '48656c6c6f'
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
declare function base64ToHex(base64: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Hex-to-base64 conversion.
|
|
19
|
+
*
|
|
20
|
+
* Accepts optional 0x prefix.
|
|
21
|
+
*
|
|
22
|
+
* ```ts
|
|
23
|
+
* hexToBase64('48656c6c6f') // → 'SGVsbG8='
|
|
24
|
+
* hexToBase64('0x48656c6c6f') // → 'SGVsbG8='
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
declare function hexToBase64(hex: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Convert a Uint8Array to a hex string (lowercase, no prefix).
|
|
30
|
+
*/
|
|
31
|
+
declare function bytesToHex(bytes: Uint8Array): string;
|
|
32
|
+
/**
|
|
33
|
+
* Convert a hex string (with optional 0x prefix) to Uint8Array.
|
|
34
|
+
*/
|
|
35
|
+
declare function hexToBytes(hex: string): Uint8Array;
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/utils/timestamp.d.ts
|
|
38
|
+
/**
|
|
39
|
+
* HieroTimestamp — factory methods for Hedera/Hiero timestamps.
|
|
40
|
+
*
|
|
41
|
+
* Hedera timestamps use the format `seconds.nanoseconds`, e.g., `1710000000.123456789`.
|
|
42
|
+
*
|
|
43
|
+
* @packageDocumentation
|
|
44
|
+
*/
|
|
45
|
+
/**
|
|
46
|
+
* Represents a Hedera consensus timestamp as `seconds.nanoseconds`.
|
|
47
|
+
*/
|
|
48
|
+
interface HieroTimestamp {
|
|
49
|
+
/** Whole seconds since epoch. */
|
|
50
|
+
readonly seconds: bigint;
|
|
51
|
+
/** Nanosecond component (0–999,999,999). */
|
|
52
|
+
readonly nanos: number;
|
|
53
|
+
/** Full timestamp string: `<seconds>.<nanos padded to 9 digits>`. */
|
|
54
|
+
toString(): string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Creates a HieroTimestamp from a `seconds.nanos` string.
|
|
58
|
+
*
|
|
59
|
+
* ```ts
|
|
60
|
+
* const ts = fromString('1710000000.123456789');
|
|
61
|
+
* ts.seconds // 1710000000n
|
|
62
|
+
* ts.nanos // 123456789
|
|
63
|
+
* ts.toString() // '1710000000.123456789'
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
declare function fromString(timestamp: string): HieroTimestamp;
|
|
67
|
+
/**
|
|
68
|
+
* Creates a HieroTimestamp from a JavaScript `Date`.
|
|
69
|
+
*
|
|
70
|
+
* Note: JS Date only has millisecond precision. Nanoseconds below ms will be 0.
|
|
71
|
+
*
|
|
72
|
+
* ```ts
|
|
73
|
+
* const ts = fromDate(new Date('2024-03-10T00:00:00Z'));
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
declare function fromDate(date: Date): HieroTimestamp;
|
|
77
|
+
/**
|
|
78
|
+
* Creates a HieroTimestamp for the current moment.
|
|
79
|
+
*
|
|
80
|
+
* ```ts
|
|
81
|
+
* const ts = now();
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
declare function now(): HieroTimestamp;
|
|
85
|
+
/**
|
|
86
|
+
* Creates a HieroTimestamp from separate seconds and nanoseconds.
|
|
87
|
+
*
|
|
88
|
+
* ```ts
|
|
89
|
+
* const ts = fromParts(1710000000n, 123456789);
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
declare function fromParts(seconds: bigint, nanos: number): HieroTimestamp;
|
|
93
|
+
/**
|
|
94
|
+
* Converts a HieroTimestamp to a JavaScript Date.
|
|
95
|
+
*
|
|
96
|
+
* Note: sub-millisecond precision is lost.
|
|
97
|
+
*/
|
|
98
|
+
declare function toDate(timestamp: HieroTimestamp): Date;
|
|
99
|
+
/**
|
|
100
|
+
* Compares two timestamps. Returns -1, 0, or 1.
|
|
101
|
+
*/
|
|
102
|
+
declare function compare(a: HieroTimestamp, b: HieroTimestamp): -1 | 0 | 1;
|
|
103
|
+
//#endregion
|
|
104
|
+
export { type HieroTimestamp, base64ToHex, bytesToHex, compare, fromDate, fromParts, fromString, hexToBase64, hexToBytes, now, toDate };
|
|
105
|
+
//# sourceMappingURL=utils.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.mts","names":[],"sources":["../src/utils/encoding.ts","../src/utils/timestamp.ts"],"mappings":";;AAeA;;;;;AAiBA;;;;;AAeA;;;iBAhCgB,WAAA,CAAY,MAAA;;AAyC5B;;;;;;;;AC7CA;iBDqBgB,WAAA,CAAY,GAAA;;;;iBAeZ,UAAA,CAAW,KAAA,EAAO,UAAA;;;;iBASlB,UAAA,CAAW,GAAA,WAAc,UAAA;;;;AAzCzC;;;;;AAiBA;;;;UCrBiB,cAAA;EDoCD;EAAA,SClCL,OAAA;;WAEA,KAAA;EDgCiC;EC9B1C,QAAA;AAAA;;;;;;;AANF;;;;iBAmBgB,UAAA,CAAW,SAAA,WAAoB,cAAA;;;;;AAA/C;;;;;iBA0BgB,QAAA,CAAS,IAAA,EAAM,IAAA,GAAO,cAAA;;;;;;;;iBActB,GAAA,CAAA,GAAO,cAAA;AAAvB;;;;;AAWA;;AAXA,iBAWgB,SAAA,CAAU,OAAA,UAAiB,KAAA,WAAgB,cAAA;;;;;;iBAY3C,MAAA,CAAO,SAAA,EAAW,cAAA,GAAiB,IAAA;AAAnD;;;AAAA,iBAQgB,OAAA,CAAQ,CAAA,EAAG,cAAA,EAAgB,CAAA,EAAG,cAAA"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
//#region src/utils/encoding.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Cross-platform encoding utilities.
|
|
4
|
+
*
|
|
5
|
+
* No dependency on Node.js `Buffer` — uses Web-standard APIs only.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Base64-to-hex conversion.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* base64ToHex('SGVsbG8=') // → '48656c6c6f'
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
declare function base64ToHex(base64: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Hex-to-base64 conversion.
|
|
19
|
+
*
|
|
20
|
+
* Accepts optional 0x prefix.
|
|
21
|
+
*
|
|
22
|
+
* ```ts
|
|
23
|
+
* hexToBase64('48656c6c6f') // → 'SGVsbG8='
|
|
24
|
+
* hexToBase64('0x48656c6c6f') // → 'SGVsbG8='
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
declare function hexToBase64(hex: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Convert a Uint8Array to a hex string (lowercase, no prefix).
|
|
30
|
+
*/
|
|
31
|
+
declare function bytesToHex(bytes: Uint8Array): string;
|
|
32
|
+
/**
|
|
33
|
+
* Convert a hex string (with optional 0x prefix) to Uint8Array.
|
|
34
|
+
*/
|
|
35
|
+
declare function hexToBytes(hex: string): Uint8Array;
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/utils/timestamp.d.ts
|
|
38
|
+
/**
|
|
39
|
+
* HieroTimestamp — factory methods for Hedera/Hiero timestamps.
|
|
40
|
+
*
|
|
41
|
+
* Hedera timestamps use the format `seconds.nanoseconds`, e.g., `1710000000.123456789`.
|
|
42
|
+
*
|
|
43
|
+
* @packageDocumentation
|
|
44
|
+
*/
|
|
45
|
+
/**
|
|
46
|
+
* Represents a Hedera consensus timestamp as `seconds.nanoseconds`.
|
|
47
|
+
*/
|
|
48
|
+
interface HieroTimestamp {
|
|
49
|
+
/** Whole seconds since epoch. */
|
|
50
|
+
readonly seconds: bigint;
|
|
51
|
+
/** Nanosecond component (0–999,999,999). */
|
|
52
|
+
readonly nanos: number;
|
|
53
|
+
/** Full timestamp string: `<seconds>.<nanos padded to 9 digits>`. */
|
|
54
|
+
toString(): string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Creates a HieroTimestamp from a `seconds.nanos` string.
|
|
58
|
+
*
|
|
59
|
+
* ```ts
|
|
60
|
+
* const ts = fromString('1710000000.123456789');
|
|
61
|
+
* ts.seconds // 1710000000n
|
|
62
|
+
* ts.nanos // 123456789
|
|
63
|
+
* ts.toString() // '1710000000.123456789'
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
declare function fromString(timestamp: string): HieroTimestamp;
|
|
67
|
+
/**
|
|
68
|
+
* Creates a HieroTimestamp from a JavaScript `Date`.
|
|
69
|
+
*
|
|
70
|
+
* Note: JS Date only has millisecond precision. Nanoseconds below ms will be 0.
|
|
71
|
+
*
|
|
72
|
+
* ```ts
|
|
73
|
+
* const ts = fromDate(new Date('2024-03-10T00:00:00Z'));
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
declare function fromDate(date: Date): HieroTimestamp;
|
|
77
|
+
/**
|
|
78
|
+
* Creates a HieroTimestamp for the current moment.
|
|
79
|
+
*
|
|
80
|
+
* ```ts
|
|
81
|
+
* const ts = now();
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
declare function now(): HieroTimestamp;
|
|
85
|
+
/**
|
|
86
|
+
* Creates a HieroTimestamp from separate seconds and nanoseconds.
|
|
87
|
+
*
|
|
88
|
+
* ```ts
|
|
89
|
+
* const ts = fromParts(1710000000n, 123456789);
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
declare function fromParts(seconds: bigint, nanos: number): HieroTimestamp;
|
|
93
|
+
/**
|
|
94
|
+
* Converts a HieroTimestamp to a JavaScript Date.
|
|
95
|
+
*
|
|
96
|
+
* Note: sub-millisecond precision is lost.
|
|
97
|
+
*/
|
|
98
|
+
declare function toDate(timestamp: HieroTimestamp): Date;
|
|
99
|
+
/**
|
|
100
|
+
* Compares two timestamps. Returns -1, 0, or 1.
|
|
101
|
+
*/
|
|
102
|
+
declare function compare(a: HieroTimestamp, b: HieroTimestamp): -1 | 0 | 1;
|
|
103
|
+
//#endregion
|
|
104
|
+
export { type HieroTimestamp, base64ToHex, bytesToHex, compare, fromDate, fromParts, fromString, hexToBase64, hexToBytes, now, toDate };
|
|
105
|
+
//# sourceMappingURL=utils.d.mts.map
|
package/dist/utils.mjs
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
//#region src/utils/encoding.ts
|
|
2
|
+
/**
|
|
3
|
+
* Cross-platform encoding utilities.
|
|
4
|
+
*
|
|
5
|
+
* No dependency on Node.js `Buffer` — uses Web-standard APIs only.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Base64-to-hex conversion.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* base64ToHex('SGVsbG8=') // → '48656c6c6f'
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
function base64ToHex(base64) {
|
|
17
|
+
const bytes = base64ToBytes(base64);
|
|
18
|
+
return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Hex-to-base64 conversion.
|
|
22
|
+
*
|
|
23
|
+
* Accepts optional 0x prefix.
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* hexToBase64('48656c6c6f') // → 'SGVsbG8='
|
|
27
|
+
* hexToBase64('0x48656c6c6f') // → 'SGVsbG8='
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
function hexToBase64(hex) {
|
|
31
|
+
const cleaned = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
32
|
+
if (cleaned.length % 2 !== 0) throw new Error(`Invalid hex string: odd length (${cleaned.length})`);
|
|
33
|
+
const bytes = new Uint8Array(cleaned.length / 2);
|
|
34
|
+
for (let i = 0; i < cleaned.length; i += 2) bytes[i / 2] = Number.parseInt(cleaned.slice(i, i + 2), 16);
|
|
35
|
+
return bytesToBase64(bytes);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Convert a Uint8Array to a hex string (lowercase, no prefix).
|
|
39
|
+
*/
|
|
40
|
+
function bytesToHex(bytes) {
|
|
41
|
+
return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Convert a hex string (with optional 0x prefix) to Uint8Array.
|
|
45
|
+
*/
|
|
46
|
+
function hexToBytes(hex) {
|
|
47
|
+
const cleaned = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
48
|
+
if (cleaned.length % 2 !== 0) throw new Error(`Invalid hex string: odd length (${cleaned.length})`);
|
|
49
|
+
const bytes = new Uint8Array(cleaned.length / 2);
|
|
50
|
+
for (let i = 0; i < cleaned.length; i += 2) bytes[i / 2] = Number.parseInt(cleaned.slice(i, i + 2), 16);
|
|
51
|
+
return bytes;
|
|
52
|
+
}
|
|
53
|
+
const BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
54
|
+
function base64ToBytes(base64) {
|
|
55
|
+
if (typeof atob === "function") {
|
|
56
|
+
const binary = atob(base64);
|
|
57
|
+
const bytes = new Uint8Array(binary.length);
|
|
58
|
+
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
59
|
+
return bytes;
|
|
60
|
+
}
|
|
61
|
+
const cleaned = base64.replace(/=+$/, "");
|
|
62
|
+
const byteLength = cleaned.length * 3 >> 2;
|
|
63
|
+
const bytes = new Uint8Array(byteLength);
|
|
64
|
+
let byteIndex = 0;
|
|
65
|
+
for (let i = 0; i < cleaned.length; i += 4) {
|
|
66
|
+
const a = BASE64_CHARS.indexOf(cleaned.charAt(i));
|
|
67
|
+
const b = BASE64_CHARS.indexOf(cleaned.charAt(i + 1));
|
|
68
|
+
const c = BASE64_CHARS.indexOf(i + 2 < cleaned.length ? cleaned.charAt(i + 2) : "A");
|
|
69
|
+
const d = BASE64_CHARS.indexOf(i + 3 < cleaned.length ? cleaned.charAt(i + 3) : "A");
|
|
70
|
+
bytes[byteIndex++] = a << 2 | b >> 4;
|
|
71
|
+
if (i + 2 < cleaned.length) bytes[byteIndex++] = (b & 15) << 4 | c >> 2;
|
|
72
|
+
if (i + 3 < cleaned.length) bytes[byteIndex++] = (c & 3) << 6 | d;
|
|
73
|
+
}
|
|
74
|
+
return bytes;
|
|
75
|
+
}
|
|
76
|
+
function bytesToBase64(bytes) {
|
|
77
|
+
if (typeof btoa === "function") {
|
|
78
|
+
let binary = "";
|
|
79
|
+
for (const b of bytes) binary += String.fromCharCode(b);
|
|
80
|
+
return btoa(binary);
|
|
81
|
+
}
|
|
82
|
+
let result = "";
|
|
83
|
+
for (let i = 0; i < bytes.length; i += 3) {
|
|
84
|
+
const a = bytes[i];
|
|
85
|
+
const b = bytes[i + 1] ?? 0;
|
|
86
|
+
const c = bytes[i + 2] ?? 0;
|
|
87
|
+
result += BASE64_CHARS[a >> 2 & 63];
|
|
88
|
+
result += BASE64_CHARS[(a & 3) << 4 | b >> 4 & 15];
|
|
89
|
+
result += i + 1 < bytes.length ? BASE64_CHARS[(b & 15) << 2 | c >> 6 & 3] : "=";
|
|
90
|
+
result += i + 2 < bytes.length ? BASE64_CHARS[c & 63] : "=";
|
|
91
|
+
}
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/utils/timestamp.ts
|
|
96
|
+
/**
|
|
97
|
+
* Creates a HieroTimestamp from a `seconds.nanos` string.
|
|
98
|
+
*
|
|
99
|
+
* ```ts
|
|
100
|
+
* const ts = fromString('1710000000.123456789');
|
|
101
|
+
* ts.seconds // 1710000000n
|
|
102
|
+
* ts.nanos // 123456789
|
|
103
|
+
* ts.toString() // '1710000000.123456789'
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
function fromString(timestamp) {
|
|
107
|
+
const dotIndex = timestamp.indexOf(".");
|
|
108
|
+
if (dotIndex === -1) return makeTimestamp(BigInt(timestamp), 0);
|
|
109
|
+
const seconds = BigInt(timestamp.slice(0, dotIndex));
|
|
110
|
+
const nanosStr = timestamp.slice(dotIndex + 1).padEnd(9, "0").slice(0, 9);
|
|
111
|
+
return makeTimestamp(seconds, Number.parseInt(nanosStr, 10));
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Creates a HieroTimestamp from a JavaScript `Date`.
|
|
115
|
+
*
|
|
116
|
+
* Note: JS Date only has millisecond precision. Nanoseconds below ms will be 0.
|
|
117
|
+
*
|
|
118
|
+
* ```ts
|
|
119
|
+
* const ts = fromDate(new Date('2024-03-10T00:00:00Z'));
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
function fromDate(date) {
|
|
123
|
+
const epochMs = date.getTime();
|
|
124
|
+
return makeTimestamp(BigInt(Math.floor(epochMs / 1e3)), epochMs % 1e3 * 1e6);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Creates a HieroTimestamp for the current moment.
|
|
128
|
+
*
|
|
129
|
+
* ```ts
|
|
130
|
+
* const ts = now();
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
function now() {
|
|
134
|
+
return fromDate(/* @__PURE__ */ new Date());
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Creates a HieroTimestamp from separate seconds and nanoseconds.
|
|
138
|
+
*
|
|
139
|
+
* ```ts
|
|
140
|
+
* const ts = fromParts(1710000000n, 123456789);
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
function fromParts(seconds, nanos) {
|
|
144
|
+
if (nanos < 0 || nanos > 999999999) throw new RangeError(`nanoseconds must be 0..999_999_999, got ${nanos}`);
|
|
145
|
+
return makeTimestamp(seconds, nanos);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Converts a HieroTimestamp to a JavaScript Date.
|
|
149
|
+
*
|
|
150
|
+
* Note: sub-millisecond precision is lost.
|
|
151
|
+
*/
|
|
152
|
+
function toDate(timestamp) {
|
|
153
|
+
const ms = Number(timestamp.seconds) * 1e3 + Math.floor(timestamp.nanos / 1e6);
|
|
154
|
+
return new Date(ms);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Compares two timestamps. Returns -1, 0, or 1.
|
|
158
|
+
*/
|
|
159
|
+
function compare(a, b) {
|
|
160
|
+
if (a.seconds < b.seconds) return -1;
|
|
161
|
+
if (a.seconds > b.seconds) return 1;
|
|
162
|
+
if (a.nanos < b.nanos) return -1;
|
|
163
|
+
if (a.nanos > b.nanos) return 1;
|
|
164
|
+
return 0;
|
|
165
|
+
}
|
|
166
|
+
function makeTimestamp(seconds, nanos) {
|
|
167
|
+
return {
|
|
168
|
+
seconds,
|
|
169
|
+
nanos,
|
|
170
|
+
toString() {
|
|
171
|
+
return `${seconds}.${String(nanos).padStart(9, "0")}`;
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
//#endregion
|
|
176
|
+
export { base64ToHex, bytesToHex, compare, fromDate, fromParts, fromString, hexToBase64, hexToBytes, now, toDate };
|
|
177
|
+
|
|
178
|
+
//# sourceMappingURL=utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":[],"sources":["../src/utils/encoding.ts","../src/utils/timestamp.ts"],"sourcesContent":["/**\n * Cross-platform encoding utilities.\n *\n * No dependency on Node.js `Buffer` — uses Web-standard APIs only.\n *\n * @packageDocumentation\n */\n\n/**\n * Base64-to-hex conversion.\n *\n * ```ts\n * base64ToHex('SGVsbG8=') // → '48656c6c6f'\n * ```\n */\nexport function base64ToHex(base64: string): string {\n const bytes = base64ToBytes(base64);\n return Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('');\n}\n\n/**\n * Hex-to-base64 conversion.\n *\n * Accepts optional 0x prefix.\n *\n * ```ts\n * hexToBase64('48656c6c6f') // → 'SGVsbG8='\n * hexToBase64('0x48656c6c6f') // → 'SGVsbG8='\n * ```\n */\nexport function hexToBase64(hex: string): string {\n const cleaned = hex.startsWith('0x') || hex.startsWith('0X') ? hex.slice(2) : hex;\n if (cleaned.length % 2 !== 0) {\n throw new Error(`Invalid hex string: odd length (${cleaned.length})`);\n }\n const bytes = new Uint8Array(cleaned.length / 2);\n for (let i = 0; i < cleaned.length; i += 2) {\n bytes[i / 2] = Number.parseInt(cleaned.slice(i, i + 2), 16);\n }\n return bytesToBase64(bytes);\n}\n\n/**\n * Convert a Uint8Array to a hex string (lowercase, no prefix).\n */\nexport function bytesToHex(bytes: Uint8Array): string {\n return Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('');\n}\n\n/**\n * Convert a hex string (with optional 0x prefix) to Uint8Array.\n */\nexport function hexToBytes(hex: string): Uint8Array {\n const cleaned = hex.startsWith('0x') || hex.startsWith('0X') ? hex.slice(2) : hex;\n if (cleaned.length % 2 !== 0) {\n throw new Error(`Invalid hex string: odd length (${cleaned.length})`);\n }\n const bytes = new Uint8Array(cleaned.length / 2);\n for (let i = 0; i < cleaned.length; i += 2) {\n bytes[i / 2] = Number.parseInt(cleaned.slice(i, i + 2), 16);\n }\n return bytes;\n}\n\n// ---------------------------------------------------------------------------\n// Internal helpers (no Buffer, cross-platform)\n// ---------------------------------------------------------------------------\n\nconst BASE64_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n\nfunction base64ToBytes(base64: string): Uint8Array {\n // Use atob if available (browser + Node 16+)\n if (typeof atob === 'function') {\n const binary = atob(base64);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i);\n }\n return bytes;\n }\n\n // Manual fallback (should rarely be needed)\n const cleaned = base64.replace(/=+$/, '');\n const byteLength = (cleaned.length * 3) >> 2;\n const bytes = new Uint8Array(byteLength);\n let byteIndex = 0;\n\n for (let i = 0; i < cleaned.length; i += 4) {\n const a = BASE64_CHARS.indexOf(cleaned.charAt(i));\n const b = BASE64_CHARS.indexOf(cleaned.charAt(i + 1));\n const c = BASE64_CHARS.indexOf(i + 2 < cleaned.length ? cleaned.charAt(i + 2) : 'A');\n const d = BASE64_CHARS.indexOf(i + 3 < cleaned.length ? cleaned.charAt(i + 3) : 'A');\n\n bytes[byteIndex++] = (a << 2) | (b >> 4);\n if (i + 2 < cleaned.length) bytes[byteIndex++] = ((b & 15) << 4) | (c >> 2);\n if (i + 3 < cleaned.length) bytes[byteIndex++] = ((c & 3) << 6) | d;\n }\n\n return bytes;\n}\n\nfunction bytesToBase64(bytes: Uint8Array): string {\n // Use btoa if available (browser + Node 16+)\n if (typeof btoa === 'function') {\n let binary = '';\n for (const b of bytes) {\n binary += String.fromCharCode(b);\n }\n return btoa(binary);\n }\n\n // Manual fallback\n let result = '';\n for (let i = 0; i < bytes.length; i += 3) {\n const a = bytes[i]!;\n const b = bytes[i + 1] ?? 0;\n const c = bytes[i + 2] ?? 0;\n\n result += BASE64_CHARS[(a >> 2) & 63];\n result += BASE64_CHARS[((a & 3) << 4) | ((b >> 4) & 15)];\n result += i + 1 < bytes.length ? BASE64_CHARS[((b & 15) << 2) | ((c >> 6) & 3)] : '=';\n result += i + 2 < bytes.length ? BASE64_CHARS[c & 63] : '=';\n }\n\n return result;\n}\n","/**\n * HieroTimestamp — factory methods for Hedera/Hiero timestamps.\n *\n * Hedera timestamps use the format `seconds.nanoseconds`, e.g., `1710000000.123456789`.\n *\n * @packageDocumentation\n */\n\n/**\n * Represents a Hedera consensus timestamp as `seconds.nanoseconds`.\n */\nexport interface HieroTimestamp {\n /** Whole seconds since epoch. */\n readonly seconds: bigint;\n /** Nanosecond component (0–999,999,999). */\n readonly nanos: number;\n /** Full timestamp string: `<seconds>.<nanos padded to 9 digits>`. */\n toString(): string;\n}\n\n/**\n * Creates a HieroTimestamp from a `seconds.nanos` string.\n *\n * ```ts\n * const ts = fromString('1710000000.123456789');\n * ts.seconds // 1710000000n\n * ts.nanos // 123456789\n * ts.toString() // '1710000000.123456789'\n * ```\n */\nexport function fromString(timestamp: string): HieroTimestamp {\n const dotIndex = timestamp.indexOf('.');\n if (dotIndex === -1) {\n const seconds = BigInt(timestamp);\n return makeTimestamp(seconds, 0);\n }\n\n const seconds = BigInt(timestamp.slice(0, dotIndex));\n const nanosStr = timestamp\n .slice(dotIndex + 1)\n .padEnd(9, '0')\n .slice(0, 9);\n const nanos = Number.parseInt(nanosStr, 10);\n\n return makeTimestamp(seconds, nanos);\n}\n\n/**\n * Creates a HieroTimestamp from a JavaScript `Date`.\n *\n * Note: JS Date only has millisecond precision. Nanoseconds below ms will be 0.\n *\n * ```ts\n * const ts = fromDate(new Date('2024-03-10T00:00:00Z'));\n * ```\n */\nexport function fromDate(date: Date): HieroTimestamp {\n const epochMs = date.getTime();\n const seconds = BigInt(Math.floor(epochMs / 1000));\n const nanos = (epochMs % 1000) * 1_000_000;\n return makeTimestamp(seconds, nanos);\n}\n\n/**\n * Creates a HieroTimestamp for the current moment.\n *\n * ```ts\n * const ts = now();\n * ```\n */\nexport function now(): HieroTimestamp {\n return fromDate(new Date());\n}\n\n/**\n * Creates a HieroTimestamp from separate seconds and nanoseconds.\n *\n * ```ts\n * const ts = fromParts(1710000000n, 123456789);\n * ```\n */\nexport function fromParts(seconds: bigint, nanos: number): HieroTimestamp {\n if (nanos < 0 || nanos > 999_999_999) {\n throw new RangeError(`nanoseconds must be 0..999_999_999, got ${nanos}`);\n }\n return makeTimestamp(seconds, nanos);\n}\n\n/**\n * Converts a HieroTimestamp to a JavaScript Date.\n *\n * Note: sub-millisecond precision is lost.\n */\nexport function toDate(timestamp: HieroTimestamp): Date {\n const ms = Number(timestamp.seconds) * 1000 + Math.floor(timestamp.nanos / 1_000_000);\n return new Date(ms);\n}\n\n/**\n * Compares two timestamps. Returns -1, 0, or 1.\n */\nexport function compare(a: HieroTimestamp, b: HieroTimestamp): -1 | 0 | 1 {\n if (a.seconds < b.seconds) return -1;\n if (a.seconds > b.seconds) return 1;\n if (a.nanos < b.nanos) return -1;\n if (a.nanos > b.nanos) return 1;\n return 0;\n}\n\n// ---------------------------------------------------------------------------\n// Internal\n// ---------------------------------------------------------------------------\n\nfunction makeTimestamp(seconds: bigint, nanos: number): HieroTimestamp {\n return {\n seconds,\n nanos,\n toString() {\n return `${seconds}.${String(nanos).padStart(9, '0')}`;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,S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EAAE,QAAQ,EAAE,MAAO,QAAO;AAC9B,QAAO;;AAOT,SAAS,cAAc,SAAiB,OAA+B;AACrE,QAAO;EACL;EACA;EACA,WAAW;AACT,UAAO,GAAG,QAAQ,GAAG,OAAO,MAAM,CAAC,SAAS,GAAG,IAAI;;EAEtD"}
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@satianurag/hiero-mirror-client",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Standalone TypeScript client for the Hedera/Hiero Mirror Node REST API",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=18"
|
|
8
|
+
},
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./utils": {
|
|
16
|
+
"types": "./dist/utils.d.ts",
|
|
17
|
+
"import": "./dist/utils.mjs",
|
|
18
|
+
"require": "./dist/utils.cjs"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"main": "./dist/index.cjs",
|
|
22
|
+
"module": "./dist/index.mjs",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsdown",
|
|
29
|
+
"postbuild": "cp dist/index.d.mts dist/index.d.ts && cp dist/utils.d.mts dist/utils.d.ts",
|
|
30
|
+
"check": "biome check .",
|
|
31
|
+
"check:fix": "biome check --write .",
|
|
32
|
+
"typecheck": "tsc --noEmit",
|
|
33
|
+
"test": "vitest run",
|
|
34
|
+
"test:watch": "vitest",
|
|
35
|
+
"test:integration": "vitest run tests/integration/",
|
|
36
|
+
"api-report": "api-extractor run --local --verbose",
|
|
37
|
+
"api-report:ci": "api-extractor run",
|
|
38
|
+
"generate:spec": "curl -o openapi.yml https://testnet.mirrornode.hedera.com/api/v1/docs/openapi.yml",
|
|
39
|
+
"generate:types": "npx openapi-typescript openapi.yml -o src/generated/types.ts",
|
|
40
|
+
"generate": "npm run generate:spec && npm run generate:types",
|
|
41
|
+
"check:drift": "npx openapi-typescript openapi.yml -o src/generated/types.ts --check"
|
|
42
|
+
},
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "git+https://github.com/Satianurag/hiero-mirror-client.git"
|
|
46
|
+
},
|
|
47
|
+
"keywords": [
|
|
48
|
+
"hedera",
|
|
49
|
+
"hiero",
|
|
50
|
+
"mirror-node",
|
|
51
|
+
"blockchain",
|
|
52
|
+
"sdk",
|
|
53
|
+
"typescript"
|
|
54
|
+
],
|
|
55
|
+
"author": "satianurag",
|
|
56
|
+
"license": "MIT",
|
|
57
|
+
"bugs": {
|
|
58
|
+
"url": "https://github.com/Satianurag/hiero-mirror-client/issues"
|
|
59
|
+
},
|
|
60
|
+
"homepage": "https://github.com/Satianurag/hiero-mirror-client#readme",
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"lossless-json": "^4.0.2"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@biomejs/biome": "^1.9.4",
|
|
66
|
+
"@changesets/cli": "^2.28.1",
|
|
67
|
+
"@microsoft/api-extractor": "^7.52.8",
|
|
68
|
+
"openapi-typescript": "^7.6.1",
|
|
69
|
+
"tsdown": "^0.12.5",
|
|
70
|
+
"typescript": "^5.7.3",
|
|
71
|
+
"vitest": "^3.1.1"
|
|
72
|
+
}
|
|
73
|
+
}
|