konnekt-wallet 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +125 -0
- package/dist/index.d.mts +118 -0
- package/dist/index.d.ts +118 -0
- package/dist/index.js +1027 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +984 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +55 -0
package/README.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# Konnekt
|
|
2
|
+
|
|
3
|
+
Lightweight, no-bullshit wallet connector for EVM dApps. Pure injected wallet detection via EIP-6963. No WalletConnect, no social logins, no email wallets, no third-party services. Just your users' browser wallets.
|
|
4
|
+
|
|
5
|
+
**Zero dependencies. Zero API keys. Zero subscriptions.**
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install konnekt
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { KonnektProvider, useKonnekt } from 'konnekt';
|
|
17
|
+
|
|
18
|
+
function App() {
|
|
19
|
+
return (
|
|
20
|
+
<KonnektProvider config={{}}>
|
|
21
|
+
<ConnectButton />
|
|
22
|
+
</KonnektProvider>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function ConnectButton() {
|
|
27
|
+
const { isConnected, address, chainId, openModal, disconnect } = useKonnekt();
|
|
28
|
+
|
|
29
|
+
if (isConnected) {
|
|
30
|
+
return (
|
|
31
|
+
<div>
|
|
32
|
+
<p>{address}</p>
|
|
33
|
+
<button onClick={disconnect}>Disconnect</button>
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return <button onClick={openModal}>Connect Wallet</button>;
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
That's it. No project IDs, no config files, no dashboard signups.
|
|
43
|
+
|
|
44
|
+
## What it does
|
|
45
|
+
|
|
46
|
+
- Detects all installed browser wallets automatically via EIP-6963
|
|
47
|
+
- Shows a clean modal with detected wallets
|
|
48
|
+
- Connects with one click
|
|
49
|
+
- Tracks account and chain changes in real-time
|
|
50
|
+
- Provides React hooks for everything
|
|
51
|
+
|
|
52
|
+
## What it doesn't do
|
|
53
|
+
|
|
54
|
+
- No WalletConnect (no relay servers, no QR codes)
|
|
55
|
+
- No social logins (no Google, no Discord, no email)
|
|
56
|
+
- No embedded wallets
|
|
57
|
+
- No analytics, no tracking
|
|
58
|
+
- No external API calls whatsoever
|
|
59
|
+
|
|
60
|
+
## Supported Wallets
|
|
61
|
+
|
|
62
|
+
Any wallet that implements EIP-6963 (which is all modern wallets):
|
|
63
|
+
|
|
64
|
+
MetaMask, Coinbase Wallet, Rabby, Phantom, Trust Wallet, OKX Wallet, Brave Wallet, Rainbow, Zerion, and more.
|
|
65
|
+
|
|
66
|
+
## Theming
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
<KonnektProvider config={{
|
|
70
|
+
theme: {
|
|
71
|
+
accent: '#15803d',
|
|
72
|
+
background: '#0F0F0F',
|
|
73
|
+
surface: '#1A1A1A',
|
|
74
|
+
text: '#F5F0EB',
|
|
75
|
+
border: '#2A2A2A',
|
|
76
|
+
radius: '16px',
|
|
77
|
+
backgroundImage: '/your-project-art.jpg', // optional bg for the modal
|
|
78
|
+
}
|
|
79
|
+
}}>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## API
|
|
83
|
+
|
|
84
|
+
### `useKonnekt()`
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
const {
|
|
88
|
+
status, // 'disconnected' | 'connecting' | 'connected' | 'error'
|
|
89
|
+
address, // string | null
|
|
90
|
+
chainId, // number | null
|
|
91
|
+
walletId, // string | null (rdns of connected wallet)
|
|
92
|
+
error, // string | null
|
|
93
|
+
isConnected, // boolean
|
|
94
|
+
isConnecting, // boolean
|
|
95
|
+
availableWallets, // WalletInfo[]
|
|
96
|
+
connect, // (walletId: string) => Promise<void>
|
|
97
|
+
disconnect, // () => void
|
|
98
|
+
openModal, // () => void
|
|
99
|
+
closeModal, // () => void
|
|
100
|
+
} = useKonnekt();
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### `createKonnekt()` (vanilla JS)
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
import { createKonnekt } from 'konnekt';
|
|
107
|
+
|
|
108
|
+
const konnekt = createKonnekt();
|
|
109
|
+
|
|
110
|
+
konnekt.store.subscribe((state) => {
|
|
111
|
+
console.log(state.address, state.chainId);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
await konnekt.connect('io.metamask');
|
|
115
|
+
konnekt.disconnect();
|
|
116
|
+
konnekt.destroy();
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Size
|
|
120
|
+
|
|
121
|
+
~37KB ESM. Zero runtime dependencies. React 18+ as peer dep.
|
|
122
|
+
|
|
123
|
+
## License
|
|
124
|
+
|
|
125
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
interface WalletInfo {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
icon: string;
|
|
7
|
+
rdns?: string;
|
|
8
|
+
installed: boolean;
|
|
9
|
+
type: 'injected';
|
|
10
|
+
chain: 'evm' | 'solana';
|
|
11
|
+
}
|
|
12
|
+
interface KonnektConfig {
|
|
13
|
+
chains?: number[];
|
|
14
|
+
theme?: KonnektTheme;
|
|
15
|
+
autoConnect?: boolean;
|
|
16
|
+
}
|
|
17
|
+
interface KonnektTheme {
|
|
18
|
+
accent?: string;
|
|
19
|
+
background?: string;
|
|
20
|
+
surface?: string;
|
|
21
|
+
text?: string;
|
|
22
|
+
textSecondary?: string;
|
|
23
|
+
border?: string;
|
|
24
|
+
radius?: string;
|
|
25
|
+
fontFamily?: string;
|
|
26
|
+
backgroundImage?: string;
|
|
27
|
+
}
|
|
28
|
+
type ConnectionStatus = 'disconnected' | 'connecting' | 'connected' | 'error';
|
|
29
|
+
interface KonnektState {
|
|
30
|
+
status: ConnectionStatus;
|
|
31
|
+
address: string | null;
|
|
32
|
+
chainId: number | null;
|
|
33
|
+
walletId: string | null;
|
|
34
|
+
error: string | null;
|
|
35
|
+
availableWallets: WalletInfo[];
|
|
36
|
+
isModalOpen: boolean;
|
|
37
|
+
}
|
|
38
|
+
interface EIP1193Provider {
|
|
39
|
+
request: (args: {
|
|
40
|
+
method: string;
|
|
41
|
+
params?: unknown[];
|
|
42
|
+
}) => Promise<unknown>;
|
|
43
|
+
on: (event: string, handler: (...args: unknown[]) => void) => void;
|
|
44
|
+
removeListener: (event: string, handler: (...args: unknown[]) => void) => void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
type Listener = (state: KonnektState) => void;
|
|
48
|
+
declare function createStore(): {
|
|
49
|
+
getState: () => KonnektState;
|
|
50
|
+
setState: (partial: Partial<KonnektState>) => void;
|
|
51
|
+
subscribe: (listener: Listener) => () => void;
|
|
52
|
+
reset: () => void;
|
|
53
|
+
setWallets: (wallets: WalletInfo[]) => void;
|
|
54
|
+
setStatus: (status: ConnectionStatus, error?: string) => void;
|
|
55
|
+
setConnected: (address: string, chainId: number, walletId: string) => void;
|
|
56
|
+
openModal: () => void;
|
|
57
|
+
closeModal: () => void;
|
|
58
|
+
};
|
|
59
|
+
type Store = ReturnType<typeof createStore>;
|
|
60
|
+
|
|
61
|
+
interface KonnektInstance {
|
|
62
|
+
store: Store;
|
|
63
|
+
connect: (walletId: string) => Promise<void>;
|
|
64
|
+
disconnect: () => void;
|
|
65
|
+
openModal: () => void;
|
|
66
|
+
closeModal: () => void;
|
|
67
|
+
destroy: () => void;
|
|
68
|
+
}
|
|
69
|
+
declare function createKonnekt(config?: KonnektConfig): KonnektInstance;
|
|
70
|
+
|
|
71
|
+
declare function getProviderByRdns(rdns: string): EIP1193Provider | null;
|
|
72
|
+
|
|
73
|
+
declare function connectSolanaWallet(walletId: string): Promise<{
|
|
74
|
+
address: string;
|
|
75
|
+
}>;
|
|
76
|
+
declare function getSolanaProvider(walletId: string): any;
|
|
77
|
+
|
|
78
|
+
interface Props$1 {
|
|
79
|
+
config: KonnektConfig;
|
|
80
|
+
children: React.ReactNode;
|
|
81
|
+
}
|
|
82
|
+
declare function KonnektProvider({ config, children }: Props$1): react_jsx_runtime.JSX.Element;
|
|
83
|
+
|
|
84
|
+
declare function useKonnekt(): {
|
|
85
|
+
status: ConnectionStatus;
|
|
86
|
+
address: string | null;
|
|
87
|
+
chainId: number | null;
|
|
88
|
+
walletId: string | null;
|
|
89
|
+
error: string | null;
|
|
90
|
+
isConnected: boolean;
|
|
91
|
+
isConnecting: boolean;
|
|
92
|
+
availableWallets: WalletInfo[];
|
|
93
|
+
connectedWallet: WalletInfo | null;
|
|
94
|
+
provider: EIP1193Provider | null;
|
|
95
|
+
connect: (walletId: string) => Promise<void>;
|
|
96
|
+
disconnect: () => void;
|
|
97
|
+
openModal: () => void;
|
|
98
|
+
closeModal: () => void;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
interface Props {
|
|
102
|
+
theme?: KonnektTheme;
|
|
103
|
+
}
|
|
104
|
+
declare function KonnektModal({ theme }: Props): react_jsx_runtime.JSX.Element | null;
|
|
105
|
+
|
|
106
|
+
declare function KonnektButton(): react_jsx_runtime.JSX.Element;
|
|
107
|
+
|
|
108
|
+
declare function MetaMaskIcon(): react_jsx_runtime.JSX.Element;
|
|
109
|
+
declare function CoinbaseIcon(): react_jsx_runtime.JSX.Element;
|
|
110
|
+
declare function RabbyIcon(): react_jsx_runtime.JSX.Element;
|
|
111
|
+
declare function PhantomIcon(): react_jsx_runtime.JSX.Element;
|
|
112
|
+
declare function TrustWalletIcon(): react_jsx_runtime.JSX.Element;
|
|
113
|
+
declare function OKXIcon(): react_jsx_runtime.JSX.Element;
|
|
114
|
+
declare function BraveIcon(): react_jsx_runtime.JSX.Element;
|
|
115
|
+
declare const WALLET_ICON_MAP: Record<string, () => JSX.Element>;
|
|
116
|
+
declare function getWalletIcon(id: string): (() => JSX.Element) | null;
|
|
117
|
+
|
|
118
|
+
export { BraveIcon, CoinbaseIcon, type ConnectionStatus, type EIP1193Provider, KonnektButton, type KonnektConfig, type KonnektInstance, KonnektModal, KonnektProvider, type KonnektState, type KonnektTheme, MetaMaskIcon, OKXIcon, PhantomIcon, RabbyIcon, type Store, TrustWalletIcon, WALLET_ICON_MAP, type WalletInfo, connectSolanaWallet, createKonnekt, getProviderByRdns, getSolanaProvider, getWalletIcon, useKonnekt };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
interface WalletInfo {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
icon: string;
|
|
7
|
+
rdns?: string;
|
|
8
|
+
installed: boolean;
|
|
9
|
+
type: 'injected';
|
|
10
|
+
chain: 'evm' | 'solana';
|
|
11
|
+
}
|
|
12
|
+
interface KonnektConfig {
|
|
13
|
+
chains?: number[];
|
|
14
|
+
theme?: KonnektTheme;
|
|
15
|
+
autoConnect?: boolean;
|
|
16
|
+
}
|
|
17
|
+
interface KonnektTheme {
|
|
18
|
+
accent?: string;
|
|
19
|
+
background?: string;
|
|
20
|
+
surface?: string;
|
|
21
|
+
text?: string;
|
|
22
|
+
textSecondary?: string;
|
|
23
|
+
border?: string;
|
|
24
|
+
radius?: string;
|
|
25
|
+
fontFamily?: string;
|
|
26
|
+
backgroundImage?: string;
|
|
27
|
+
}
|
|
28
|
+
type ConnectionStatus = 'disconnected' | 'connecting' | 'connected' | 'error';
|
|
29
|
+
interface KonnektState {
|
|
30
|
+
status: ConnectionStatus;
|
|
31
|
+
address: string | null;
|
|
32
|
+
chainId: number | null;
|
|
33
|
+
walletId: string | null;
|
|
34
|
+
error: string | null;
|
|
35
|
+
availableWallets: WalletInfo[];
|
|
36
|
+
isModalOpen: boolean;
|
|
37
|
+
}
|
|
38
|
+
interface EIP1193Provider {
|
|
39
|
+
request: (args: {
|
|
40
|
+
method: string;
|
|
41
|
+
params?: unknown[];
|
|
42
|
+
}) => Promise<unknown>;
|
|
43
|
+
on: (event: string, handler: (...args: unknown[]) => void) => void;
|
|
44
|
+
removeListener: (event: string, handler: (...args: unknown[]) => void) => void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
type Listener = (state: KonnektState) => void;
|
|
48
|
+
declare function createStore(): {
|
|
49
|
+
getState: () => KonnektState;
|
|
50
|
+
setState: (partial: Partial<KonnektState>) => void;
|
|
51
|
+
subscribe: (listener: Listener) => () => void;
|
|
52
|
+
reset: () => void;
|
|
53
|
+
setWallets: (wallets: WalletInfo[]) => void;
|
|
54
|
+
setStatus: (status: ConnectionStatus, error?: string) => void;
|
|
55
|
+
setConnected: (address: string, chainId: number, walletId: string) => void;
|
|
56
|
+
openModal: () => void;
|
|
57
|
+
closeModal: () => void;
|
|
58
|
+
};
|
|
59
|
+
type Store = ReturnType<typeof createStore>;
|
|
60
|
+
|
|
61
|
+
interface KonnektInstance {
|
|
62
|
+
store: Store;
|
|
63
|
+
connect: (walletId: string) => Promise<void>;
|
|
64
|
+
disconnect: () => void;
|
|
65
|
+
openModal: () => void;
|
|
66
|
+
closeModal: () => void;
|
|
67
|
+
destroy: () => void;
|
|
68
|
+
}
|
|
69
|
+
declare function createKonnekt(config?: KonnektConfig): KonnektInstance;
|
|
70
|
+
|
|
71
|
+
declare function getProviderByRdns(rdns: string): EIP1193Provider | null;
|
|
72
|
+
|
|
73
|
+
declare function connectSolanaWallet(walletId: string): Promise<{
|
|
74
|
+
address: string;
|
|
75
|
+
}>;
|
|
76
|
+
declare function getSolanaProvider(walletId: string): any;
|
|
77
|
+
|
|
78
|
+
interface Props$1 {
|
|
79
|
+
config: KonnektConfig;
|
|
80
|
+
children: React.ReactNode;
|
|
81
|
+
}
|
|
82
|
+
declare function KonnektProvider({ config, children }: Props$1): react_jsx_runtime.JSX.Element;
|
|
83
|
+
|
|
84
|
+
declare function useKonnekt(): {
|
|
85
|
+
status: ConnectionStatus;
|
|
86
|
+
address: string | null;
|
|
87
|
+
chainId: number | null;
|
|
88
|
+
walletId: string | null;
|
|
89
|
+
error: string | null;
|
|
90
|
+
isConnected: boolean;
|
|
91
|
+
isConnecting: boolean;
|
|
92
|
+
availableWallets: WalletInfo[];
|
|
93
|
+
connectedWallet: WalletInfo | null;
|
|
94
|
+
provider: EIP1193Provider | null;
|
|
95
|
+
connect: (walletId: string) => Promise<void>;
|
|
96
|
+
disconnect: () => void;
|
|
97
|
+
openModal: () => void;
|
|
98
|
+
closeModal: () => void;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
interface Props {
|
|
102
|
+
theme?: KonnektTheme;
|
|
103
|
+
}
|
|
104
|
+
declare function KonnektModal({ theme }: Props): react_jsx_runtime.JSX.Element | null;
|
|
105
|
+
|
|
106
|
+
declare function KonnektButton(): react_jsx_runtime.JSX.Element;
|
|
107
|
+
|
|
108
|
+
declare function MetaMaskIcon(): react_jsx_runtime.JSX.Element;
|
|
109
|
+
declare function CoinbaseIcon(): react_jsx_runtime.JSX.Element;
|
|
110
|
+
declare function RabbyIcon(): react_jsx_runtime.JSX.Element;
|
|
111
|
+
declare function PhantomIcon(): react_jsx_runtime.JSX.Element;
|
|
112
|
+
declare function TrustWalletIcon(): react_jsx_runtime.JSX.Element;
|
|
113
|
+
declare function OKXIcon(): react_jsx_runtime.JSX.Element;
|
|
114
|
+
declare function BraveIcon(): react_jsx_runtime.JSX.Element;
|
|
115
|
+
declare const WALLET_ICON_MAP: Record<string, () => JSX.Element>;
|
|
116
|
+
declare function getWalletIcon(id: string): (() => JSX.Element) | null;
|
|
117
|
+
|
|
118
|
+
export { BraveIcon, CoinbaseIcon, type ConnectionStatus, type EIP1193Provider, KonnektButton, type KonnektConfig, type KonnektInstance, KonnektModal, KonnektProvider, type KonnektState, type KonnektTheme, MetaMaskIcon, OKXIcon, PhantomIcon, RabbyIcon, type Store, TrustWalletIcon, WALLET_ICON_MAP, type WalletInfo, connectSolanaWallet, createKonnekt, getProviderByRdns, getSolanaProvider, getWalletIcon, useKonnekt };
|