Skip to content

Commit

Permalink
revert: LOGTO_MANAGEMENT_API config variable
Browse files Browse the repository at this point in the history
  • Loading branch information
ankurdotb committed Aug 15, 2023
1 parent d9533c3 commit afdccbc
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 28 deletions.
2 changes: 1 addition & 1 deletion example.env
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ LOGTO_APP_ID="ldfsr...rq432"
LOGTO_APP_SECRET="sdf...sdf"
LOGTO_M2M_APP_ID="aaaa...ddddd"
LOGTO_M2M_APP_SECRET="aaaa...ddddd"
# LOGTO_MANAGEMENT_API="https://default.logto.app/api"
LOGTO_MANAGEMENT_API="https://default.logto.app/api"
LOGTO_DEFAULT_RESOURCE_URL="http://localhost:8787"
LOGTO_DEFAULT_ROLE_ID="sdf...sdf"
LOGTO_WEBHOOK_SECRET="sdf...sdf"
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"eslint-config-prettier": "^9.0.0",
"eslint-config-typescript": "^3.0.0",
"jest": "^29.6.2",
"prettier": "^3.0.1",
"prettier": "^3.0.2",
"semantic-release": "^21.0.7",
"swagger-jsdoc": "^6.2.8",
"ts-jest": "^29.1.1",
Expand Down
20 changes: 10 additions & 10 deletions src/controllers/customer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,16 @@ export class AccountController {
// 3. Check the token balance for Testnet account
if (customer.address && process.env.ENABLE_ACCOUNT_TOPUP === 'true') {
const balances = await checkBalance(customer.address, process.env.TESTNET_RPC_URL);
const balance = balances[0];
if (!balance || +balance.amount < (TESTNET_MINIMUM_BALANCE * Math.pow(10, DEFAULT_DENOM_EXPONENT))) {
// 3.1 If it's less then required for DID creation - assign new portion from testnet-faucet
const resp = await FaucetHelper.delegateTokens(customer.address);
if (resp.status !== StatusCodes.OK) {
return response.status(StatusCodes.BAD_GATEWAY).json({
error: resp.error,
});
}
}
const balance = balances[0];
if (!balance || +balance.amount < TESTNET_MINIMUM_BALANCE * Math.pow(10, DEFAULT_DENOM_EXPONENT)) {
// 3.1 If it's less then required for DID creation - assign new portion from testnet-faucet
const resp = await FaucetHelper.delegateTokens(customer.address);
if (resp.status !== StatusCodes.OK) {
return response.status(StatusCodes.BAD_GATEWAY).json({
error: resp.error,
});
}
}
}
return response.status(StatusCodes.OK).json({});
}
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/revocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ export class RevocationController {
* - revoke
* - suspend
* - reinstate
* - in: query
* - in: query
* name: publish
* description: Publish the status list to the DID network. The default is `false`, which means the status list is not published to the DID network.
* required: true
Expand Down
3 changes: 1 addition & 2 deletions src/middleware/auth/logto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { ICommonErrorResponse } from '../../types/authentication';
import { LOGTO_MANAGEMENT_API } from '../../types/constants';
import { StatusCodes } from 'http-status-codes';
import jwt from 'jsonwebtoken';
import * as dotenv from 'dotenv';
Expand Down Expand Up @@ -272,7 +271,7 @@ export class LogToHelper {
private async setM2MToken(): Promise<ICommonErrorResponse> {
const searchParams = new URLSearchParams({
grant_type: 'client_credentials',
resource: LOGTO_MANAGEMENT_API as string,
resource: process.env.LOGTO_MANAGEMENT_API as string,
scope: 'all',
});

Expand Down
7 changes: 3 additions & 4 deletions src/types/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const HEADERS = {

// Application constants
export const APPLICATION_BASE_URL = process.env.APPLICATION_BASE_URL || 'http://localhost:3000';
export const MAINNET_RPC_URL = process.env.MAINNET_RPC_URL || 'https://rpc.cheqd.net:443';
export const CORS_ALLOWED_ORIGINS = process.env.CORS_ALLOWED_ORIGINS || APPLICATION_BASE_URL;

// LogTo contants
Expand All @@ -22,19 +21,19 @@ export const configLogToExpress = {
LOGTO_ENDPOINT ||
(function () {
if (ENABLE_AUTHENTICATION === 'true') throw new Error('LOGTO_ENDPOINT is not defined');
return ''
return '';
})(),
appId:
LOGTO_APP_ID ||
(function () {
if (ENABLE_AUTHENTICATION === 'true') throw new Error('LOGTO_APP_ID is not defined');
return ''
return '';
})(),
appSecret:
LOGTO_APP_SECRET ||
(function () {
if (ENABLE_AUTHENTICATION === 'true') throw new Error('LOGTO_APP_SECRET is not defined');
return ''
return '';
})(),
baseUrl:
APPLICATION_BASE_URL ||
Expand Down

0 comments on commit afdccbc

Please sign in to comment.