Skip to content

Commit ce6ed96

Browse files
fix(gate): skip unnecessary secret decryption step on SYNC_FORCE_REMOVE (#976)
#### Migration notes None - [ ] The change comes with new or modified tests - [ ] Hard-to-understand functions have explanatory comments - [ ] End-user documentation is updated to reflect the change <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a secure, improved mechanism for downloading type graph data, enhancing the retrieval process and ensuring sensitive data is handled safely. - **Refactor** - Updated processes to consistently leverage the new download approach, streamlining functionality and reinforcing robust error handling. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 47d1005 commit ce6ed96

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/typegate/src/sync/typegraph.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,23 @@ export class TypegraphStore {
6363
return id;
6464
}
6565

66-
public async download(
66+
public async downloadTypegraph(
6767
id: TypegraphId,
68-
): Promise<[TypeGraphDS, SecretManager]> {
68+
) {
6969
const key = TypegraphStore.#getKey(id);
7070
const data = await this.#downloadData(this.bucket, key);
7171
const [typegraph, encryptedSecrets] = JSON.parse(data) as [
7272
TypeGraphDS,
7373
string,
7474
];
75+
76+
return [typegraph, encryptedSecrets] satisfies [TypeGraphDS, string];
77+
}
78+
79+
public async download(
80+
id: TypegraphId,
81+
): Promise<[TypeGraphDS, SecretManager]> {
82+
const [typegraph, encryptedSecrets] = await this.downloadTypegraph(id);
7583
const secrets = JSON.parse(await this.cryptoKeys.decrypt(encryptedSecrets));
7684
const secretManager = new SecretManager(typegraph, secrets);
7785

src/typegate/src/typegate/mod.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ export class Typegate implements AsyncDisposable {
418418
) {
419419
logger.warn(`Dropping "${name}": started`);
420420
const typegraphId = typegraphIdSchema.parse(JSON.parse(payload));
421-
const [tg] = await typegraphStore.download(
421+
const [tg] = await typegraphStore.downloadTypegraph(
422422
typegraphId,
423423
);
424424
const artifacts = new Set(

0 commit comments

Comments
 (0)