-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: delete account - partial for review (#263)
Co-authored-by: Andrew Radulescu <[email protected]>
- Loading branch information
1 parent
7237710
commit bc7f35e
Showing
28 changed files
with
12,602 additions
and
1,299 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
backend/src/infrastructure/providers/cognito/cognito-provider.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Global, Module } from '@nestjs/common'; | ||
import { CognitoModule } from './module/cognito.module'; | ||
import { CognitoConfigService } from 'src/infrastructure/config/cognito.config'; | ||
|
||
@Global() | ||
@Module({ | ||
imports: [ | ||
CognitoModule.registerAsync({ | ||
useClass: CognitoConfigService, | ||
}), | ||
], | ||
exports: [CognitoModule], | ||
}) | ||
export class CognitoProviderModule {} |
Empty file.
6 changes: 6 additions & 0 deletions
6
backend/src/infrastructure/providers/cognito/module/cognito.interfaces.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export interface CognitoModuleOptions { | ||
accessKeyId: string; | ||
secretAccessKey: string; | ||
region: string; | ||
defaultUserPoolId: string; | ||
} |
16 changes: 16 additions & 0 deletions
16
backend/src/infrastructure/providers/cognito/module/cognito.module-definition.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { ConfigurableModuleBuilder } from '@nestjs/common'; | ||
import { CognitoModuleOptions } from './cognito.interfaces'; | ||
|
||
export const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN } = | ||
new ConfigurableModuleBuilder<CognitoModuleOptions>() | ||
.setExtras( | ||
{ | ||
isGlobal: true, | ||
}, | ||
(definition, extras) => ({ | ||
...definition, | ||
global: extras.isGlobal, | ||
}), | ||
) | ||
.setFactoryMethodName('createCognitoConfigOptions') | ||
.build(); |
9 changes: 9 additions & 0 deletions
9
backend/src/infrastructure/providers/cognito/module/cognito.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { ConfigurableModuleClass } from './cognito.module-definition'; | ||
import { CognitoService } from './cognito.service'; | ||
|
||
@Module({ | ||
providers: [CognitoService], | ||
exports: [CognitoService], | ||
}) | ||
export class CognitoModule extends ConfigurableModuleClass {} |
45 changes: 45 additions & 0 deletions
45
backend/src/infrastructure/providers/cognito/module/cognito.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Inject, Injectable, Logger } from '@nestjs/common'; | ||
import { MODULE_OPTIONS_TOKEN } from './cognito.module-definition'; | ||
import { CognitoModuleOptions } from './cognito.interfaces'; | ||
import { | ||
AdminDeleteUserCommand, | ||
AdminUserGlobalSignOutCommand, | ||
CognitoIdentityProviderClient, | ||
} from '@aws-sdk/client-cognito-identity-provider'; | ||
|
||
@Injectable() | ||
export class CognitoService { | ||
private readonly logger = new Logger(CognitoService.name); | ||
private readonly cognitoProvider: CognitoIdentityProviderClient; | ||
|
||
constructor( | ||
@Inject(MODULE_OPTIONS_TOKEN) private options: CognitoModuleOptions, | ||
) { | ||
this.cognitoProvider = new CognitoIdentityProviderClient({ | ||
credentials: { | ||
accessKeyId: this.options.accessKeyId, | ||
secretAccessKey: this.options.secretAccessKey, | ||
}, | ||
region: options.region, | ||
}); | ||
} | ||
|
||
async deleteUser(cognitoId: string): Promise<unknown> { | ||
const deleteUserCommand = new AdminDeleteUserCommand({ | ||
UserPoolId: this.options.defaultUserPoolId, | ||
Username: cognitoId, | ||
}); | ||
|
||
return this.cognitoProvider.send(deleteUserCommand); | ||
} | ||
|
||
async globalSignOut(cognitoId: string): Promise<unknown> { | ||
const revokeTokenCommand = new AdminUserGlobalSignOutCommand({ | ||
UserPoolId: this.options.defaultUserPoolId, | ||
Username: cognitoId, | ||
}); | ||
|
||
const data = await this.cognitoProvider.send(revokeTokenCommand); | ||
return data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.