Skip to content

Commit 7ba9119

Browse files
authored
Merge pull request #303 from cipherstash/remove-examples
chore: remove outdated examples
2 parents fa2b85d + 158d5b9 commit 7ba9119

148 files changed

Lines changed: 446 additions & 16646 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/basic/README.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Basic example of using @cipherstash/protect
1+
# Basic example of using @cipherstash/stack
22

3-
This basic example demonstrates how to use the `@cipherstash/protect` package to encrypt arbitrary input.
3+
This basic example demonstrates how to use the `@cipherstash/stack` package and the **Encryption SDK** to encrypt and decrypt arbitrary input.
44

55
## Installing the basic example
66

@@ -16,7 +16,7 @@ git clone https://github.com/cipherstash/protectjs
1616
Install dependencies:
1717

1818
```bash
19-
# Build Project.js
19+
# Build the repo (including @cipherstash/stack)
2020
cd protectjs
2121
pnpm build
2222

@@ -43,7 +43,7 @@ Lastly, install the CipherStash CLI:
4343
> [!IMPORTANT]
4444
> Make sure you have [installed the CipherStash CLI](#installation) before following these steps.
4545
46-
Set up all the configuration and credentials required for Protect.js:
46+
Set up all the configuration and credentials required for the Encryption SDK:
4747

4848
```bash
4949
stash setup
@@ -53,8 +53,8 @@ If you have not already signed up for a CipherStash account, this will prompt yo
5353

5454
At the end of `stash setup`, you will have two files in your project:
5555

56-
- `cipherstash.toml` which contains the configuration for Protect.js
57-
- `cipherstash.secret.toml` which contains the credentials for Protect.js
56+
- `cipherstash.toml` which contains the configuration for the Encryption SDK
57+
- `cipherstash.secret.toml` which contains the credentials for the Encryption SDK
5858

5959
> [!WARNING]
6060
> Do not commit `cipherstash.secret.toml` to git, because it contains sensitive credentials.
@@ -68,8 +68,4 @@ Run the example:
6868
pnpm start
6969
```
7070

71-
The application will log the plaintext to the console that has been encrypted using the CipherStash, decrypted, and logged the original plaintext.
72-
73-
## Next steps
74-
75-
Check out the [Protect.js + Next.js + Clerk example app](../nextjs-clerk) to see how to add end-user identity as an extra control when encrypting data.
71+
The application will prompt for a name, encrypt it with CipherStash, log the ciphertext, decrypt it, and log the original plaintext. It then runs a short bulk-encryption demo.

examples/basic/encrypt.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import 'dotenv/config'
2+
import {
3+
Encryption,
4+
encryptedTable,
5+
encryptedColumn,
6+
} from '@cipherstash/stack'
7+
8+
export const users = encryptedTable('users', {
9+
name: encryptedColumn('name'),
10+
})
11+
12+
export const client = await Encryption({
13+
schemas: [users],
14+
})

examples/basic/index.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'dotenv/config'
22
import readline from 'node:readline'
3-
import { protectClient, users } from './protect'
3+
import { client, users } from './encrypt'
44

55
const rl = readline.createInterface({
66
input: process.stdin,
@@ -18,24 +18,24 @@ const askQuestion = (): Promise<string> => {
1818
async function main() {
1919
const input = await askQuestion()
2020

21-
const encryptResult = await protectClient.encrypt(input, {
21+
const encryptResult = await client.encrypt(input, {
2222
column: users.name,
2323
table: users,
2424
})
2525

2626
if (encryptResult.failure) {
27-
throw new Error(`[protect]: ${encryptResult.failure.message}`)
27+
throw new Error(`[encryption]: ${encryptResult.failure.message}`)
2828
}
2929

3030
const ciphertext = encryptResult.data
3131

3232
console.log('Encrypting your name...')
3333
console.log('The ciphertext is:', ciphertext)
3434

35-
const decryptResult = await protectClient.decrypt(ciphertext)
35+
const decryptResult = await client.decrypt(ciphertext)
3636

3737
if (decryptResult.failure) {
38-
throw new Error(`[protect]: ${decryptResult.failure.message}`)
38+
throw new Error(`[encryption]: ${decryptResult.failure.message}`)
3939
}
4040

4141
const plaintext = decryptResult.data
@@ -50,21 +50,20 @@ async function main() {
5050
{ id: '1', plaintext: 'Alice' },
5151
{ id: '2', plaintext: 'Bob' },
5252
{ id: '3', plaintext: 'Charlie' },
53-
{ id: '4', plaintext: null },
5453
]
5554

5655
console.log(
5756
'Bulk encrypting names:',
5857
bulkPlaintexts.map((p) => p.plaintext),
5958
)
6059

61-
const bulkEncryptResult = await protectClient.bulkEncrypt(bulkPlaintexts, {
60+
const bulkEncryptResult = await client.bulkEncrypt(bulkPlaintexts, {
6261
column: users.name,
6362
table: users,
6463
})
6564

6665
if (bulkEncryptResult.failure) {
67-
throw new Error(`[protect]: ${bulkEncryptResult.failure.message}`)
66+
throw new Error(`[encryption]: ${bulkEncryptResult.failure.message}`)
6867
}
6968

7069
console.log('Bulk encrypted data:', bulkEncryptResult.data)

examples/basic/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"license": "ISC",
1212
"description": "",
1313
"dependencies": {
14-
"@cipherstash/protect": "workspace:*",
14+
"@cipherstash/stack": "workspace:*",
1515
"dotenv": "^16.4.7"
1616
},
1717
"devDependencies": {

examples/basic/protect.ts

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

examples/drizzle/.env.example

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

0 commit comments

Comments
 (0)