Skip to content

Commit

Permalink
Merge branch 'master' into depfu/batch_dev/yarn/2023-09-02
Browse files Browse the repository at this point in the history
  • Loading branch information
pavanjoshi914 authored Oct 30, 2023
2 parents 39ddf7a + 9d9d0b0 commit e899c1a
Show file tree
Hide file tree
Showing 90 changed files with 2,364 additions and 520 deletions.
35 changes: 34 additions & 1 deletion create-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,39 @@

# Extract version from package.json
VERSION=$(node -pe "require('./package.json').version")
NODE_ENV=production

if [ -z ${ALBY_OAUTH_CLIENT_ID_CHROME+x} ];
then
echo "OAuth client id for Chrome:"
read ALBY_OAUTH_CLIENT_ID_CHROME
fi

if [ -z ${ALBY_OAUTH_CLIENT_SECRET_CHROME+x} ];
then
echo "OAuth client secret for Chrome:"
read ALBY_OAUTH_CLIENT_SECRET_CHROME
fi

if [ -z ${ALBY_OAUTH_CLIENT_ID_FIREFOX+x} ];
then
echo "OAuth client id for Firefox:"
read ALBY_OAUTH_CLIENT_ID_FIREFOX
fi

if [ -z ${ALBY_OAUTH_CLIENT_SECRET_FIREFOX+x} ];
then
echo "OAuth client secret for Firefox:"
read ALBY_OAUTH_CLIENT_SECRET_FIREFOX
fi

if [ -z ${ALBY_API_URL+x} ];
then
ALBY_API_URL="https://api.getalby.com"
fi

echo "Creating the build for v$VERSION"
yarn build

echo "Creating zip packages for v$VERSION"
cd dist/production
Expand Down Expand Up @@ -38,4 +71,4 @@ echo "Created alby-opera-v$VERSION.crx (SHA512: $SHA)"

echo "done!"

cd ../../../
cd ../../../
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lightning-browser-extension",
"version": "3.2.1",
"version": "3.3.0",
"description": "Lightning browser extension",
"private": true,
"repository": "https://github.com/bumi/lightning-browser-extension.git",
Expand All @@ -21,7 +21,7 @@
"build:firefox": "NODE_ENV=production TARGET_BROWSER=firefox webpack",
"build:opera": "NODE_ENV=production TARGET_BROWSER=opera webpack",
"build": "yarn build:chrome && yarn build:firefox && yarn build:opera",
"package": "yarn build && ./create-packages.sh",
"package": "./create-packages.sh",
"lint": "yarn lint:js && yarn tsc:compile && yarn format:fix",
"lint:js": "eslint src --ext .js,.jsx,.ts,.tsx --max-warnings 0",
"lint:js:fix": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
Expand All @@ -35,19 +35,20 @@
"prepare": "husky install"
},
"dependencies": {
"@bitcoin-design/bitcoin-icons-react": "^0.1.9",
"@bitcoin-design/bitcoin-icons-react": "^0.1.10",
"@bitcoinerlab/secp256k1": "^1.0.5",
"@getalby/sdk": "^2.2.3",
"@headlessui/react": "^1.7.16",
"@lightninglabs/lnc-web": "^0.2.4-alpha",
"@noble/curves": "^1.1.0",
"@noble/secp256k1": "^2.0.0",
"@scure/bip32": "^1.3.1",
"@scure/bip39": "^1.2.1",
"@scure/btc-signer": "^0.5.1",
"@tailwindcss/forms": "^0.5.4",
"@vespaiach/axios-fetch-adapter": "^0.3.0",
"axios": "^0.27.2",
"bech32": "^2.0.0",
"bitcoinjs-lib": "^6.1.0",
"bolt11": "^1.4.1",
"crypto-js": "^4.1.1",
"dayjs": "^1.11.9",
Expand Down
14 changes: 7 additions & 7 deletions src/app/components/Badge/index.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { useTranslation } from "react-i18next";
import { classNames } from "~/app/utils";

type Props = {
label: "budget" | "auth" | "imported";
color: string;
textColor: string;
small?: boolean;
className: string;
};

export default function Badge({ label, color, textColor, small }: Props) {
export default function Badge({ label, className }: Props) {
const { t: tComponents } = useTranslation("components", {
keyPrefix: "badge",
});

return (
<span
className={`inline-block leading-none rounded-full font-medium mr-2 py-1 bg-${color} text-${textColor} ${
!small ? "px-2 text-xs" : "px-1.5 text-xxxs"
}`}
className={classNames(
"inline-block leading-none rounded-full font-medium mr-2 py-1 px-2 text-xs",
className
)}
>
{tComponents(`label.${label}`)}
</span>
Expand Down
15 changes: 3 additions & 12 deletions src/app/components/BadgesList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,20 @@ export default function BadgesList({ allowance }: Props) {
if (allowance.remainingBudget > 0) {
badges.push({
label: "budget",
color: "green-bitcoin",
textColor: "white",
className: "bg-blue-500 text-white",
});
}
if (allowance.lnurlAuth) {
badges.push({
label: "auth",
color: "green-bitcoin",
textColor: "white",
className: "bg-green-bitcoin text-white",
});
}

return (
<>
{badges?.map((b) => {
return (
<Badge
key={b.label}
label={b.label}
color={b.color}
textColor={b.textColor}
/>
);
return <Badge key={b.label} label={b.label} className={b.className} />;
})}
</>
);
Expand Down
140 changes: 140 additions & 0 deletions src/app/components/LNURLAuth/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import Button from "@components/Button";
import ConfirmOrCancel from "@components/ConfirmOrCancel";
import Container from "@components/Container";
import ContentMessage from "@components/ContentMessage";
import PublisherCard from "@components/PublisherCard";
import ResultCard from "@components/ResultCard";
import React, { useState } from "react";
import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom";
import ScreenHeader from "~/app/components/ScreenHeader";
import { useNavigationState } from "~/app/hooks/useNavigationState";
import { USER_REJECTED_ERROR } from "~/common/constants";
import api from "~/common/lib/api";
import msg from "~/common/lib/msg";
import type { LNURLAuthServiceResponse } from "~/types";

function LNURLAuthComponent() {
const { t } = useTranslation("translation", { keyPrefix: "lnurlauth" });
const { t: tCommon } = useTranslation("common");

const navigate = useNavigate();
const navState = useNavigationState();

const details = navState.args?.lnurlDetails as LNURLAuthServiceResponse;
const origin = navState.origin;

const [successMessage, setSuccessMessage] = useState("");
const [errorMessage, setErrorMessage] = useState("");
const [loading, setLoading] = useState(false);

async function confirm() {
try {
setLoading(true);
const response = await api.lnurlAuth({
origin,
lnurlDetails: details,
});

if (navState.isPrompt && origin?.host) {
const allowance = await api.getAllowance(origin.host);

if (allowance.lnurlAuth === false) {
await msg.request("updateAllowance", {
id: allowance.id,
lnurlAuth: true,
});
}
}

if (response.success) {
setSuccessMessage(
t("success", { name: origin ? origin.name : details.domain })
);
// ATTENTION: if this LNURL is called through `webln.lnurl` then we immediately return and return the response. This closes the window which means the user will NOT see the above successAction.
// We assume this is OK when it is called through webln.
if (navState.isPrompt) {
msg.reply(response);
}
} else {
setErrorMessage(t("errors.status"));
}
} catch (e) {
console.error(e);
if (e instanceof Error) {
setErrorMessage(`Error: ${e.message}`);
}
} finally {
setLoading(false);
}
}

function reject(e: React.MouseEvent<HTMLButtonElement>) {
e.preventDefault();
if (navState.isPrompt) {
msg.error(USER_REJECTED_ERROR);
} else {
navigate(-1);
}
}

function close(e: React.MouseEvent<HTMLButtonElement>) {
// will never be reached via prompt
e.preventDefault();
navigate(-1);
}

return (
<div className="h-full flex flex-col overflow-y-auto no-scrollbar">
<ScreenHeader title={t("title")} />
{!successMessage ? (
<>
<Container justifyBetween maxWidth="sm">
<div>
{origin ? (
<PublisherCard
title={origin.name}
image={origin.icon}
url={details.domain}
/>
) : (
<PublisherCard title={details.domain} />
)}

<ContentMessage
heading={`${t("content_message.heading")} ${
origin ? origin.name : details.domain
}?`}
content={details.domain}
/>

{errorMessage && (
<p className="my-2 mx-5 text-red-500">{errorMessage}</p>
)}
</div>
<ConfirmOrCancel
label={t("submit")}
onConfirm={confirm}
onCancel={reject}
disabled={loading}
loading={loading}
/>
</Container>
</>
) : (
<Container justifyBetween maxWidth="sm">
<ResultCard isSuccess message={successMessage} />
<div className="mt-4">
<Button
onClick={close}
label={tCommon("actions.close")}
fullWidth
/>
</div>
</Container>
)}
</div>
);
}

export default LNURLAuthComponent;
2 changes: 1 addition & 1 deletion src/app/components/PaymentSummary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const PaymentSummary: FC<Props> = ({
<dt className="mt-4 font-medium dark:text-white">
{tCommon("description")}
</dt>
<dd className="text-gray-500 dark:text-neutral-400 break-all">
<dd className="text-gray-500 dark:text-neutral-400 break-words whitespace-pre-wrap overflow-y-auto max-h-36">
{description}
</dd>
</>
Expand Down
16 changes: 13 additions & 3 deletions src/app/components/QRCode/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,19 @@ export type Props = {
value: string;
size?: number;
className?: string;

// set the level to Q if there are overlays
// Q will improve error correction (so we can add overlays covering up to 25% of the QR)
// at the price of decreased information density (meaning the QR codes "pixels" have to be
// smaller to encode the same information).
// While that isn't that much of a problem for lightning addresses (because they are usually quite short),
// for invoices that contain larger amount of data those QR codes can get "harder" to read.
// (meaning you have to aim your phone very precisely and have to wait longer for the reader
// to recognize the QR code)
level?: "Q" | undefined;
};

export default function QRCode({ value, size, className }: Props) {
export default function QRCode({ value, size, level, className }: Props) {
const theme = useTheme();
const fgColor = theme === "dark" ? "#FFFFFF" : "#000000";
const bgColor = theme === "dark" ? "#000000" : "#FFFFFF";
Expand All @@ -16,10 +26,10 @@ export default function QRCode({ value, size, className }: Props) {
<ReactQRCode
value={value}
size={size}
className={classNames("rounded-md", className ?? "")}
fgColor={fgColor}
bgColor={bgColor}
level="M"
className={classNames("w-full h-auto rounded-md", className ?? "")}
level={level}
/>
);
}
14 changes: 0 additions & 14 deletions src/app/components/TransactionsTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import Button from "~/app/components/Button";
import { useSettings } from "~/app/context/SettingsContext";
import { Transaction } from "~/types";

import Badge from "../Badge";

export type Props = {
transactions: Transaction[] | null | undefined;
loading?: boolean;
Expand Down Expand Up @@ -60,18 +58,6 @@ export default function TransactionsTable({
{tx.date}
</p>
</div>
{tx.badges && (
<div className="ml-6 space-x-3">
{tx.badges.map((badge) => (
<Badge
key={badge.label}
label={badge.label}
color={badge.color}
textColor={badge.textColor}
/>
))}
</div>
)}
<div className="flex ml-auto text-right space-x-3 shrink-0">
<div>
<p className="text-sm font-medium dark:text-white">
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/onboard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
ClockIcon,
InfoCircleIcon,
TwoKeysIcon,
} from "@bitcoin-design/bitcoin-icons-react/outline";
import { useTranslation } from "react-i18next";
Expand All @@ -9,7 +10,6 @@ import PublisherCard from "~/app/components/PublisherCard";
import ScreenHeader from "~/app/components/ScreenHeader";
import { useAccount } from "~/app/context/AccountContext";
import { useNavigationState } from "~/app/hooks/useNavigationState";
import InfoCircleIcon from "~/app/icons/InfoCircleIcon";
import { NO_KEYS_ERROR, USER_REJECTED_ERROR } from "~/common/constants";
import api from "~/common/lib/api";
import msg from "~/common/lib/msg";
Expand Down
21 changes: 0 additions & 21 deletions src/app/icons/InfoCircleIcon.tsx

This file was deleted.

Loading

0 comments on commit e899c1a

Please sign in to comment.