Skip to content

Commit 2d62064

Browse files
chore: 🤖 bump NestJS and other deps
1 parent f8aac8b commit 2d62064

37 files changed

+3646
-3367
lines changed

‎package.json‎

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -39,58 +39,58 @@
3939
"docker:build:no-cache": "docker build --no-cache -t polymeshassociation/polymesh-rest-api:local ."
4040
},
4141
"dependencies": {
42-
"@golevelup/ts-jest": "^0.3.3",
43-
"@nestjs/axios": "^3.0.2",
44-
"@nestjs/common": "^10.3.7",
45-
"@nestjs/config": "^3.2.2",
46-
"@nestjs/core": "^10.3.7",
47-
"@nestjs/passport": "^10.0.3",
48-
"@nestjs/platform-express": "^10.3.7",
49-
"@nestjs/schedule": "^4.0.2",
50-
"@nestjs/swagger": "^7.3.1",
51-
"@nestjs/typeorm": "^10.0.2",
42+
"@golevelup/ts-jest": "0.3.3",
43+
"@nestjs/axios": "^4.0.1",
44+
"@nestjs/common": "^11.1.6",
45+
"@nestjs/config": "^4.0.2",
46+
"@nestjs/core": "^11.1.6",
47+
"@nestjs/passport": "^11.0.5",
48+
"@nestjs/platform-express": "^11.1.6",
49+
"@nestjs/schedule": "^6.0.1",
50+
"@nestjs/swagger": "^11.2.0",
51+
"@nestjs/typeorm": "^11.0.0",
5252
"@polymeshassociation/fireblocks-signing-manager": "^2.5.0",
53-
"@polymeshassociation/hashicorp-vault-signing-manager": "^3.4.0",
54-
"@polymeshassociation/local-signing-manager": "^3.3.0",
53+
"@polymeshassociation/hashicorp-vault-signing-manager": "^3.5.0",
54+
"@polymeshassociation/local-signing-manager": "^3.5.2",
5555
"@polymeshassociation/polymesh-sdk": "v29.1.0-beta.9",
5656
"@polymeshassociation/polymesh-types": "^6.2.0",
57-
"@polymeshassociation/signing-manager-types": "^3.2.0",
57+
"@polymeshassociation/signing-manager-types": "^3.4.2",
5858
"class-transformer": "0.5.1",
5959
"class-validator": "^0.14.0",
60-
"joi": "17.4.0",
61-
"json-stable-stringify": "^1.0.2",
60+
"joi": "18.0.1",
61+
"json-stable-stringify": "^1.3.0",
6262
"lodash": "4.17.21",
6363
"passport": "^0.7.0",
6464
"passport-custom": "^1.1.1",
6565
"passport-headerapikey": "^1.2.2",
66-
"pg": "^8.11.5",
66+
"pg": "^8.16.3",
6767
"reflect-metadata": "0.2.2",
6868
"rhea-promise": "^3.0.1",
6969
"rimraf": "3.0.2",
70-
"rxjs": "^7.5.7",
71-
"swagger-ui-express": "5.0.0",
72-
"typeorm": "^0.3.17"
70+
"rxjs": "^7.8.2",
71+
"swagger-ui-express": "5.0.1",
72+
"typeorm": "^0.3.27"
7373
},
7474
"devDependencies": {
7575
"@babel/plugin-transform-modules-commonjs": "7.22.11",
76-
"@commitlint/cli": "^17.7.1",
77-
"@commitlint/config-conventional": "^17.7.0",
78-
"@nestjs/cli": "^10.1.17",
79-
"@nestjs/schematics": "^10.0.2",
80-
"@nestjs/testing": "^10.2.4",
76+
"@commitlint/cli": "^20.1.0",
77+
"@commitlint/config-conventional": "^20.0.0",
78+
"@nestjs/cli": "^11.0.10",
79+
"@nestjs/schematics": "^11.0.8",
80+
"@nestjs/testing": "^11.1.6",
8181
"@semantic-release/changelog": "^6.0.3",
82-
"@semantic-release/exec": "^6.0.3",
83-
"@semantic-release/npm": "^11.0.0",
84-
"@types/axios": "^0.14.0",
85-
"@types/cron": "^1.7.3",
86-
"@types/express": "4.17.17",
82+
"@semantic-release/exec": "^7.1.0",
83+
"@semantic-release/npm": "^12.0.2",
84+
"@types/axios": "^0.14.4",
85+
"@types/cron": "^2.4.3",
86+
"@types/express": "5.0.3",
8787
"@types/jest": "29.5.4",
88-
"@types/jest-when": "^3.5.2",
89-
"@types/json-stable-stringify": "^1.0.34",
88+
"@types/jest-when": "^3.5.5",
89+
"@types/json-stable-stringify": "^1.2.0",
9090
"@types/lodash": "^4.14.197",
9191
"@types/node": "^18.15.11",
92-
"@types/passport": "^1.0.11",
93-
"@types/supertest": "2.0.12",
92+
"@types/passport": "^1.0.17",
93+
"@types/supertest": "6.0.3",
9494
"@typescript-eslint/eslint-plugin": "6.9.1",
9595
"@typescript-eslint/parser": "6.9.1",
9696
"@zerollup/ts-transform-paths": "1.7.11",
@@ -106,16 +106,17 @@
106106
"eslint-plugin-simple-import-sort": "10.0.0",
107107
"husky": "8.0.3",
108108
"jest": "29.7.0",
109-
"jest-when": "^3.6.0",
109+
"jest-when": "^3.7.0",
110110
"lint-staged": "14.0.1",
111+
"path-to-regexp": "^8.3.0",
111112
"prettier": "2.8.8",
112113
"prettier-eslint": "15.0.1",
113114
"prettier-eslint-cli": "7.1.0",
114-
"semantic-release": "^22.0.0",
115-
"supertest": "6.1.3",
116-
"ts-jest": "29.1.1",
117-
"ts-loader": "9.4.4",
118-
"ts-node": "10.9.1",
115+
"semantic-release": "^24.2.9",
116+
"supertest": "7.1.4",
117+
"ts-jest": "29.4.4",
118+
"ts-loader": "9.5.4",
119+
"ts-node": "10.9.2",
119120
"tsconfig-paths": "^4.2.0",
120121
"typescript": "4.8.2"
121122
},

‎src/accounts/accounts.service.spec.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ describe('AccountsService', () => {
8686

8787
const address = 'address';
8888

89-
await expect(() => service.findOne(address)).rejects.toThrowError();
89+
await expect(() => service.findOne(address)).rejects.toThrow();
9090

9191
expect(handleSdkErrorSpy).toHaveBeenCalledWith(mockError);
9292
});
@@ -217,7 +217,7 @@ describe('AccountsService', () => {
217217

218218
const handleSdkErrorSpy = jest.spyOn(transactionsUtilModule, 'handleSdkError');
219219

220-
await expect(() => service.getPermissions('address')).rejects.toThrowError();
220+
await expect(() => service.getPermissions('address')).rejects.toThrow();
221221

222222
expect(handleSdkErrorSpy).toHaveBeenCalledWith(mockError);
223223
});

‎src/assets/assets.service.spec.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ describe('AssetsService', () => {
117117

118118
const address = 'address';
119119

120-
await expect(() => service.findOne(address)).rejects.toThrowError();
120+
await expect(() => service.findOne(address)).rejects.toThrow();
121121

122122
expect(handleSdkErrorSpy).toHaveBeenCalledWith(mockError);
123123
});
@@ -144,7 +144,7 @@ describe('AssetsService', () => {
144144

145145
const address = 'address';
146146

147-
await expect(() => service.findFungible(address)).rejects.toThrowError();
147+
await expect(() => service.findFungible(address)).rejects.toThrow();
148148

149149
expect(handleSdkErrorSpy).toHaveBeenCalledWith(mockError);
150150
});

‎src/assets/models/transfer-restrictions-values.model.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ export class TransferRestrictionClaimDetailsModel {
129129
@ApiPropertyOneOf({
130130
description:
131131
'Breakdown of holders or balances for the statistic. Jurisdiction claims include an entry per country code, while other claims display holders with/without the claim.',
132-
required: false,
133132
union: [
134133
TransferRestrictionClaimValueBreakdownModel,
135134
{

‎src/auth/auth.service.spec.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ describe('AuthService', () => {
7676

7777
await service.deleteApiKey({ apiKey: testApiKey });
7878

79-
expect(mockApiKeyRepo.deleteApiKey).toBeCalledWith(testApiKey);
79+
expect(mockApiKeyRepo.deleteApiKey).toHaveBeenCalledWith(testApiKey);
8080
});
8181
});
8282
});
Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { Test, TestingModule } from '@nestjs/testing';
22
import { when } from 'jest-when';
3-
import passport from 'passport';
43

54
import { ApiKeyStrategy } from '~/auth/strategies/api-key.strategy';
6-
import { AuthStrategy } from '~/auth/strategies/strategies.consts';
75
import { MockAuthService, mockAuthServiceProvider } from '~/test-utils/service-mocks';
86

97
describe('ApiKeyStrategy', () => {
@@ -26,42 +24,15 @@ describe('ApiKeyStrategy', () => {
2624
});
2725

2826
it('should verify with the user when given a valid api key', async () => {
29-
const mockRequest = {
30-
headers: {
31-
'x-api-key': mockApiKey,
32-
},
33-
};
27+
when(authService.validateApiKey).calledWith(mockApiKey).mockResolvedValue(mockedUser);
3428

35-
when(authService.validateApiKey).calledWith(mockApiKey).mockReturnValue(mockedUser);
36-
37-
let authorizedUser;
38-
passport.authenticate(
39-
AuthStrategy.ApiKey,
40-
(request: unknown, user: Express.User | false | null) => {
41-
authorizedUser = user;
42-
}
43-
)(mockRequest, {}, {});
44-
45-
expect(authorizedUser).toEqual(mockedUser);
29+
const result = await strategy.validate(mockApiKey);
30+
expect(result).toEqual(mockedUser);
4631
});
4732

4833
it('should return an Unauthorized response if the key is not found', async () => {
49-
const mockRequest = {
50-
headers: {
51-
'x-api-key': 'not-a-secret',
52-
},
53-
};
54-
55-
when(authService.validateApiKey).calledWith(mockApiKey).mockReturnValue(mockedUser);
56-
57-
let authorizedUser;
58-
passport.authenticate(
59-
AuthStrategy.ApiKey,
60-
(request: unknown, user: Express.User | false | null) => {
61-
authorizedUser = user;
62-
}
63-
)(mockRequest, {}, {});
34+
when(authService.validateApiKey).calledWith('not-a-secret').mockResolvedValue(null);
6435

65-
expect(authorizedUser).toBeFalsy();
36+
await expect(strategy.validate('not-a-secret')).rejects.toThrow('API key not found');
6637
});
6738
});

‎src/auth/strategies/api-key.strategy.ts‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,26 @@ import { HeaderAPIKeyStrategy } from 'passport-headerapikey';
55
import { AuthService } from '~/auth/auth.service';
66
import { AuthStrategy } from '~/auth/strategies/strategies.consts';
77
import { AppUnauthorizedError } from '~/common/errors';
8+
import { UserModel } from '~/users/model/user.model';
89

910
export const apiKeyHeader = 'x-api-key';
1011

11-
// eslint-disable-next-line @typescript-eslint/ban-types
12-
type Callback = (err: Error | null, user?: Object, info?: Object) => void;
13-
1412
/**
1513
* authenticate with an API key
1614
*/
1715
@Injectable()
1816
export class ApiKeyStrategy extends PassportStrategy(HeaderAPIKeyStrategy, AuthStrategy.ApiKey) {
19-
constructor(private authService: AuthService) {
20-
super({ header: apiKeyHeader }, false, (apiKey: string, done: Callback) => {
21-
const user = this.authService.validateApiKey(apiKey);
22-
if (!user) {
23-
return done(new AppUnauthorizedError('API key not found'), undefined);
24-
}
25-
return done(null, user);
26-
});
17+
constructor(private readonly authService: AuthService) {
18+
super({ header: apiKeyHeader, prefix: '' }, false);
19+
}
20+
21+
public async validate(apiKey: string): Promise<UserModel> {
22+
const user = await this.authService.validateApiKey(apiKey);
23+
24+
if (!user) {
25+
throw new AppUnauthorizedError('API key not found');
26+
}
27+
28+
return user;
2729
}
2830
}
Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { Test, TestingModule } from '@nestjs/testing';
2-
import passport from 'passport';
32

43
import { OpenStrategy } from '~/auth/strategies/open.strategy';
5-
import { AuthStrategy } from '~/auth/strategies/strategies.consts';
64
import { defaultUser } from '~/users/user.consts';
75

86
describe('OpenStrategy', () => {
@@ -21,14 +19,8 @@ describe('OpenStrategy', () => {
2119
});
2220

2321
it('should verify with the open user', async () => {
24-
let authorizedUser;
25-
passport.authenticate(
26-
AuthStrategy.Open,
27-
(request: unknown, user: Express.User | false | null) => {
28-
authorizedUser = user;
29-
}
30-
)({}, {}, {});
31-
32-
expect(authorizedUser).toEqual(defaultUser);
22+
// Test the validate method directly
23+
const result = strategy.validate();
24+
expect(result).toEqual(defaultUser);
3325
});
3426
});
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Injectable } from '@nestjs/common';
22
import { PassportStrategy } from '@nestjs/passport';
3-
import { Strategy, VerifyCallback } from 'passport-custom';
3+
import { Strategy } from 'passport-custom';
44

55
import { AuthStrategy } from '~/auth/strategies/strategies.consts';
66
import { defaultUser } from '~/users/user.consts';
@@ -12,9 +12,7 @@ import { defaultUser } from '~/users/user.consts';
1212
*/
1313
@Injectable()
1414
export class OpenStrategy extends PassportStrategy(Strategy, AuthStrategy.Open) {
15-
constructor() {
16-
const verifyEveryone: VerifyCallback = (req, done) => done(null, defaultUser);
17-
18-
super(verifyEveryone);
15+
public validate(): Express.User {
16+
return defaultUser;
1917
}
2018
}

‎src/authorizations/authorizations.service.spec.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ describe('AuthorizationsService', () => {
178178
await expect(() =>
179179
// eslint-disable-next-line @typescript-eslint/no-explicit-any
180180
service.findOne(mockAccount as any, new BigNumber(1))
181-
).rejects.toThrowError();
181+
).rejects.toThrow();
182182

183183
expect(handleSdkErrorSpy).toHaveBeenCalledWith(mockError);
184184
});
@@ -226,7 +226,7 @@ describe('AuthorizationsService', () => {
226226
.calledWith(mockIdentity as any, id)
227227
.mockRejectedValue(mockError);
228228

229-
await expect(() => service.getAuthRequest(address, id)).rejects.toThrowError(mockError);
229+
await expect(() => service.getAuthRequest(address, id)).rejects.toThrow(mockError);
230230

231231
when(findOneSpy)
232232
// eslint-disable-next-line @typescript-eslint/no-explicit-any

0 commit comments

Comments
 (0)