Skip to content

Commit

Permalink
Merge pull request #21 (release 0.2.0)
Browse files Browse the repository at this point in the history
Release 0.2.0
  • Loading branch information
LowderPlay authored Apr 5, 2024
2 parents 59c1156 + f17f7b2 commit 13bae1d
Show file tree
Hide file tree
Showing 15 changed files with 1,537 additions and 689 deletions.
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
VITE_BOT_USERNAME=TeleOTPAppBot
VITE_BOT_USERNAME=TeleOTPAppBot
VITE_PLAUSIBLE_DOMAIN=teleotp.pages.dev
VITE_PLAUSIBLE_API_HOST=https://analytics.gesti.tech
4 changes: 4 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ module.exports = {
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
Expand Down
77 changes: 77 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 🔐 [TeleOTP](http://t.me/TeleOTPAppBot)
[![Deploy static content to Pages](https://github.com/UselessStudio/TeleOTP/actions/workflows/deploy.yml/badge.svg)](https://github.com/UselessStudio/TeleOTP/actions/workflows/deploy.yml)
[![Build Telegram bot image](https://github.com/UselessStudio/TeleOTP/actions/workflows/bot.yml/badge.svg)](https://github.com/UselessStudio/TeleOTP/actions/workflows/bot.yml)
[![Plausible analytics](https://img.shields.io/badge/Plausible-analytics-blue)](https://analytics.gesti.tech/teleotp.pages.dev)

Telegram Mini App that allows you to generate one-time 2FA passwords inside Telegram.

Expand Down Expand Up @@ -43,6 +44,11 @@ You can switch the platforms at any time without any hassle!
* [📷 Telegram QR Scanner](#-telegram-qr-scanner)
* [🎨 Telegram Theme](#-telegram-theme)
* [🔑 Account](#-account)
* [👁️ Biometrics manager](#-biometrics-manager)
* [isAvailable](#isavailable)
* [isSaved](#issaved)
* [updateToken](#updatetoken)
* [getToken](#gettoken)
* [⚙️ Settings manager](#-settings-manager)
* [shouldKeepUnlocked](#shouldkeepunlocked)
* [setKeepUnlocked](#setkeepunlocked)
Expand Down Expand Up @@ -337,6 +343,77 @@ If `accountUri` is not provided or invalid, the code returned is "N/A".

Generation of codes is implemented in the [otpauth library](https://github.com/hectorm/otpauth).

### 👁️ Biometrics manager

`BiometricsManager` is used as an interface to Telegram's `WebApp.BiometricManager`.
It allows to store the encryption key inside secure storage on device, locked by a biometric lock.

To get an instance of BiometricsManager, you should use the `useContext` hook:

```ts
import {BiometricsManagerContext} from "./biometrics";

const biometricsManager = useContext(BiometricsManagerContext);
```

BiometricsManager is created using `BiometricsManagerProvider` component:

> [!IMPORTANT]
> BiometricsManagerProvider must be used inside the [SettingsManagerProvider](#-settings-manager)

- `requestReason` is a message when user is prompted to provide necessary permissions
- `authenticateReason` is a message shown to the user, when the key is requested

```tsx
import {BiometricsManagerProvider} from "./biometrics";

<BiometricsManagerProvider requestReason="Allow access to biometrics to be able to decrypt your accounts"
authenticateReason="Authenticate to decrypt your accounts">
... rest of the app code ...
</BiometricsManagerProvider>
```

#### isAvailable

```ts
isAvailable: boolean;
```

Boolean flag indicating whether biometric storage is available on the current device.

#### isSaved

```ts
isSaved: boolean;
```

Boolean flag indicating whether the encryption key is saved inside the storage.
This flag is stored using the [`SettingsManager`](#-settings-manager).

> [!NOTE]
> Behaviour of this flag is different to `WebApp.BiometricManager.isBiometricTokenSaved`, as
> in the current implementation `isBiometricTokenSaved` returns `true` even if a token is empty.

#### updateToken

```ts
updateToken(token: string): void;
```

This method saves the key inside secure storage.
It may ask the user for necessary permissions.
To delete the stored key, pass empty string to the `token` parameter.

#### getToken

```ts
getToken(callback: (token?: string) => void): void;
```

This method requests a token from the storage. If a request is successful,
the token is passed in the `token` parameter inside a callback. In case of a failure,
callback is called with empty `token`.

### ⚙️ Settings manager

SettingsManager is used to provide the app with user's preferences.
Expand Down
Loading

0 comments on commit 13bae1d

Please sign in to comment.