@nktkas/hyperliquid 0.22.2 → 0.23.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/README.md +47 -49
- package/esm/src/base.d.ts +4 -1
- package/esm/src/base.d.ts.map +1 -1
- package/esm/src/base.js +2 -2
- package/esm/src/clients/exchange.d.ts +289 -207
- package/esm/src/clients/exchange.d.ts.map +1 -1
- package/esm/src/clients/exchange.js +605 -410
- package/esm/src/clients/info.d.ts +137 -41
- package/esm/src/clients/info.d.ts.map +1 -1
- package/esm/src/clients/info.js +124 -28
- package/esm/src/clients/multiSign.d.ts +285 -204
- package/esm/src/clients/multiSign.d.ts.map +1 -1
- package/esm/src/clients/multiSign.js +521 -493
- package/esm/src/clients/subscription.d.ts +38 -3
- package/esm/src/clients/subscription.d.ts.map +1 -1
- package/esm/src/clients/subscription.js +36 -3
- package/esm/src/signing/{_ethers.d.ts → _signTypedData/ethers.d.ts} +1 -1
- package/esm/src/signing/_signTypedData/ethers.d.ts.map +1 -0
- package/esm/src/signing/_signTypedData/mod.d.ts +35 -0
- package/esm/src/signing/_signTypedData/mod.d.ts.map +1 -0
- package/esm/src/signing/_signTypedData/mod.js +59 -0
- package/esm/src/signing/_signTypedData/private_key.d.ts +26 -0
- package/esm/src/signing/_signTypedData/private_key.d.ts.map +1 -0
- package/esm/src/signing/_signTypedData/private_key.js +144 -0
- package/esm/src/signing/{_viem.d.ts → _signTypedData/viem.d.ts} +2 -2
- package/esm/src/signing/_signTypedData/viem.d.ts.map +1 -0
- package/{script/src/signing/_window.d.ts → esm/src/signing/_signTypedData/window.d.ts} +18 -12
- package/esm/src/signing/_signTypedData/window.d.ts.map +1 -0
- package/esm/src/signing/{_window.js → _signTypedData/window.js} +3 -2
- package/esm/src/signing/_sorter.d.ts +56 -82
- package/esm/src/signing/_sorter.d.ts.map +1 -1
- package/esm/src/signing/_sorter.js +36 -49
- package/esm/src/signing/mod.d.ts +151 -130
- package/esm/src/signing/mod.d.ts.map +1 -1
- package/esm/src/signing/mod.js +182 -228
- package/esm/src/transports/base.d.ts +1 -1
- package/esm/src/transports/base.d.ts.map +1 -1
- package/esm/src/transports/base.js +2 -2
- package/esm/src/transports/http/http_transport.d.ts +9 -15
- package/esm/src/transports/http/http_transport.d.ts.map +1 -1
- package/esm/src/transports/http/http_transport.js +64 -59
- package/esm/src/transports/websocket/_hyperliquid_event_target.d.ts +1 -1
- package/esm/src/transports/websocket/_hyperliquid_event_target.d.ts.map +1 -1
- package/esm/src/transports/websocket/_hyperliquid_event_target.js +1 -1
- package/esm/src/transports/websocket/_reconnecting_websocket.d.ts.map +1 -1
- package/esm/src/transports/websocket/_reconnecting_websocket.js +17 -4
- package/esm/src/transports/websocket/_websocket_async_request.d.ts +0 -9
- package/esm/src/transports/websocket/_websocket_async_request.d.ts.map +1 -1
- package/esm/src/transports/websocket/_websocket_async_request.js +14 -20
- package/esm/src/transports/websocket/websocket_transport.d.ts +8 -4
- package/esm/src/transports/websocket/websocket_transport.d.ts.map +1 -1
- package/esm/src/transports/websocket/websocket_transport.js +83 -54
- package/esm/src/types/exchange/requests.d.ts +27 -51
- package/esm/src/types/exchange/requests.d.ts.map +1 -1
- package/esm/src/types/explorer/requests.d.ts +5 -8
- package/esm/src/types/explorer/requests.d.ts.map +1 -1
- package/esm/src/types/info/accounts.d.ts +5 -5
- package/esm/src/types/info/accounts.d.ts.map +1 -1
- package/esm/src/types/info/delegations.d.ts +1 -1
- package/esm/src/types/info/delegations.d.ts.map +1 -1
- package/esm/src/types/info/orders.d.ts +1 -1
- package/esm/src/types/info/orders.d.ts.map +1 -1
- package/esm/src/types/info/requests.d.ts +49 -96
- package/esm/src/types/info/requests.d.ts.map +1 -1
- package/esm/src/types/subscriptions/requests.d.ts +72 -18
- package/esm/src/types/subscriptions/requests.d.ts.map +1 -1
- package/esm/src/types/subscriptions/responses.d.ts +2 -0
- package/esm/src/types/subscriptions/responses.d.ts.map +1 -1
- package/package.json +8 -5
- package/script/mod.js +13 -23
- package/script/src/base.d.ts +4 -1
- package/script/src/base.d.ts.map +1 -1
- package/script/src/base.js +10 -20
- package/script/src/clients/exchange.d.ts +289 -207
- package/script/src/clients/exchange.d.ts.map +1 -1
- package/script/src/clients/exchange.js +2000 -1815
- package/script/src/clients/info.d.ts +137 -41
- package/script/src/clients/info.d.ts.map +1 -1
- package/script/src/clients/info.js +1296 -1210
- package/script/src/clients/multiSign.d.ts +285 -204
- package/script/src/clients/multiSign.d.ts.map +1 -1
- package/script/src/clients/multiSign.js +2043 -2025
- package/script/src/clients/subscription.d.ts +38 -3
- package/script/src/clients/subscription.d.ts.map +1 -1
- package/script/src/clients/subscription.js +568 -545
- package/script/src/signing/{_ethers.d.ts → _signTypedData/ethers.d.ts} +1 -1
- package/script/src/signing/_signTypedData/ethers.d.ts.map +1 -0
- package/script/src/signing/_signTypedData/ethers.js +16 -0
- package/script/src/signing/_signTypedData/mod.d.ts +35 -0
- package/script/src/signing/_signTypedData/mod.d.ts.map +1 -0
- package/script/src/signing/_signTypedData/mod.js +67 -0
- package/script/src/signing/_signTypedData/private_key.d.ts +26 -0
- package/script/src/signing/_signTypedData/private_key.d.ts.map +1 -0
- package/script/src/signing/_signTypedData/private_key.js +148 -0
- package/script/src/signing/{_viem.d.ts → _signTypedData/viem.d.ts} +2 -2
- package/script/src/signing/_signTypedData/viem.d.ts.map +1 -0
- package/script/src/signing/_signTypedData/viem.js +9 -0
- package/{esm/src/signing/_window.d.ts → script/src/signing/_signTypedData/window.d.ts} +18 -12
- package/script/src/signing/_signTypedData/window.d.ts.map +1 -0
- package/script/src/signing/_signTypedData/window.js +34 -0
- package/script/src/signing/_sorter.d.ts +56 -82
- package/script/src/signing/_sorter.d.ts.map +1 -1
- package/script/src/signing/_sorter.js +655 -678
- package/script/src/signing/mod.d.ts +151 -130
- package/script/src/signing/mod.d.ts.map +1 -1
- package/script/src/signing/mod.js +286 -342
- package/script/src/transports/base.d.ts +1 -1
- package/script/src/transports/base.d.ts.map +1 -1
- package/script/src/transports/base.js +11 -21
- package/script/src/transports/http/http_transport.d.ts +9 -15
- package/script/src/transports/http/http_transport.d.ts.map +1 -1
- package/script/src/transports/http/http_transport.js +97 -102
- package/script/src/transports/websocket/_hyperliquid_event_target.d.ts +1 -1
- package/script/src/transports/websocket/_hyperliquid_event_target.d.ts.map +1 -1
- package/script/src/transports/websocket/_hyperliquid_event_target.js +51 -61
- package/script/src/transports/websocket/_reconnecting_websocket.d.ts.map +1 -1
- package/script/src/transports/websocket/_reconnecting_websocket.js +271 -268
- package/script/src/transports/websocket/_websocket_async_request.d.ts +0 -9
- package/script/src/transports/websocket/_websocket_async_request.d.ts.map +1 -1
- package/script/src/transports/websocket/_websocket_async_request.js +157 -174
- package/script/src/transports/websocket/websocket_transport.d.ts +8 -4
- package/script/src/transports/websocket/websocket_transport.d.ts.map +1 -1
- package/script/src/transports/websocket/websocket_transport.js +209 -189
- package/script/src/types/exchange/requests.d.ts +27 -51
- package/script/src/types/exchange/requests.d.ts.map +1 -1
- package/script/src/types/exchange/requests.js +2 -12
- package/script/src/types/exchange/responses.js +2 -12
- package/script/src/types/explorer/requests.d.ts +5 -8
- package/script/src/types/explorer/requests.d.ts.map +1 -1
- package/script/src/types/explorer/requests.js +2 -12
- package/script/src/types/explorer/responses.js +2 -12
- package/script/src/types/info/accounts.d.ts +5 -5
- package/script/src/types/info/accounts.d.ts.map +1 -1
- package/script/src/types/info/accounts.js +2 -12
- package/script/src/types/info/assets.js +2 -12
- package/script/src/types/info/delegations.d.ts +1 -1
- package/script/src/types/info/delegations.d.ts.map +1 -1
- package/script/src/types/info/delegations.js +2 -12
- package/script/src/types/info/markets.js +2 -12
- package/script/src/types/info/orders.d.ts +1 -1
- package/script/src/types/info/orders.d.ts.map +1 -1
- package/script/src/types/info/orders.js +2 -12
- package/script/src/types/info/requests.d.ts +49 -96
- package/script/src/types/info/requests.d.ts.map +1 -1
- package/script/src/types/info/requests.js +2 -12
- package/script/src/types/info/vaults.js +2 -12
- package/script/src/types/mod.js +2 -12
- package/script/src/types/subscriptions/requests.d.ts +72 -18
- package/script/src/types/subscriptions/requests.d.ts.map +1 -1
- package/script/src/types/subscriptions/requests.js +2 -12
- package/script/src/types/subscriptions/responses.d.ts +2 -0
- package/script/src/types/subscriptions/responses.d.ts.map +1 -1
- package/script/src/types/subscriptions/responses.js +2 -12
- package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.d.ts +0 -2
- package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.d.ts.map +0 -1
- package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.js +0 -1
- package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.d.ts +0 -95
- package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.d.ts.map +0 -1
- package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.js +0 -10
- package/esm/deps/jsr.io/@std/async/1.0.13/delay.d.ts +0 -43
- package/esm/deps/jsr.io/@std/async/1.0.13/delay.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/async/1.0.13/delay.js +0 -63
- package/esm/deps/jsr.io/@std/bytes/1.0.6/_types.d.ts +0 -9
- package/esm/deps/jsr.io/@std/bytes/1.0.6/_types.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/bytes/1.0.6/_types.js +0 -2
- package/esm/deps/jsr.io/@std/bytes/1.0.6/concat.d.ts +0 -21
- package/esm/deps/jsr.io/@std/bytes/1.0.6/concat.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/bytes/1.0.6/concat.js +0 -32
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_common16.d.ts +0 -23
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_common16.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_common16.js +0 -51
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_common_detach.d.ts +0 -4
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_common_detach.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_common_detach.js +0 -13
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_types.d.ts +0 -9
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_types.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_types.js +0 -2
- package/esm/deps/jsr.io/@std/encoding/1.0.10/hex.d.ts +0 -39
- package/esm/deps/jsr.io/@std/encoding/1.0.10/hex.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/encoding/1.0.10/hex.js +0 -87
- package/esm/deps/jsr.io/@std/msgpack/1.0.3/_types.d.ts +0 -9
- package/esm/deps/jsr.io/@std/msgpack/1.0.3/_types.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/msgpack/1.0.3/_types.js +0 -2
- package/esm/deps/jsr.io/@std/msgpack/1.0.3/encode.d.ts +0 -39
- package/esm/deps/jsr.io/@std/msgpack/1.0.3/encode.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/msgpack/1.0.3/encode.js +0 -237
- package/esm/src/signing/_ethers.d.ts.map +0 -1
- package/esm/src/signing/_private_key.d.ts +0 -22
- package/esm/src/signing/_private_key.d.ts.map +0 -1
- package/esm/src/signing/_private_key.js +0 -124
- package/esm/src/signing/_viem.d.ts.map +0 -1
- package/esm/src/signing/_window.d.ts.map +0 -1
- package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.d.ts +0 -2
- package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.d.ts.map +0 -1
- package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.js +0 -27
- package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.d.ts +0 -95
- package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.d.ts.map +0 -1
- package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.js +0 -24
- package/script/deps/jsr.io/@std/async/1.0.13/delay.d.ts +0 -43
- package/script/deps/jsr.io/@std/async/1.0.13/delay.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/async/1.0.13/delay.js +0 -76
- package/script/deps/jsr.io/@std/bytes/1.0.6/_types.d.ts +0 -9
- package/script/deps/jsr.io/@std/bytes/1.0.6/_types.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/bytes/1.0.6/_types.js +0 -13
- package/script/deps/jsr.io/@std/bytes/1.0.6/concat.d.ts +0 -21
- package/script/deps/jsr.io/@std/bytes/1.0.6/concat.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/bytes/1.0.6/concat.js +0 -45
- package/script/deps/jsr.io/@std/encoding/1.0.10/_common16.d.ts +0 -23
- package/script/deps/jsr.io/@std/encoding/1.0.10/_common16.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/encoding/1.0.10/_common16.js +0 -67
- package/script/deps/jsr.io/@std/encoding/1.0.10/_common_detach.d.ts +0 -4
- package/script/deps/jsr.io/@std/encoding/1.0.10/_common_detach.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/encoding/1.0.10/_common_detach.js +0 -26
- package/script/deps/jsr.io/@std/encoding/1.0.10/_types.d.ts +0 -9
- package/script/deps/jsr.io/@std/encoding/1.0.10/_types.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/encoding/1.0.10/_types.js +0 -13
- package/script/deps/jsr.io/@std/encoding/1.0.10/hex.d.ts +0 -39
- package/script/deps/jsr.io/@std/encoding/1.0.10/hex.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/encoding/1.0.10/hex.js +0 -101
- package/script/deps/jsr.io/@std/msgpack/1.0.3/_types.d.ts +0 -9
- package/script/deps/jsr.io/@std/msgpack/1.0.3/_types.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/msgpack/1.0.3/_types.js +0 -13
- package/script/deps/jsr.io/@std/msgpack/1.0.3/encode.d.ts +0 -39
- package/script/deps/jsr.io/@std/msgpack/1.0.3/encode.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/msgpack/1.0.3/encode.js +0 -250
- package/script/src/signing/_ethers.d.ts.map +0 -1
- package/script/src/signing/_ethers.js +0 -26
- package/script/src/signing/_private_key.d.ts +0 -22
- package/script/src/signing/_private_key.d.ts.map +0 -1
- package/script/src/signing/_private_key.js +0 -138
- package/script/src/signing/_viem.d.ts.map +0 -1
- package/script/src/signing/_viem.js +0 -19
- package/script/src/signing/_window.d.ts.map +0 -1
- package/script/src/signing/_window.js +0 -43
- /package/esm/src/signing/{_ethers.js → _signTypedData/ethers.js} +0 -0
- /package/esm/src/signing/{_viem.js → _signTypedData/viem.js} +0 -0
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
-
// This module is browser compatible.
|
|
3
|
-
/**
|
|
4
|
-
* Concatenate an array of byte slices into a single slice.
|
|
5
|
-
*
|
|
6
|
-
* @param buffers Array of byte slices to concatenate.
|
|
7
|
-
* @returns A new byte slice containing all the input slices concatenated.
|
|
8
|
-
*
|
|
9
|
-
* @example Basic usage
|
|
10
|
-
* ```ts
|
|
11
|
-
* import { concat } from "@std/bytes/concat";
|
|
12
|
-
* import { assertEquals } from "@std/assert";
|
|
13
|
-
*
|
|
14
|
-
* const a = new Uint8Array([0, 1, 2]);
|
|
15
|
-
* const b = new Uint8Array([3, 4, 5]);
|
|
16
|
-
*
|
|
17
|
-
* assertEquals(concat([a, b]), new Uint8Array([0, 1, 2, 3, 4, 5]));
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export function concat(buffers) {
|
|
21
|
-
let length = 0;
|
|
22
|
-
for (const buffer of buffers) {
|
|
23
|
-
length += buffer.length;
|
|
24
|
-
}
|
|
25
|
-
const output = new Uint8Array(length);
|
|
26
|
-
let index = 0;
|
|
27
|
-
for (const buffer of buffers) {
|
|
28
|
-
output.set(buffer, index);
|
|
29
|
-
index += buffer.length;
|
|
30
|
-
}
|
|
31
|
-
return output;
|
|
32
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { Uint8Array_ } from "./_types.js";
|
|
2
|
-
export type { Uint8Array_ };
|
|
3
|
-
export declare const alphabet: Uint8Array;
|
|
4
|
-
export declare const rAlphabet: Uint8Array;
|
|
5
|
-
/**
|
|
6
|
-
* Calculate the output size needed to encode a given input size for
|
|
7
|
-
* {@linkcode encodeIntoHex}.
|
|
8
|
-
*
|
|
9
|
-
* @param originalSize The size of the input buffer.
|
|
10
|
-
* @returns The size of the output buffer.
|
|
11
|
-
*
|
|
12
|
-
* @example Basic Usage
|
|
13
|
-
* ```ts
|
|
14
|
-
* import { assertEquals } from "@std/assert";
|
|
15
|
-
* import { calcSizeHex } from "@std/encoding/unstable-hex";
|
|
16
|
-
*
|
|
17
|
-
* assertEquals(calcSizeHex(1), 2);
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export declare function calcSizeHex(originalSize: number): number;
|
|
21
|
-
export declare function encode(buffer: Uint8Array_, i: number, o: number, alphabet: Uint8Array): number;
|
|
22
|
-
export declare function decode(buffer: Uint8Array_, i: number, o: number, alphabet: Uint8Array): number;
|
|
23
|
-
//# sourceMappingURL=_common16.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_common16.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.10/_common16.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAE5B,eAAO,MAAM,QAAQ,YAA+C,CAAC;AACrE,eAAO,MAAM,SAAS,YAA+B,CAAC;AAMtD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,wBAAgB,MAAM,CACpB,MAAM,EAAE,WAAW,EACnB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,QAAQ,EAAE,UAAU,GACnB,MAAM,CAOR;AAED,wBAAgB,MAAM,CACpB,MAAM,EAAE,WAAW,EACnB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,QAAQ,EAAE,UAAU,GACnB,MAAM,CAeR"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
-
export const alphabet = new TextEncoder().encode("0123456789abcdef");
|
|
3
|
-
export const rAlphabet = new Uint8Array(128).fill(16); // alphabet.Hex.length
|
|
4
|
-
alphabet.forEach((byte, i) => rAlphabet[byte] = i);
|
|
5
|
-
new TextEncoder()
|
|
6
|
-
.encode("ABCDEF")
|
|
7
|
-
.forEach((byte, i) => rAlphabet[byte] = i + 10);
|
|
8
|
-
/**
|
|
9
|
-
* Calculate the output size needed to encode a given input size for
|
|
10
|
-
* {@linkcode encodeIntoHex}.
|
|
11
|
-
*
|
|
12
|
-
* @param originalSize The size of the input buffer.
|
|
13
|
-
* @returns The size of the output buffer.
|
|
14
|
-
*
|
|
15
|
-
* @example Basic Usage
|
|
16
|
-
* ```ts
|
|
17
|
-
* import { assertEquals } from "@std/assert";
|
|
18
|
-
* import { calcSizeHex } from "@std/encoding/unstable-hex";
|
|
19
|
-
*
|
|
20
|
-
* assertEquals(calcSizeHex(1), 2);
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export function calcSizeHex(originalSize) {
|
|
24
|
-
return originalSize * 2;
|
|
25
|
-
}
|
|
26
|
-
export function encode(buffer, i, o, alphabet) {
|
|
27
|
-
for (; i < buffer.length; ++i) {
|
|
28
|
-
const x = buffer[i];
|
|
29
|
-
buffer[o++] = alphabet[x >> 4];
|
|
30
|
-
buffer[o++] = alphabet[x & 0xF];
|
|
31
|
-
}
|
|
32
|
-
return o;
|
|
33
|
-
}
|
|
34
|
-
export function decode(buffer, i, o, alphabet) {
|
|
35
|
-
if ((buffer.length - o) % 2 === 1) {
|
|
36
|
-
throw new RangeError(`Cannot decode input as hex: Length (${buffer.length - o}) must be divisible by 2`);
|
|
37
|
-
}
|
|
38
|
-
i += 1;
|
|
39
|
-
for (; i < buffer.length; i += 2) {
|
|
40
|
-
buffer[o++] = (getByte(buffer[i - 1], alphabet) << 4) |
|
|
41
|
-
getByte(buffer[i], alphabet);
|
|
42
|
-
}
|
|
43
|
-
return o;
|
|
44
|
-
}
|
|
45
|
-
function getByte(char, alphabet) {
|
|
46
|
-
const byte = alphabet[char] ?? 16;
|
|
47
|
-
if (byte === 16) { // alphabet.Hex.length
|
|
48
|
-
throw new TypeError(`Cannot decode input as hex: Invalid character (${String.fromCharCode(char)})`);
|
|
49
|
-
}
|
|
50
|
-
return byte;
|
|
51
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_common_detach.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.10/_common_detach.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAE5B,wBAAgB,MAAM,CACpB,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,MAAM,GACd,CAAC,WAAW,EAAE,MAAM,CAAC,CAWvB"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
-
export function detach(buffer, maxSize) {
|
|
3
|
-
const originalSize = buffer.length;
|
|
4
|
-
if (buffer.byteOffset) {
|
|
5
|
-
const b = new Uint8Array(buffer.buffer);
|
|
6
|
-
b.set(buffer);
|
|
7
|
-
buffer = b.subarray(0, originalSize);
|
|
8
|
-
}
|
|
9
|
-
// deno-lint-ignore no-explicit-any
|
|
10
|
-
buffer = new Uint8Array(buffer.buffer.transfer(maxSize));
|
|
11
|
-
buffer.set(buffer.subarray(0, originalSize), maxSize - originalSize);
|
|
12
|
-
return [buffer, maxSize - originalSize];
|
|
13
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Proxy type of {@code Uint8Array<ArrayBuffer} or {@code Uint8Array} in TypeScript 5.7 or below respectively.
|
|
3
|
-
*
|
|
4
|
-
* This type is internal utility type and should not be used directly.
|
|
5
|
-
*
|
|
6
|
-
* @internal @private
|
|
7
|
-
*/
|
|
8
|
-
export type Uint8Array_ = ReturnType<Uint8Array["slice"]>;
|
|
9
|
-
//# sourceMappingURL=_types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_types.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.10/_types.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { Uint8Array_ } from "./_types.js";
|
|
2
|
-
export type { Uint8Array_ };
|
|
3
|
-
/**
|
|
4
|
-
* Converts data into a hex-encoded string.
|
|
5
|
-
*
|
|
6
|
-
* @param src The data to encode.
|
|
7
|
-
*
|
|
8
|
-
* @returns The hex-encoded string.
|
|
9
|
-
*
|
|
10
|
-
* @example Usage
|
|
11
|
-
* ```ts
|
|
12
|
-
* import { encodeHex } from "@std/encoding/hex";
|
|
13
|
-
* import { assertEquals } from "@std/assert";
|
|
14
|
-
*
|
|
15
|
-
* assertEquals(encodeHex("abc"), "616263");
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export declare function encodeHex(src: string | Uint8Array | ArrayBuffer): string;
|
|
19
|
-
/**
|
|
20
|
-
* Decodes the given hex-encoded string. If the input is malformed, an error is
|
|
21
|
-
* thrown.
|
|
22
|
-
*
|
|
23
|
-
* @param src The hex-encoded string to decode.
|
|
24
|
-
*
|
|
25
|
-
* @returns The decoded data.
|
|
26
|
-
*
|
|
27
|
-
* @example Usage
|
|
28
|
-
* ```ts
|
|
29
|
-
* import { decodeHex } from "@std/encoding/hex";
|
|
30
|
-
* import { assertEquals } from "@std/assert";
|
|
31
|
-
*
|
|
32
|
-
* assertEquals(
|
|
33
|
-
* decodeHex("616263"),
|
|
34
|
-
* new TextEncoder().encode("abc"),
|
|
35
|
-
* );
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export declare function decodeHex(src: string): Uint8Array_;
|
|
39
|
-
//# sourceMappingURL=hex.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.10/hex.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAU5B;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,MAAM,CAWxE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAKlD"}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
// Copyright 2009 The Go Authors. All rights reserved.
|
|
2
|
-
// https://github.com/golang/go/blob/master/LICENSE
|
|
3
|
-
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
4
|
-
// This module is browser compatible.
|
|
5
|
-
/**
|
|
6
|
-
* Port of the Go
|
|
7
|
-
* {@link https://github.com/golang/go/blob/go1.12.5/src/encoding/hex/hex.go | encoding/hex}
|
|
8
|
-
* library.
|
|
9
|
-
*
|
|
10
|
-
* ```ts
|
|
11
|
-
* import {
|
|
12
|
-
* decodeHex,
|
|
13
|
-
* encodeHex,
|
|
14
|
-
* } from "@std/encoding/hex";
|
|
15
|
-
* import { assertEquals } from "@std/assert";
|
|
16
|
-
*
|
|
17
|
-
* assertEquals(encodeHex("abc"), "616263");
|
|
18
|
-
*
|
|
19
|
-
* assertEquals(
|
|
20
|
-
* decodeHex("616263"),
|
|
21
|
-
* new TextEncoder().encode("abc"),
|
|
22
|
-
* );
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
* @module
|
|
26
|
-
*/
|
|
27
|
-
import { calcSizeHex, decode, encode } from "./_common16.js";
|
|
28
|
-
import { detach } from "./_common_detach.js";
|
|
29
|
-
const alphabet = new TextEncoder()
|
|
30
|
-
.encode("0123456789abcdef");
|
|
31
|
-
const rAlphabet = new Uint8Array(128).fill(16); // alphabet.length
|
|
32
|
-
alphabet.forEach((byte, i) => rAlphabet[byte] = i);
|
|
33
|
-
new TextEncoder()
|
|
34
|
-
.encode("ABCDEF")
|
|
35
|
-
.forEach((byte, i) => rAlphabet[byte] = i + 10);
|
|
36
|
-
/**
|
|
37
|
-
* Converts data into a hex-encoded string.
|
|
38
|
-
*
|
|
39
|
-
* @param src The data to encode.
|
|
40
|
-
*
|
|
41
|
-
* @returns The hex-encoded string.
|
|
42
|
-
*
|
|
43
|
-
* @example Usage
|
|
44
|
-
* ```ts
|
|
45
|
-
* import { encodeHex } from "@std/encoding/hex";
|
|
46
|
-
* import { assertEquals } from "@std/assert";
|
|
47
|
-
*
|
|
48
|
-
* assertEquals(encodeHex("abc"), "616263");
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
export function encodeHex(src) {
|
|
52
|
-
if (typeof src === "string") {
|
|
53
|
-
src = new TextEncoder().encode(src);
|
|
54
|
-
}
|
|
55
|
-
else if (src instanceof ArrayBuffer)
|
|
56
|
-
src = new Uint8Array(src).slice();
|
|
57
|
-
else
|
|
58
|
-
src = src.slice();
|
|
59
|
-
const [output, i] = detach(src, calcSizeHex(src.length));
|
|
60
|
-
encode(output, i, 0, alphabet);
|
|
61
|
-
return new TextDecoder().decode(output);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Decodes the given hex-encoded string. If the input is malformed, an error is
|
|
65
|
-
* thrown.
|
|
66
|
-
*
|
|
67
|
-
* @param src The hex-encoded string to decode.
|
|
68
|
-
*
|
|
69
|
-
* @returns The decoded data.
|
|
70
|
-
*
|
|
71
|
-
* @example Usage
|
|
72
|
-
* ```ts
|
|
73
|
-
* import { decodeHex } from "@std/encoding/hex";
|
|
74
|
-
* import { assertEquals } from "@std/assert";
|
|
75
|
-
*
|
|
76
|
-
* assertEquals(
|
|
77
|
-
* decodeHex("616263"),
|
|
78
|
-
* new TextEncoder().encode("abc"),
|
|
79
|
-
* );
|
|
80
|
-
* ```
|
|
81
|
-
*/
|
|
82
|
-
export function decodeHex(src) {
|
|
83
|
-
const output = new TextEncoder().encode(src);
|
|
84
|
-
// deno-lint-ignore no-explicit-any
|
|
85
|
-
return new Uint8Array(output.buffer
|
|
86
|
-
.transfer(decode(output, 0, 0, rAlphabet)));
|
|
87
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Proxy type of {@code Uint8Array<ArrayBuffer} or {@code Uint8Array} in TypeScript 5.7 or below respectively.
|
|
3
|
-
*
|
|
4
|
-
* This type is internal utility type and should not be used directly.
|
|
5
|
-
*
|
|
6
|
-
* @internal @private
|
|
7
|
-
*/
|
|
8
|
-
export type Uint8Array_ = ReturnType<Uint8Array["slice"]>;
|
|
9
|
-
//# sourceMappingURL=_types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_types.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/msgpack/1.0.3/_types.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { Uint8Array_ } from "./_types.js";
|
|
2
|
-
export type { Uint8Array_ };
|
|
3
|
-
/**
|
|
4
|
-
* Value types that can be encoded to MessagePack.
|
|
5
|
-
*/
|
|
6
|
-
export type ValueType = number | bigint | string | boolean | null | Uint8Array | readonly ValueType[] | ValueMap;
|
|
7
|
-
/**
|
|
8
|
-
* Value map that can be encoded to MessagePack.
|
|
9
|
-
*/
|
|
10
|
-
export interface ValueMap {
|
|
11
|
-
/** Value map entry */
|
|
12
|
-
[index: string | number]: ValueType;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Encode a value to {@link https://msgpack.org/ | MessagePack} binary format.
|
|
16
|
-
*
|
|
17
|
-
* @example Usage
|
|
18
|
-
* ```ts
|
|
19
|
-
* import { encode } from "@std/msgpack/encode";
|
|
20
|
-
* import { assertEquals } from "@std/assert";
|
|
21
|
-
*
|
|
22
|
-
* const obj = {
|
|
23
|
-
* str: "deno",
|
|
24
|
-
* arr: [1, 2, 3],
|
|
25
|
-
* map: {
|
|
26
|
-
* foo: "bar"
|
|
27
|
-
* }
|
|
28
|
-
* }
|
|
29
|
-
*
|
|
30
|
-
* const encoded = encode(obj);
|
|
31
|
-
*
|
|
32
|
-
* assertEquals(encoded.length, 31);
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
35
|
-
* @param object Value to encode to MessagePack binary format.
|
|
36
|
-
* @returns Encoded MessagePack binary data.
|
|
37
|
-
*/
|
|
38
|
-
export declare function encode(object: ValueType): Uint8Array_;
|
|
39
|
-
//# sourceMappingURL=encode.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/msgpack/1.0.3/encode.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAE5B;;GAEG;AACH,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,UAAU,GACV,SAAS,SAAS,EAAE,GACpB,QAAQ,CAAC;AAEb;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,sBAAsB;IACtB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACrC;AAeD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,WAAW,CAIrD"}
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
-
// This module is browser compatible.
|
|
3
|
-
import { concat } from "../../bytes/1.0.6/concat.js";
|
|
4
|
-
const FOUR_BITS = 16;
|
|
5
|
-
const FIVE_BITS = 32;
|
|
6
|
-
const SEVEN_BITS = 128;
|
|
7
|
-
const EIGHT_BITS = 256;
|
|
8
|
-
const FIFTEEN_BITS = 32768;
|
|
9
|
-
const SIXTEEN_BITS = 65536;
|
|
10
|
-
const THIRTY_ONE_BITS = 2147483648;
|
|
11
|
-
const THIRTY_TWO_BITS = 4294967296;
|
|
12
|
-
const SIXTY_THREE_BITS = 9223372036854775808n;
|
|
13
|
-
const SIXTY_FOUR_BITS = 18446744073709551616n;
|
|
14
|
-
const encoder = new TextEncoder();
|
|
15
|
-
/**
|
|
16
|
-
* Encode a value to {@link https://msgpack.org/ | MessagePack} binary format.
|
|
17
|
-
*
|
|
18
|
-
* @example Usage
|
|
19
|
-
* ```ts
|
|
20
|
-
* import { encode } from "@std/msgpack/encode";
|
|
21
|
-
* import { assertEquals } from "@std/assert";
|
|
22
|
-
*
|
|
23
|
-
* const obj = {
|
|
24
|
-
* str: "deno",
|
|
25
|
-
* arr: [1, 2, 3],
|
|
26
|
-
* map: {
|
|
27
|
-
* foo: "bar"
|
|
28
|
-
* }
|
|
29
|
-
* }
|
|
30
|
-
*
|
|
31
|
-
* const encoded = encode(obj);
|
|
32
|
-
*
|
|
33
|
-
* assertEquals(encoded.length, 31);
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* @param object Value to encode to MessagePack binary format.
|
|
37
|
-
* @returns Encoded MessagePack binary data.
|
|
38
|
-
*/
|
|
39
|
-
export function encode(object) {
|
|
40
|
-
const byteParts = [];
|
|
41
|
-
encodeSlice(object, byteParts);
|
|
42
|
-
return concat(byteParts);
|
|
43
|
-
}
|
|
44
|
-
function encodeFloat64(num) {
|
|
45
|
-
const dataView = new DataView(new ArrayBuffer(9));
|
|
46
|
-
dataView.setFloat64(1, num);
|
|
47
|
-
dataView.setUint8(0, 0xcb);
|
|
48
|
-
return new Uint8Array(dataView.buffer);
|
|
49
|
-
}
|
|
50
|
-
function encodeNumber(num) {
|
|
51
|
-
if (!Number.isInteger(num)) { // float 64
|
|
52
|
-
return encodeFloat64(num);
|
|
53
|
-
}
|
|
54
|
-
if (num < 0) {
|
|
55
|
-
if (num >= -FIVE_BITS) { // negative fixint
|
|
56
|
-
return new Uint8Array([num]);
|
|
57
|
-
}
|
|
58
|
-
if (num >= -SEVEN_BITS) { // int 8
|
|
59
|
-
return new Uint8Array([0xd0, num]);
|
|
60
|
-
}
|
|
61
|
-
if (num >= -FIFTEEN_BITS) { // int 16
|
|
62
|
-
const dataView = new DataView(new ArrayBuffer(3));
|
|
63
|
-
dataView.setInt16(1, num);
|
|
64
|
-
dataView.setUint8(0, 0xd1);
|
|
65
|
-
return new Uint8Array(dataView.buffer);
|
|
66
|
-
}
|
|
67
|
-
if (num >= -THIRTY_ONE_BITS) { // int 32
|
|
68
|
-
const dataView = new DataView(new ArrayBuffer(5));
|
|
69
|
-
dataView.setInt32(1, num);
|
|
70
|
-
dataView.setUint8(0, 0xd2);
|
|
71
|
-
return new Uint8Array(dataView.buffer);
|
|
72
|
-
}
|
|
73
|
-
// float 64
|
|
74
|
-
return encodeFloat64(num);
|
|
75
|
-
}
|
|
76
|
-
// if the number fits within a positive fixint, use it
|
|
77
|
-
if (num <= 0x7f) {
|
|
78
|
-
return new Uint8Array([num]);
|
|
79
|
-
}
|
|
80
|
-
if (num < EIGHT_BITS) { // uint8
|
|
81
|
-
return new Uint8Array([0xcc, num]);
|
|
82
|
-
}
|
|
83
|
-
if (num < SIXTEEN_BITS) { // uint16
|
|
84
|
-
const dataView = new DataView(new ArrayBuffer(3));
|
|
85
|
-
dataView.setUint16(1, num);
|
|
86
|
-
dataView.setUint8(0, 0xcd);
|
|
87
|
-
return new Uint8Array(dataView.buffer);
|
|
88
|
-
}
|
|
89
|
-
if (num < THIRTY_TWO_BITS) { // uint32
|
|
90
|
-
const dataView = new DataView(new ArrayBuffer(5));
|
|
91
|
-
dataView.setUint32(1, num);
|
|
92
|
-
dataView.setUint8(0, 0xce);
|
|
93
|
-
return new Uint8Array(dataView.buffer);
|
|
94
|
-
}
|
|
95
|
-
// float 64
|
|
96
|
-
return encodeFloat64(num);
|
|
97
|
-
}
|
|
98
|
-
function encodeSlice(object, byteParts) {
|
|
99
|
-
if (object === null) {
|
|
100
|
-
byteParts.push(new Uint8Array([0xc0]));
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
if (object === false) {
|
|
104
|
-
byteParts.push(new Uint8Array([0xc2]));
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
if (object === true) {
|
|
108
|
-
byteParts.push(new Uint8Array([0xc3]));
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
if (typeof object === "number") {
|
|
112
|
-
byteParts.push(encodeNumber(object));
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
if (typeof object === "bigint") {
|
|
116
|
-
if (object < 0) {
|
|
117
|
-
if (object < -SIXTY_THREE_BITS) {
|
|
118
|
-
throw new Error("Cannot safely encode bigint larger than 64 bits");
|
|
119
|
-
}
|
|
120
|
-
const dataView = new DataView(new ArrayBuffer(9));
|
|
121
|
-
dataView.setBigInt64(1, object);
|
|
122
|
-
dataView.setUint8(0, 0xd3);
|
|
123
|
-
byteParts.push(new Uint8Array(dataView.buffer));
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
if (object >= SIXTY_FOUR_BITS) {
|
|
127
|
-
throw new Error("Cannot safely encode bigint larger than 64 bits");
|
|
128
|
-
}
|
|
129
|
-
const dataView = new DataView(new ArrayBuffer(9));
|
|
130
|
-
dataView.setBigUint64(1, object);
|
|
131
|
-
dataView.setUint8(0, 0xcf);
|
|
132
|
-
byteParts.push(new Uint8Array(dataView.buffer));
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
if (typeof object === "string") {
|
|
136
|
-
const encoded = encoder.encode(object);
|
|
137
|
-
const len = encoded.length;
|
|
138
|
-
if (len < FIVE_BITS) { // fixstr
|
|
139
|
-
byteParts.push(new Uint8Array([0xa0 | len]));
|
|
140
|
-
}
|
|
141
|
-
else if (len < EIGHT_BITS) { // str 8
|
|
142
|
-
byteParts.push(new Uint8Array([0xd9, len]));
|
|
143
|
-
}
|
|
144
|
-
else if (len < SIXTEEN_BITS) { // str 16
|
|
145
|
-
const dataView = new DataView(new ArrayBuffer(3));
|
|
146
|
-
dataView.setUint16(1, len);
|
|
147
|
-
dataView.setUint8(0, 0xda);
|
|
148
|
-
byteParts.push(new Uint8Array(dataView.buffer));
|
|
149
|
-
}
|
|
150
|
-
else if (len < THIRTY_TWO_BITS) { // str 32
|
|
151
|
-
const dataView = new DataView(new ArrayBuffer(5));
|
|
152
|
-
dataView.setUint32(1, len);
|
|
153
|
-
dataView.setUint8(0, 0xdb);
|
|
154
|
-
byteParts.push(new Uint8Array(dataView.buffer));
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
throw new Error("Cannot safely encode string with size larger than 32 bits");
|
|
158
|
-
}
|
|
159
|
-
byteParts.push(encoded);
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
if (object instanceof Uint8Array) {
|
|
163
|
-
if (object.length < EIGHT_BITS) { // bin 8
|
|
164
|
-
byteParts.push(new Uint8Array([0xc4, object.length]));
|
|
165
|
-
}
|
|
166
|
-
else if (object.length < SIXTEEN_BITS) { // bin 16
|
|
167
|
-
const dataView = new DataView(new ArrayBuffer(3));
|
|
168
|
-
dataView.setUint16(1, object.length);
|
|
169
|
-
dataView.setUint8(0, 0xc5);
|
|
170
|
-
byteParts.push(new Uint8Array(dataView.buffer));
|
|
171
|
-
}
|
|
172
|
-
else if (object.length < THIRTY_TWO_BITS) { // bin 32
|
|
173
|
-
const dataView = new DataView(new ArrayBuffer(5));
|
|
174
|
-
dataView.setUint32(1, object.length);
|
|
175
|
-
dataView.setUint8(0, 0xc6);
|
|
176
|
-
byteParts.push(new Uint8Array(dataView.buffer));
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
throw new Error("Cannot safely encode Uint8Array with size larger than 32 bits");
|
|
180
|
-
}
|
|
181
|
-
byteParts.push(object);
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
if (Array.isArray(object)) {
|
|
185
|
-
if (object.length < FOUR_BITS) { // fixarray
|
|
186
|
-
byteParts.push(new Uint8Array([0x90 | object.length]));
|
|
187
|
-
}
|
|
188
|
-
else if (object.length < SIXTEEN_BITS) { // array 16
|
|
189
|
-
const dataView = new DataView(new ArrayBuffer(3));
|
|
190
|
-
dataView.setUint16(1, object.length);
|
|
191
|
-
dataView.setUint8(0, 0xdc);
|
|
192
|
-
byteParts.push(new Uint8Array(dataView.buffer));
|
|
193
|
-
}
|
|
194
|
-
else if (object.length < THIRTY_TWO_BITS) { // array 32
|
|
195
|
-
const dataView = new DataView(new ArrayBuffer(5));
|
|
196
|
-
dataView.setUint32(1, object.length);
|
|
197
|
-
dataView.setUint8(0, 0xdd);
|
|
198
|
-
byteParts.push(new Uint8Array(dataView.buffer));
|
|
199
|
-
}
|
|
200
|
-
else {
|
|
201
|
-
throw new Error("Cannot safely encode array with size larger than 32 bits");
|
|
202
|
-
}
|
|
203
|
-
for (const obj of object) {
|
|
204
|
-
encodeSlice(obj, byteParts);
|
|
205
|
-
}
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
// If object is a plain object
|
|
209
|
-
const prototype = Object.getPrototypeOf(object);
|
|
210
|
-
if (prototype === null || prototype === Object.prototype) {
|
|
211
|
-
const numKeys = Object.keys(object).length;
|
|
212
|
-
if (numKeys < FOUR_BITS) { // fixarray
|
|
213
|
-
byteParts.push(new Uint8Array([0x80 | numKeys]));
|
|
214
|
-
}
|
|
215
|
-
else if (numKeys < SIXTEEN_BITS) { // map 16
|
|
216
|
-
const dataView = new DataView(new ArrayBuffer(3));
|
|
217
|
-
dataView.setUint16(1, numKeys);
|
|
218
|
-
dataView.setUint8(0, 0xde);
|
|
219
|
-
byteParts.push(new Uint8Array(dataView.buffer));
|
|
220
|
-
}
|
|
221
|
-
else if (numKeys < THIRTY_TWO_BITS) { // map 32
|
|
222
|
-
const dataView = new DataView(new ArrayBuffer(5));
|
|
223
|
-
dataView.setUint32(1, numKeys);
|
|
224
|
-
dataView.setUint8(0, 0xdf);
|
|
225
|
-
byteParts.push(new Uint8Array(dataView.buffer));
|
|
226
|
-
}
|
|
227
|
-
else {
|
|
228
|
-
throw new Error("Cannot safely encode map with size larger than 32 bits");
|
|
229
|
-
}
|
|
230
|
-
for (const [key, value] of Object.entries(object)) {
|
|
231
|
-
encodeSlice(key, byteParts);
|
|
232
|
-
encodeSlice(value, byteParts);
|
|
233
|
-
}
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
throw new Error("Cannot safely encode value into messagepack");
|
|
237
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_ethers.d.ts","sourceRoot":"","sources":["../../../src/src/signing/_ethers.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,MAAM,WAAW,oBAAoB;IACjC,aAAa,CACT,MAAM,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,iBAAiB,EAAE,MAAM,CAAC;KAC7B,EACD,KAAK,EAAE;QACH,CAAC,GAAG,EAAE,MAAM,GAAG;YACX,IAAI,EAAE,MAAM,CAAC;YACb,IAAI,EAAE,MAAM,CAAC;SAChB,EAAE,CAAC;KACP,EACD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,MAAM,CAAC,CAAC;CACtB;AAED,+FAA+F;AAC/F,MAAM,WAAW,sBAAsB;IACnC,cAAc,CACV,MAAM,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,iBAAiB,EAAE,MAAM,CAAC;KAC7B,EACD,KAAK,EAAE;QACH,CAAC,GAAG,EAAE,MAAM,GAAG;YACX,IAAI,EAAE,MAAM,CAAC;YACb,IAAI,EAAE,MAAM,CAAC;SAChB,EAAE,CAAC;KACP,EACD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,MAAM,CAAC,CAAC;CACtB;AAED,8DAA8D;AAC9D,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,oBAAoB,CAItF;AAED,iEAAiE;AACjE,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,sBAAsB,CAI1F"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { Hex } from "../base.js";
|
|
2
|
-
/** Signs typed data (EIP-712) with a private key. */
|
|
3
|
-
export declare function signTypedDataWithPrivateKey(args: {
|
|
4
|
-
privateKey: string;
|
|
5
|
-
domain: {
|
|
6
|
-
name: string;
|
|
7
|
-
version: string;
|
|
8
|
-
chainId: number;
|
|
9
|
-
verifyingContract: Hex;
|
|
10
|
-
};
|
|
11
|
-
types: {
|
|
12
|
-
[key: string]: {
|
|
13
|
-
name: string;
|
|
14
|
-
type: string;
|
|
15
|
-
}[];
|
|
16
|
-
};
|
|
17
|
-
primaryType: string;
|
|
18
|
-
message: Record<string, unknown>;
|
|
19
|
-
}): Promise<Hex>;
|
|
20
|
-
/** Validates if a string is a valid secp256k1 private key. */
|
|
21
|
-
export declare function isValidPrivateKey(privateKey: unknown): privateKey is string;
|
|
22
|
-
//# sourceMappingURL=_private_key.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_private_key.d.ts","sourceRoot":"","sources":["../../../src/src/signing/_private_key.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,qDAAqD;AACrD,wBAAsB,2BAA2B,CAAC,IAAI,EAAE;IACpD,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,iBAAiB,EAAE,GAAG,CAAC;KAC1B,CAAC;IACF,KAAK,EAAE;QACH,CAAC,GAAG,EAAE,MAAM,GAAG;YACX,IAAI,EAAE,MAAM,CAAC;YACb,IAAI,EAAE,MAAM,CAAC;SAChB,EAAE,CAAC;KACP,CAAC;IACF,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,GAAG,OAAO,CAAC,GAAG,CAAC,CAiCf;AA8GD,8DAA8D;AAC9D,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,OAAO,GAAG,UAAU,IAAI,MAAM,CAQ3E"}
|