Skip to content

Commit

Permalink
ArrayBuffer back to Uint8Array, CI cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
boorad committed May 16, 2024
1 parent b493a20 commit 9bb4964
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 26 deletions.
17 changes: 0 additions & 17 deletions examples/react-native/__tests__/App.test.tsx

This file was deleted.

3 changes: 1 addition & 2 deletions examples/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"ios": "react-native run-ios",
"lint": "eslint .",
"pods": "bundle install && bundle exec pod install --project-directory=ios/",
"start": "react-native start",
"test": "jest"
"start": "react-native start"
},
"dependencies": {
"@fireproof/core": "workspace:^",
Expand Down
8 changes: 4 additions & 4 deletions packages/encrypted-blockstore/src/encrypt-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ function makeEncDec(crypto: any, randomBytes: (size: number) => Uint8Array) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
const chunker = bf(30)

function hexStringToArrayBuffer(hexString: string): ArrayBuffer {
function hexStringToUint8Array(hexString: string): Uint8Array {
const length = hexString.length
const uint8Array = new Uint8Array(length / 2)
for (let i = 0; i < length; i += 2) {
uint8Array[i / 2] = parseInt(hexString.substring(i, i + 2), 16)
}
return uint8Array.buffer
return uint8Array
}

export async function encryptedEncodeCarFile(
Expand All @@ -143,7 +143,7 @@ export async function encryptedEncodeCarFile(
rootCid: AnyLink,
t: CarMakeable
): Promise<AnyBlock> {
const encryptionKey = hexStringToArrayBuffer(key)
const encryptionKey = hexStringToUint8Array(key)
const encryptedBlocks = new MemoryBlockstore()
const cidsToEncrypt = [] as AnyLink[]
for (const { cid } of t.entries()) {
Expand Down Expand Up @@ -184,7 +184,7 @@ async function decodeCarBlocks(
get: (cid: any) => Promise<AnyBlock | undefined>,
keyMaterial: string
): Promise<{ blocks: MemoryBlockstore; root: AnyLink }> {
const decryptionKeyUint8 = hexStringToArrayBuffer(keyMaterial)
const decryptionKeyUint8 = hexStringToUint8Array(keyMaterial)
const decryptionKey = decryptionKeyUint8.slice(0, decryptionKeyUint8.byteLength)

const decryptedBlocks = new MemoryBlockstore()
Expand Down
4 changes: 1 addition & 3 deletions packages/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@
"format:fix": "prettier . --write",
"lint:check": "eslint . --ext .ts,.tsx",
"lint:fix": "eslint . --ext .ts,.tsx --fix",
"start": "tsup -w",
"test": "vitest run",
"test:cov": "vitest run --coverage"
"start": "tsup -w"
},
"author": "J Chris Anderson",
"license": "Apache-2.0 OR MIT",
Expand Down
1 change: 1 addition & 0 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"react-dom": ">=18.0.0"
},
"devDependencies": {
"@babel/runtime": "^7.20.0",
"@testing-library/react": "^14.1.2",
"@types/react": "^18.2.48",
"@types/react-dom": "^18.2.18",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9bb4964

Please sign in to comment.