@kryptos_connect/mobile-sdk 1.0.4 → 1.0.6-dev.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @kryptos_connect/mobile-sdk
2
2
 
3
- Kryptos Connect Mobile SDK for React Native - Works with both **Expo** and **React Native CLI**. Simplifies Web3 finance integration for mobile apps.
3
+ Kryptos Connect Mobile SDK for React Native works with **Expo** and **React Native CLI**. Seamless Kryptos integration with built-in authentication, theme support, and wallet connectivity. Connect your users to the complete Web3 finance ecosystem with support for 5000+ DeFi protocols, 200+ exchanges and wallets, and 100+ blockchains.
4
4
 
5
5
  ## Installation
6
6
 
@@ -28,6 +28,13 @@ npx expo install @kryptos_connect/mobile-sdk react-native-svg
28
28
  cd ios && pod install
29
29
  ```
30
30
 
31
+ ## Prerequisites
32
+
33
+ Before using this package, you'll need:
34
+
35
+ 1. **Client ID**: Obtain from [Kryptos Developer Portal](https://dashboard.kryptos.io)
36
+ 2. **WalletConnect Project ID**: Get from [WalletConnect Cloud](https://cloud.walletconnect.com) (optional, for wallet connectivity)
37
+
31
38
  ## Core library (all-in-one)
32
39
 
33
40
  For Expo or bare React Native, install the core WalletConnect/AppKit deps together:
@@ -77,7 +84,7 @@ const config = {
77
84
  appLogo: "https://your-logo-url.com/logo.png", // or require('./logo.png')
78
85
  clientId: "your-client-id",
79
86
  theme: "light", // or 'dark'
80
- walletConnectProjectId: "your-walletconnect-project-id", // optional
87
+ walletConnectProjectId: "your-walletconnect-project-id",
81
88
  };
82
89
 
83
90
  export default function App() {
@@ -89,6 +96,16 @@ export default function App() {
89
96
  }
90
97
  ```
91
98
 
99
+ ### Configuration Options
100
+
101
+ | Property | Type | Required | Description |
102
+ | ------------------------ | ------------------------------------------ | -------- | --------------------------------------------------------------------------- |
103
+ | `appName` | `string` | Yes | Your application name |
104
+ | `appLogo` | `React.ReactNode \| string \| ImageSource` | No | Your app logo (URL, `require()`, or React Native image source) |
105
+ | `clientId` | `string` | Yes | Your Kryptos client ID |
106
+ | `theme` | `"light" \| "dark"` | No | Default theme mode (defaults to `"light"` if not set) |
107
+ | `walletConnectProjectId` | `string` | No | Your WalletConnect project ID (enables built-in AppKit / wallet connection) |
108
+
92
109
  ### 2. Add the Connect Button
93
110
 
94
111
  ```tsx
@@ -138,29 +155,27 @@ function YourComponent() {
138
155
  }
139
156
  ```
140
157
 
141
- ## User Flow Variations
158
+ #### User Flow Variations
142
159
 
143
160
  The SDK automatically handles two different user flows based on the `isAuthorized` flag returned from `generateLinkToken`:
144
161
 
145
- ### Flow 1: New/Anonymous User (`isAuthorized: false` or undefined)
162
+ **Flow 1: New User** (`isAuthorized: false` or undefined)
146
163
 
147
164
  ```
148
- INIT → AUTH (Login) OTP → INTEGRATION → PERMISSIONS → STATUS
165
+ INIT → Connect → INTEGRATION → STATUS
149
166
  ```
150
167
 
151
- - User enters email and verifies OTP (or continues as guest)
152
- - User selects integrations to connect
153
- - User grants permissions/consent
154
- - Returns `public_token` in `onSuccess` callback
168
+ - **INIT (Connect)**: Fetches link token and initializes the session & an account is created for them on the backend
169
+ - **INTEGRATION**: User selects and connects integrations (wallets, exchanges, blockchains)
170
+ - **STATUS**: Success or error result; returns `public_token` in `onSuccess` when consent is given, or `null` when user was already authorized
155
171
 
156
- ### Flow 2: Authenticated User (`isAuthorized: true`)
172
+ **Flow 2: Authenticated User** (`isAuthorized: true`)
157
173
 
158
174
  ```
159
175
  INIT → INTEGRATION → STATUS
160
176
  ```
161
177
 
162
- - Skips login/OTP (already authenticated)
163
- - Skips permissions (already consented)
178
+ - Skips Connect (an account already exists for the user on the backend)
164
179
  - User directly selects integrations
165
180
  - Returns `null` in `onSuccess` callback (no new token needed)
166
181
 
@@ -290,15 +305,39 @@ const styles = StyleSheet.create({
290
305
  });
291
306
  ```
292
307
 
293
- ## Features
308
+ #### Direct Integration Flow
294
309
 
295
- ### Sandbox Mode Indicator
310
+ You can use the `integrationName` prop to direct users to a specific integration, bypassing the general integration selection. Useful for dedicated buttons for specific exchanges or wallets.
296
311
 
297
- The SDK automatically displays a "Sandbox Mode" badge when using the development environment. This helps distinguish between development and production environments visually. The badge appears at the bottom of the authentication modal and only shows when:
312
+ **Getting supported integration IDs:** Fetch from the public Kryptos API:
298
313
 
299
- - The client's project stage is not "production"
314
+ ```bash
315
+ GET {BASE_URL}/integrations/public/list
316
+ ```
300
317
 
301
- This indicator is automatically managed by the SDK and requires no additional configuration.
318
+ **Usage example:**
319
+
320
+ ```tsx
321
+ // Direct connection to a specific integration (e.g. Binance)
322
+ <KryptosConnectButton
323
+ generateLinkToken={generateLinkToken}
324
+ integrationName="binance"
325
+ onSuccess={(userConsent) => {
326
+ console.log("Binance connected:", userConsent);
327
+ }}
328
+ >
329
+ Connect Binance Account
330
+ </KryptosConnectButton>
331
+
332
+ // Default button text when integrationName is set: "Connect {Integration} Account"
333
+ <KryptosConnectButton
334
+ generateLinkToken={generateLinkToken}
335
+ integrationName="metamask"
336
+ onSuccess={(userConsent) => console.log("MetaMask connected:", userConsent)}
337
+ />
338
+ ```
339
+
340
+ **Use cases:** Dedicated integration buttons, contextual integration (e.g. exchange-focused screens), onboarding steps (e.g. connect wallet then exchange). The `integrationName` value must match an integration ID from the supported providers list.
302
341
 
303
342
  ## API Reference
304
343
 
@@ -331,14 +370,15 @@ The main button component that triggers the connection flow.
331
370
 
332
371
  #### Props
333
372
 
334
- | Prop | Type | Required | Description |
335
- | ------------------- | --------------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------ |
336
- | `generateLinkToken` | `() => Promise<{ link_token: string; isAuthorized?: boolean }>` | Yes | Function that returns link token and authorization status. `isAuthorized: true` skips login flow for authenticated users |
337
- | `onSuccess` | `(consent: UserConsent \| null) => void` | No | Callback fired when connection succeeds. Receives `public_token` for new users, `null` for authorized users |
338
- | `onError` | `(error?: Error) => void` | No | Callback fired when connection fails |
339
- | `children` | `ReactNode` | No | Custom button content |
340
- | `style` | `ViewStyle` | No | Custom button container style |
341
- | `textStyle` | `TextStyle` | No | Custom button text style |
373
+ | Prop | Type | Required | Description |
374
+ | ------------------- | --------------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
375
+ | `generateLinkToken` | `() => Promise<{ link_token: string; isAuthorized?: boolean }>` | Yes | Function that returns link token and authorization status. `isAuthorized: true` indicates the user is already authorized (consent API may be skipped; `onSuccess` receives `null`) |
376
+ | `onSuccess` | `(data: UserConsent \| null) => void` | No | Callback invoked when connection succeeds. Receives `public_token` for new users, `null` for authorized users |
377
+ | `onError` | `(error?: Error) => void` | No | Callback invoked when connection fails |
378
+ | `integrationName` | `string` | No | Integration ID from the supported providers list. When provided, skips the integration list and goes directly to that integration |
379
+ | `children` | `ReactNode` | No | Custom button content. Defaults to "Connect With Kryptos", or "Connect {Integration} Account" when `integrationName` is set |
380
+ | `style` | `ViewStyle` | No | Custom button container style |
381
+ | `textStyle` | `TextStyle` | No | Custom button text style |
342
382
 
343
383
  #### TypeScript Types
344
384
 
@@ -350,6 +390,7 @@ interface KryptosConnectButtonProps {
350
390
  }>;
351
391
  onSuccess?: (data: UserConsent | null) => void;
352
392
  onError?: (error?: Error) => void;
393
+ integrationName?: string; // Integration ID from the supported providers list
353
394
  children?: ReactNode;
354
395
  style?: ViewStyle;
355
396
  textStyle?: TextStyle;
@@ -365,23 +406,40 @@ interface UserConsent {
365
406
  // - null for authenticated users (isAuthorized: true)
366
407
  ```
367
408
 
409
+ ### TypeScript
410
+
411
+ The package includes type definitions. You can import types from the package:
412
+
413
+ ```typescript
414
+ import type {
415
+ KryptosConnectButtonProps,
416
+ KryptosConfig,
417
+ UserConsent,
418
+ } from "@kryptos_connect/mobile-sdk";
419
+ ```
420
+
368
421
  ## Backend Integration
369
422
 
370
- You'll need to implement two backend endpoints to complete the integration.
423
+ You need to implement two backend endpoints. The same API is used for web and mobile.
371
424
 
372
425
  ### Base URLs
373
426
 
374
- | Environment | URL |
375
- | -------------- | --------------------------------- |
376
- | **Production** | `https://connect-api.kryptos.io/` |
427
+ | Environment | URL |
428
+ | -------------- | -------------------------------- |
429
+ | **Production** | `https://connect-api.kryptos.io` |
377
430
 
378
431
  ### 1. Create Link Token
379
432
 
380
- The link token can be created in two ways, depending on whether you want to authenticate an existing user or create a new session.
433
+ A link token can be created in two ways: to authenticate an existing user or to create a new session.
434
+
435
+ | Approach | When to use |
436
+ | -------- | -------------------------------- |
437
+ | Option A | New user, no access token |
438
+ | Option B | Returning user, has access token |
381
439
 
382
440
  #### Option A: Without Access Token (New/Anonymous User)
383
441
 
384
- Use this approach for **new users** or when you want users to go through the login/OTP flow:
442
+ Use this approach for **new users** (no access token):
385
443
 
386
444
  ```javascript
387
445
  // Example: Node.js/Express
@@ -402,7 +460,7 @@ app.post("/api/kryptos/create-link-token", async (req, res) => {
402
460
 
403
461
  const data = await response.json();
404
462
  res.json({
405
- link_token: data.data.link_token,
463
+ link_token: data.link_token,
406
464
  isAuthorized: false, // No access token provided
407
465
  });
408
466
  } catch (error) {
@@ -411,18 +469,16 @@ app.post("/api/kryptos/create-link-token", async (req, res) => {
411
469
  });
412
470
  ```
413
471
 
414
- **User Experience Flow**:
472
+ **User experience flow:**
415
473
 
416
- 1. User clicks "Connect to Kryptos"
417
- 2. **Login screen appears**
418
- 3. User enters email Verifies OTP (OR continues as guest)
419
- 4. User selects integrations
420
- 5. User grants permissions
421
- 6. `onSuccess` receives `public_token` to exchange
474
+ 1. User taps "Connect to Kryptos"
475
+ 2. Connect (INIT) screen initializes, then integration selection is shown
476
+ 3. User selects and connects integrations
477
+ 4. `onSuccess` receives `public_token` to exchange
422
478
 
423
479
  #### Option B: With Access Token (Authenticated User)
424
480
 
425
- Use this approach for **existing authenticated users** to skip the login flow:
481
+ Use this approach for **existing authenticated users**:
426
482
 
427
483
  ```javascript
428
484
  // Example: Node.js/Express
@@ -447,7 +503,7 @@ app.post("/api/kryptos/create-link-token", async (req, res) => {
447
503
 
448
504
  const data = await response.json();
449
505
  res.json({
450
- link_token: data.data.link_token,
506
+ link_token: data.link_token,
451
507
  isAuthorized: true, // Access token provided, user is authenticated
452
508
  });
453
509
  } catch (error) {
@@ -456,32 +512,30 @@ app.post("/api/kryptos/create-link-token", async (req, res) => {
456
512
  });
457
513
  ```
458
514
 
459
- **User Experience Flow**:
515
+ **User experience flow:**
460
516
 
461
- 1. User clicks "Connect to Kryptos"
462
- 2. **Directly shows integration selection** (no login screen)
463
- 3. User selects integrations
464
- 4. `onSuccess` receives `null` (no new token needed)
517
+ 1. User taps "Connect to Kryptos"
518
+ 2. Connect (INIT) then integration selection is shown
519
+ 3. User selects integrations; `onSuccess` receives `null` (no new token needed)
465
520
 
466
521
  #### Choosing the Right Approach
467
522
 
468
- | Scenario | Use Option | isAuthorized | User Flow | Returns public_token |
469
- | ------------------------------------------ | ----------------- | ------------ | --------------------------------------- | -------------------- |
470
- | First-time user connecting to Kryptos | A (Without Token) | `false` | LOGINOTP → INTEGRATION → PERMISSIONS | ✅ Yes |
471
- | User doesn't have an access token yet | A (Without Token) | `false` | LOGINOTP → INTEGRATION → PERMISSIONS | ✅ Yes |
472
- | Returning user with stored access token | B (With Token) | `true` | INTEGRATION only (skip login) | ❌ No |
473
- | Adding more integrations for existing user | B (With Token) | `true` | INTEGRATION only (skip login) | ❌ No |
523
+ | Scenario | Use Option | isAuthorized | User Flow (mobile) | Returns public_token |
524
+ | ------------------------------------------ | ----------------- | ------------ | -------------------------------------------------------------------------- | -------------------- |
525
+ | First-time user connecting to Kryptos | A (Without Token) | `false` | INITConnect(account created for user on backend) → INTEGRATION → STATUS | ✅ Yes |
526
+ | User doesn't have an access token yet | A (Without Token) | `false` | INITConnect(account created for user on backend) → INTEGRATION → STATUS | ✅ Yes |
527
+ | Returning user with stored access token | B (With Token) | `true` | INIT → INTEGRATION STATUS | ❌ No |
528
+ | Adding more integrations for existing user | B (With Token) | `true` | INIT → INTEGRATION STATUS | ❌ No |
474
529
 
475
- **Important Notes**:
530
+ **Important notes:**
476
531
 
477
- - After the first successful connection (using Option A), store the `access_token` you receive from the token exchange
478
- - Use the stored `access_token` for subsequent connections (Option B) to provide a seamless experience
479
- - For authorized users (`isAuthorized: true`), the `onSuccess` callback receives `null` instead of a `public_token`
480
- - Authorized users skip both the login/OTP and permissions steps
532
+ - After the first successful connection (Option A), store the `access_token` from the token exchange.
533
+ - Use the stored `access_token` for subsequent connections (Option B).
534
+ - For authorized users (`isAuthorized: true`), `onSuccess` receives `null`.
481
535
 
482
536
  ### 2. Exchange Public Token
483
537
 
484
- After a successful connection, exchange the `public_token` for an `access_token`. **Important**: Store this `access_token` securely in your database - you'll use it to create link tokens for authenticated users (Option B above).
538
+ After a successful connection, exchange the `public_token` for an `access_token`. **Important:** Store this `access_token` securely in your database. You will use it to create link tokens for authenticated users (Option B above).
485
539
 
486
540
  ```javascript
487
541
  // Example: Node.js/Express
@@ -493,11 +547,11 @@ app.post("/api/kryptos/exchange-token", async (req, res) => {
493
547
  method: "POST",
494
548
  headers: {
495
549
  "Content-Type": "application/json",
550
+ "X-Client-Id": YOUR_CLIENT_ID,
551
+ "X-Client-Secret": YOUR_CLIENT_SECRET,
496
552
  },
497
553
  body: JSON.stringify({
498
554
  public_token,
499
- client_id: YOUR_CLIENT_ID,
500
- client_secret: YOUR_CLIENT_SECRET,
501
555
  }),
502
556
  });
503
557
 
@@ -505,9 +559,9 @@ app.post("/api/kryptos/exchange-token", async (req, res) => {
505
559
 
506
560
  // IMPORTANT: Store the access_token securely in your database
507
561
  // You'll need this token to:
508
- // 1. Create authenticated link tokens (skip login flow)
562
+ // 1. Create authenticated link tokens (Option B)
509
563
  // 2. Make API calls on behalf of the user
510
- await saveUserAccessToken(req.user.id, data.data.access_token);
564
+ await saveUserAccessToken(req.user.id, data.access_token);
511
565
 
512
566
  res.json({ success: true });
513
567
  } catch (error) {
@@ -516,29 +570,26 @@ app.post("/api/kryptos/exchange-token", async (req, res) => {
516
570
  });
517
571
  ```
518
572
 
519
- **Complete Integration Flow:**
573
+ **Complete integration flow:**
520
574
 
521
- 1. **First Connection** (New User - `isAuthorized: false`):
575
+ 1. **First connection** (new user `isAuthorized: false`):
522
576
 
523
577
  ```
524
578
  App → generateLinkToken() [returns { link_token, isAuthorized: false }]
525
- → SDK Flow: INIT → AUTHOTP → INTEGRATION → PERMISSIONS → STATUS
526
- → User logs in with email/OTP (or as guest)
527
- User connects integrations
528
- → User grants permissions
529
- → onSuccess receives { public_token: "..." }
579
+ → SDK: INIT → Connect → INTEGRATION → STATUS
580
+ → User selects and connects integrations
581
+ onSuccess receives { public_token }
530
582
  → Backend exchanges public_token for access_token
531
583
  → Store access_token in database ← IMPORTANT
532
584
  ```
533
585
 
534
- 2. **Subsequent Connections** (Returning User - `isAuthorized: true`):
586
+ 2. **Subsequent connections** (returning user `isAuthorized: true`):
535
587
  ```
536
588
  App → generateLinkToken() [returns { link_token, isAuthorized: true }]
537
- → SDK Flow: INIT → INTEGRATION → STATUS (skip AUTH, OTP)
538
- → User directly sees integrations (no login)
539
- User connects more integrations
540
- onSuccess receives null (no new token needed)
541
- → Integrations are added to user's existing account
589
+ → SDK: INIT → INTEGRATION → STATUS
590
+ → User sees integrations directly → connects more
591
+ onSuccess receives null
592
+ Integrations added to existing account
542
593
  ```
543
594
 
544
595
  ## Supported Platforms
@@ -558,12 +609,17 @@ app.post("/api/kryptos/exchange-token", async (req, res) => {
558
609
  }
559
610
  ```
560
611
 
612
+ ## Support
613
+
614
+ - 📧 Email: [support@kryptos.io](mailto:support@kryptos.io)
615
+ - 📚 Documentation: [https://docs.kryptos.io](https://docs.kryptos.io)
616
+ - 💬 Discord: [Join our community](https://discord.gg/kryptos)
617
+ - 🐛 Issues: [GitHub Issues](https://github.com/kryptos/connect-npm-package/issues)
618
+
561
619
  ## License
562
620
 
563
- MIT © Kryptos
621
+ MIT © [Kryptos](https://kryptos.io)
564
622
 
565
- ## Support
623
+ ---
566
624
 
567
- - 📧 Email: support@kryptos.io
568
- - 📚 Documentation: https://dashboard.kryptos.io
569
- - 🐛 Issues: https://github.com/Kryptoskatt/kryptos-connect-mobile-package/issues
625
+ Made with ❤️ by the Kryptos team
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import React, { ReactNode } from 'react';
2
- import { ImageSourcePropType, ViewStyle, TextStyle } from 'react-native';
2
+ import { ImageSourcePropType } from 'react-native';
3
3
 
4
4
  type KryptosConfig = {
5
5
  appName: string;
@@ -28,18 +28,20 @@ type KryptosUser = {
28
28
  type UserConsent = {
29
29
  public_token: string;
30
30
  };
31
-
32
31
  interface KryptosConnectButtonProps {
33
32
  onSuccess?: (userConsent: UserConsent | null) => void;
34
- onError?: (error?: any) => void;
33
+ onError?: () => void;
35
34
  generateLinkToken: () => Promise<{
36
35
  link_token: string;
37
36
  isAuthorized?: boolean;
38
37
  }>;
39
- children?: React.ReactNode;
40
- style?: ViewStyle;
41
- textStyle?: TextStyle;
38
+ children?: ReactNode;
39
+ style?: object;
40
+ buttonStyle?: object;
41
+ integrationName?: string;
42
+ textStyle?: object;
42
43
  }
44
+
43
45
  declare const KryptosConnectButton: React.FC<KryptosConnectButtonProps>;
44
46
  interface KryptosConnectModalProps {
45
47
  open: boolean;
@@ -50,6 +52,7 @@ interface KryptosConnectModalProps {
50
52
  link_token: string;
51
53
  isAuthorized?: boolean;
52
54
  }>;
55
+ integrationName?: string;
53
56
  }
54
57
  declare const KryptosConnectModal: React.FC<KryptosConnectModalProps>;
55
58
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import React, { ReactNode } from 'react';
2
- import { ImageSourcePropType, ViewStyle, TextStyle } from 'react-native';
2
+ import { ImageSourcePropType } from 'react-native';
3
3
 
4
4
  type KryptosConfig = {
5
5
  appName: string;
@@ -28,18 +28,20 @@ type KryptosUser = {
28
28
  type UserConsent = {
29
29
  public_token: string;
30
30
  };
31
-
32
31
  interface KryptosConnectButtonProps {
33
32
  onSuccess?: (userConsent: UserConsent | null) => void;
34
- onError?: (error?: any) => void;
33
+ onError?: () => void;
35
34
  generateLinkToken: () => Promise<{
36
35
  link_token: string;
37
36
  isAuthorized?: boolean;
38
37
  }>;
39
- children?: React.ReactNode;
40
- style?: ViewStyle;
41
- textStyle?: TextStyle;
38
+ children?: ReactNode;
39
+ style?: object;
40
+ buttonStyle?: object;
41
+ integrationName?: string;
42
+ textStyle?: object;
42
43
  }
44
+
43
45
  declare const KryptosConnectButton: React.FC<KryptosConnectButtonProps>;
44
46
  interface KryptosConnectModalProps {
45
47
  open: boolean;
@@ -50,6 +52,7 @@ interface KryptosConnectModalProps {
50
52
  link_token: string;
51
53
  isAuthorized?: boolean;
52
54
  }>;
55
+ integrationName?: string;
53
56
  }
54
57
  declare const KryptosConnectModal: React.FC<KryptosConnectModalProps>;
55
58