Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/giant-flies-hide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@cipherstash/nextjs": minor
"@cipherstash/jseql": minor
"@cipherstash/basic-example": minor
---

Implemented typing and import synatx for es6.
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,10 @@ const eqlClient = await eql()
.. or using ES6?

```typescript
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
const { eql } = require('@cipherstash/jseql')

import { eql } from '@cipherstash/jseql'
const eqlClient = await eql()
```

We are working on a solution to support the `import` statement in the future.

### Encrypting data

To encrypt data, use the `encrypt` function. This function takes a plaintext string and an object with the table and column name as parameters.
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"changeset:version": "changeset version",
"changeset:publish": "changeset publish",
"dev": "turbo dev --filter './packages/*'",
"clean": "rimraf --glob **/.next **/.turbo **/dist **/node_modules",
"code:fix": "biome check --write",
"release": "turbo run build && changeset publish",
"test": "turbo test --filter './packages/*'"
Expand All @@ -36,6 +37,7 @@
"@biomejs/biome": "^1.9.3",
"@changesets/cli": "^2.27.9",
"@types/node": "^22.10.2",
"rimraf": "6.0.1",
"turbo": "2.1.1"
},
"packageManager": "pnpm@9.15.3",
Expand Down
7 changes: 0 additions & 7 deletions packages/jseql/__tests__/jseql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ describe('jseql-ffi', () => {
describe('bulk encryption', () => {
it('should bulk encrypt and decrypt a payload', async () => {
const eqlClient = await eql()

const ciphertexts = await eqlClient.bulkEncrypt(
[
{
Expand All @@ -209,8 +208,6 @@ describe('bulk encryption', () => {
},
)

console.log('ct', ciphertexts)

const plaintexts = await eqlClient.bulkDecrypt(ciphertexts)

expect(plaintexts).toEqual([
Expand All @@ -227,21 +224,17 @@ describe('bulk encryption', () => {

it('should return null if plaintexts is empty', async () => {
const eqlClient = await eql()

const ciphertexts = await eqlClient.bulkEncrypt([], {
table: 'users',
column: 'column_name',
})

expect(ciphertexts).toEqual(null)
}, 30000)

it('should return null if decrypting empty ciphertexts', async () => {
const eqlClient = await eql()

const ciphertexts = null
const plaintexts = await eqlClient.bulkDecrypt(ciphertexts)

expect(plaintexts).toEqual(null)
}, 30000)
})
26 changes: 26 additions & 0 deletions packages/jseql/generateSchema.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env node

import fs from 'node:fs/promises'
import { execa } from 'execa'

async function main() {
const url =
'https://raw.githubusercontent.com/cipherstash/encrypt-query-language/main/sql/schemas/cs_plaintext_v1.schema.json'

const response = await fetch(url)
const data = await response.json()

await fs.writeFile(
'./cs_plaintext_v1.schema.json',
JSON.stringify(data, null, 2),
)

await execa('pnpm', ['run', 'generate-types'], { stdio: 'inherit' })

console.log('Types generated!')
}

main().catch((err) => {
console.error(err)
process.exit(1)
})
14 changes: 0 additions & 14 deletions packages/jseql/generateSchema.ts

This file was deleted.

4 changes: 3 additions & 1 deletion packages/jseql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@
"scripts": {
"build": "tsup",
"dev": "tsup --watch",
"update-schema": "node ./generateSchema.mjs",
"generate-types": "json2ts ./cs_plaintext_v1.schema.json --output ./src/cs_plaintext_v1.ts",
"test": "vitest run"
},
"devDependencies": {
"dotenv": "^16.4.7",
"execa": "^9.5.2",
"json-schema-to-typescript": "^15.0.2",
"tsup": "^8.3.0",
"vitest": "^2.1.8"
Expand All @@ -51,7 +53,7 @@
"access": "public"
},
"dependencies": {
"@cipherstash/jseql-ffi": "^0.4.0"
"@cipherstash/jseql-ffi": "0.5.0"
},
"optionalDependencies": {
"@rollup/rollup-linux-x64-gnu": "4.24.0"
Expand Down
Loading
Loading