@uniorganization/uni-lib 4.1.2 → 4.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,9 @@
1
1
  import { CanActivate, ExecutionContext } from '@nestjs/common';
2
- import { Repository } from 'typeorm';
3
- import { ClientCredential } from '../../entities/client-credential.entity';
2
+ import { DataSource } from 'typeorm';
4
3
  export declare function hashTenantCredentialSecret(secret: string): string;
5
4
  export declare class TenantCredentialGuard implements CanActivate {
6
- private readonly credentialRepository;
7
- constructor(credentialRepository: Repository<ClientCredential>);
5
+ private readonly dataSource;
6
+ constructor(dataSource: DataSource);
8
7
  canActivate(context: ExecutionContext): Promise<boolean>;
9
8
  private getHeader;
10
9
  private getCorrelationId;
@@ -33,8 +33,8 @@ function hashTenantCredentialSecret(secret) {
33
33
  return (0, crypto_1.createHash)('sha256').update(secret, 'utf8').digest('hex');
34
34
  }
35
35
  let TenantCredentialGuard = class TenantCredentialGuard {
36
- constructor(credentialRepository) {
37
- this.credentialRepository = credentialRepository;
36
+ constructor(dataSource) {
37
+ this.dataSource = dataSource;
38
38
  }
39
39
  canActivate(context) {
40
40
  return __awaiter(this, void 0, void 0, function* () {
@@ -44,7 +44,8 @@ let TenantCredentialGuard = class TenantCredentialGuard {
44
44
  if (!parsed) {
45
45
  throw new common_1.UnauthorizedException();
46
46
  }
47
- const credential = yield this.credentialRepository
47
+ const credential = yield this.dataSource
48
+ .getRepository(client_credential_entity_1.ClientCredential)
48
49
  .createQueryBuilder('credential')
49
50
  .addSelect('credential.secretHash')
50
51
  .innerJoinAndSelect('credential.client', 'client')
@@ -114,6 +115,6 @@ let TenantCredentialGuard = class TenantCredentialGuard {
114
115
  exports.TenantCredentialGuard = TenantCredentialGuard;
115
116
  exports.TenantCredentialGuard = TenantCredentialGuard = __decorate([
116
117
  (0, common_1.Injectable)(),
117
- __param(0, (0, typeorm_1.InjectRepository)(client_credential_entity_1.ClientCredential)),
118
- __metadata("design:paramtypes", [typeorm_2.Repository])
118
+ __param(0, (0, typeorm_1.InjectDataSource)()),
119
+ __metadata("design:paramtypes", [typeorm_2.DataSource])
119
120
  ], TenantCredentialGuard);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniorganization/uni-lib",
3
- "version": "4.1.2",
3
+ "version": "4.1.3",
4
4
  "description": "UNI Library",
5
5
  "author": "Jhomiguel",
6
6
  "main": "dist/index.js",