Skip to content

Commit 2f3e8d7

Browse files
chore: wip
1 parent 85a386b commit 2f3e8d7

20 files changed

Lines changed: 221 additions & 612 deletions

File tree

bun.lock

Lines changed: 93 additions & 552 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eslint.config.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@
5353
"fresh": "bunx rimraf node_modules/ bun.lock && bun i",
5454
"prepublishOnly": "bun --bun run build",
5555
"test": "bun test",
56-
"lint": "bunx --bun eslint .",
57-
"lint:fix": "bunx --bun eslint . --fix",
56+
"lint": "bunx --bun pickier lint . --config pickier.config.ts --max-warnings 9999",
57+
"lint:fix": "bunx --bun pickier lint . --fix --config pickier.config.ts --max-warnings 9999",
58+
"format": "bunx --bun pickier format . --config pickier.config.ts",
59+
"format:fix": "bunx --bun pickier format . --write --config pickier.config.ts",
5860
"changelog": "bunx logsmith --verbose",
5961
"changelog:generate": "bunx logsmith --output CHANGELOG.md",
6062
"release": "bun run changelog:generate && bunx bumpx prompt --recursive",
@@ -68,10 +70,10 @@
6870
"@stacksjs/bumpx": "^0.2.4",
6971
"@stacksjs/clarity": "^0.3.24",
7072
"@stacksjs/docs": "^0.70.23",
71-
"@stacksjs/eslint-config": "^4.2.1-beta.1",
7273
"@stacksjs/gitlint": "^0.1.5",
7374
"@stacksjs/logsmith": "^0.2.1",
7475
"@types/bun": "^1.3.9",
76+
"better-dx": "^0.2.5",
7577
"buddy-bot": "^0.9.16",
7678
"bun-git-hooks": "^0.3.1",
7779
"bun-plugin-dtsx": "^0.21.17",
@@ -83,7 +85,7 @@
8385
"git-hooks": {
8486
"pre-commit": {
8587
"staged-lint": {
86-
"*.{js,ts,json,yaml,yml,md}": "bunx --bun eslint --fix"
88+
"*.{js,ts,json,yaml,yml,md}": "bunx --bun pickier lint --fix"
8789
}
8890
},
8991
"commit-msg": "bunx gitlint --edit .git/COMMIT_EDITMSG"

packages/aes/src/aes.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818
import type { Algorithm, BlockCipher } from './cipher'
1919
import type { CipherMode } from './cipher-modes'
20-
import { ByteStringBuffer, createBuffer } from 'ts-security-utils'
20+
import type { ByteStringBuffer } from 'ts-security-utils'
21+
import { createBuffer } from 'ts-security-utils'
2122
import { createCipher, registerAlgorithm as registerCipherAlgorithm } from './cipher'
2223
import { modes } from './cipher-modes'
2324

@@ -111,7 +112,7 @@ export class AESAlgorithm implements Algorithm {
111112

112113
// convert key byte buffer into 32-bit integer array
113114
let keyInts: number[] = []
114-
if (key && key instanceof ByteStringBuffer) {
115+
if (key && typeof key === 'object' && !Array.isArray(key) && 'getInt32' in key) {
115116
// key lengths of 16, 24, 32 bytes allowed
116117
const len = key.length()
117118
if (len === 16 || len === 24 || len === 32) {

packages/base-x/test/base-x.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ describe('ts-base-x', () => {
107107
new Uint8Array([1, 2, 3, 4, 5]),
108108
new Uint8Array([0, 0, 0, 0, 1]),
109109
new Uint8Array([255, 255, 255]),
110-
new Uint8Array(Array.from({ length: 100 }).fill(65)), // Longer input
110+
new Uint8Array(new Array<number>(100).fill(65)), // Longer input
111111
]
112112

113113
for (const testCase of testCases) {

packages/crypto/src/encrypt.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export async function encrypt(
6868
const encrypted = await crypto.subtle.encrypt(
6969
{
7070
name: algorithm,
71-
iv,
71+
iv: iv as BufferSource,
7272
},
7373
key,
7474
encoder.encode(message),
@@ -111,7 +111,7 @@ export async function decrypt(
111111
const decrypted = await crypto.subtle.decrypt(
112112
{
113113
name: algorithm,
114-
iv,
114+
iv: iv as BufferSource,
115115
},
116116
key,
117117
encrypted,

packages/hash/src/md5.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
* @author Chris Breuer
66
*/
77

8-
import { ByteStringBuffer, createBuffer, encodeUtf8, fillString } from 'ts-security-utils'
8+
import type { ByteStringBuffer } from 'ts-security-utils'
9+
import { createBuffer, encodeUtf8, fillString } from 'ts-security-utils'
910

1011
interface MD5State {
1112
h0: number
@@ -51,7 +52,7 @@ function create(): MessageDigest {
5152
let _input = createBuffer()
5253

5354
// used for word storage
54-
const _w: number[] = Array.from({ length: 16 }).fill(0)
55+
const _w: number[] = new Array<number>(16).fill(0)
5556

5657
// message digest object
5758
const md: MessageDigest = {
@@ -106,7 +107,7 @@ function create(): MessageDigest {
106107
}
107108

108109
// update message length
109-
const len = msg instanceof ByteStringBuffer ? msg.length() : msg.length
110+
const len = typeof msg !== 'string' ? msg.length() : msg.length
110111
md.messageLength += len
111112
const lenArray: LengthArray = [Math.floor(len / 0x100000000) >>> 0, len >>> 0]
112113
for (let i = md.fullMessageLength.length - 1; i >= 0; --i) {
@@ -117,7 +118,7 @@ function create(): MessageDigest {
117118
}
118119

119120
// add bytes to input buffer
120-
if (msg instanceof ByteStringBuffer) {
121+
if (typeof msg !== 'string') {
121122
_input.putBytes(msg.bytes())
122123
}
123124
else {

packages/hash/src/sha1.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { MessageDigest, SHA1State } from './types'
2-
import { ByteStringBuffer } from 'ts-security-utils'
2+
import type { ByteStringBuffer } from 'ts-security-utils'
3+
import { createBuffer } from 'ts-security-utils'
34

45
/**
56
* SHA-1 implementation
@@ -42,10 +43,10 @@ export const sha1 = {
4243
let state: SHA1State = { ..._initialState }
4344

4445
// Input buffer
45-
let _input = new ByteStringBuffer()
46+
let _input = createBuffer()
4647

4748
// Used for word operations
48-
const _w = Array.from({ length: 80 })
49+
const _w: number[] = new Array(80).fill(0)
4950

5051
// Message digest object
5152
const md: MessageDigest = {
@@ -61,7 +62,7 @@ export const sha1 = {
6162
*/
6263
start() {
6364
state = { ..._initialState }
64-
_input = new ByteStringBuffer()
65+
_input = createBuffer()
6566
this.messageLength = 0
6667
this.fullMessageLength = [0, 0]
6768
return this
@@ -75,10 +76,10 @@ export const sha1 = {
7576
update(msg: string | ByteStringBuffer, encoding = 'raw') {
7677
if (typeof msg === 'string') {
7778
if (encoding === 'utf8') {
78-
msg = new ByteStringBuffer().putString(msg)
79+
msg = createBuffer().putString(msg)
7980
}
8081
else {
81-
msg = new ByteStringBuffer().putBytes(msg)
82+
msg = createBuffer().putBytes(msg)
8283
}
8384
}
8485

@@ -119,7 +120,7 @@ export const sha1 = {
119120
_finalizeHash(finalInput, finalState, finalMessageLength)
120121

121122
// Create digest from state
122-
const digest = new ByteStringBuffer()
123+
const digest = createBuffer()
123124
digest.putInt32(finalState.h0)
124125
digest.putInt32(finalState.h1)
125126
digest.putInt32(finalState.h2)

packages/hash/src/sha256.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
*/
1717

1818
import type { MessageDigest, SHA256, SHA256State } from './types'
19-
import { ByteStringBuffer, createBuffer, encodeUtf8, fillString } from 'ts-security-utils'
19+
import type { ByteStringBuffer } from 'ts-security-utils'
20+
import { createBuffer, encodeUtf8, fillString } from 'ts-security-utils'
2021

2122
// Internal state
2223
let _initialized = false
@@ -41,7 +42,7 @@ export function createSHA256(): MessageDigest {
4142
let _input = createBuffer()
4243

4344
// Used for word storage
44-
const _w = Array.from({ length: 64 }).fill(0)
45+
const _w: number[] = Array.from({ length: 64 }).fill(0) as number[]
4546

4647
// Message digest object
4748
const md: MessageDigest = {
@@ -102,7 +103,7 @@ export function createSHA256(): MessageDigest {
102103
}
103104

104105
// Update message length
105-
const len = msg instanceof ByteStringBuffer ? msg.length() : msg.length
106+
const len = typeof msg !== 'string' ? msg.length() : msg.length
106107
md.messageLength += len
107108
const lenArr = [Math.floor(len / 0x100000000), len >>> 0]
108109

@@ -114,7 +115,7 @@ export function createSHA256(): MessageDigest {
114115
}
115116

116117
// Add bytes to input buffer
117-
_input.putBytes(msg instanceof ByteStringBuffer ? msg.bytes() : msg)
118+
_input.putBytes(typeof msg !== 'string' ? msg.bytes() : msg)
118119

119120
// Process bytes
120121
_update(_state!, _w, _input)

packages/hash/src/sha512.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import type { MessageDigest, SHA512, SHA512Algorithm } from './types'
99
*
1010
* @author Chris Breuer
1111
*/
12-
import { ByteStringBuffer, createBuffer, fillString } from 'ts-security-utils'
12+
import type { ByteStringBuffer } from 'ts-security-utils'
13+
import { createBuffer, fillString } from 'ts-security-utils'
1314

1415
// SHA-512 state interface (each value is represented as two 32-bit integers)
1516
export interface SHA512State {
@@ -115,7 +116,7 @@ export function create(algorithm: SHA512Algorithm = 'sha512'): MessageDigest {
115116

116117
// Handle UTF-8 encoding
117118
let bytes: string
118-
if (msg instanceof ByteStringBuffer) {
119+
if (typeof msg !== 'string') {
119120
bytes = msg.bytes()
120121
}
121122
else {

0 commit comments

Comments
 (0)