Skip to content

Commit e2ff782

Browse files
authored
Credit fix (#117)
* fix credit * fixed url * whitelisted swagger ui
1 parent ce5ab34 commit e2ff782

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

src/credits/services/credits.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
MSG_UPDATE_CREDENTIAL_STATUS,
2323
MSG_UPDATE_DID_TYPEURL,
2424
} from 'src/utils/authz';
25+
import { sanitizeUrl } from 'src/utils/utils';
2526

2627
@Injectable()
2728
export class AuthzCreditService {
@@ -87,7 +88,7 @@ export class AuthzCreditService {
8788
expiresIn: '5m',
8889
secret: this.config.get('JWT_SECRET'),
8990
});
90-
fetch(`${tenantUrl}api/v1/credit`, {
91+
fetch(`${sanitizeUrl(tenantUrl, true)}api/v1/credit`, {
9192
method: 'POST',
9293
headers: {
9394
'Content-Type': 'Application/json',

src/customer-onboarding/services/customer-onboarding.service.ts

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ export class CustomerOnboardingService {
272272
`Inside handleCreditService() to fund credit to the service with tenantUrl ${tenantUrl}`,
273273
'CustomerOnboardingService',
274274
);
275-
const sessionId = generateHash(`credit:${serviceInfo.appId}:${Date.now()}`);
276275
const creditPayload = {
277276
serviceId: serviceInfo.appId,
278277
purpose: 'CreditRecharge',
@@ -285,24 +284,10 @@ export class CustomerOnboardingService {
285284
whitelistedCors,
286285
accessList,
287286
};
288-
await redisClient.set(
289-
sessionId,
290-
JSON.stringify(creditPayload),
291-
'EX',
292-
EXPIRY_CONFIG.CREDIT_TOKEN.redisExpiryTime,
293-
);
294-
const tokenPayload = {
295-
appId: serviceInfo.appId,
296-
sessionId,
297-
subdomain: serviceInfo.subdomain,
298-
grantType,
299-
};
300-
const creditToken = await this.generateCreditToken(tokenPayload, secret);
287+
const creditToken = await this.generateCreditToken(creditPayload, secret);
301288
const headers: Record<string, string> = {
302289
'Content-Type': 'application/json',
303-
...(grantType === GRANT_TYPES.access_service_kyc
304-
? { 'x-kyc-access-token': creditToken }
305-
: { authorization: `Bearer ${creditToken}` }),
290+
'x-api-credit-token': creditToken,
306291
};
307292
const requestOptions: any = {
308293
method: 'POST',
@@ -480,6 +465,10 @@ export class CustomerOnboardingService {
480465
this.config.get<string>('CAVACH_API_DOMAIN'),
481466
false,
482467
),
468+
sanitizeUrl(
469+
this.config.get<string>('SSI_API_DOMAIN'),
470+
false,
471+
),
483472
],
484473
env: APP_ENVIRONMENT.dev,
485474
hasDomainVerified: false,

0 commit comments

Comments
 (0)