@kryptos_connect/mobile-sdk 0.0.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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Kryptos
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
package/README.md ADDED
@@ -0,0 +1,268 @@
1
+ # @kryptos_connect/mobile-sdk
2
+
3
+ Kryptos Connect Mobile SDK for React Native - Works with both **Expo** and **React Native CLI**. Simplifies Web3 finance integration for mobile apps.
4
+
5
+ ## Installation
6
+
7
+ ### Using npm
8
+
9
+ ```bash
10
+ npm install @kryptos_connect/mobile-sdk react-native-svg
11
+ ```
12
+
13
+ ### Using yarn
14
+
15
+ ```bash
16
+ yarn add @kryptos_connect/mobile-sdk react-native-svg
17
+ ```
18
+
19
+ ### For Expo
20
+
21
+ ```bash
22
+ npx expo install @kryptos_connect/mobile-sdk react-native-svg
23
+ ```
24
+
25
+ ### iOS (React Native CLI only)
26
+
27
+ ```bash
28
+ cd ios && pod install
29
+ ```
30
+
31
+ ## Core library (all-in-one)
32
+
33
+ For Expo or bare React Native, install the core WalletConnect/AppKit deps together:
34
+
35
+ ```bash
36
+ npx expo install @reown/appkit-react-native @react-native-async-storage/async-storage react-native-get-random-values react-native-svg @react-native-community/netinfo @walletconnect/react-native-compat react-native-safe-area-context expo-application
37
+ ```
38
+
39
+ ## Platform Setup
40
+
41
+ ### Expo (managed or prebuild)
42
+
43
+ - Install the required peer deps (AppKit + WalletConnect) in one go:
44
+
45
+ ```bash
46
+ npx expo install @kryptos_connect/mobile-sdk react-native-svg @react-native-async-storage/async-storage @react-native-community/netinfo react-native-get-random-values @walletconnect/react-native-compat @reown/appkit-react-native @reown/appkit-ethers-react-native expo-application
47
+ ```
48
+
49
+ - Expo SDK 53+: add `babel.config.js` to enable `unstable_transformImportMeta` for `valtio`:
50
+ ```js
51
+ // babel.config.js
52
+ module.exports = function (api) {
53
+ api.cache(true);
54
+ return {
55
+ presets: [["babel-preset-expo", { unstable_transformImportMeta: true }]],
56
+ };
57
+ };
58
+ ```
59
+
60
+ ### React Native CLI
61
+
62
+ - Install peer deps:
63
+ ```bash
64
+ npm install @kryptos_connect/mobile-sdk react-native-svg @react-native-async-storage/async-storage @react-native-community/netinfo react-native-get-random-values @walletconnect/react-native-compat @reown/appkit-react-native @reown/appkit-ethers-react-native viem
65
+ ```
66
+ - iOS: `cd ios && pod install`.
67
+
68
+ ## Quick Start
69
+
70
+ ### 1. Wrap your app with the Provider
71
+
72
+ ```tsx
73
+ import { KryptosConnectProvider } from "@kryptos_connect/mobile-sdk";
74
+
75
+ const config = {
76
+ appName: "Your App Name",
77
+ appLogo: "https://your-logo-url.com/logo.png", // or require('./logo.png')
78
+ clientId: "your-client-id",
79
+ theme: "light", // or 'dark'
80
+ };
81
+
82
+ export default function App() {
83
+ return (
84
+ <KryptosConnectProvider config={config}>
85
+ <YourApp />
86
+ </KryptosConnectProvider>
87
+ );
88
+ }
89
+ ```
90
+
91
+ ### 2. Add the Connect Button
92
+
93
+ ```tsx
94
+ import { KryptosConnectButton } from "@kryptos_connect/mobile-sdk";
95
+
96
+ function YourComponent() {
97
+ const generateLinkToken = async () => {
98
+ // Call your backend API to generate a link token
99
+ const response = await fetch("https://your-api.com/generate-link-token");
100
+ const data = await response.json();
101
+ return data.link_token;
102
+ };
103
+
104
+ const handleSuccess = (userConsent) => {
105
+ console.log("Connection successful!", userConsent);
106
+ // Handle the public_token
107
+ const publicToken = userConsent?.public_token;
108
+ };
109
+
110
+ const handleError = () => {
111
+ console.log("Connection failed");
112
+ };
113
+
114
+ return (
115
+ <KryptosConnectButton
116
+ generateLinkToken={generateLinkToken}
117
+ onSuccess={handleSuccess}
118
+ onError={handleError}
119
+ />
120
+ );
121
+ }
122
+ ```
123
+
124
+ ## WalletConnect / Reown AppKit configuration
125
+
126
+ Passing a `walletConnectProjectId` to `KryptosConnectProvider` enables the built-in AppKit (WalletConnect v2) flow used by the `WalletConnectComponent`:
127
+
128
+ ```tsx
129
+ import "@walletconnect/react-native-compat";
130
+ import "react-native-get-random-values";
131
+ import { KryptosConnectProvider } from "@kryptos_connect/mobile-sdk";
132
+
133
+ const config = {
134
+ appName: "Your App",
135
+ appLogo: "https://your-logo.png",
136
+ clientId: "<kryptos-client-id>",
137
+ walletConnectProjectId: "<walletconnect-cloud-project-id>",
138
+ };
139
+
140
+ export default function App() {
141
+ return (
142
+ <KryptosConnectProvider config={config}>
143
+ <YourApp />
144
+ </KryptosConnectProvider>
145
+ );
146
+ }
147
+ ```
148
+
149
+ Behind the scenes the SDK creates an AppKit instance (see `src/wallet-connect/AppKitConfig.ts`) with Ethers adapter, common EVM chains, and persistent storage. If you need to customize chains, metadata, or features, copy that file into your app and adjust it following the Reown AppKit guide: https://docs.reown.com/appkit/overview
150
+
151
+ ### 3. Custom Button (Optional)
152
+
153
+ You can also use a custom button:
154
+
155
+ ```tsx
156
+ import { KryptosConnectButton } from "@kryptos_connect/mobile-sdk";
157
+ import { Text, View } from "react-native";
158
+
159
+ function CustomButton() {
160
+ return (
161
+ <KryptosConnectButton
162
+ generateLinkToken={generateLinkToken}
163
+ onSuccess={handleSuccess}
164
+ onError={handleError}
165
+ >
166
+ <View style={styles.customButton}>
167
+ <Text style={styles.customText}>Connect Your Wallet</Text>
168
+ </View>
169
+ </KryptosConnectButton>
170
+ );
171
+ }
172
+ ```
173
+
174
+ ## API Reference
175
+
176
+ ### KryptosConnectProvider
177
+
178
+ The provider component that wraps your app and provides the Kryptos context.
179
+
180
+ #### Props
181
+
182
+ | Prop | Type | Required | Description |
183
+ | ---------- | --------------- | -------- | -------------------- |
184
+ | `config` | `KryptosConfig` | Yes | Configuration object |
185
+ | `children` | `ReactNode` | Yes | Child components |
186
+
187
+ #### KryptosConfig
188
+
189
+ ```typescript
190
+ type KryptosConfig = {
191
+ appName: string; // Your app name
192
+ appLogo?: ReactNode | string; // Logo URL or React Native Image source
193
+ theme?: "light" | "dark"; // Theme mode (default: 'light')
194
+ clientId: string; // Your Kryptos client ID
195
+ walletConnectProjectId?: string; // Optional WalletConnect project ID
196
+ };
197
+ ```
198
+
199
+ ### KryptosConnectButton
200
+
201
+ The main button component that triggers the connection flow.
202
+
203
+ #### Props
204
+
205
+ | Prop | Type | Required | Description |
206
+ | ------------------- | -------------------------------- | -------- | --------------------------------- |
207
+ | `generateLinkToken` | `() => Promise<string>` | Yes | Function to generate a link token |
208
+ | `onSuccess` | `(consent: UserConsent) => void` | No | Called on successful connection |
209
+ | `onError` | `() => void` | No | Called on connection failure |
210
+ | `children` | `ReactNode` | No | Custom button content |
211
+ | `style` | `ViewStyle` | No | Custom button container style |
212
+ | `textStyle` | `TextStyle` | No | Custom button text style |
213
+
214
+ ### KryptosConnectModal
215
+
216
+ If you need more control, you can use the modal component directly:
217
+
218
+ ```tsx
219
+ import { KryptosConnectModal } from "@kryptos_connect/mobile-sdk";
220
+ import { useState } from "react";
221
+
222
+ function YourComponent() {
223
+ const [open, setOpen] = useState(false);
224
+
225
+ return (
226
+ <>
227
+ <TouchableOpacity onPress={() => setOpen(true)}>
228
+ <Text>Open Modal</Text>
229
+ </TouchableOpacity>
230
+
231
+ <KryptosConnectModal
232
+ open={open}
233
+ setOpen={setOpen}
234
+ generateLinkToken={generateLinkToken}
235
+ onSuccess={handleSuccess}
236
+ onError={handleError}
237
+ />
238
+ </>
239
+ );
240
+ }
241
+ ```
242
+
243
+ ## Supported Platforms
244
+
245
+ - ✅ iOS 12.0+
246
+ - ✅ Android 5.0+ (API 21+)
247
+ - ✅ Expo SDK 48+
248
+ - ✅ React Native 0.60+
249
+
250
+ ## Peer Dependencies
251
+
252
+ ```json
253
+ {
254
+ "react": ">=16.8.0",
255
+ "react-native": ">=0.60.0",
256
+ "react-native-svg": ">=12.0.0"
257
+ }
258
+ ```
259
+
260
+ ## License
261
+
262
+ MIT © Kryptos
263
+
264
+ ## Support
265
+
266
+ - 📧 Email: support@kryptos.io
267
+ - 📚 Documentation: https://docs.kryptos.io
268
+ - 🐛 Issues: https://github.com/Kryptoskatt/kryptos-connect-mobile-package/issues
@@ -0,0 +1,72 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { ImageSourcePropType, ViewStyle, TextStyle } from 'react-native';
3
+
4
+ type KryptosConfig = {
5
+ appName: string;
6
+ appLogo?: ReactNode | string | ImageSourcePropType;
7
+ theme?: "light" | "dark";
8
+ clientId: string;
9
+ walletConnectProjectId?: string;
10
+ };
11
+ type KryptosUser = {
12
+ message: string;
13
+ user: {
14
+ uid: string;
15
+ email: string;
16
+ baseCurrency: string;
17
+ costbasisType: string;
18
+ country: string;
19
+ userType: string;
20
+ isConnect: boolean;
21
+ timezone: string;
22
+ createdAt: number;
23
+ updatedAt: number;
24
+ lastUsage: number;
25
+ connectMeta: {
26
+ lastUsage: number;
27
+ isAnonymous: boolean;
28
+ clientId: string;
29
+ };
30
+ };
31
+ };
32
+ type UserConsent = {
33
+ public_token: string;
34
+ };
35
+
36
+ interface KryptosConnectButtonProps {
37
+ onSuccess?: (userConsent: UserConsent | null) => void;
38
+ onError?: (error?: any) => void;
39
+ generateLinkToken: () => Promise<string>;
40
+ children?: React.ReactNode;
41
+ style?: ViewStyle;
42
+ textStyle?: TextStyle;
43
+ }
44
+ declare const KryptosConnectButton: React.FC<KryptosConnectButtonProps>;
45
+ interface KryptosConnectModalProps {
46
+ open: boolean;
47
+ setOpen: (open: boolean) => void;
48
+ onSuccess?: (userConsent: UserConsent | null) => void;
49
+ onError?: (error?: any) => void;
50
+ generateLinkToken: () => Promise<string>;
51
+ }
52
+ declare const KryptosConnectModal: React.FC<KryptosConnectModalProps>;
53
+
54
+ type KryptosContextType = KryptosConfig & {
55
+ isInitialized: boolean;
56
+ setIsInitialized: (value: boolean) => void;
57
+ linkToken: string;
58
+ setLinkToken: (value: string) => void;
59
+ user: KryptosUser | null;
60
+ setUser: (value: KryptosUser | null) => void;
61
+ email: string;
62
+ setEmail: (value: string) => void;
63
+ userConsent: UserConsent | null;
64
+ setUserConsent: (value: UserConsent | null) => void;
65
+ };
66
+ declare const KryptosConnectProvider: React.FC<{
67
+ children: React.ReactNode;
68
+ config: KryptosConfig;
69
+ }>;
70
+ declare const useKryptosConnect: () => KryptosContextType;
71
+
72
+ export { KryptosConnectButton, type KryptosConnectButtonProps, KryptosConnectModal, KryptosConnectProvider, useKryptosConnect };
@@ -0,0 +1,72 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { ImageSourcePropType, ViewStyle, TextStyle } from 'react-native';
3
+
4
+ type KryptosConfig = {
5
+ appName: string;
6
+ appLogo?: ReactNode | string | ImageSourcePropType;
7
+ theme?: "light" | "dark";
8
+ clientId: string;
9
+ walletConnectProjectId?: string;
10
+ };
11
+ type KryptosUser = {
12
+ message: string;
13
+ user: {
14
+ uid: string;
15
+ email: string;
16
+ baseCurrency: string;
17
+ costbasisType: string;
18
+ country: string;
19
+ userType: string;
20
+ isConnect: boolean;
21
+ timezone: string;
22
+ createdAt: number;
23
+ updatedAt: number;
24
+ lastUsage: number;
25
+ connectMeta: {
26
+ lastUsage: number;
27
+ isAnonymous: boolean;
28
+ clientId: string;
29
+ };
30
+ };
31
+ };
32
+ type UserConsent = {
33
+ public_token: string;
34
+ };
35
+
36
+ interface KryptosConnectButtonProps {
37
+ onSuccess?: (userConsent: UserConsent | null) => void;
38
+ onError?: (error?: any) => void;
39
+ generateLinkToken: () => Promise<string>;
40
+ children?: React.ReactNode;
41
+ style?: ViewStyle;
42
+ textStyle?: TextStyle;
43
+ }
44
+ declare const KryptosConnectButton: React.FC<KryptosConnectButtonProps>;
45
+ interface KryptosConnectModalProps {
46
+ open: boolean;
47
+ setOpen: (open: boolean) => void;
48
+ onSuccess?: (userConsent: UserConsent | null) => void;
49
+ onError?: (error?: any) => void;
50
+ generateLinkToken: () => Promise<string>;
51
+ }
52
+ declare const KryptosConnectModal: React.FC<KryptosConnectModalProps>;
53
+
54
+ type KryptosContextType = KryptosConfig & {
55
+ isInitialized: boolean;
56
+ setIsInitialized: (value: boolean) => void;
57
+ linkToken: string;
58
+ setLinkToken: (value: string) => void;
59
+ user: KryptosUser | null;
60
+ setUser: (value: KryptosUser | null) => void;
61
+ email: string;
62
+ setEmail: (value: string) => void;
63
+ userConsent: UserConsent | null;
64
+ setUserConsent: (value: UserConsent | null) => void;
65
+ };
66
+ declare const KryptosConnectProvider: React.FC<{
67
+ children: React.ReactNode;
68
+ config: KryptosConfig;
69
+ }>;
70
+ declare const useKryptosConnect: () => KryptosContextType;
71
+
72
+ export { KryptosConnectButton, type KryptosConnectButtonProps, KryptosConnectModal, KryptosConnectProvider, useKryptosConnect };