File tree Expand file tree Collapse file tree 2 files changed +11
-13
lines changed Expand file tree Collapse file tree 2 files changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -177,6 +177,11 @@ export const projectRepository = new ProjectRepository({
177177 repository : projectUserDataRepository
178178} )
179179
180+ export const encryptionService = new RsaEncryptionService ( {
181+ publicKey : Buffer . from ( env . getOrThrow ( "ENCRYPTION_PUBLIC_KEY_BASE_64" ) , "base64" ) . toString ( "utf-8" ) ,
182+ privateKey : Buffer . from ( env . getOrThrow ( "ENCRYPTION_PRIVATE_KEY_BASE_64" ) , "base64" ) . toString ( "utf-8" )
183+ } )
184+
180185export const projectDataSource = new CachingProjectDataSource ( {
181186 dataSource : new GitHubProjectDataSource ( {
182187 repositoryDataSource : new FilteringGitHubRepositoryDataSource ( {
@@ -190,7 +195,8 @@ export const projectDataSource = new CachingProjectDataSource({
190195 projectConfigurationFilename : env . getOrThrow ( "FRAMNA_DOCS_PROJECT_CONFIGURATION_FILENAME" )
191196 } )
192197 } ) ,
193- repositoryNameSuffix : env . getOrThrow ( "REPOSITORY_NAME_SUFFIX" )
198+ repositoryNameSuffix : env . getOrThrow ( "REPOSITORY_NAME_SUFFIX" ) ,
199+ encryptionService : encryptionService
194200 } ) ,
195201 repository : projectRepository
196202} )
@@ -221,8 +227,3 @@ export const gitHubHookHandler = new GitHubHookHandler({
221227 } )
222228 } )
223229} )
224-
225- export const encryptionService = new RsaEncryptionService ( {
226- publicKey : Buffer . from ( env . getOrThrow ( "ENCRYPTION_PUBLIC_KEY_BASE_64" ) , "base64" ) . toString ( "utf-8" ) ,
227- privateKey : Buffer . from ( env . getOrThrow ( "ENCRYPTION_PRIVATE_KEY_BASE_64" ) , "base64" ) . toString ( "utf-8" )
228- } )
Original file line number Diff line number Diff line change @@ -10,24 +10,21 @@ import {
1010 GitHubRepositoryRef
1111} from "../domain"
1212import { RemoteConfig } from "@/app/api/remotes/[encryptedRemoteConfig]/route"
13- import RsaEncryptionService from "@/common/encryption/EncryptionService"
14- import { env } from "@/common"
13+ import { IEncryptionService } from "@/common/encryption/EncryptionService"
1514
1615export default class GitHubProjectDataSource implements IProjectDataSource {
1716 private readonly repositoryDataSource : IGitHubRepositoryDataSource
1817 private readonly repositoryNameSuffix : string
19- private readonly encryptionService : RsaEncryptionService
18+ private readonly encryptionService : IEncryptionService
2019
2120 constructor ( config : {
2221 repositoryDataSource : IGitHubRepositoryDataSource
2322 repositoryNameSuffix : string
23+ encryptionService : IEncryptionService
2424 } ) {
2525 this . repositoryDataSource = config . repositoryDataSource
2626 this . repositoryNameSuffix = config . repositoryNameSuffix
27- this . encryptionService = new RsaEncryptionService ( { // TODO: Would be better to load from composition root, but causes errors
28- publicKey : Buffer . from ( env . getOrThrow ( "ENCRYPTION_PUBLIC_KEY_BASE_64" ) , "base64" ) . toString ( "utf-8" ) ,
29- privateKey : Buffer . from ( env . getOrThrow ( "ENCRYPTION_PRIVATE_KEY_BASE_64" ) , "base64" ) . toString ( "utf-8" )
30- } )
27+ this . encryptionService = config . encryptionService
3128 }
3229
3330 async getProjects ( ) : Promise < Project [ ] > {
You can’t perform that action at this time.
0 commit comments