Skip to content

Commit

Permalink
fix build error
Browse files Browse the repository at this point in the history
  • Loading branch information
overthestream committed Oct 6, 2024
1 parent 9c506b2 commit ec5679b
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 7 deletions.
87 changes: 86 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
"dependencies": {
"@apple/app-store-server-library": "^1.4.0",
"@aws-sdk/client-s3": "^3.428.0",
"@nestjs/schedule": "^4.0.0",

"@nestjs-modules/mailer": "^2.0.2",
"@nestjs/bull": "^10.2.1",
"@nestjs/cache-manager": "^2.0.0",
Expand All @@ -35,6 +33,7 @@
"@nestjs/passport": "^10.0.2",
"@nestjs/platform-express": "^10.0.0",
"@nestjs/platform-socket.io": "^10.4.1",
"@nestjs/schedule": "^4.1.1",
"@nestjs/swagger": "^7.4.0",
"@nestjs/typeorm": "^10.0.2",
"@nestjs/websockets": "^10.4.1",
Expand All @@ -55,7 +54,7 @@
"passport-jwt": "^4.0.1",
"passport-local": "^1.0.0",
"pg": "^8.11.3",
"query-string": "^9.0.0",
"query-string": "^9.1.0",
"redis": "^4.6.10",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.8.1",
Expand Down
22 changes: 19 additions & 3 deletions src/domain/validation/validation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { AppStoreConnectTransactionEntity } from 'src/domain/entities';
import type { ProductPurchase } from 'src/interfaces/productPurchase';
import type { Repository } from 'typeorm';
import { PointService } from '../point/point.service';
import queryString from 'query-string'

@Injectable()
export class ValidationService {
Expand Down Expand Up @@ -66,13 +65,30 @@ export class ValidationService {
}

async verify(queryUrl: string, debug: boolean) {
const { signature, key_id, user_id } = queryString.parse(queryUrl);
const queries = queryUrl.split('?')[1];
if (!queries) {
throw new BadRequestException('Invalid query');
}
const kvs = queries.split('&');

const kvmaps = kvs.map((kv) => {
const [key, value] = kv.split('=');
return { key, value };
});

const queryString: Record<string, string> = kvmaps.reduce((acc, kv) => {
acc[kv.key] = kv.value;
return acc;
}, {});
const { signature, key_id, user_id } = queryString;

if (
!signature ||
typeof signature !== 'string' ||
!key_id ||
typeof key_id !== 'string'
typeof key_id !== 'string' ||
!user_id ||
typeof user_id !== 'string'
) {
throw new BadRequestException('Invalid signature');
}
Expand Down

0 comments on commit ec5679b

Please sign in to comment.