@chainfuse/helpers 2.0.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/buffers.d.mts +3 -0
- package/dist/buffers.mjs +10 -0
- package/dist/crypto.d.mts +1 -1
- package/package.json +5 -5
package/dist/buffers.d.mts
CHANGED
|
@@ -10,6 +10,9 @@ export declare class BufferHelpers {
|
|
|
10
10
|
* @link https://base64.guru/standards/base64url
|
|
11
11
|
*/
|
|
12
12
|
static readonly base64urlRegex: RegExp;
|
|
13
|
+
static bigintToBuffer(number: bigint): Promise<UuidExport['blob']>;
|
|
14
|
+
static bigintToHex(number: bigint): UuidExport['hex'];
|
|
15
|
+
static bufferToBigint(buffer: UuidExport['blob'] | D1Blob): Promise<bigint>;
|
|
13
16
|
static hexToBuffer(hex: UuidExport['hex']): Promise<UuidExport['blob']>;
|
|
14
17
|
static bufferToHex(buffer: UuidExport['blob'] | D1Blob): Promise<UuidExport['hex']>;
|
|
15
18
|
static base64ToBuffer(rawBase64: string): Promise<UuidExport['blob']>;
|
package/dist/buffers.mjs
CHANGED
|
@@ -10,6 +10,16 @@ export class BufferHelpers {
|
|
|
10
10
|
* @link https://base64.guru/standards/base64url
|
|
11
11
|
*/
|
|
12
12
|
static base64urlRegex = new RegExp(/^[a-z\d_-]+$/i);
|
|
13
|
+
static bigintToBuffer(number) {
|
|
14
|
+
const hexString = number.toString(16);
|
|
15
|
+
return this.hexToBuffer(hexString.length % 2 === 0 ? hexString : `0${hexString}`);
|
|
16
|
+
}
|
|
17
|
+
static bigintToHex(number) {
|
|
18
|
+
return number.toString(16).length % 2 === 0 ? number.toString(16) : `0${number.toString(16)}`;
|
|
19
|
+
}
|
|
20
|
+
static bufferToBigint(buffer) {
|
|
21
|
+
return this.bufferToHex(buffer).then((hex) => BigInt(`0x${hex}`));
|
|
22
|
+
}
|
|
13
23
|
static hexToBuffer(hex) {
|
|
14
24
|
return (import('node:buffer')
|
|
15
25
|
.then(({ Buffer }) => {
|
package/dist/crypto.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare class CryptoHelpers {
|
|
2
|
-
static secretBytes(byteSize: number): Promise<Uint8Array<ArrayBuffer
|
|
2
|
+
static secretBytes(byteSize: number): Promise<Uint8Array<ArrayBuffer> | Uint8Array<ArrayBuffer | SharedArrayBuffer>>;
|
|
3
3
|
static base16secret(secretLength: number): Promise<string>;
|
|
4
4
|
static base62secret(secretLength: number): Promise<string>;
|
|
5
5
|
static getHash(algorithm: 'SHA-1' | 'SHA-256' | 'SHA-384' | 'SHA-512', input: string | ArrayBufferLike): Promise<string>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainfuse/helpers",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "ChainFuse",
|
|
6
6
|
"homepage": "https://github.com/ChainFuse/packages/tree/main/packages/helpers#readme",
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@discordjs/rest": "^2.4.3",
|
|
52
52
|
"chalk": "^5.4.1",
|
|
53
|
-
"cloudflare": "^4.
|
|
53
|
+
"cloudflare": "^4.2.0",
|
|
54
54
|
"uuid": "^11.1.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@chainfuse/types": "^1.7.
|
|
58
|
-
"@cloudflare/workers-types": "^4.
|
|
57
|
+
"@chainfuse/types": "^1.7.3",
|
|
58
|
+
"@cloudflare/workers-types": "^4.20250319.0",
|
|
59
59
|
"@types/node": "^22.13.10"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "6c9f392a8b4f0415927e2031f9cf4e585b7c2a5b"
|
|
62
62
|
}
|