@chainfuse/helpers 2.1.0 → 2.2.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.
@@ -1,4 +1,4 @@
1
- import type { D1Blob, PrefixedUuid, UndefinedProperties, UuidExport } from '@chainfuse/types';
1
+ import type { PrefixedUuid, UndefinedProperties, UuidExport } from '@chainfuse/types';
2
2
  export declare class BufferHelpers {
3
3
  static readonly utf8Regex: RegExp;
4
4
  static readonly hexRegex: RegExp;
@@ -12,18 +12,17 @@ export declare class BufferHelpers {
12
12
  static readonly base64urlRegex: RegExp;
13
13
  static bigintToBuffer(number: bigint): Promise<UuidExport['blob']>;
14
14
  static bigintToHex(number: bigint): UuidExport['hex'];
15
- static bufferToBigint(buffer: UuidExport['blob'] | D1Blob): Promise<bigint>;
15
+ static bufferToBigint(buffer: UuidExport['blob']): Promise<bigint>;
16
16
  static hexToBuffer(hex: UuidExport['hex']): Promise<UuidExport['blob']>;
17
- static bufferToHex(buffer: UuidExport['blob'] | D1Blob): Promise<UuidExport['hex']>;
17
+ static bufferToHex(buffer: UuidExport['blob']): Promise<UuidExport['hex']>;
18
18
  static base64ToBuffer(rawBase64: string): Promise<UuidExport['blob']>;
19
- static bufferToBase64(buffer: UuidExport['blob'] | D1Blob, urlSafe: boolean): Promise<string>;
19
+ static bufferToBase64(buffer: UuidExport['blob'], urlSafe: boolean): Promise<string>;
20
20
  static get generateUuid(): Promise<UuidExport>;
21
21
  static uuidConvert(input: undefined): Promise<UndefinedProperties<UuidExport>>;
22
22
  static uuidConvert(prefixedUtf: PrefixedUuid): Promise<UuidExport>;
23
23
  static uuidConvert(input: UuidExport['utf8']): Promise<UuidExport>;
24
24
  static uuidConvert(input: UuidExport['hex']): Promise<UuidExport>;
25
25
  static uuidConvert(input: UuidExport['blob']): Promise<UuidExport>;
26
- static uuidConvert(input: D1Blob): Promise<UuidExport>;
27
26
  static uuidConvert(input: UuidExport['base64']): Promise<UuidExport>;
28
27
  static uuidConvert(input: UuidExport['base64url']): Promise<UuidExport>;
29
28
  }
package/dist/buffers.mjs CHANGED
@@ -33,12 +33,12 @@ export class BufferHelpers {
33
33
  }
34
34
  static bufferToHex(buffer) {
35
35
  return (import('node:buffer')
36
- // @ts-expect-error `ArrayBufferLike` or D1Blob is actually accepted and fine
36
+ // @ts-expect-error `ArrayBufferLike` is actually accepted and fine
37
37
  .then(({ Buffer }) => Buffer.from(buffer).toString('hex'))
38
38
  /**
39
39
  * @link https://jsbm.dev/AoXo8dEke1GUg
40
40
  */
41
- // @ts-expect-error `ArrayBufferLike` or D1Blob is actually accepted and fine
41
+ // @ts-expect-error `ArrayBufferLike` is actually accepted and fine
42
42
  .catch(() => new Uint8Array(buffer).reduce((output, elem) => output + ('0' + elem.toString(16)).slice(-2), '')));
43
43
  }
44
44
  static base64ToBuffer(rawBase64) {
@@ -73,7 +73,7 @@ export class BufferHelpers {
73
73
  }
74
74
  static bufferToBase64(buffer, urlSafe) {
75
75
  return (import('node:buffer')
76
- // @ts-expect-error `ArrayBufferLike` or D1Blob is actually accepted and fine
76
+ // @ts-expect-error `ArrayBufferLike` is actually accepted and fine
77
77
  .then(({ Buffer }) => Buffer.from(buffer).toString(urlSafe ? 'base64url' : 'base64'))
78
78
  .catch(() => {
79
79
  // @ts-expect-error `ArrayBufferLike` is actually accepted and fine
@@ -152,7 +152,7 @@ export class BufferHelpers {
152
152
  return Promise.all([this.bufferToHex(input), this.bufferToBase64(input, false), this.bufferToBase64(input, true)]).then(([hex, base64, base64url]) => ({
153
153
  utf8: `${hex.substring(0, 8)}-${hex.substring(8, 12)}-${hex.substring(12, 16)}-${hex.substring(16, 20)}-${hex.substring(20)}`,
154
154
  hex,
155
- // @ts-expect-error `ArrayBufferLike` or D1Blob is actually accepted and fine
155
+ // @ts-expect-error `ArrayBufferLike` is actually accepted and fine
156
156
  blob: new Uint8Array(input).buffer,
157
157
  base64,
158
158
  base64url,
package/dist/crypto.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  export declare class CryptoHelpers {
2
- static secretBytes(byteSize: number): Promise<Uint8Array<ArrayBuffer> | Uint8Array<ArrayBuffer | SharedArrayBuffer>>;
2
+ static secretBytes(byteSize: number): Promise<Uint8Array<ArrayBuffer | SharedArrayBuffer> | Uint8Array<ArrayBuffer>>;
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.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "",
5
5
  "author": "ChainFuse",
6
6
  "homepage": "https://github.com/ChainFuse/packages/tree/main/packages/helpers#readme",
@@ -24,7 +24,7 @@
24
24
  "scripts": {
25
25
  "fmt": "prettier --check .",
26
26
  "fmt:fix": "prettier --write .",
27
- "lint": "eslint .",
27
+ "lint": "eslint src",
28
28
  "lint:fix": "npm run lint -- --fix",
29
29
  "clean": "npx -y rimraf@latest ./dist ./.tsbuildinfo",
30
30
  "build": "tsc",
@@ -54,9 +54,9 @@
54
54
  "uuid": "^11.1.0"
55
55
  },
56
56
  "devDependencies": {
57
- "@chainfuse/types": "^1.7.3",
58
- "@cloudflare/workers-types": "^4.20250319.0",
59
- "@types/node": "^22.13.10"
57
+ "@chainfuse/types": "^2.1.0",
58
+ "@cloudflare/workers-types": "^4.20250320.0",
59
+ "@types/node": "^22.13.11"
60
60
  },
61
- "gitHead": "6c9f392a8b4f0415927e2031f9cf4e585b7c2a5b"
61
+ "gitHead": "5879ee852f2629bd5b1e718602204165e097fb2d"
62
62
  }