@vex-chat/crypto 1.1.0-rc.1 → 1.1.1
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 +6 -6
- package/dist/index.d.ts +24 -14
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +56 -41
- package/dist/index.js.map +1 -0
- package/package.json +81 -77
package/README.md
CHANGED
|
@@ -10,9 +10,9 @@ All of the crypto functions for the key exchange are contained in here.
|
|
|
10
10
|
|
|
11
11
|
This library utilizes native Node.js crypto where possible for performance and security.
|
|
12
12
|
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
13
|
+
- **tweetnacl**: Primitives for signing and encryption (X25519 / Ed25519).
|
|
14
|
+
- **ed2curve**: Ed25519 signing key to X25519 encryption key conversion.
|
|
15
|
+
- **msgpackr**: High-performance MessagePack serialization (replacing `msgpack-lite`).
|
|
16
|
+
- **bip39**: Mnemonic generation for keys.
|
|
17
|
+
- **Node Crypto**: Native implementations for HKDF, PBKDF2, HMAC, and SHA hashing (replacing `futoin-hkdf`, `create-hmac`, and `sha.js`).
|
|
18
|
+
- **@stablelib**: Constant-time encoding for Base64 and UTF8.
|
package/dist/index.d.ts
CHANGED
|
@@ -63,22 +63,31 @@ export declare class XUtils {
|
|
|
63
63
|
*/
|
|
64
64
|
static emptyHeader(): Uint8Array<ArrayBuffer>;
|
|
65
65
|
/**
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
* Encrypts a secret key with a password and saves it as a file.
|
|
67
|
+
*
|
|
68
|
+
* @param path The path to save the keyfile.
|
|
69
|
+
/**
|
|
70
|
+
* Encrypts a secret key into a portable binary format.
|
|
71
|
+
* The result can be written to disk, sent over the network, etc.
|
|
72
|
+
* No I/O — the caller handles persistence.
|
|
73
|
+
*
|
|
74
|
+
* Format: [iterations(6)|salt(24)|nonce(24)|ciphertext(N)]
|
|
75
|
+
*
|
|
76
|
+
* @param password The password to derive the encryption key from.
|
|
77
|
+
* @param keyToSave The hex-encoded secret key to encrypt.
|
|
78
|
+
* @param iterationOverride Optional PBKDF2 iteration count (random if omitted).
|
|
79
|
+
* @returns The encrypted key data as a Uint8Array.
|
|
80
|
+
*/
|
|
81
|
+
static encryptKeyData: (password: string, keyToSave: string, iterationOverride?: number) => Uint8Array;
|
|
75
82
|
/**
|
|
76
|
-
* Decrypts
|
|
83
|
+
* Decrypts a secret key from the binary format produced by encryptKeyData().
|
|
84
|
+
* No I/O — the caller handles reading the data.
|
|
77
85
|
*
|
|
78
|
-
* @param
|
|
79
|
-
* @param password The password
|
|
86
|
+
* @param keyData The encrypted key data as a Uint8Array.
|
|
87
|
+
* @param password The password used to encrypt.
|
|
88
|
+
* @returns The hex-encoded secret key.
|
|
80
89
|
*/
|
|
81
|
-
static
|
|
90
|
+
static decryptKeyData: (keyData: Uint8Array, password: string) => string;
|
|
82
91
|
/**
|
|
83
92
|
* Decodes a hex string into a Uint8Array.
|
|
84
93
|
*
|
|
@@ -105,7 +114,7 @@ export declare function xMnemonic(entropy: Uint8Array, wordList?: string[] | und
|
|
|
105
114
|
* @param msg the message to create the HMAC of
|
|
106
115
|
* @param SK the secret key to create the HMAC with
|
|
107
116
|
*/
|
|
108
|
-
export declare function xHMAC(msg: any, SK: Uint8Array): Uint8Array<
|
|
117
|
+
export declare function xHMAC(msg: any, SK: Uint8Array): Uint8Array<ArrayBufferLike>;
|
|
109
118
|
/**
|
|
110
119
|
* Constants for vex.
|
|
111
120
|
*/
|
|
@@ -162,3 +171,4 @@ interface XConstants {
|
|
|
162
171
|
HEADER_SIZE: 32;
|
|
163
172
|
}
|
|
164
173
|
export {};
|
|
174
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.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D;;;;OAIG;WACW,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM;CAMrD;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CACrB,OAAO,EAAE,UAAU,EACnB,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,UAGlC;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,UAAU,+BAG7C;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,UAOxB,CAAC;AAEF;;GAEG;AACH,wBAAgB,UAAU,IAAI,UAAU,CAEvC;AAED;;;;;GAKG;AAWH,wBAAgB,IAAI,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,CAQhD;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,UAAU,UAErC;AAED;;;;;;;GAOG;AACH,wBAAgB,GAAG,CACf,YAAY,EAAE,UAAU,EACxB,cAAc,EAAE,UAAU,GAC3B,UAAU,CAEZ;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,GAAG,UAAU,CAkB3D;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CACnB,SAAS,EAAE,QAAQ,GAAG,MAAM,EAC5B,SAAS,EAAE,UAAU,GACtB,UAAU,CAiCZ;AAkCD;;GAEG;AACH,UAAU,UAAU;IAChB,KAAK,EAAE,QAAQ,CAAC;IAChB,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,EAAE,GAAG,EAAE,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,EAAE,CAAC;CACnB"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { decode as decodeBase64, encode as encodeBase64, } from "@stablelib/base64";
|
|
2
2
|
import { decode as encodeUTF8, encode as decodeUTF8 } from "@stablelib/utf8";
|
|
3
3
|
import * as bip39 from "bip39";
|
|
4
|
-
import {
|
|
4
|
+
import { hmac } from "@noble/hashes/hmac.js";
|
|
5
|
+
import { sha256, sha512 } from "@noble/hashes/sha2.js";
|
|
6
|
+
import { hkdf } from "@noble/hashes/hkdf.js";
|
|
7
|
+
import { pbkdf2 as noblePbkdf2 } from "@noble/hashes/pbkdf2.js";
|
|
5
8
|
import ed2curve from "ed2curve";
|
|
6
|
-
import { writeFileSync, readFileSync } from "node:fs";
|
|
7
|
-
import { hkdfSync } from "node:crypto";
|
|
8
9
|
import { Packr } from "msgpackr";
|
|
9
10
|
import nacl from "tweetnacl";
|
|
10
11
|
// msgpackr with useRecords:false emits standard msgpack (no nonstandard record extension).
|
|
@@ -73,7 +74,11 @@ export class XUtils {
|
|
|
73
74
|
* @returns the number representation of arr.
|
|
74
75
|
*/
|
|
75
76
|
static uint8ArrToNumber(arr) {
|
|
76
|
-
|
|
77
|
+
let n = 0;
|
|
78
|
+
for (let i = 0; i < arr.length; i++) {
|
|
79
|
+
n = n * 256 + arr[i];
|
|
80
|
+
}
|
|
81
|
+
return n;
|
|
77
82
|
}
|
|
78
83
|
/**
|
|
79
84
|
* Takes a vex message and unpacks it into its header and a javascript object
|
|
@@ -108,27 +113,38 @@ export class XUtils {
|
|
|
108
113
|
return new Uint8Array(xConstants.HEADER_SIZE);
|
|
109
114
|
}
|
|
110
115
|
/**
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
116
|
+
* Encrypts a secret key with a password and saves it as a file.
|
|
117
|
+
*
|
|
118
|
+
* @param path The path to save the keyfile.
|
|
119
|
+
/**
|
|
120
|
+
* Encrypts a secret key into a portable binary format.
|
|
121
|
+
* The result can be written to disk, sent over the network, etc.
|
|
122
|
+
* No I/O — the caller handles persistence.
|
|
123
|
+
*
|
|
124
|
+
* Format: [iterations(6)|salt(24)|nonce(24)|ciphertext(N)]
|
|
125
|
+
*
|
|
126
|
+
* @param password The password to derive the encryption key from.
|
|
127
|
+
* @param keyToSave The hex-encoded secret key to encrypt.
|
|
128
|
+
* @param iterationOverride Optional PBKDF2 iteration count (random if omitted).
|
|
129
|
+
* @returns The encrypted key data as a Uint8Array.
|
|
130
|
+
*/
|
|
131
|
+
static encryptKeyData = (password, keyToSave, iterationOverride) => {
|
|
120
132
|
const UNENCRYPTED_SIGNKEY = XUtils.decodeHex(keyToSave);
|
|
121
133
|
const OFFSET = 1000;
|
|
122
|
-
|
|
123
|
-
const rand = randomBytes(2);
|
|
134
|
+
const rand = nacl.randomBytes(2);
|
|
124
135
|
const N1 = rand[0];
|
|
125
136
|
const N2 = rand[1];
|
|
126
|
-
const iterations = iterationOverride
|
|
137
|
+
const iterations = iterationOverride
|
|
138
|
+
? iterationOverride
|
|
139
|
+
: N1 * N2 + OFFSET;
|
|
127
140
|
const ITERATIONS = XUtils.numberToUint8Arr(iterations);
|
|
128
141
|
const PKBDF_SALT = xMakeNonce();
|
|
129
|
-
const ENCRYPTION_KEY =
|
|
142
|
+
const ENCRYPTION_KEY = noblePbkdf2(sha512, password, PKBDF_SALT, {
|
|
143
|
+
c: iterations,
|
|
144
|
+
dkLen: 32,
|
|
145
|
+
});
|
|
130
146
|
const NONCE = xMakeNonce();
|
|
131
|
-
const ENCRYPTED_SIGNKEY = nacl.secretbox(UNENCRYPTED_SIGNKEY, NONCE,
|
|
147
|
+
const ENCRYPTED_SIGNKEY = nacl.secretbox(UNENCRYPTED_SIGNKEY, NONCE, ENCRYPTION_KEY);
|
|
132
148
|
const result = new Uint8Array(ITERATIONS.length +
|
|
133
149
|
PKBDF_SALT.length +
|
|
134
150
|
NONCE.length +
|
|
@@ -141,28 +157,30 @@ export class XUtils {
|
|
|
141
157
|
result.set(NONCE, offset);
|
|
142
158
|
offset += NONCE.length;
|
|
143
159
|
result.set(ENCRYPTED_SIGNKEY, offset);
|
|
144
|
-
|
|
160
|
+
return result;
|
|
145
161
|
};
|
|
146
162
|
/**
|
|
147
|
-
* Decrypts
|
|
163
|
+
* Decrypts a secret key from the binary format produced by encryptKeyData().
|
|
164
|
+
* No I/O — the caller handles reading the data.
|
|
148
165
|
*
|
|
149
|
-
* @param
|
|
150
|
-
* @param password The password
|
|
166
|
+
* @param keyData The encrypted key data as a Uint8Array.
|
|
167
|
+
* @param password The password used to encrypt.
|
|
168
|
+
* @returns The hex-encoded secret key.
|
|
151
169
|
*/
|
|
152
|
-
static
|
|
153
|
-
const
|
|
154
|
-
const
|
|
155
|
-
const
|
|
156
|
-
const
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
170
|
+
static decryptKeyData = (keyData, password) => {
|
|
171
|
+
const ITERATIONS = XUtils.uint8ArrToNumber(keyData.slice(0, 6));
|
|
172
|
+
const PKBDF_SALT = keyData.slice(6, 30);
|
|
173
|
+
const ENCRYPTION_NONCE = keyData.slice(30, 54);
|
|
174
|
+
const ENCRYPTED_KEY = keyData.slice(54);
|
|
175
|
+
const DERIVED_KEY = noblePbkdf2(sha512, password, PKBDF_SALT, {
|
|
176
|
+
c: ITERATIONS,
|
|
177
|
+
dkLen: 32,
|
|
178
|
+
});
|
|
179
|
+
const DECRYPTED_SIGNKEY = nacl.secretbox.open(ENCRYPTED_KEY, ENCRYPTION_NONCE, DERIVED_KEY);
|
|
160
180
|
if (!DECRYPTED_SIGNKEY) {
|
|
161
181
|
throw new Error("Decryption failed. Wrong password?");
|
|
162
182
|
}
|
|
163
|
-
|
|
164
|
-
return XUtils.encodeHex(DECRYPTED_SIGNKEY);
|
|
165
|
-
}
|
|
183
|
+
return XUtils.encodeHex(DECRYPTED_SIGNKEY);
|
|
166
184
|
};
|
|
167
185
|
/**
|
|
168
186
|
* Decodes a hex string into a Uint8Array.
|
|
@@ -191,7 +209,7 @@ export class XUtils {
|
|
|
191
209
|
* @param wordList Optional, override the wordlist. See bip39 docs for details.
|
|
192
210
|
*/
|
|
193
211
|
export function xMnemonic(entropy, wordList) {
|
|
194
|
-
return bip39.entropyToMnemonic(
|
|
212
|
+
return bip39.entropyToMnemonic(XUtils.encodeHex(entropy), wordList);
|
|
195
213
|
}
|
|
196
214
|
/**
|
|
197
215
|
* Returns a 32 byte HMAC of a javscript object.
|
|
@@ -201,10 +219,7 @@ export function xMnemonic(entropy, wordList) {
|
|
|
201
219
|
*/
|
|
202
220
|
export function xHMAC(msg, SK) {
|
|
203
221
|
const packedMsg = msgpackEncode(msg);
|
|
204
|
-
|
|
205
|
-
hmacGen.update(packedMsg);
|
|
206
|
-
const hmac = Uint8Array.from(hmacGen.digest());
|
|
207
|
-
return hmac;
|
|
222
|
+
return hmac(sha256, SK, packedMsg);
|
|
208
223
|
}
|
|
209
224
|
/**
|
|
210
225
|
* Constants for vex.
|
|
@@ -239,7 +254,7 @@ export function xMakeNonce() {
|
|
|
239
254
|
// );
|
|
240
255
|
// }
|
|
241
256
|
export function xKDF(IKM) {
|
|
242
|
-
return
|
|
257
|
+
return hkdf(sha512, IKM, xMakeSalt(xConstants.CURVE), new TextEncoder().encode(xConstants.INFO), xConstants.KEY_LENGTH);
|
|
243
258
|
}
|
|
244
259
|
/**
|
|
245
260
|
* Hashes some data.
|
|
@@ -248,8 +263,7 @@ export function xKDF(IKM) {
|
|
|
248
263
|
* @returns The hash of the data.
|
|
249
264
|
*/
|
|
250
265
|
export function xHash(data) {
|
|
251
|
-
|
|
252
|
-
return hash.update(data).digest("hex");
|
|
266
|
+
return XUtils.encodeHex(sha512(data));
|
|
253
267
|
}
|
|
254
268
|
/**
|
|
255
269
|
* Derives a shared Secret Key from a known private key and
|
|
@@ -343,3 +357,4 @@ function isEven(value) {
|
|
|
343
357
|
return false;
|
|
344
358
|
}
|
|
345
359
|
}
|
|
360
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,MAAM,IAAI,YA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3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
"name": "@vex-chat/crypto",
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"description": "Crypto primitives for Vex",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"author": "Extra <extrahash@protonmail.com>",
|
|
19
|
+
"license": "AGPL-3.0-or-later",
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc",
|
|
22
|
+
"build:clean": "rimraf dist && tsc",
|
|
23
|
+
"prepack": "npm run build",
|
|
24
|
+
"format": "prettier --write .",
|
|
25
|
+
"format:check": "prettier --check .",
|
|
26
|
+
"lint": "eslint src/",
|
|
27
|
+
"lint:fix": "eslint src/ --fix",
|
|
28
|
+
"prepublish": "npm run build",
|
|
29
|
+
"test": "vitest run"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"@vex-chat/types": "^1.0.0-rc.1",
|
|
33
|
+
"typescript": ">=5.9.0 || >=6.0.0"
|
|
34
|
+
},
|
|
35
|
+
"peerDependenciesMeta": {
|
|
36
|
+
"typescript": {
|
|
37
|
+
"optional": true
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@noble/hashes": "^2.0.1",
|
|
42
|
+
"@stablelib/base64": "^2.0.1",
|
|
43
|
+
"@stablelib/utf8": "^2.1.0",
|
|
44
|
+
"bip39": "^3.1.0",
|
|
45
|
+
"ed2curve": "^0.3.0",
|
|
46
|
+
"msgpackr": "1.11.8",
|
|
47
|
+
"tweetnacl": "^1.0.3"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@changesets/cli": "^2.29.8",
|
|
51
|
+
"@types/create-hmac": "^1.1.3",
|
|
52
|
+
"@types/ed2curve": "^0.2.4",
|
|
53
|
+
"@types/node": "^24.12.2",
|
|
54
|
+
"@typescript-eslint/eslint-plugin": "^8.57.1",
|
|
55
|
+
"@typescript-eslint/parser": "^8.57.1",
|
|
56
|
+
"@vex-chat/types": "^1.0.1",
|
|
57
|
+
"eslint": "^10.1.0",
|
|
58
|
+
"eslint-config-prettier": "^9.0.0",
|
|
59
|
+
"husky": "^9.0.0",
|
|
60
|
+
"lint-staged": "^15.2.0",
|
|
61
|
+
"prettier": "^3.2.0",
|
|
62
|
+
"rimraf": "^6.1.3",
|
|
63
|
+
"typescript": "^6.0.2",
|
|
64
|
+
"vitest": "^3.0.0"
|
|
65
|
+
},
|
|
66
|
+
"lint-staged": {
|
|
67
|
+
"*.ts": [
|
|
68
|
+
"eslint --fix",
|
|
69
|
+
"prettier --write"
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
"repository": {
|
|
73
|
+
"type": "git",
|
|
74
|
+
"url": "git+https://github.com/vex-chat/libvex-js.git"
|
|
75
|
+
},
|
|
76
|
+
"bugs": {
|
|
77
|
+
"url": "https://github.com/vex-chat/libvex-js/issues"
|
|
78
|
+
},
|
|
79
|
+
"homepage": "https://github.com/vex-chat/libvex-js#readme",
|
|
80
|
+
"publishConfig": {
|
|
81
|
+
"access": "public",
|
|
82
|
+
"registry": "https://registry.npmjs.org/"
|
|
13
83
|
}
|
|
14
|
-
},
|
|
15
|
-
"files": [
|
|
16
|
-
"dist"
|
|
17
|
-
],
|
|
18
|
-
"author": "Extra <extrahash@protonmail.com>",
|
|
19
|
-
"license": "AGPL-3.0-or-later",
|
|
20
|
-
"scripts": {
|
|
21
|
-
"build": "rimraf dist && tsc",
|
|
22
|
-
"prepack": "npm run build",
|
|
23
|
-
"prettier": "prettier '**/*.{ts,tsx,json,md}' --ignore-path .gitignore --write",
|
|
24
|
-
"lint": "eslint src/**/*.ts",
|
|
25
|
-
"lint-fix": "eslint src/**/*.ts --fix",
|
|
26
|
-
"prepublish": "npm run build",
|
|
27
|
-
"test": "vitest run"
|
|
28
|
-
},
|
|
29
|
-
"peerDependencies": {
|
|
30
|
-
"@vex-chat/types": "^1.0.0-rc.1",
|
|
31
|
-
"typescript": ">=5.9.0 || >=6.0.0"
|
|
32
|
-
},
|
|
33
|
-
"peerDependenciesMeta": {
|
|
34
|
-
"typescript": {
|
|
35
|
-
"optional": true
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"msgpackr": "1.11.8",
|
|
40
|
-
"@stablelib/base64": "^2.0.1",
|
|
41
|
-
"@stablelib/utf8": "^2.1.0",
|
|
42
|
-
"bip39": "^3.1.0",
|
|
43
|
-
"ed2curve": "^0.3.0",
|
|
44
|
-
"tweetnacl": "^1.0.3"
|
|
45
|
-
},
|
|
46
|
-
"devDependencies": {
|
|
47
|
-
"@changesets/cli": "^2.29.8",
|
|
48
|
-
"@types/create-hmac": "^1.1.3",
|
|
49
|
-
"@types/ed2curve": "^0.2.4",
|
|
50
|
-
"@types/node": "^24.12.2",
|
|
51
|
-
"@typescript-eslint/eslint-plugin": "^8.57.1",
|
|
52
|
-
"@typescript-eslint/parser": "^8.57.1",
|
|
53
|
-
"@vex-chat/types": "^1.0.0-rc.1",
|
|
54
|
-
"eslint": "^10.1.0",
|
|
55
|
-
"eslint-config-prettier": "^9.0.0",
|
|
56
|
-
"husky": "^9.0.0",
|
|
57
|
-
"lint-staged": "^15.2.0",
|
|
58
|
-
"prettier": "^3.2.0",
|
|
59
|
-
"rimraf": "^6.1.3",
|
|
60
|
-
"typescript": "^6.0.2",
|
|
61
|
-
"vitest": "^3.0.0"
|
|
62
|
-
},
|
|
63
|
-
"lint-staged": {
|
|
64
|
-
"src/**/*.{ts}": [
|
|
65
|
-
"eslint --fix"
|
|
66
|
-
]
|
|
67
|
-
},
|
|
68
|
-
"repository": {
|
|
69
|
-
"type": "git",
|
|
70
|
-
"url": "git+https://github.com/vex-chat/libvex-js.git"
|
|
71
|
-
},
|
|
72
|
-
"bugs": {
|
|
73
|
-
"url": "https://github.com/vex-chat/libvex-js/issues"
|
|
74
|
-
},
|
|
75
|
-
"homepage": "https://github.com/vex-chat/libvex-js#readme",
|
|
76
|
-
"publishConfig": {
|
|
77
|
-
"access": "public",
|
|
78
|
-
"registry": "https://registry.npmjs.org/"
|
|
79
|
-
}
|
|
80
84
|
}
|