Skip to content

Commit

Permalink
Merge pull request #26 from ElementsProject/fix-token-expiry
Browse files Browse the repository at this point in the history
Token expiry and other UI fixes
  • Loading branch information
ShahanaFarooqui authored Aug 30, 2023
2 parents 129ae0a + 2aea113 commit 3ab11c8
Show file tree
Hide file tree
Showing 20 changed files with 35 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/docs/Contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Development
* Change directory: cd cln-application
* Install dependencies: Assuming that nodejs (v14 & above) and npm are already installed, run `npm install`.
* Setup environment variables: Assuming that bitcoind and core-lightning are already running, adjust environment variables listed in `./env.sh` file and execute the script with `'. env.sh'` to setup required environment variables to connect to the node.
* Setup Commando auth: Update `LIGHTNING_PUBKEY` and `LIGHTNING_RUNE` variables in `.commando` for successful backend authentication and connection via commando.
* Setup Commando auth: Update `LIGHTNING_PUBKEY` and `LIGHTNING_RUNE` variables in `.commando` for successful backend authentication and connection via commando. Or run `entrypoint.sh` with correct lightningd path to do the same.
* Run backend server: Get backend server up by running `npm run backend:serve`.
* Watch backend server: Watch backend server for realtime changes with `npm run backend:watch`.
* React frontend server: React development server is set to serve on port 4300. Run `npm run frontend:dev` script to get it working.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,6 @@

# Acknowledgements

- This app is inpired by the work done by [Umbrel lightning app](https://github.com/getumbrel/umbrel-lightning).
- This app is inspired by the work done by [Umbrel lightning app](https://github.com/getumbrel/umbrel-lightning).

- The backend api connects with core lightning via [lnmessage](https://github.com/aaronbarnardsound/lnmessage).
3 changes: 2 additions & 1 deletion apps/backend/dist/controllers/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class AuthController {
const vpRes = verifyPassword(req.body.password);
if (vpRes === true) {
const token = jwt.sign({ userID: SECRET_KEY }, SECRET_KEY);
res.cookie('token', token, { httpOnly: true, maxAge: 3600 * 24 * 7 });
// Expire the token in a day
res.cookie('token', token, { httpOnly: true, maxAge: 3600000 * 24 });
return res.status(201).json({ isAuthenticated: true, isValidPassword: isValidPassword() });
}
else {
Expand Down
3 changes: 2 additions & 1 deletion apps/backend/source/controllers/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class AuthController {
const vpRes = verifyPassword(req.body.password);
if (vpRes === true) {
const token = jwt.sign({ userID: SECRET_KEY }, SECRET_KEY);
res.cookie('token', token, { httpOnly: true, maxAge: 3600 * 24 * 7 });
// Expire the token in a day
res.cookie('token', token, { httpOnly: true, maxAge: 3600000 * 24 });
return res.status(201).json({ isAuthenticated: true, isValidPassword: isValidPassword() });
} else {
const err = new AuthError(vpRes, vpRes, HttpStatusCode.UNAUTHORIZED, vpRes);
Expand Down
12 changes: 6 additions & 6 deletions apps/frontend/build/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"files": {
"main.css": "/static/css/main.179aa97d.css",
"main.js": "/static/js/main.08092983.js",
"main.css": "/static/css/main.ec053e02.css",
"main.js": "/static/js/main.45257535.js",
"static/media/Inter-Bold.ttf": "/static/media/Inter-Bold.88fa7ae373b07b41ecce.ttf",
"static/media/Inter-SemiBold.ttf": "/static/media/Inter-SemiBold.4d56bb21f2399db8ad48.ttf",
"static/media/Inter-Medium.ttf": "/static/media/Inter-Medium.6dcbc9bed1ec438907ee.ttf",
"static/media/Inter-Thin.ttf": "/static/media/Inter-Thin.f341ca512063c66296d1.ttf",
"index.html": "/index.html",
"main.179aa97d.css.map": "/static/css/main.179aa97d.css.map",
"main.08092983.js.map": "/static/js/main.08092983.js.map"
"main.ec053e02.css.map": "/static/css/main.ec053e02.css.map",
"main.45257535.js.map": "/static/js/main.45257535.js.map"
},
"entrypoints": [
"static/css/main.179aa97d.css",
"static/js/main.08092983.js"
"static/css/main.ec053e02.css",
"static/js/main.45257535.js"
]
}
2 changes: 1 addition & 1 deletion apps/frontend/build/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="./images/cln-favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="color-scheme" content="light dark"><meta name="description" content="Core lightning application"/><link rel="apple-touch-icon" href="./images/cln-logo-dark.png"/><title>Core Lightning</title><script defer="defer" src="/static/js/main.08092983.js"></script><link href="/static/css/main.179aa97d.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="./images/cln-favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="color-scheme" content="light dark"><meta name="description" content="Core lightning application"/><link rel="apple-touch-icon" href="./images/cln-logo-dark.png"/><title>Core Lightning</title><script defer="defer" src="/static/js/main.45257535.js"></script><link href="/static/css/main.ec053e02.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
1 change: 0 additions & 1 deletion apps/frontend/build/static/css/main.179aa97d.css.map

This file was deleted.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions apps/frontend/build/static/css/main.ec053e02.css.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion apps/frontend/build/static/js/main.08092983.js.map

This file was deleted.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions apps/frontend/build/static/js/main.45257535.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/frontend/src/components/cln/BTCWallet/BTCWallet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

.btc-transactions-tabs {
border-bottom: 0.5px solid $border-color;
padding: 0 2rem 0.25rem 0.25rem;
}

@include color-mode(dark) {
.btc-transactions-tabs {
border-bottom: 0.5px solid $border-color-dark;
padding: 0 2rem 0 0.25rem;
}
}
9 changes: 7 additions & 2 deletions apps/frontend/src/components/cln/CLNWallet/CLNWallet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@
border-right: none;
border-top: none;
& .nav-item .nav-link {
padding: 0 2rem 0 0.25rem;
padding: 0 1rem 0.25rem 0.25rem;
color: $light;
& span {
padding: 0.25rem 0.25rem 0.25rem 0.25rem;
}
&.active, &:hover, &:focus {
background-color: transparent;
border-bottom: 1px solid $primary;
& span {
border-bottom: 2px solid $primary;
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions apps/frontend/src/components/cln/CLNWallet/CLNWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ const CLNWallet = (props) => {
>
<Nav className='flex-row cln-transactions-tabs'>
<Nav.Item>
<Nav.Link eventKey='transactions'>Transactions</Nav.Link>
<Nav.Link eventKey='transactions'><span>Transactions</span></Nav.Link>
</Nav.Item>
<Nav.Item>
<Nav.Link eventKey='offers'>Offers</Nav.Link>
<Nav.Link eventKey='offers'><span>Offers</span></Nav.Link>
</Nav.Item>
</Nav>
<PerfectScrollbar className='ps-show-always'>
Expand Down
4 changes: 2 additions & 2 deletions apps/frontend/src/components/modals/Logout/Logout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ const LogoutComponent = () => {
<Col xs={2} className='message-type-box d-flex align-items-center justify-content-center'>
<QuestionMarkSVG />
</Col>
<Col xs={10} className='py-3 px-2'>
<Col xs={10} className='p-3'>
<Col className='d-flex align-items-center justify-content-between'>
<Col xs={7}>Logout?</Col>
<Col xs={7} className='ps-1'>Logout?</Col>
<button type="button" className="btn btn-rounded btn-sm btn-secondary" onClick={() => logoutHandler(true)}>Yes</button>
<button type="button" className="btn btn-rounded btn-sm btn-secondary" onClick={() => logoutHandler(false)}>No</button>
</Col>
Expand Down
1 change: 1 addition & 0 deletions apps/frontend/src/styles/shared.scss
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ svg {
.dropdown {
& .dropdown-item {
font-weight: 500;
padding: 0.5rem 1rem;
&.active, &:active, &:focus, &:hover {
color: $primary;
background-color: unset;
Expand Down
2 changes: 1 addition & 1 deletion env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if [ "$SETUP" == "docker" ]; then
export COMMANDO_CONFIG="/data/.lightning/.commando-env"
echo "Docker Environment Variables Set"
else
export DEVICE_DOMAIN_NAME="umbrel.local"
export DEVICE_DOMAIN_NAME="local.local"
export LOCAL_HOST="http://""$DEVICE_DOMAIN_NAME"
export APP_BITCOIN_NODE_IP="localhost"
export APP_CORE_LIGHTNING_DAEMON_IP="localhost"
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
"scripts": {
"frontend:dev": "npm run start -w cln-application-frontend",
"frontend:build": "npm run build -w cln-application-frontend",
"backend:dev": "npm run start -w cln-application-backend",
"backend:build": "npm run build -w cln-application-backend",
"backend:serve": "npm run serve -w cln-application-backend",
"backend:watch": "npm run watch -w cln-application-backend",
"dev": "npm run backend:dev & npm run frontend:dev",
"dev": "npm run backend:serve & npm run frontend:dev",
"build": "npm run backend:build & npm run frontend:build",
"start": "npm run serve -w cln-application-backend"
},
Expand Down

0 comments on commit 3ab11c8

Please sign in to comment.