Skip to content

Commit 837c4d6

Browse files
Shawclaude
andcommitted
fix(cloud-shared): biome organizeImports + format across db/crypto + token-redemption + payout-fork test
Auto-fix: `biome check --write`. Sweeps: - db/crypto/{api-keys,conversations,crypto.test,field-crypto,index,platform-credentials,users}.ts - db/schemas/{index,secrets,users}.ts - db/migrations/meta/_journal.json - lib/services/token-redemption-secure.ts - lib/services/__tests__/payout-fork.integration.test.ts Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e67b2be commit 837c4d6

13 files changed

Lines changed: 32 additions & 54 deletions

File tree

packages/cloud-shared/src/db/crypto/api-keys.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* after insert — the plaintext never persists outside the encrypted columns.
1111
*/
1212

13-
import { encryptField, decryptField, type EncryptedField, type FieldCoords } from "./field-crypto";
13+
import { decryptField, type EncryptedField, encryptField, type FieldCoords } from "./field-crypto";
1414

1515
const COORDS = (rowId: string): FieldCoords => ({
1616
table: "api_keys",
@@ -33,9 +33,6 @@ export async function encryptApiKey(
3333
/**
3434
* Decrypt an API-key plaintext from the encrypted columns.
3535
*/
36-
export async function decryptApiKey(
37-
rowId: string,
38-
field: EncryptedField,
39-
): Promise<string> {
36+
export async function decryptApiKey(rowId: string, field: EncryptedField): Promise<string> {
4037
return decryptField(field, COORDS(rowId));
4138
}

packages/cloud-shared/src/db/crypto/conversations.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@
77
* column.
88
*/
99

10-
import {
11-
decryptField,
12-
encryptField,
13-
type EncryptedField,
14-
} from "./field-crypto";
10+
import { decryptField, type EncryptedField, encryptField } from "./field-crypto";
1511

1612
const TABLE = "conversation_messages";
1713
const COLUMN = "content";

packages/cloud-shared/src/db/crypto/crypto.test.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,9 @@ describe("field-crypto", () => {
5252
test("AAD mismatch causes decrypt to fail", async () => {
5353
const coords = { table: "t1", rowId: ROW, column: "c1" };
5454
const enc = await encryptField(ORG, "secret", coords);
55-
await expect(
56-
decryptField(enc, { ...coords, rowId: ROW_B }),
57-
).rejects.toThrow();
58-
await expect(
59-
decryptField(enc, { ...coords, column: "c2" }),
60-
).rejects.toThrow();
61-
await expect(
62-
decryptField(enc, { ...coords, table: "other" }),
63-
).rejects.toThrow();
55+
await expect(decryptField(enc, { ...coords, rowId: ROW_B })).rejects.toThrow();
56+
await expect(decryptField(enc, { ...coords, column: "c2" })).rejects.toThrow();
57+
await expect(decryptField(enc, { ...coords, table: "other" })).rejects.toThrow();
6458
});
6559

6660
test("blindIndex is deterministic for the same input", async () => {

packages/cloud-shared/src/db/crypto/field-crypto.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ export async function encryptField(
5454
const kms = getKmsClient();
5555
const keyId = orgKey(orgId, "dek");
5656
await kms.getOrCreateKey(keyId);
57-
const result = await kms.encrypt(keyId, enc.encode(plaintext), aadFor(coords.table, coords.rowId, coords.column));
57+
const result = await kms.encrypt(
58+
keyId,
59+
enc.encode(plaintext),
60+
aadFor(coords.table, coords.rowId, coords.column),
61+
);
5862
return {
5963
ciphertext: b64encode(result.ciphertext),
6064
nonce: b64encode(result.nonce),
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
export * as apiKeyCrypto from "./api-keys";
2+
export * as conversationCrypto from "./conversations";
13
export * from "./field-crypto";
24
export * from "./kms-client";
3-
export * as apiKeyCrypto from "./api-keys";
4-
export * as userCrypto from "./users";
55
export * as platformCredentialCrypto from "./platform-credentials";
6-
export * as conversationCrypto from "./conversations";
6+
export * as userCrypto from "./users";

packages/cloud-shared/src/db/crypto/platform-credentials.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44
* Encrypted columns: platform_user_id, platform_email, platform_display_name.
55
*/
66

7-
import {
8-
decryptField,
9-
encryptField,
10-
type EncryptedField,
11-
} from "./field-crypto";
7+
import { decryptField, type EncryptedField, encryptField } from "./field-crypto";
128

139
const TABLE = "platform_credentials";
1410

packages/cloud-shared/src/db/crypto/users.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
import {
1111
blindIndex,
1212
decryptField,
13+
type EncryptedField,
1314
encryptField,
1415
normalizeEmail,
1516
normalizePhone,
1617
normalizeWallet,
17-
type EncryptedField,
1818
} from "./field-crypto";
1919

2020
const TABLE = "users";

packages/cloud-shared/src/db/migrations/meta/_journal.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,4 +920,4 @@
920920
"breakpoints": true
921921
}
922922
]
923-
}
923+
}

packages/cloud-shared/src/db/schemas/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ export * from "./alb-priorities";
2323
export * from "./analytics-alert-events";
2424
export * from "./anonymous-sessions";
2525
export * from "./api-keys";
26-
export * from "./auth-events";
2726
export * from "./app-billing";
2827
export * from "./app-config";
2928
export * from "./app-credit-balances";
3029
export * from "./app-databases";
3130
export * from "./app-domains";
3231
export * from "./app-earnings";
3332
export * from "./apps";
33+
export * from "./auth-events";
3434
export * from "./cli-auth-sessions";
3535
export * from "./containers";
3636
export * from "./conversations";

packages/cloud-shared/src/db/schemas/secrets.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,7 @@ export const secretAuditLog = pgTable(
256256
// shorter retention (e.g. dev events). Purge job at
257257
// packages/cloud-api/src/jobs/audit-log-purge.ts removes rows where
258258
// expires_at < now().
259-
expires_at: timestamp("expires_at")
260-
.notNull()
261-
.default(sql`now() + interval '7 years'`),
259+
expires_at: timestamp("expires_at").notNull().default(sql`now() + interval '7 years'`),
262260
},
263261
(table) => ({
264262
secret_idx: index("secret_audit_log_secret_idx").on(table.secret_id),

0 commit comments

Comments
 (0)