@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,124 +0,0 @@
|
|
|
1
|
-
import { keccak_256 } from "@noble/hashes/sha3";
|
|
2
|
-
import { CURVE, signAsync as secp256k1 } from "@noble/secp256k1";
|
|
3
|
-
import { decodeHex } from "../../deps/jsr.io/@std/encoding/1.0.10/hex.js";
|
|
4
|
-
import { concat as concatBytes } from "../../deps/jsr.io/@std/bytes/1.0.6/concat.js";
|
|
5
|
-
/** Signs typed data (EIP-712) with a private key. */
|
|
6
|
-
export async function signTypedDataWithPrivateKey(args) {
|
|
7
|
-
const { privateKey, domain, types, primaryType, message } = args;
|
|
8
|
-
// 1. Create a complete set of types, including EIP712Domain
|
|
9
|
-
const fullTypes = {
|
|
10
|
-
EIP712Domain: [
|
|
11
|
-
{ name: "name", type: "string" },
|
|
12
|
-
{ name: "version", type: "string" },
|
|
13
|
-
{ name: "chainId", type: "uint256" },
|
|
14
|
-
{ name: "verifyingContract", type: "address" },
|
|
15
|
-
],
|
|
16
|
-
...types,
|
|
17
|
-
};
|
|
18
|
-
// 2. Calculate `domainSeparator`
|
|
19
|
-
const domainSeparator = hashStruct("EIP712Domain", domain, fullTypes);
|
|
20
|
-
// 3. Calculate the message hash
|
|
21
|
-
const messageHash = hashStruct(primaryType, message, fullTypes);
|
|
22
|
-
// 4. Forming the final hash
|
|
23
|
-
const finalHash = keccak_256(concatBytes([new Uint8Array([0x19, 0x01]), domainSeparator, messageHash]));
|
|
24
|
-
// 5. Sign the final hash
|
|
25
|
-
const cleanPrivateKey = privateKey.startsWith("0x") ? privateKey.slice(2) : privateKey;
|
|
26
|
-
const signature = await secp256k1(finalHash, cleanPrivateKey);
|
|
27
|
-
// 6. Format the signature
|
|
28
|
-
const r = signature.r.toString(16).padStart(64, "0");
|
|
29
|
-
const s = signature.s.toString(16).padStart(64, "0");
|
|
30
|
-
const v = (signature.recovery + 27).toString(16).padStart(2, "0");
|
|
31
|
-
return `0x${r}${s}${v}`;
|
|
32
|
-
}
|
|
33
|
-
/** Finds all dependent structure types for a given type. */
|
|
34
|
-
function findTypeDependencies(primaryType, types, found = new Set()) {
|
|
35
|
-
if (found.has(primaryType) || !types[primaryType]) {
|
|
36
|
-
return [];
|
|
37
|
-
}
|
|
38
|
-
found.add(primaryType);
|
|
39
|
-
for (const field of types[primaryType]) {
|
|
40
|
-
const baseType = field.type.replace(/\[\]$/, "");
|
|
41
|
-
if (types[baseType]) {
|
|
42
|
-
findTypeDependencies(baseType, types, found);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return Array.from(found);
|
|
46
|
-
}
|
|
47
|
-
/** Encodes the type definition into a string according to EIP-712. */
|
|
48
|
-
function encodeType(primaryType, types) {
|
|
49
|
-
const deps = findTypeDependencies(primaryType, types);
|
|
50
|
-
const sortedDeps = [primaryType, ...deps.filter((d) => d !== primaryType).sort()];
|
|
51
|
-
return sortedDeps
|
|
52
|
-
.map((type) => `${type}(${types[type].map((field) => `${field.type} ${field.name}`).join(",")})`)
|
|
53
|
-
.join("");
|
|
54
|
-
}
|
|
55
|
-
/** Encodes a single value into a 32-byte Uint8Array according to EIP-712 rules. */
|
|
56
|
-
function encodeValue(type, value, allTypes) {
|
|
57
|
-
if (type.endsWith("[]")) {
|
|
58
|
-
if (!Array.isArray(value)) {
|
|
59
|
-
throw new Error(`Expected array for type ${type}, but got ${typeof value}`);
|
|
60
|
-
}
|
|
61
|
-
const baseType = type.slice(0, -2);
|
|
62
|
-
const encodedElements = value.map((item) => encodeValue(baseType, item, allTypes));
|
|
63
|
-
return keccak_256(concatBytes(encodedElements));
|
|
64
|
-
}
|
|
65
|
-
if (allTypes[type]) {
|
|
66
|
-
return hashStruct(type, value, allTypes);
|
|
67
|
-
}
|
|
68
|
-
if (type === "string") {
|
|
69
|
-
return keccak_256(new TextEncoder().encode(value));
|
|
70
|
-
}
|
|
71
|
-
if (type === "bytes") {
|
|
72
|
-
return keccak_256(value);
|
|
73
|
-
}
|
|
74
|
-
if (type === "bytes32") {
|
|
75
|
-
return decodeHex(value.slice(2).padStart(64, "0"));
|
|
76
|
-
}
|
|
77
|
-
if (type === "address") {
|
|
78
|
-
const padded = new Uint8Array(32);
|
|
79
|
-
padded.set(decodeHex(value.slice(2)), 12);
|
|
80
|
-
return padded;
|
|
81
|
-
}
|
|
82
|
-
if (type.startsWith("uint") || type.startsWith("int")) {
|
|
83
|
-
const bigIntValue = BigInt(value);
|
|
84
|
-
const bits = parseInt(type.slice(type.startsWith("u") ? 4 : 3) || "256", 10);
|
|
85
|
-
const signedValue = type.startsWith("int")
|
|
86
|
-
? BigInt.asIntN(bits, bigIntValue)
|
|
87
|
-
: BigInt.asUintN(bits, bigIntValue);
|
|
88
|
-
let hex = signedValue.toString(16);
|
|
89
|
-
if (hex.length % 2)
|
|
90
|
-
hex = "0" + hex;
|
|
91
|
-
if (signedValue < 0) {
|
|
92
|
-
while (hex.length < 64)
|
|
93
|
-
hex = "f" + hex;
|
|
94
|
-
hex = hex.slice(-64);
|
|
95
|
-
}
|
|
96
|
-
const bytes = decodeHex(hex);
|
|
97
|
-
const result = new Uint8Array(32).fill(0);
|
|
98
|
-
result.set(bytes, 32 - bytes.length);
|
|
99
|
-
return result;
|
|
100
|
-
}
|
|
101
|
-
if (type === "bool") {
|
|
102
|
-
const result = new Uint8Array(32);
|
|
103
|
-
result[31] = value ? 1 : 0;
|
|
104
|
-
return result;
|
|
105
|
-
}
|
|
106
|
-
throw new Error(`Unsupported type: ${type}`);
|
|
107
|
-
}
|
|
108
|
-
/** Hashes a data structure according to EIP-712. */
|
|
109
|
-
function hashStruct(primaryType, data, types) {
|
|
110
|
-
const typeHash = keccak_256(new TextEncoder().encode(encodeType(primaryType, types)));
|
|
111
|
-
const fields = types[primaryType];
|
|
112
|
-
const encodedValues = fields.map((field) => encodeValue(field.type, data[field.name], types));
|
|
113
|
-
return keccak_256(concatBytes([typeHash, ...encodedValues]));
|
|
114
|
-
}
|
|
115
|
-
/** Validates if a string is a valid secp256k1 private key. */
|
|
116
|
-
export function isValidPrivateKey(privateKey) {
|
|
117
|
-
if (typeof privateKey !== "string")
|
|
118
|
-
return false;
|
|
119
|
-
const cleanKey = privateKey.startsWith("0x") ? privateKey.slice(2) : privateKey;
|
|
120
|
-
if (cleanKey.length !== 64 || !/^[0-9a-fA-F]+$/.test(cleanKey))
|
|
121
|
-
return false;
|
|
122
|
-
const keyBigInt = BigInt("0x" + cleanKey);
|
|
123
|
-
return keyBigInt > 0n && keyBigInt < CURVE.n;
|
|
124
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_viem.d.ts","sourceRoot":"","sources":["../../../src/src/signing/_viem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,mFAAmF;AACnF,MAAM,WAAW,wBAAwB;IACrC,aAAa,CACT,MAAM,EAAE;QACJ,MAAM,EAAE;YACJ,IAAI,EAAE,MAAM,CAAC;YACb,OAAO,EAAE,MAAM,CAAC;YAChB,OAAO,EAAE,MAAM,CAAC;YAChB,iBAAiB,EAAE,GAAG,CAAC;SAC1B,CAAC;QACF,KAAK,EAAE;YACH,CAAC,GAAG,EAAE,MAAM,GAAG;gBACX,IAAI,EAAE,MAAM,CAAC;gBACb,IAAI,EAAE,MAAM,CAAC;aAChB,EAAE,CAAC;SACP,CAAC;QACF,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACpC,EACD,OAAO,CAAC,EAAE,OAAO,GAClB,OAAO,CAAC,GAAG,CAAC,CAAC;CACnB;AAED,4DAA4D;AAC5D,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,wBAAwB,CAI9F"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_window.d.ts","sourceRoot":"","sources":["../../../src/src/signing/_window.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,kGAAkG;AAClG,MAAM,WAAW,sBAAsB;IAEnC,OAAO,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,GAAG,CAAC;QAAC,MAAM,EAAE,GAAG,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;CAC7D;AAED,iGAAiG;AACjG,wBAAsB,+BAA+B,CACjD,QAAQ,EAAE,sBAAsB,EAChC,MAAM,EAAE;IACJ,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,GAAG,CAAC;CAC1B,EACD,KAAK,EAAE;IACH,CAAC,GAAG,EAAE,MAAM,GAAG;QACX,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KAChB,EAAE,CAAC;CACP,EACD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,OAAO,CAAC,GAAG,CAAC,CAsBd;AAED,yEAAyE;AACzE,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,sBAAsB,CAI1F"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
|
-
if (k2 === undefined) k2 = k;
|
|
3
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
5
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
6
|
-
}
|
|
7
|
-
Object.defineProperty(o, k2, desc);
|
|
8
|
-
}) : (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
o[k2] = m[k];
|
|
11
|
-
}));
|
|
12
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
13
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
14
|
-
};
|
|
15
|
-
(function (factory) {
|
|
16
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
17
|
-
var v = factory(require, exports);
|
|
18
|
-
if (v !== undefined) module.exports = v;
|
|
19
|
-
}
|
|
20
|
-
else if (typeof define === "function" && define.amd) {
|
|
21
|
-
define(["require", "exports", "./src/TypedEventTarget.js"], factory);
|
|
22
|
-
}
|
|
23
|
-
})(function (require, exports) {
|
|
24
|
-
"use strict";
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
__exportStar(require("./src/TypedEventTarget.js"), exports);
|
|
27
|
-
});
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A function that can be passed to the `listener` parameter of {@link TypedEventTarget.addEventListener} and {@link TypedEventTarget.removeEventListener}.
|
|
3
|
-
*
|
|
4
|
-
* @template M A map of event types to their respective event classes.
|
|
5
|
-
* @template T The type of event to listen for (has to be keyof `M`).
|
|
6
|
-
*/
|
|
7
|
-
export type TypedEventListener<M, T extends keyof M> = (evt: M[T]) => void | Promise<void>;
|
|
8
|
-
/**
|
|
9
|
-
* An object that can be passed to the `listener` parameter of {@link TypedEventTarget.addEventListener} and {@link TypedEventTarget.removeEventListener}.
|
|
10
|
-
*
|
|
11
|
-
* @template M A map of event types to their respective event classes.
|
|
12
|
-
* @template T The type of event to listen for (has to be keyof `M`).
|
|
13
|
-
*/
|
|
14
|
-
export interface TypedEventListenerObject<M, T extends keyof M> {
|
|
15
|
-
handleEvent: (evt: M[T]) => void | Promise<void>;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Type of parameter `listener` in {@link TypedEventTarget.addEventListener} and {@link TypedEventTarget.removeEventListener}.
|
|
19
|
-
*
|
|
20
|
-
* The object that receives a notification (an object that implements the Event interface) when an event of the specified type occurs.
|
|
21
|
-
*
|
|
22
|
-
* Can be either an object with a handleEvent() method, or a JavaScript function.
|
|
23
|
-
*
|
|
24
|
-
* @template M A map of event types to their respective event classes.
|
|
25
|
-
* @template T The type of event to listen for (has to be keyof `M`).
|
|
26
|
-
*/
|
|
27
|
-
export type TypedEventListenerOrEventListenerObject<M, T extends keyof M> = TypedEventListener<M, T> | TypedEventListenerObject<M, T>;
|
|
28
|
-
type ValueIsEvent<T> = {
|
|
29
|
-
[key in keyof T]: Event;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Typescript friendly version of {@link EventTarget}
|
|
33
|
-
*
|
|
34
|
-
* @template M A map of event types to their respective event classes.
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* ```typescript
|
|
38
|
-
* interface MyEventMap {
|
|
39
|
-
* hello: Event;
|
|
40
|
-
* time: CustomEvent<number>;
|
|
41
|
-
* }
|
|
42
|
-
*
|
|
43
|
-
* const eventTarget = new TypedEventTarget<MyEventMap>();
|
|
44
|
-
*
|
|
45
|
-
* eventTarget.addEventListener('time', (event) => {
|
|
46
|
-
* // event is of type CustomEvent<number>
|
|
47
|
-
* });
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
export interface TypedEventTarget<M extends ValueIsEvent<M>> {
|
|
51
|
-
/** Appends an event listener for events whose type attribute value is type.
|
|
52
|
-
* The callback argument sets the callback that will be invoked when the event
|
|
53
|
-
* is dispatched.
|
|
54
|
-
*
|
|
55
|
-
* The options argument sets listener-specific options. For compatibility this
|
|
56
|
-
* can be a boolean, in which case the method behaves exactly as if the value
|
|
57
|
-
* was specified as options's capture.
|
|
58
|
-
*
|
|
59
|
-
* When set to true, options's capture prevents callback from being invoked
|
|
60
|
-
* when the event's eventPhase attribute value is BUBBLING_PHASE. When false
|
|
61
|
-
* (or not present), callback will not be invoked when event's eventPhase
|
|
62
|
-
* attribute value is CAPTURING_PHASE. Either way, callback will be invoked if
|
|
63
|
-
* event's eventPhase attribute value is AT_TARGET.
|
|
64
|
-
*
|
|
65
|
-
* When set to true, options's passive indicates that the callback will not
|
|
66
|
-
* cancel the event by invoking preventDefault(). This is used to enable
|
|
67
|
-
* performance optimizations described in § 2.8 Observing event listeners.
|
|
68
|
-
*
|
|
69
|
-
* When set to true, options's once indicates that the callback will only be
|
|
70
|
-
* invoked once after which the event listener will be removed.
|
|
71
|
-
*
|
|
72
|
-
* The event listener is appended to target's event listener list and is not
|
|
73
|
-
* appended if it has the same type, callback, and capture. */
|
|
74
|
-
addEventListener: <T extends keyof M & string>(type: T, listener: TypedEventListenerOrEventListenerObject<M, T> | null, options?: boolean | AddEventListenerOptions) => void;
|
|
75
|
-
/** Removes the event listener in target's event listener list with the same
|
|
76
|
-
* type, callback, and options. */
|
|
77
|
-
removeEventListener: <T extends keyof M & string>(type: T, callback: TypedEventListenerOrEventListenerObject<M, T> | null, options?: EventListenerOptions | boolean) => void;
|
|
78
|
-
/**
|
|
79
|
-
* Dispatches a synthetic event event to target and returns true if either
|
|
80
|
-
* event's cancelable attribute value is false or its preventDefault() method
|
|
81
|
-
* was not invoked, and false otherwise.
|
|
82
|
-
* @deprecated To ensure type safety use `dispatchTypedEvent` instead.
|
|
83
|
-
*/
|
|
84
|
-
dispatchEvent: (event: Event) => boolean;
|
|
85
|
-
}
|
|
86
|
-
export declare class TypedEventTarget<M extends ValueIsEvent<M>> extends EventTarget {
|
|
87
|
-
/**
|
|
88
|
-
* Dispatches a synthetic event event to target and returns true if either
|
|
89
|
-
* event's cancelable attribute value is false or its preventDefault() method
|
|
90
|
-
* was not invoked, and false otherwise.
|
|
91
|
-
*/
|
|
92
|
-
dispatchTypedEvent<T extends keyof M>(_type: T, event: M[T]): boolean;
|
|
93
|
-
}
|
|
94
|
-
export {};
|
|
95
|
-
//# sourceMappingURL=TypedEventTarget.d.ts.map
|
package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TypedEventTarget.d.ts","sourceRoot":"","sources":["../../../../../../../src/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,CACnD,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,KACR,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1B;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC;IAC1D,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpD;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,uCAAuC,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAClE,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,GACxB,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAErC,KAAK,YAAY,CAAC,CAAC,IAAI;KAClB,GAAG,IAAI,MAAM,CAAC,GAAG,KAAK;CAC1B,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,YAAY,CAAC,CAAC,CAAC;IACvD;;;;;;;;;;;;;;;;;;;;;;kEAsB8D;IAC9D,gBAAgB,EAAE,CAAC,CAAC,SAAS,MAAM,CAAC,GAAG,MAAM,EACzC,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,uCAAuC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,EAC9D,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,KAC1C,IAAI,CAAC;IAEV;sCACkC;IAClC,mBAAmB,EAAE,CAAC,CAAC,SAAS,MAAM,CAAC,GAAG,MAAM,EAC5C,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,uCAAuC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,EAC9D,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,KACvC,IAAI,CAAC;IAEV;;;;;OAKG;IACH,aAAa,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC;CAC5C;AACD,qBAAa,gBAAgB,CAAC,CAAC,SAAS,YAAY,CAAC,CAAC,CAAC,CAAE,SAAQ,WAAW;IACxE;;;;OAIG;IACI,kBAAkB,CAAC,CAAC,SAAS,MAAM,CAAC,EACvC,KAAK,EAAE,CAAC,EACR,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,GACZ,OAAO;CAGb"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.TypedEventTarget = void 0;
|
|
13
|
-
class TypedEventTarget extends EventTarget {
|
|
14
|
-
/**
|
|
15
|
-
* Dispatches a synthetic event event to target and returns true if either
|
|
16
|
-
* event's cancelable attribute value is false or its preventDefault() method
|
|
17
|
-
* was not invoked, and false otherwise.
|
|
18
|
-
*/
|
|
19
|
-
dispatchTypedEvent(_type, event) {
|
|
20
|
-
return super.dispatchEvent(event);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.TypedEventTarget = TypedEventTarget;
|
|
24
|
-
});
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/** Options for {@linkcode delay}. */
|
|
2
|
-
export interface DelayOptions {
|
|
3
|
-
/** Signal used to abort the delay. */
|
|
4
|
-
signal?: AbortSignal;
|
|
5
|
-
/** Indicates whether the process should continue to run as long as the timer exists.
|
|
6
|
-
*
|
|
7
|
-
* @default {true}
|
|
8
|
-
*/
|
|
9
|
-
persistent?: boolean;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Resolve a {@linkcode Promise} after a given amount of milliseconds.
|
|
13
|
-
*
|
|
14
|
-
* @throws {DOMException} If the optional signal is aborted before the delay
|
|
15
|
-
* duration, and `signal.reason` is undefined.
|
|
16
|
-
* @param ms Duration in milliseconds for how long the delay should last.
|
|
17
|
-
* @param options Additional options.
|
|
18
|
-
*
|
|
19
|
-
* @example Basic usage
|
|
20
|
-
* ```ts no-assert
|
|
21
|
-
* import { delay } from "@std/async/delay";
|
|
22
|
-
*
|
|
23
|
-
* // ...
|
|
24
|
-
* const delayedPromise = delay(100);
|
|
25
|
-
* const result = await delayedPromise;
|
|
26
|
-
* // ...
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* @example Disable persistence
|
|
30
|
-
*
|
|
31
|
-
* Setting `persistent` to `false` will allow the process to continue to run as
|
|
32
|
-
* long as the timer exists.
|
|
33
|
-
*
|
|
34
|
-
* ```ts no-assert ignore
|
|
35
|
-
* import { delay } from "@std/async/delay";
|
|
36
|
-
*
|
|
37
|
-
* // ...
|
|
38
|
-
* await delay(100, { persistent: false });
|
|
39
|
-
* // ...
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
export declare function delay(ms: number, options?: DelayOptions): Promise<void>;
|
|
43
|
-
//# sourceMappingURL=delay.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delay.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/async/1.0.13/delay.ts"],"names":[],"mappings":"AAGA,qCAAqC;AACrC,MAAM,WAAW,YAAY;IAC3B,sCAAsC;IACtC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CA2B3E"}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
-
// This module is browser compatible.
|
|
3
|
-
(function (factory) {
|
|
4
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
5
|
-
var v = factory(require, exports);
|
|
6
|
-
if (v !== undefined) module.exports = v;
|
|
7
|
-
}
|
|
8
|
-
else if (typeof define === "function" && define.amd) {
|
|
9
|
-
define(["require", "exports"], factory);
|
|
10
|
-
}
|
|
11
|
-
})(function (require, exports) {
|
|
12
|
-
"use strict";
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.delay = delay;
|
|
15
|
-
/**
|
|
16
|
-
* Resolve a {@linkcode Promise} after a given amount of milliseconds.
|
|
17
|
-
*
|
|
18
|
-
* @throws {DOMException} If the optional signal is aborted before the delay
|
|
19
|
-
* duration, and `signal.reason` is undefined.
|
|
20
|
-
* @param ms Duration in milliseconds for how long the delay should last.
|
|
21
|
-
* @param options Additional options.
|
|
22
|
-
*
|
|
23
|
-
* @example Basic usage
|
|
24
|
-
* ```ts no-assert
|
|
25
|
-
* import { delay } from "@std/async/delay";
|
|
26
|
-
*
|
|
27
|
-
* // ...
|
|
28
|
-
* const delayedPromise = delay(100);
|
|
29
|
-
* const result = await delayedPromise;
|
|
30
|
-
* // ...
|
|
31
|
-
* ```
|
|
32
|
-
*
|
|
33
|
-
* @example Disable persistence
|
|
34
|
-
*
|
|
35
|
-
* Setting `persistent` to `false` will allow the process to continue to run as
|
|
36
|
-
* long as the timer exists.
|
|
37
|
-
*
|
|
38
|
-
* ```ts no-assert ignore
|
|
39
|
-
* import { delay } from "@std/async/delay";
|
|
40
|
-
*
|
|
41
|
-
* // ...
|
|
42
|
-
* await delay(100, { persistent: false });
|
|
43
|
-
* // ...
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
function delay(ms, options = {}) {
|
|
47
|
-
const { signal, persistent = true } = options;
|
|
48
|
-
if (signal?.aborted)
|
|
49
|
-
return Promise.reject(signal.reason);
|
|
50
|
-
return new Promise((resolve, reject) => {
|
|
51
|
-
const abort = () => {
|
|
52
|
-
clearTimeout(i);
|
|
53
|
-
reject(signal?.reason);
|
|
54
|
-
};
|
|
55
|
-
const done = () => {
|
|
56
|
-
signal?.removeEventListener("abort", abort);
|
|
57
|
-
resolve();
|
|
58
|
-
};
|
|
59
|
-
const i = setTimeout(done, ms);
|
|
60
|
-
signal?.addEventListener("abort", abort, { once: true });
|
|
61
|
-
if (persistent === false) {
|
|
62
|
-
try {
|
|
63
|
-
// @ts-ignore For browser compatibility
|
|
64
|
-
Deno.unrefTimer(i);
|
|
65
|
-
}
|
|
66
|
-
catch (error) {
|
|
67
|
-
if (!(error instanceof ReferenceError)) {
|
|
68
|
-
throw error;
|
|
69
|
-
}
|
|
70
|
-
// deno-lint-ignore no-console
|
|
71
|
-
console.error("`persistent` option is only available in Deno");
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
});
|
|
@@ -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/bytes/1.0.6/_types.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
-
(function (factory) {
|
|
3
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
4
|
-
var v = factory(require, exports);
|
|
5
|
-
if (v !== undefined) module.exports = v;
|
|
6
|
-
}
|
|
7
|
-
else if (typeof define === "function" && define.amd) {
|
|
8
|
-
define(["require", "exports"], factory);
|
|
9
|
-
}
|
|
10
|
-
})(function (require, exports) {
|
|
11
|
-
"use strict";
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { Uint8Array_ } from "./_types.js";
|
|
2
|
-
export type { Uint8Array_ };
|
|
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 declare function concat(buffers: readonly Uint8Array[]): Uint8Array_;
|
|
21
|
-
//# sourceMappingURL=concat.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"concat.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/bytes/1.0.6/concat.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAE5B;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,GAAG,WAAW,CAalE"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
-
// This module is browser compatible.
|
|
3
|
-
(function (factory) {
|
|
4
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
5
|
-
var v = factory(require, exports);
|
|
6
|
-
if (v !== undefined) module.exports = v;
|
|
7
|
-
}
|
|
8
|
-
else if (typeof define === "function" && define.amd) {
|
|
9
|
-
define(["require", "exports"], factory);
|
|
10
|
-
}
|
|
11
|
-
})(function (require, exports) {
|
|
12
|
-
"use strict";
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.concat = concat;
|
|
15
|
-
/**
|
|
16
|
-
* Concatenate an array of byte slices into a single slice.
|
|
17
|
-
*
|
|
18
|
-
* @param buffers Array of byte slices to concatenate.
|
|
19
|
-
* @returns A new byte slice containing all the input slices concatenated.
|
|
20
|
-
*
|
|
21
|
-
* @example Basic usage
|
|
22
|
-
* ```ts
|
|
23
|
-
* import { concat } from "@std/bytes/concat";
|
|
24
|
-
* import { assertEquals } from "@std/assert";
|
|
25
|
-
*
|
|
26
|
-
* const a = new Uint8Array([0, 1, 2]);
|
|
27
|
-
* const b = new Uint8Array([3, 4, 5]);
|
|
28
|
-
*
|
|
29
|
-
* assertEquals(concat([a, b]), new Uint8Array([0, 1, 2, 3, 4, 5]));
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
function concat(buffers) {
|
|
33
|
-
let length = 0;
|
|
34
|
-
for (const buffer of buffers) {
|
|
35
|
-
length += buffer.length;
|
|
36
|
-
}
|
|
37
|
-
const output = new Uint8Array(length);
|
|
38
|
-
let index = 0;
|
|
39
|
-
for (const buffer of buffers) {
|
|
40
|
-
output.set(buffer, index);
|
|
41
|
-
index += buffer.length;
|
|
42
|
-
}
|
|
43
|
-
return output;
|
|
44
|
-
}
|
|
45
|
-
});
|
|
@@ -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,67 +0,0 @@
|
|
|
1
|
-
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
-
(function (factory) {
|
|
3
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
4
|
-
var v = factory(require, exports);
|
|
5
|
-
if (v !== undefined) module.exports = v;
|
|
6
|
-
}
|
|
7
|
-
else if (typeof define === "function" && define.amd) {
|
|
8
|
-
define(["require", "exports"], factory);
|
|
9
|
-
}
|
|
10
|
-
})(function (require, exports) {
|
|
11
|
-
"use strict";
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.rAlphabet = exports.alphabet = void 0;
|
|
14
|
-
exports.calcSizeHex = calcSizeHex;
|
|
15
|
-
exports.encode = encode;
|
|
16
|
-
exports.decode = decode;
|
|
17
|
-
exports.alphabet = new TextEncoder().encode("0123456789abcdef");
|
|
18
|
-
exports.rAlphabet = new Uint8Array(128).fill(16); // alphabet.Hex.length
|
|
19
|
-
exports.alphabet.forEach((byte, i) => exports.rAlphabet[byte] = i);
|
|
20
|
-
new TextEncoder()
|
|
21
|
-
.encode("ABCDEF")
|
|
22
|
-
.forEach((byte, i) => exports.rAlphabet[byte] = i + 10);
|
|
23
|
-
/**
|
|
24
|
-
* Calculate the output size needed to encode a given input size for
|
|
25
|
-
* {@linkcode encodeIntoHex}.
|
|
26
|
-
*
|
|
27
|
-
* @param originalSize The size of the input buffer.
|
|
28
|
-
* @returns The size of the output buffer.
|
|
29
|
-
*
|
|
30
|
-
* @example Basic Usage
|
|
31
|
-
* ```ts
|
|
32
|
-
* import { assertEquals } from "@std/assert";
|
|
33
|
-
* import { calcSizeHex } from "@std/encoding/unstable-hex";
|
|
34
|
-
*
|
|
35
|
-
* assertEquals(calcSizeHex(1), 2);
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
function calcSizeHex(originalSize) {
|
|
39
|
-
return originalSize * 2;
|
|
40
|
-
}
|
|
41
|
-
function encode(buffer, i, o, alphabet) {
|
|
42
|
-
for (; i < buffer.length; ++i) {
|
|
43
|
-
const x = buffer[i];
|
|
44
|
-
buffer[o++] = alphabet[x >> 4];
|
|
45
|
-
buffer[o++] = alphabet[x & 0xF];
|
|
46
|
-
}
|
|
47
|
-
return o;
|
|
48
|
-
}
|
|
49
|
-
function decode(buffer, i, o, alphabet) {
|
|
50
|
-
if ((buffer.length - o) % 2 === 1) {
|
|
51
|
-
throw new RangeError(`Cannot decode input as hex: Length (${buffer.length - o}) must be divisible by 2`);
|
|
52
|
-
}
|
|
53
|
-
i += 1;
|
|
54
|
-
for (; i < buffer.length; i += 2) {
|
|
55
|
-
buffer[o++] = (getByte(buffer[i - 1], alphabet) << 4) |
|
|
56
|
-
getByte(buffer[i], alphabet);
|
|
57
|
-
}
|
|
58
|
-
return o;
|
|
59
|
-
}
|
|
60
|
-
function getByte(char, alphabet) {
|
|
61
|
-
const byte = alphabet[char] ?? 16;
|
|
62
|
-
if (byte === 16) { // alphabet.Hex.length
|
|
63
|
-
throw new TypeError(`Cannot decode input as hex: Invalid character (${String.fromCharCode(char)})`);
|
|
64
|
-
}
|
|
65
|
-
return byte;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
@@ -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,26 +0,0 @@
|
|
|
1
|
-
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
-
(function (factory) {
|
|
3
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
4
|
-
var v = factory(require, exports);
|
|
5
|
-
if (v !== undefined) module.exports = v;
|
|
6
|
-
}
|
|
7
|
-
else if (typeof define === "function" && define.amd) {
|
|
8
|
-
define(["require", "exports"], factory);
|
|
9
|
-
}
|
|
10
|
-
})(function (require, exports) {
|
|
11
|
-
"use strict";
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.detach = detach;
|
|
14
|
-
function detach(buffer, maxSize) {
|
|
15
|
-
const originalSize = buffer.length;
|
|
16
|
-
if (buffer.byteOffset) {
|
|
17
|
-
const b = new Uint8Array(buffer.buffer);
|
|
18
|
-
b.set(buffer);
|
|
19
|
-
buffer = b.subarray(0, originalSize);
|
|
20
|
-
}
|
|
21
|
-
// deno-lint-ignore no-explicit-any
|
|
22
|
-
buffer = new Uint8Array(buffer.buffer.transfer(maxSize));
|
|
23
|
-
buffer.set(buffer.subarray(0, originalSize), maxSize - originalSize);
|
|
24
|
-
return [buffer, maxSize - originalSize];
|
|
25
|
-
}
|
|
26
|
-
});
|