@kikiutils/shared 13.5.1 → 13.5.2
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/dist/buffer.d.ts +3 -2
- package/dist/buffer.d.ts.map +1 -1
- package/dist/buffer.js.map +1 -1
- package/dist/classes/ssh-client.d.ts +1 -1
- package/dist/hash.js +2 -2
- package/dist/hash.js.map +1 -1
- package/dist/object.js +2 -2
- package/dist/object.js.map +1 -1
- package/package.json +14 -13
- package/src/buffer.ts +3 -5
- package/src/hash.ts +2 -2
- package/src/object.ts +2 -2
package/dist/buffer.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BinaryInput } from "./types/index.js";
|
|
2
|
+
import { Buffer } from "node:buffer";
|
|
2
3
|
|
|
3
4
|
//#region src/buffer.d.ts
|
|
4
5
|
|
|
@@ -33,7 +34,7 @@ import { Blob as Blob$1, Buffer, File as File$1 } from "node:buffer";
|
|
|
33
34
|
* console.log(result3.toString()); // 'File content'
|
|
34
35
|
* ```
|
|
35
36
|
*/
|
|
36
|
-
declare function toBuffer(input:
|
|
37
|
+
declare function toBuffer(input: BinaryInput): Promise<Buffer<ArrayBufferLike>>;
|
|
37
38
|
//#endregion
|
|
38
39
|
export { toBuffer };
|
|
39
40
|
//# sourceMappingURL=buffer.d.ts.map
|
package/dist/buffer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer.d.ts","names":[],"sources":["../src/buffer.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buffer.d.ts","names":[],"sources":["../src/buffer.ts"],"sourcesContent":[],"mappings":";;;;;;;AAmCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAsB,QAAA,QAAgB,cAAW,QAAA,OAAA"}
|
package/dist/buffer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer.js","names":[],"sources":["../src/buffer.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\nimport type {
|
|
1
|
+
{"version":3,"file":"buffer.js","names":[],"sources":["../src/buffer.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\n\nimport type { BinaryInput } from './types';\n\n/**\n * Converts a Blob, Buffer, or File to a Buffer.\n *\n * This function provides a unified way to convert various binary data types\n * to Node.js Buffer. If the input is already a Buffer, it returns it as-is.\n * For Blob or File inputs, it converts them to Buffer via ArrayBuffer.\n *\n * @param {Blob | Buffer | File} input - The input to convert to Buffer\n *\n * @returns {Promise<Buffer>} A Promise that resolves to a Buffer\n *\n * @example\n * ```typescript\n * import { toBuffer } from '@kikiutils/shared/general';\n *\n * // Convert a Buffer (returns as-is)\n * const buffer = Buffer.from('Hello World');\n * const result1 = await toBuffer(buffer);\n * console.log(result1); // <Buffer 48 65 6c 6c 6f 20 57 6f 72 6c 64>\n *\n * // Convert a Blob\n * const blob = new Blob(['Hello from Blob'], { type: 'text/plain' });\n * const result2 = await toBuffer(blob);\n * console.log(result2.toString()); // 'Hello from Blob'\n *\n * // Convert a File\n * const file = new File(['File content'], 'test.txt', { type: 'text/plain' });\n * const result3 = await toBuffer(file);\n * console.log(result3.toString()); // 'File content'\n * ```\n */\nexport async function toBuffer(input: BinaryInput) {\n if (Buffer.isBuffer(input)) return input;\n return Buffer.from(await input.arrayBuffer());\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,eAAsB,SAAS,OAAoB;AAC/C,KAAI,OAAO,SAAS,MAAM,CAAE,QAAO;AACnC,QAAO,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PathLike } from "./path.js";
|
|
2
1
|
import { Nullable } from "../types/index.js";
|
|
2
|
+
import { PathLike } from "./path.js";
|
|
3
3
|
import * as node_ssh0 from "node-ssh";
|
|
4
4
|
import { Config, NodeSSH, SSHExecCommandOptions, SSHGetPutDirectoryOptions, SSHPutFilesOptions } from "node-ssh";
|
|
5
5
|
import { SFTPWrapper, TransferOptions } from "ssh2";
|
package/dist/hash.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { sha3_224, sha3_256, sha3_384, sha3_512 } from "@noble/hashes/sha3";
|
|
2
|
-
import { bytesToHex, utf8ToBytes } from "@noble/hashes/utils";
|
|
1
|
+
import { sha3_224, sha3_256, sha3_384, sha3_512 } from "@noble/hashes/sha3.js";
|
|
2
|
+
import { bytesToHex, utf8ToBytes } from "@noble/hashes/utils.js";
|
|
3
3
|
|
|
4
4
|
//#region src/hash.ts
|
|
5
5
|
function sha3224(data) {
|
package/dist/hash.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.js","names":[],"sources":["../src/hash.ts"],"sourcesContent":["/**\n * This file provides a set of functions for creating SHA-3 hash digests\n * using different bit lengths (224, 256, 384, 512).\n * These functions use the [@noble/hashes](https://github.com/paulmillr/noble-hashes) library to generate the hashes.\n * Can be used in the browser, mainly for Nuxt/Vue and other frameworks compiled and executed in the browser.\n *\n * @example\n * ```typescript\n * import { sha3256 } from '@kikiutils/shared/hash';\n *\n * console.log(sha3256('test')); // 36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80\n * ```\n */\n\nimport {\n sha3_224,\n sha3_256,\n sha3_384,\n sha3_512,\n} from '@noble/hashes/sha3';\nimport {\n bytesToHex,\n utf8ToBytes,\n} from '@noble/hashes/utils';\n\nexport function sha3224(data: string | Uint8Array) {\n return bytesToHex(sha3_224(typeof data === 'string' ? utf8ToBytes(data) : data));\n}\n\nexport function sha3256(data: string | Uint8Array) {\n return bytesToHex(sha3_256(typeof data === 'string' ? utf8ToBytes(data) : data));\n}\n\nexport function sha3384(data: string | Uint8Array) {\n return bytesToHex(sha3_384(typeof data === 'string' ? utf8ToBytes(data) : data));\n}\n\nexport function sha3512(data: string | Uint8Array) {\n return bytesToHex(sha3_512(typeof data === 'string' ? utf8ToBytes(data) : data));\n}\n"],"mappings":";;;;AAyBA,SAAgB,QAAQ,MAA2B;AAC/C,QAAO,WAAW,SAAS,OAAO,SAAS,WAAW,YAAY,KAAK,GAAG,KAAK,CAAC;;AAGpF,SAAgB,QAAQ,MAA2B;AAC/C,QAAO,WAAW,SAAS,OAAO,SAAS,WAAW,YAAY,KAAK,GAAG,KAAK,CAAC;;AAGpF,SAAgB,QAAQ,MAA2B;AAC/C,QAAO,WAAW,SAAS,OAAO,SAAS,WAAW,YAAY,KAAK,GAAG,KAAK,CAAC;;AAGpF,SAAgB,QAAQ,MAA2B;AAC/C,QAAO,WAAW,SAAS,OAAO,SAAS,WAAW,YAAY,KAAK,GAAG,KAAK,CAAC"}
|
|
1
|
+
{"version":3,"file":"hash.js","names":[],"sources":["../src/hash.ts"],"sourcesContent":["/**\n * This file provides a set of functions for creating SHA-3 hash digests\n * using different bit lengths (224, 256, 384, 512).\n * These functions use the [@noble/hashes](https://github.com/paulmillr/noble-hashes) library to generate the hashes.\n * Can be used in the browser, mainly for Nuxt/Vue and other frameworks compiled and executed in the browser.\n *\n * @example\n * ```typescript\n * import { sha3256 } from '@kikiutils/shared/hash';\n *\n * console.log(sha3256('test')); // 36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80\n * ```\n */\n\nimport {\n sha3_224,\n sha3_256,\n sha3_384,\n sha3_512,\n} from '@noble/hashes/sha3.js';\nimport {\n bytesToHex,\n utf8ToBytes,\n} from '@noble/hashes/utils.js';\n\nexport function sha3224(data: string | Uint8Array) {\n return bytesToHex(sha3_224(typeof data === 'string' ? utf8ToBytes(data) : data));\n}\n\nexport function sha3256(data: string | Uint8Array) {\n return bytesToHex(sha3_256(typeof data === 'string' ? utf8ToBytes(data) : data));\n}\n\nexport function sha3384(data: string | Uint8Array) {\n return bytesToHex(sha3_384(typeof data === 'string' ? utf8ToBytes(data) : data));\n}\n\nexport function sha3512(data: string | Uint8Array) {\n return bytesToHex(sha3_512(typeof data === 'string' ? utf8ToBytes(data) : data));\n}\n"],"mappings":";;;;AAyBA,SAAgB,QAAQ,MAA2B;AAC/C,QAAO,WAAW,SAAS,OAAO,SAAS,WAAW,YAAY,KAAK,GAAG,KAAK,CAAC;;AAGpF,SAAgB,QAAQ,MAA2B;AAC/C,QAAO,WAAW,SAAS,OAAO,SAAS,WAAW,YAAY,KAAK,GAAG,KAAK,CAAC;;AAGpF,SAAgB,QAAQ,MAA2B;AAC/C,QAAO,WAAW,SAAS,OAAO,SAAS,WAAW,YAAY,KAAK,GAAG,KAAK,CAAC;;AAGpF,SAAgB,QAAQ,MAA2B;AAC/C,QAAO,WAAW,SAAS,OAAO,SAAS,WAAW,YAAY,KAAK,GAAG,KAAK,CAAC"}
|
package/dist/object.js
CHANGED
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
function stringifyObjectDeterministically(input, kvSeparator = "=", pairSeparator = "&") {
|
|
26
26
|
const entries = [];
|
|
27
27
|
function walk(object, path = []) {
|
|
28
|
-
if (Array.isArray(object)) object.forEach((value,
|
|
29
|
-
walk(value, [...path,
|
|
28
|
+
if (Array.isArray(object)) object.forEach((value, i) => {
|
|
29
|
+
walk(value, [...path, i.toString()]);
|
|
30
30
|
});
|
|
31
31
|
else if (object !== null && typeof object === "object" && Object.prototype.toString.call(object) === "[object Object]") Object.keys(object).sort().forEach((key) => {
|
|
32
32
|
walk(object[key], [...path, key]);
|
package/dist/object.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object.js","names":["entries: string[]"],"sources":["../src/object.ts"],"sourcesContent":["/**\n * Serializes a nested object into a deterministic, flat string format.\n *\n * This function recursively traverses the input object (including nested objects and arrays),\n * flattens it into key paths using dot notation (e.g. \"a.b.0.c\"), sorts all keys,\n * and joins each key-value pair into a string with customizable separators.\n *\n * It is designed for use cases such as signature generation, cache key construction,\n * or any context requiring consistent and predictable object serialization.\n *\n * @param {Record<string, any>} input - The object to serialize. Can contain nested objects and arrays\n * @param {string} kvSeparator - The string used to separate each key from its value (default: '=')\n * @param {string} pairSeparator - The string used to separate each key-value pair (default: '&')\n * @returns {string} A deterministic string representation of the input object\n *\n * @example\n * ```typescript\n * import { stringifyObjectDeterministically } from '@kikiutils/shared/object';\n *\n * console.log(stringifyObjectDeterministically({ b: 2, a: { x: 1, y: [3, 4] } })); // a.x=1&a.y.0=3&a.y.1=4&b=2\n * console.log(stringifyObjectDeterministically({ foo: 'bar' }, ':', '|')); // foo:bar\n * ```\n */\nexport function stringifyObjectDeterministically(\n input: Record<string, any>,\n kvSeparator: string = '=',\n pairSeparator: string = '&',\n) {\n const entries: string[] = [];\n\n function walk(object: any, path: string[] = []) {\n if (Array.isArray(object)) {\n object.forEach((value,
|
|
1
|
+
{"version":3,"file":"object.js","names":["entries: string[]"],"sources":["../src/object.ts"],"sourcesContent":["/**\n * Serializes a nested object into a deterministic, flat string format.\n *\n * This function recursively traverses the input object (including nested objects and arrays),\n * flattens it into key paths using dot notation (e.g. \"a.b.0.c\"), sorts all keys,\n * and joins each key-value pair into a string with customizable separators.\n *\n * It is designed for use cases such as signature generation, cache key construction,\n * or any context requiring consistent and predictable object serialization.\n *\n * @param {Record<string, any>} input - The object to serialize. Can contain nested objects and arrays\n * @param {string} kvSeparator - The string used to separate each key from its value (default: '=')\n * @param {string} pairSeparator - The string used to separate each key-value pair (default: '&')\n * @returns {string} A deterministic string representation of the input object\n *\n * @example\n * ```typescript\n * import { stringifyObjectDeterministically } from '@kikiutils/shared/object';\n *\n * console.log(stringifyObjectDeterministically({ b: 2, a: { x: 1, y: [3, 4] } })); // a.x=1&a.y.0=3&a.y.1=4&b=2\n * console.log(stringifyObjectDeterministically({ foo: 'bar' }, ':', '|')); // foo:bar\n * ```\n */\nexport function stringifyObjectDeterministically(\n input: Record<string, any>,\n kvSeparator: string = '=',\n pairSeparator: string = '&',\n) {\n const entries: string[] = [];\n\n function walk(object: any, path: string[] = []) {\n if (Array.isArray(object)) {\n object.forEach((value, i) => {\n walk(\n value,\n [\n ...path,\n i.toString(),\n ],\n );\n });\n } else if (\n object !== null\n && typeof object === 'object'\n && Object.prototype.toString.call(object) === '[object Object]'\n ) {\n Object.keys(object).sort().forEach((key) => {\n walk(\n object[key],\n [\n ...path,\n key,\n ],\n );\n });\n } else entries.push(`${path.join('.')}${kvSeparator}${String(object)}`);\n }\n\n walk(input);\n return entries.sort().join(pairSeparator);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAuBA,SAAgB,iCACZ,OACA,cAAsB,KACtB,gBAAwB,KAC1B;CACE,MAAMA,UAAoB,EAAE;CAE5B,SAAS,KAAK,QAAa,OAAiB,EAAE,EAAE;AAC5C,MAAI,MAAM,QAAQ,OAAO,CACrB,QAAO,SAAS,OAAO,MAAM;AACzB,QACI,OACA,CACI,GAAG,MACH,EAAE,UAAU,CACf,CACJ;IACH;WAEF,WAAW,QACR,OAAO,WAAW,YAClB,OAAO,UAAU,SAAS,KAAK,OAAO,KAAK,kBAE9C,QAAO,KAAK,OAAO,CAAC,MAAM,CAAC,SAAS,QAAQ;AACxC,QACI,OAAO,MACP,CACI,GAAG,MACH,IACH,CACJ;IACH;MACC,SAAQ,KAAK,GAAG,KAAK,KAAK,IAAI,GAAG,cAAc,OAAO,OAAO,GAAG;;AAG3E,MAAK,MAAM;AACX,QAAO,QAAQ,MAAM,CAAC,KAAK,cAAc"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kikiutils/shared",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "13.5.
|
|
4
|
+
"version": "13.5.2",
|
|
5
5
|
"description": "A lightweight and modular utility library for modern JavaScript and TypeScript — includes secure hashing, flexible logging, datetime tools, Vue/web helpers, storage abstraction, and more.",
|
|
6
6
|
"author": "kiki-kanri",
|
|
7
7
|
"license": "MIT",
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"lru-cache": "^11.2.1",
|
|
104
104
|
"millify": "^6.1.0",
|
|
105
105
|
"node-ssh": "^13.2.1",
|
|
106
|
-
"pino": "^
|
|
106
|
+
"pino": "^10.0.0",
|
|
107
107
|
"pino-pretty": "^13.1.1",
|
|
108
108
|
"superjson": "^2.2.2",
|
|
109
109
|
"vue": "^3.5.21",
|
|
@@ -176,38 +176,39 @@
|
|
|
176
176
|
},
|
|
177
177
|
"devDependencies": {
|
|
178
178
|
"@kikiutils/changelogen": "^0.9.0",
|
|
179
|
-
"@kikiutils/eslint-config": "^
|
|
179
|
+
"@kikiutils/eslint-config": "^4.0.0",
|
|
180
180
|
"@kikiutils/tsconfigs": "^5.0.5",
|
|
181
|
-
"@noble/hashes": "^2.0.
|
|
181
|
+
"@noble/hashes": "^2.0.1",
|
|
182
182
|
"@types/fs-extra": "^11.0.4",
|
|
183
183
|
"@types/jsonfile": "^6.1.4",
|
|
184
|
-
"@types/node": "^24.
|
|
184
|
+
"@types/node": "^24.6.2",
|
|
185
185
|
"@types/ssh2": "^1.15.5",
|
|
186
186
|
"@vitest/coverage-v8": "^3.2.4",
|
|
187
187
|
"async-validator": "^4.2.5",
|
|
188
188
|
"bson": "^6.10.4",
|
|
189
189
|
"consola": "^3.4.2",
|
|
190
|
-
"cross-env": "^10.
|
|
190
|
+
"cross-env": "^10.1.0",
|
|
191
191
|
"date-fns": "^4.1.0",
|
|
192
192
|
"decimal.js": "^10.6.0",
|
|
193
193
|
"depcheck": "^1.4.7",
|
|
194
|
-
"element-plus": "^2.11.
|
|
194
|
+
"element-plus": "^2.11.4",
|
|
195
195
|
"fs-extra": "^11.3.2",
|
|
196
|
-
"ioredis": "^5.
|
|
196
|
+
"ioredis": "^5.8.0",
|
|
197
197
|
"jsdom": "^27.0.0",
|
|
198
|
-
"lru-cache": "^11.2.
|
|
198
|
+
"lru-cache": "^11.2.2",
|
|
199
199
|
"millify": "^6.1.0",
|
|
200
200
|
"node-ssh": "^13.2.1",
|
|
201
|
-
"pino": "^
|
|
201
|
+
"pino": "^10.0.0",
|
|
202
202
|
"pino-pretty": "^13.1.1",
|
|
203
203
|
"publint": "^0.3.13",
|
|
204
|
+
"redis": "^5.8.3",
|
|
204
205
|
"superjson": "^2.2.2",
|
|
205
206
|
"ts-unused-exports": "^11.0.1",
|
|
206
|
-
"tsdown": "^0.15.
|
|
207
|
-
"typescript": "^5.9.
|
|
207
|
+
"tsdown": "^0.15.6",
|
|
208
|
+
"typescript": "^5.9.3",
|
|
208
209
|
"unplugin-unused": "^0.5.3",
|
|
209
210
|
"vitest": "^3.2.4",
|
|
210
|
-
"vue": "^3.5.
|
|
211
|
+
"vue": "^3.5.22",
|
|
211
212
|
"vue-router": "^4.5.1"
|
|
212
213
|
},
|
|
213
214
|
"pnpm": {
|
package/src/buffer.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Buffer } from 'node:buffer';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
File as NodeFile,
|
|
5
|
-
} from 'node:buffer';
|
|
2
|
+
|
|
3
|
+
import type { BinaryInput } from './types';
|
|
6
4
|
|
|
7
5
|
/**
|
|
8
6
|
* Converts a Blob, Buffer, or File to a Buffer.
|
|
@@ -35,7 +33,7 @@ import type {
|
|
|
35
33
|
* console.log(result3.toString()); // 'File content'
|
|
36
34
|
* ```
|
|
37
35
|
*/
|
|
38
|
-
export async function toBuffer(input:
|
|
36
|
+
export async function toBuffer(input: BinaryInput) {
|
|
39
37
|
if (Buffer.isBuffer(input)) return input;
|
|
40
38
|
return Buffer.from(await input.arrayBuffer());
|
|
41
39
|
}
|
package/src/hash.ts
CHANGED
|
@@ -17,11 +17,11 @@ import {
|
|
|
17
17
|
sha3_256,
|
|
18
18
|
sha3_384,
|
|
19
19
|
sha3_512,
|
|
20
|
-
} from '@noble/hashes/sha3';
|
|
20
|
+
} from '@noble/hashes/sha3.js';
|
|
21
21
|
import {
|
|
22
22
|
bytesToHex,
|
|
23
23
|
utf8ToBytes,
|
|
24
|
-
} from '@noble/hashes/utils';
|
|
24
|
+
} from '@noble/hashes/utils.js';
|
|
25
25
|
|
|
26
26
|
export function sha3224(data: string | Uint8Array) {
|
|
27
27
|
return bytesToHex(sha3_224(typeof data === 'string' ? utf8ToBytes(data) : data));
|
package/src/object.ts
CHANGED
|
@@ -30,12 +30,12 @@ export function stringifyObjectDeterministically(
|
|
|
30
30
|
|
|
31
31
|
function walk(object: any, path: string[] = []) {
|
|
32
32
|
if (Array.isArray(object)) {
|
|
33
|
-
object.forEach((value,
|
|
33
|
+
object.forEach((value, i) => {
|
|
34
34
|
walk(
|
|
35
35
|
value,
|
|
36
36
|
[
|
|
37
37
|
...path,
|
|
38
|
-
|
|
38
|
+
i.toString(),
|
|
39
39
|
],
|
|
40
40
|
);
|
|
41
41
|
});
|