Skip to content

Commit

Permalink
npm fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Szotkowski committed Sep 19, 2023
1 parent 016729b commit a0fac10
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 32 deletions.
5 changes: 3 additions & 2 deletions src/controllers/user-instruction.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class UserInstructionController {
@repository(StepRepository) public stepRepository: StepRepository,
@repository(UserRepository)
protected progressRepository: ProgressRepository,
) { }
) {}

@authenticate('jwt')
@post('/users/{id}/instructions/{instructionId}', {
Expand Down Expand Up @@ -664,7 +664,8 @@ export class UserInstructionController {
@param.query.number('instructionId') instructionId: number,
@param.query.number('userId') userId: number,
): Promise<boolean> {
const instructionKey = process.env.INSTRUCTION_KEY_PREMIUM_PERMISSIONS ?? '';
const instructionKey =
process.env.INSTRUCTION_KEY_PREMIUM_PERMISSIONS ?? '';
const keyMatch = await this.hasher.comparePassword(
request.key,
instructionKey,
Expand Down
14 changes: 6 additions & 8 deletions src/controllers/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class UserController {
@repository(StepRepository) public stepRepository: StepRepository,
@repository(UserLinkRepository)
public userLinkRepository: UserLinkRepository,
) { }
) {}

@post('/login', {
responses: {
Expand Down Expand Up @@ -182,16 +182,12 @@ export class UserController {
language: credentials.language,
});
const dbUser = await this.userRepository.create(newUser);
await this.vaultService.createUserPolicy(
String(dbUser.id),
);
await this.vaultService.createUserPolicy(String(dbUser.id));
await this.vaultService.createUser(
String(dbUser.id),
credentials.password0,
);
await this.vaultService.createUserKey(
String(dbUser.id),
);
await this.vaultService.createUserKey(String(dbUser.id));
await this.emailService.sendRegistrationEmail(dbUser);
const secret = process.env.JWT_SECRET_SIGNUP ?? '';
const userId = dbUser.id;
Expand Down Expand Up @@ -253,7 +249,9 @@ export class UserController {
if (user.wrappedDEK !== 'null') {
throw new HttpErrors.UnprocessableEntity('DEK already saved');
}
await this.userRepository.updateById(user.id, {wrappedDEK: request.wrappedDEK});
await this.userRepository.updateById(user.id, {
wrappedDEK: request.wrappedDEK,
});
return true;
} catch (error) {
if (error.name === 'TokenExpiredError') {
Expand Down
3 changes: 2 additions & 1 deletion src/datasources/db.datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const config = {
@lifeCycleObserver('datasource')
export class DbDataSource
extends juggler.DataSource
implements LifeCycleObserver {
implements LifeCycleObserver
{
static dataSourceName = 'db';
static readonly defaultConfig = config;

Expand Down
2 changes: 1 addition & 1 deletion src/services/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dotenv.config();

@bind({scope: BindingScope.TRANSIENT})
export class EmailService {
constructor() { }
constructor() {}

public generateVerificationToken(userId: number): string {
const secret = process.env.JWT_SECRET_EMAIL ?? '';
Expand Down
2 changes: 1 addition & 1 deletion src/services/imgur-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dotenv.config();
export class ImgurService {
private readonly clientId = process.env.IMGUR_CLIENT_ID ?? '';

constructor() { }
constructor() {}

async savePicture(
request: Request,
Expand Down
30 changes: 11 additions & 19 deletions src/services/vault-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ export class VaultService {

private async unseal(): Promise<void> {
try {
const unsealKeys: string[] = [this.unsealKeys[0], this.unsealKeys[1], this.unsealKeys[2]];
const unsealKeys: string[] = [
this.unsealKeys[0],
this.unsealKeys[1],
this.unsealKeys[2],
];
for (const key of unsealKeys) {
const response = await fetch(`${this.vaultEndpoint}/v1/sys/unseal`, {
method: 'POST',
Expand All @@ -51,9 +55,7 @@ export class VaultService {
}),
});
if (!response.ok) {
throw new Error(
`Unseal error`,
);
throw new Error(`Unseal error`);
}
}
} catch (error) {
Expand All @@ -79,9 +81,7 @@ export class VaultService {
},
);
if (!response.ok) {
throw new Error(
`Unable to create policy`,
);
throw new Error(`Unable to create policy`);
}
} catch (error) {
throw new Error(`Authentication error: ${error.message}`);
Expand All @@ -105,9 +105,7 @@ export class VaultService {
},
);
if (!response.ok) {
throw new Error(
`Unable to create user`,
);
throw new Error(`Unable to create user`);
}
} catch (error) {
throw new Error(`Authentication error: ${error.message}`);
Expand All @@ -126,9 +124,7 @@ export class VaultService {
},
);
if (!response.ok) {
throw new Error(
`Unable to create key`,
);
throw new Error(`Unable to create key`);
}
} catch (error) {
throw new Error(`Authentication error: ${error.message}`);
Expand All @@ -151,9 +147,7 @@ export class VaultService {
},
);
if (!response.ok) {
throw new Error(
`Unable to update password`,
);
throw new Error(`Unable to update password`);
}
} catch (error) {
throw new Error(`Authentication error: ${error.message}`);
Expand All @@ -172,9 +166,7 @@ export class VaultService {
},
);
if (!response.ok) {
throw new Error(
`Unable to delete user`,
);
throw new Error(`Unable to delete user`);
}
} catch (error) {
throw new Error(`Authentication error: ${error.message}`);
Expand Down

0 comments on commit a0fac10

Please sign in to comment.