|
1 | | -import { getEmailArg } from "@cipherstash/utils"; |
2 | | -import { cs_match_v1 } from "@cipherstash/eql/drizzle"; |
3 | | -import { getPlaintext } from "@cipherstash/eql"; |
4 | | -import { db } from "./db"; |
5 | | -import { users } from "./schema"; |
| 1 | +import { getEmailArg } from '@cipherstash-jseql-examples/utils' |
| 2 | +import { cs_match_v1 } from '@cipherstash/jseql/drizzle' |
| 3 | +import { getPlaintext } from '@cipherstash/jseql' |
| 4 | +import { db } from './db' |
| 5 | +import { users } from './schema' |
6 | 6 |
|
7 | 7 | const email = getEmailArg({ |
8 | | - required: false, |
9 | | -}); |
| 8 | + required: false, |
| 9 | +}) |
10 | 10 |
|
11 | 11 | const sql = db |
12 | | - .select({ |
13 | | - email: users.email_encrypted, |
14 | | - }) |
15 | | - .from(users); |
| 12 | + .select({ |
| 13 | + email: users.email_encrypted, |
| 14 | + }) |
| 15 | + .from(users) |
16 | 16 |
|
17 | 17 | if (email) { |
18 | | - sql.where(cs_match_v1(users, users.email_encrypted, email)); |
| 18 | + sql.where(cs_match_v1(users, users.email_encrypted, email)) |
19 | 19 | } |
20 | 20 |
|
21 | | -const sqlResult = sql.toSQL(); |
22 | | -console.log("[INFO] SQL statement:", sqlResult); |
| 21 | +const sqlResult = sql.toSQL() |
| 22 | +console.log('[INFO] SQL statement:', sqlResult) |
23 | 23 |
|
24 | | -const data = await sql.execute(); |
25 | | -console.log("[INFO] All emails have been decrypted by CipherStash Proxy"); |
| 24 | +const data = await sql.execute() |
| 25 | +console.log('[INFO] All emails have been decrypted by CipherStash Proxy') |
26 | 26 | console.log( |
27 | | - "Emails:", |
28 | | - JSON.stringify( |
29 | | - data.map((row) => getPlaintext(row.email)), |
30 | | - null, |
31 | | - 2, |
32 | | - ), |
33 | | -); |
| 27 | + 'Emails:', |
| 28 | + JSON.stringify( |
| 29 | + data.map((row) => row.email && getPlaintext(row.email)), |
| 30 | + null, |
| 31 | + 2, |
| 32 | + ), |
| 33 | +) |
34 | 34 |
|
35 | | -process.exit(0); |
| 35 | +process.exit(0) |
0 commit comments