Skip to content

Commit d2527aa

Browse files
committed
Add encrypted environment variable persistence
- Store global and project env vars encrypted at rest - Share runtime env schema across server, terminal, and provider contracts - Add shared helpers for resolving project runtime environment
1 parent 57cc5d0 commit d2527aa

10 files changed

Lines changed: 746 additions & 10 deletions

File tree

apps/server/src/persistence/Errors.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ export class PersistenceDecodeError extends Schema.TaggedErrorClass<PersistenceD
3030
}
3131
}
3232

33+
export class PersistenceCryptoError extends Schema.TaggedErrorClass<PersistenceCryptoError>()(
34+
"PersistenceCryptoError",
35+
{
36+
operation: Schema.String,
37+
detail: Schema.String,
38+
cause: Schema.optional(Schema.Defect),
39+
},
40+
) {
41+
override get message(): string {
42+
return `Crypto error in ${this.operation}: ${this.detail}`;
43+
}
44+
}
45+
3346
export function toPersistenceSqlError(operation: string) {
3447
return (cause: unknown): PersistenceSqlError =>
3548
new PersistenceSqlError({
@@ -57,8 +70,19 @@ export function toPersistenceDecodeCauseError(operation: string) {
5770
});
5871
}
5972

73+
export function toPersistenceCryptoError(operation: string) {
74+
return (cause: unknown): PersistenceCryptoError =>
75+
new PersistenceCryptoError({
76+
operation,
77+
detail: `Failed to execute ${operation}`,
78+
cause,
79+
});
80+
}
81+
6082
export const isPersistenceError = (u: unknown) =>
61-
Schema.is(PersistenceSqlError)(u) || Schema.is(PersistenceDecodeError)(u);
83+
Schema.is(PersistenceSqlError)(u) ||
84+
Schema.is(PersistenceDecodeError)(u) ||
85+
Schema.is(PersistenceCryptoError)(u);
6286

6387
// ===============================
6488
// Provider Session Repository Errors

0 commit comments

Comments
 (0)