Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 55 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,56 @@ export interface CloudStorage {
) => void;
}

type DeviceStorageKey = string;
type DeviceStorageValue = unknown;

export interface DeviceStorage {
setItem: (
key: DeviceStorageKey,
value: DeviceStorageValue,
callback?: (error: string | null, result?: boolean) => unknown
) => void;
getItem: (
key: DeviceStorageKey,
callback?: (error: string | null, result?: DeviceStorageValue) => unknown
) => void;
getKeys: (
callback?: (
error: string | null,
result?: Array<DeviceStorageKey>
) => unknown
) => void;
removeItem: (
key: DeviceStorageKey,
callback?: (error: string | null, result?: boolean) => unknown
) => void;
}

type SecureStorageKey = string;
type SecureStorageValue = unknown;

export interface SecureStorage {
setItem: (
key: SecureStorageKey,
value: SecureStorageValue,
callback?: (error: string | null, result?: boolean) => unknown
) => void;
getItem: (
key: SecureStorageKey,
callback?: (error: string | null, result?: SecureStorageValue) => unknown
) => void;
getKeys: (
callback?: (
error: string | null,
result?: Array<SecureStorageKey>
) => unknown
) => void;
removeItem: (
key: SecureStorageKey,
callback?: (error: string | null, result?: boolean) => unknown
) => void;
}

export type Contact = {
first_name?: string;
last_name?: string;
Expand Down Expand Up @@ -154,7 +204,7 @@ export interface BottomButton {
offClick: (callback: VoidFunction) => BottomButton;
setText: (text: string) => BottomButton;
setParams: (params: BottomButtonParams) => BottomButton;
hasShineEffect: string;
hasShineEffect: boolean;
}

export type MainButton = BottomButton;
Expand Down Expand Up @@ -410,7 +460,7 @@ export type BiometricManager = {
) => BiometricManager;
authenticate: (
params: BiometricAuthenticateParams,
callback?: (isAuthenticated: boolean) => unknown
callback?: (isAuthenticated: boolean, token?: string) => unknown
) => BiometricManager;
updateBiometricToken: (
token: string,
Expand Down Expand Up @@ -476,6 +526,8 @@ export interface WebApp {
SecondaryButton: SecondaryButton;
HapticFeedback: HapticFeedback;
CloudStorage: CloudStorage;
DeviceStorage: DeviceStorage;
SecureStorage: SecureStorage;
openLink: (link: string, options?: { try_instant_view: boolean }) => void;
openTelegramLink: (link: string) => void;
BackButton: BackButton;
Expand Down Expand Up @@ -536,6 +588,7 @@ export interface WebApp {
lockOrientation: VoidFunction;
unlockOrientation: VoidFunction;
addToHomeScreen: VoidFunction;
hideKeyboard: VoidFunction;
checkHomeScreenStatus: (
callback?: (status: HomeScreenStatus) => unknown
) => void;
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@twa-dev/types",
"version": "8.0.2",
"version": "9.1.0",
"main": "index.js",
"description": "Types for Telegram Web Apps (TWA) SDK",
"keywords": [
Expand All @@ -16,11 +16,11 @@
"author": "Artur Stambultsian <bumbledos@gmail.com>",
"license": "MIT",
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.33.0",
"@typescript-eslint/parser": "^5.33.0",
"eslint": "^8.21.0",
"eslint-config-prettier": "^8.5.0",
"prettier": "^2.7.1",
"typescript": "^4.7.4"
"@typescript-eslint/eslint-plugin": "^8.40.0",
"@typescript-eslint/parser": "^8.40.0",
"eslint": "^9.33.0",
"eslint-config-prettier": "^10.1.8",
"prettier": "^3.6.2",
"typescript": "^5.9.2"
}
}