From 7fc7fa1f2f3c405df0c5e8c0003f2f4e248f8c13 Mon Sep 17 00:00:00 2001 From: secondl1ght Date: Sat, 18 Nov 2023 20:56:03 -0700 Subject: [PATCH 1/3] feat: add keysend messenger to custom permissions --- .../components/connect/CustomSessionPage.tsx | 20 +++++++++++++++++++ app/src/i18n/locales/en-US.json | 4 ++++ app/src/store/views/addSessionView.ts | 10 +++++++++- app/src/util/constants.ts | 1 + 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/app/src/components/connect/CustomSessionPage.tsx b/app/src/components/connect/CustomSessionPage.tsx index 973387ce2..8c875c357 100644 --- a/app/src/components/connect/CustomSessionPage.tsx +++ b/app/src/components/connect/CustomSessionPage.tsx @@ -206,6 +206,14 @@ const CustomSessionPage: React.FC = () => { {l('paymentsDesc')} + + {l('messenger')} + {l('messengerDesc')} + + { onChange={togglePermission('receive')} /> + + +
+ {l('permSign')} + {l('permSignDesc')} +
+ + +
diff --git a/app/src/i18n/locales/en-US.json b/app/src/i18n/locales/en-US.json index 55a8f0092..0c2b41b31 100644 --- a/app/src/i18n/locales/en-US.json +++ b/app/src/i18n/locales/en-US.json @@ -56,6 +56,8 @@ "cmps.connect.CustomSessionPage.liquidityDesc": "User can only set fees, use Loop, and use Pool.", "cmps.connect.CustomSessionPage.payments": "Payments Manager", "cmps.connect.CustomSessionPage.paymentsDesc": "User can only send and receive payments.", + "cmps.connect.CustomSessionPage.messenger": "Keysend Messenger", + "cmps.connect.CustomSessionPage.messengerDesc": "Payments Manager permissions plus user can sign messages.", "cmps.connect.CustomSessionPage.custodial": "Custodial Account", "cmps.connect.CustomSessionPage.custodialDesc": "Create a custodial off-chain account for your node.", "cmps.connect.CustomSessionPage.custom": "Custom", @@ -78,6 +80,8 @@ "cmps.connect.CustomSessionPage.permSendDesc": "Send funds from this node.", "cmps.connect.CustomSessionPage.permReceive": "Receive", "cmps.connect.CustomSessionPage.permReceiveDesc": "Receive funds on this node.", + "cmps.connect.CustomSessionPage.permSign": "Sign", + "cmps.connect.CustomSessionPage.permSignDesc": "Sign messages to verify node.", "cmps.connect.CustomSessionPage.advanced": "Advanced Options", "cmps.connect.CustomSessionPage.proxy": "Proxy Server", "cmps.connect.CustomSessionPage.proxyDesc": "Specify a custom Lightning Node Connect proxy server", diff --git a/app/src/store/views/addSessionView.ts b/app/src/store/views/addSessionView.ts index 86660276e..7c566bd13 100644 --- a/app/src/store/views/addSessionView.ts +++ b/app/src/store/views/addSessionView.ts @@ -7,7 +7,7 @@ export default class AddSessionView { private _store: Store; label = ''; - permissionType = 'admin'; // Expected values: admin | read-only | custodial | custom | liquidity | payments + permissionType = 'admin'; // Expected values: admin | read-only | custodial | custom | liquidity | payments | messenger editing = false; permissions: { [key: string]: boolean } = { openChannel: false, @@ -17,6 +17,7 @@ export default class AddSessionView { pool: false, send: false, receive: false, + sign: false, }; expiration = 'never'; // Expected values: 7 | 30 | 60 | 90 | never | custom expirationOptions = [ @@ -157,6 +158,13 @@ export default class AddSessionView { this.permissions.receive = true; break; + case 'messenger': + this.setAllPermissions(false); + this.permissions.send = true; + this.permissions.receive = true; + this.permissions.sign = true; + break; + case 'custodial': this.setAllPermissions(false); this.permissions.send = true; diff --git a/app/src/util/constants.ts b/app/src/util/constants.ts index ae5a7a965..0b9ce3c03 100644 --- a/app/src/util/constants.ts +++ b/app/src/util/constants.ts @@ -116,4 +116,5 @@ export const PermissionUriMap: { [key: string]: string[] } = { '/lnrpc.Lightning/ListInvoices', '/lnrpc.Lightning/SubscribeInvoices', ], + sign: ['/lnrpc.Lightning/SignMessage'], }; From 4e84ada534d0f5b8b767ac3556386fc55e81a061 Mon Sep 17 00:00:00 2001 From: secondl1ght Date: Mon, 20 Nov 2023 19:12:20 -0700 Subject: [PATCH 2/3] copy: update messenger desc --- app/src/i18n/locales/en-US.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/i18n/locales/en-US.json b/app/src/i18n/locales/en-US.json index 0c2b41b31..78ac05ee1 100644 --- a/app/src/i18n/locales/en-US.json +++ b/app/src/i18n/locales/en-US.json @@ -57,7 +57,7 @@ "cmps.connect.CustomSessionPage.payments": "Payments Manager", "cmps.connect.CustomSessionPage.paymentsDesc": "User can only send and receive payments.", "cmps.connect.CustomSessionPage.messenger": "Keysend Messenger", - "cmps.connect.CustomSessionPage.messengerDesc": "Payments Manager permissions plus user can sign messages.", + "cmps.connect.CustomSessionPage.messengerDesc": "User can send and receive payments plus sign messages.", "cmps.connect.CustomSessionPage.custodial": "Custodial Account", "cmps.connect.CustomSessionPage.custodialDesc": "Create a custodial off-chain account for your node.", "cmps.connect.CustomSessionPage.custom": "Custom", From a751f1653848b284ba37e2769e1d30ac1148ec4c Mon Sep 17 00:00:00 2001 From: secondl1ght Date: Mon, 20 Nov 2023 23:41:26 -0700 Subject: [PATCH 3/3] refactor: use type for permissionType --- app/src/components/connect/AddSession.tsx | 19 ++++++--- .../components/connect/CustomSessionPage.tsx | 39 ++++++++++------- app/src/store/views/addSessionView.ts | 42 ++++++++++++------- 3 files changed, 63 insertions(+), 37 deletions(-) diff --git a/app/src/components/connect/AddSession.tsx b/app/src/components/connect/AddSession.tsx index 7980027f5..874aaef4b 100644 --- a/app/src/components/connect/AddSession.tsx +++ b/app/src/components/connect/AddSession.tsx @@ -8,6 +8,7 @@ import FormField from 'components/common/FormField'; import FormInput from 'components/common/FormInput'; import FormSelect from 'components/common/FormSelect'; import PurpleButton from './PurpleButton'; +import { PermissionTypeValues } from 'store/views/addSessionView'; const Styled = { Wrapper: styled.div``, @@ -50,6 +51,14 @@ const AddSession: React.FC = ({ primary }) => { ); } + const validatePermissionType = (v: string) => { + const permissionType = Object.values(PermissionTypeValues).find(value => value === v); + + if (!permissionType) return; + + addSessionView.setPermissionType(permissionType); + }; + return ( @@ -74,18 +83,18 @@ const AddSession: React.FC = ({ primary }) => { - {addSessionView.permissionType === 'custom' + {addSessionView.permissionType === PermissionTypeValues.Custom ? l('common.next') : l('common.submit')} diff --git a/app/src/components/connect/CustomSessionPage.tsx b/app/src/components/connect/CustomSessionPage.tsx index 8c875c357..c17864495 100644 --- a/app/src/components/connect/CustomSessionPage.tsx +++ b/app/src/components/connect/CustomSessionPage.tsx @@ -14,6 +14,7 @@ import FormSelect from 'components/common/FormSelect'; import FormDate from 'components/common/FormDate'; import FormSwitch from 'components/common/v2/FormSwitch'; import PurpleButton from './PurpleButton'; +import { PermissionTypeValues } from 'store/views/addSessionView'; const Styled = { Wrapper: styled.div` @@ -108,7 +109,7 @@ const CustomSessionPage: React.FC = () => { addSessionView.handleCustomSubmit(); }, []); - const setPermissionType = (permissionType: string) => { + const setPermissionType = (permissionType: PermissionTypeValues) => { return () => { addSessionView.setPermissionType(permissionType); }; @@ -175,56 +176,62 @@ const CustomSessionPage: React.FC = () => { {l('admin')} {l('adminDesc')} {l('readonly')} {l('readonlyDesc')} {l('liquidity')} {l('liquidityDesc')} {l('payments')} {l('paymentsDesc')} {l('messenger')} {l('messengerDesc')} {l('custodial')} {l('custodialDesc')} {l('custom')} {l('customDesc')} @@ -236,7 +243,7 @@ const CustomSessionPage: React.FC = () => { - {addSessionView.permissionType === 'custodial' && ( + {addSessionView.permissionType === PermissionTypeValues.Custodial && (