@bounded-sh/client 0.0.26 → 0.0.27

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.
Files changed (34) hide show
  1. package/REACT_NATIVE.md +144 -0
  2. package/README.md +24 -18
  3. package/dist/auth/index.d.ts +18 -21
  4. package/dist/auth/providers/email-auth-provider.d.ts +8 -19
  5. package/dist/auth/providers/privy-expo-provider.d.ts +1 -1
  6. package/dist/global.d.ts +2 -2
  7. package/dist/index.d.ts +0 -3
  8. package/dist/index.js +84 -4617
  9. package/dist/index.js.map +1 -1
  10. package/dist/index.mjs +94 -4621
  11. package/dist/index.mjs.map +1 -1
  12. package/dist/index.native.d.ts +2 -2
  13. package/dist/index.native.js +5184 -78
  14. package/dist/index.native.js.map +1 -1
  15. package/dist/index.native.mjs +5095 -4
  16. package/dist/index.native.mjs.map +1 -1
  17. package/dist/platform.d.ts +1 -1
  18. package/package.json +7 -3
  19. package/dist/index.native-BfAzgVuY.js +0 -5802
  20. package/dist/index.native-BfAzgVuY.js.map +0 -1
  21. package/dist/index.native-DEWlFCQV.mjs +0 -5742
  22. package/dist/index.native-DEWlFCQV.mjs.map +0 -1
  23. package/dist/phantom-wallet-provider-3xKduOOY.js +0 -1452
  24. package/dist/phantom-wallet-provider-3xKduOOY.js.map +0 -1
  25. package/dist/phantom-wallet-provider-B3ztJGu2.mjs +0 -1431
  26. package/dist/phantom-wallet-provider-B3ztJGu2.mjs.map +0 -1
  27. package/dist/privy-wallet-provider-3LnqlNI-.js +0 -949
  28. package/dist/privy-wallet-provider-3LnqlNI-.js.map +0 -1
  29. package/dist/privy-wallet-provider-D2i_xwYW.mjs +0 -926
  30. package/dist/privy-wallet-provider-D2i_xwYW.mjs.map +0 -1
  31. package/dist/solana-mobile-wallet-provider-D2nTRj-4.js +0 -1492
  32. package/dist/solana-mobile-wallet-provider-D2nTRj-4.js.map +0 -1
  33. package/dist/solana-mobile-wallet-provider-dOWiujmo.mjs +0 -1471
  34. package/dist/solana-mobile-wallet-provider-dOWiujmo.mjs.map +0 -1
@@ -0,0 +1,144 @@
1
+ # React Native / Expo support - `@bounded-sh/client`
2
+
3
+ The SDK ships a dedicated React Native entry (`react-native` condition ->
4
+ `dist/index.native.js`) and a platform-abstraction layer so the same
5
+ `@bounded-sh/client` package runs on web and React Native.
6
+
7
+ ## 1. One-time setup before `init()`
8
+
9
+ React Native has no `localStorage`, no `document`, and no reliable browser
10
+ base64 helpers, so configure the SDK platform once at app startup:
11
+
12
+ ```ts
13
+ import "react-native-get-random-values";
14
+ import "react-native-url-polyfill/auto";
15
+ import { setPlatform, ReactNativeSessionManager } from "@bounded-sh/client";
16
+ import { createMMKV } from "react-native-mmkv";
17
+ import { decode as atob, encode as btoa } from "base-64";
18
+
19
+ const store = createMMKV();
20
+ const storage = {
21
+ getItem: (key: string) => store.getString(key) ?? null,
22
+ setItem: (key: string, value: string) => store.set(key, value),
23
+ removeItem: (key: string) => store.remove(key),
24
+ };
25
+
26
+ setPlatform({ storage, sessionStorage: storage, atob, btoa, hasDOM: false });
27
+ ReactNativeSessionManager.configure({ storage, atob });
28
+ ```
29
+
30
+ `setPlatform` fills general browser API gaps. `ReactNativeSessionManager.configure`
31
+ selects the RN token store used by login, restore, logout, and authenticated
32
+ requests.
33
+
34
+ ## 2. Hosted email / social login
35
+
36
+ Human login runs through the hosted Bounded issuer. The retired app-origin OTP
37
+ helpers (`sendEmailOtp`, `verifyEmailOtp`, `sendTextOtp`, `verifyTextOtp`) throw
38
+ migration errors.
39
+
40
+ Install the Expo optional peers if your RN app uses hosted login:
41
+
42
+ ```sh
43
+ npx expo install expo-web-browser expo-crypto
44
+ ```
45
+
46
+ Use an https universal link as your redirect URI and register that origin in the
47
+ Bounded app's `allowedOrigins`:
48
+
49
+ ```ts
50
+ import { init, loginWithRedirect, getCurrentUser } from "@bounded-sh/client";
51
+
52
+ await init({ appId: "YOUR_APP_ID" });
53
+
54
+ const user = await loginWithRedirect({
55
+ redirectUri: "https://yourapp.com/auth/callback",
56
+ methods: ["email"],
57
+ });
58
+
59
+ const restored = await getCurrentUser();
60
+ ```
61
+
62
+ On native, `loginWithRedirect()` opens the system/in-app browser and resolves
63
+ with the user when the callback returns to the app. `completeLoginFromRedirect()`
64
+ is for web callback pages.
65
+
66
+ ## 3. Guest login
67
+
68
+ Anonymous auth is fully native and does not require Expo browser packages:
69
+
70
+ ```ts
71
+ import { init, signInAnonymously, getCurrentUser } from "@bounded-sh/client";
72
+
73
+ await init({ appId: "YOUR_APP_ID" });
74
+ await signInAnonymously();
75
+ const user = await getCurrentUser();
76
+ ```
77
+
78
+ The device-local ed25519 keypair is stored in the RN storage adapter, so the
79
+ guest identity survives app restarts until `logout()` clears it.
80
+
81
+ ## 4. Privy on React Native (`privy-expo`)
82
+
83
+ `@privy-io/expo` is hook-based, so the host app renders `<PrivyProvider>` and
84
+ bridges the hooks into a `PrivyExpoProvider` instance.
85
+
86
+ ```bash
87
+ npm i @privy-io/expo @privy-io/expo-native-extensions
88
+ ```
89
+
90
+ ```tsx
91
+ import { PrivyProvider, usePrivy, useEmbeddedSolanaWallet, useIdentityToken } from "@privy-io/expo";
92
+ import { PrivyExpoProvider, init, loginWithPrivy } from "@bounded-sh/client";
93
+
94
+ const provider = new PrivyExpoProvider(PRIVY_APP_ID, SOLANA_RPC_URL);
95
+
96
+ function PrivyBridge() {
97
+ const privy = usePrivy();
98
+ const wallet = useEmbeddedSolanaWallet();
99
+ const { getIdentityToken } = useIdentityToken();
100
+
101
+ useEffect(() => {
102
+ provider.setPrivyMethods({
103
+ isReady: privy.isReady,
104
+ isAuthenticated: !!privy.user,
105
+ user: privy.user,
106
+ login: privy.login,
107
+ logout: privy.logout,
108
+ getAccessToken: privy.getAccessToken,
109
+ getIdentityToken,
110
+ getWalletProvider: async () => {
111
+ const solanaWallet = wallet.wallets?.[0];
112
+ if (!solanaWallet) return null;
113
+ const solanaProvider = await solanaWallet.getProvider();
114
+ return {
115
+ address: solanaWallet.address,
116
+ signMessage: solanaProvider.signMessage,
117
+ signTransaction: solanaProvider.signTransaction,
118
+ signAndSendTransaction: solanaProvider.signAndSendTransaction,
119
+ };
120
+ },
121
+ });
122
+ }, [privy.isReady, privy.user, wallet.wallets]);
123
+
124
+ return null;
125
+ }
126
+
127
+ await init({
128
+ appId,
129
+ authMethod: "privy-expo",
130
+ privyExpoProvider: provider,
131
+ rpcUrl: SOLANA_RPC_URL,
132
+ });
133
+
134
+ await loginWithPrivy();
135
+ ```
136
+
137
+ ## 5. Metro notes
138
+
139
+ The default client entry no longer imports Phantom, web Privy, mobile wallet
140
+ adapter, or `react-dom` provider implementations. Apps that only use hosted login
141
+ or guest login should not need Metro stubs for those optional peers.
142
+
143
+ For Solana signing paths, keep `react-native-get-random-values` at app entry and
144
+ make sure `buffer` is polyfilled if your bundler setup does not provide it.
package/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
 
2
- # Tarobase JS SDK
3
- Tarobase is the web3 alternative to firebase. It is a powerful platform that simplifies the integration of hybrid on-chain actions and data for modern web and mobile applications.
2
+ # Bounded JS SDK
3
+ Bounded is a provable realtime backend for web and React Native applications.
4
4
 
5
- Welcome to the **Tarobase JavaScript SDK**! This SDK allows you to interact with the Tarobase platform seamlessly from your JavaScript or TypeScript applications. Whether you're building a web app, a Node.js service, or a React Native application (support coming soon), the Tarobase JS SDK provides the tools you need.
5
+ Welcome to the **Bounded JavaScript SDK**. This SDK lets JavaScript and
6
+ TypeScript applications authenticate users, read and write policy-governed data,
7
+ subscribe to realtime updates, and call Bounded services.
6
8
 
7
9
 
8
10
  ## Table of Contents
@@ -66,28 +68,26 @@ yarn add @bounded-sh/client
66
68
 
67
69
 
68
70
 
69
- Before using the SDK, initialize it with your **Application ID** and the one auth method this app intends to use. Missing `authMethod` fails closed so examples do not silently select the wrong identity path. Use `authMethod: 'email'` for Bounded Auth email OTP, `authMethod: 'phantom'` for Solana wallet auth, or `authMethod: 'none'` for public unauthenticated reads only.
71
+ Before using the SDK, initialize it with your **Application ID**. Hosted Bounded
72
+ Auth email login is the default human-login provider.
70
73
 
71
74
 
72
75
  ```typescript
73
76
  import { init } from '@bounded-sh/client';
74
77
 
75
- await init({ appId: 'YOUR_APP_ID', authMethod: 'email' });
78
+ await init({ appId: 'YOUR_APP_ID' });
76
79
  ```
77
80
 
78
81
  ### Authentication
79
82
 
80
- For email OTP, initialize with `authMethod: 'email'` and call `login()` for the
81
- inline email-code modal. OAuth/social providers use the hosted redirect or popup
82
- helpers, which bind the returned token to the app id and registered redirect URI.
83
+ Human login runs through the hosted redirect or popup helpers, which bind the
84
+ returned token to the app id and registered redirect URI. Inline app-origin OTP
85
+ helpers are retired.
83
86
 
84
87
  ```typescript
85
- import { login, loginWithRedirect, completeLoginFromRedirect } from '@bounded-sh/client';
88
+ import { loginWithRedirect, completeLoginFromRedirect } from '@bounded-sh/client';
86
89
 
87
- // Email OTP:
88
- await login();
89
-
90
- // Hosted OAuth/social or hosted chooser:
90
+ // Start hosted login:
91
91
  await loginWithRedirect({ redirectUri: 'https://yourapp.com/auth/callback', methods: ['email'] });
92
92
 
93
93
  // On your callback page, on load:
@@ -99,13 +99,16 @@ You can also listen for authentication state changes:
99
99
  ```typescript
100
100
  import { onAuthStateChanged } from '@bounded-sh/client';
101
101
 
102
- onAuthStateChanged((user) => {
102
+ const unsubscribe = onAuthStateChanged((user) => {
103
103
  if (user) {
104
104
  console.log('User logged in:', user.address);
105
105
  } else {
106
106
  console.log('User logged out');
107
107
  }
108
108
  });
109
+
110
+ // Later:
111
+ unsubscribe();
109
112
  ```
110
113
 
111
114
 
@@ -291,16 +294,19 @@ For more comprehensive examples, detailed guides, and API references, please vis
291
294
  - [API Reference](https://docs.tarobase.com/api)
292
295
 
293
296
 
294
- ### React Native Support
295
- Support for **React Native** is coming soon! Stay tuned for updates, and feel free to check back on our [documentation site](https://docs.tarobase.com) for the latest information.
297
+ ### React Native Support
298
+ React Native and Expo are supported through the same `@bounded-sh/client`
299
+ package. See [REACT_NATIVE.md](./REACT_NATIVE.md) for platform setup, hosted
300
+ login, and guest login examples.
296
301
 
297
302
  ### Contributing
298
303
  Contributions are welcome! Please open an issue or submit a pull request on GitHub.
299
304
 
300
305
  ### License
301
- This Tarobase JS SDK project is licensed under the MIT License.
306
+ This Bounded JS SDK project is licensed under the MIT License.
302
307
 
303
308
  * * * * *
304
309
 
305
310
 
306
- Thank you for using the Tarobase JS SDK! If you have any questions or need further assistance, feel free to crete an issue.
311
+ Thank you for using the Bounded JS SDK. If you have questions or need help,
312
+ please create an issue.
@@ -31,11 +31,11 @@ export declare function signInAnonymously(): Promise<User | null>;
31
31
  * Log in with Privy as a co-equal route — selectable at runtime alongside
32
32
  * `login()` (email/wallet) and `signInAnonymously()`, without re-`init()`.
33
33
  *
34
- * On WEB it lazy-loads the @privy-io/react-auth-backed PrivyWalletProvider from
35
- * `config.privyConfig`. On REACT NATIVE the host must have created a
36
- * PrivyExpoProvider and bridged the Privy hooks via setPrivyMethods() (pass it as
37
- * `config.privyExpoProvider` to init()) — RN can't construct it here because the
38
- * Privy hooks live in the app's component tree.
34
+ * On REACT NATIVE the host must have created a PrivyExpoProvider and bridged the
35
+ * Privy hooks via setPrivyMethods() (pass it as `config.privyExpoProvider` to
36
+ * init()) — RN can't construct it here because the Privy hooks live in the app's
37
+ * component tree. Web Privy is no longer loaded through the default client entry;
38
+ * opt into a dedicated provider entry when your app needs it.
39
39
  *
40
40
  * Either way the Privy Solana wallet signs the SIWS challenge, so the session is
41
41
  * minted via the same wallet path as Phantom and shares the unified session store
@@ -43,40 +43,37 @@ export declare function signInAnonymously(): Promise<User | null>;
43
43
  */
44
44
  export declare function loginWithPrivy(options?: LoginOptions): Promise<User | null>;
45
45
  /**
46
- * Send a 6-digit login code to `email` (Bounded Better Auth). Step 1 of the
47
- * inline email flow — build your own email/code UI, or just call `login()` for
48
- * the built-in modal. Works on web AND React Native (no DOM needed).
46
+ * @deprecated Inline app-origin OTP is retired. Use
47
+ * `loginWithRedirect({ redirectUri, methods: ["email"] })` so the credential is
48
+ * entered on the Bounded hosted issuer.
49
49
  */
50
50
  export declare function sendEmailOtp(email: string): Promise<{
51
51
  ok: true;
52
52
  expiresInSeconds?: number;
53
53
  }>;
54
54
  /**
55
- * Send a 6-digit login code by text message. Requires the configured Bounded
56
- * auth issuer to have text OTP explicitly enabled and SMS delivery configured.
57
- * Works on web AND React Native.
55
+ * @deprecated Inline app-origin text OTP is retired. Use hosted login with
56
+ * `provider: "text"` or `methods: ["text"]` when text OTP is enabled.
58
57
  */
59
58
  export declare function sendTextOtp(phoneNumber: string): Promise<{
60
59
  ok: true;
61
60
  expiresInSeconds?: number;
62
61
  }>;
63
62
  /**
64
- * Verify the `code` for `email`, establish the session, and return the user.
65
- * Step 2 of the inline email flow. Coexists with signInAnonymously()/wallets.
63
+ * @deprecated Inline app-origin OTP is retired. Finish hosted login with
64
+ * `completeLoginFromRedirect()` on web; React Native `loginWithRedirect()`
65
+ * resolves inline.
66
66
  */
67
67
  export declare function verifyEmailOtp(email: string, code: string): Promise<User | null>;
68
68
  /**
69
- * Verify the text-message `code`, establish the session, and return the user.
70
- * Phone-only users have no `user.email`; use `user.id` for app identity.
69
+ * @deprecated Inline app-origin text OTP is retired. Finish hosted login with
70
+ * `completeLoginFromRedirect()` on web; React Native `loginWithRedirect()`
71
+ * resolves inline.
71
72
  */
72
73
  export declare function verifyTextOtp(phoneNumber: string, code: string): Promise<User | null>;
73
74
  /**
74
- * UPGRADE the current anonymous (guest) session by linking an email — Firebase
75
- * `linkWithCredential` parity. Send the code first with `sendEmailOtp(email)`,
76
- * then call `linkEmail(email, code)`. If the email is brand-new the guest's
77
- * `@user.id` (and its data) is preserved; if the email already exists the user
78
- * just signs into it (no merge). After it resolves, `getCurrentUser().isAnonymous`
79
- * is `false`. Requires an active guest session (`signInAnonymously()` first).
75
+ * @deprecated Inline app-origin guest upgrade is retired. Send the user through
76
+ * hosted login and transfer guest-owned data explicitly.
80
77
  */
81
78
  export declare function linkEmail(email: string, code: string): Promise<User | null>;
82
79
  export declare function login(options?: LoginOptions): Promise<User | null>;
@@ -1,33 +1,22 @@
1
1
  import type { AuthProvider, User, TransactionResult, SolTransaction, EVMTransaction, SetOptions } from '@bounded-sh/core';
2
- import { Transaction, VersionedTransaction } from '@solana/web3.js';
3
- /** Send a login code to `email`. Step 1 of the inline email-OTP flow. */
2
+ import type { Transaction, VersionedTransaction } from '@solana/web3.js';
3
+ /** @deprecated Inline app-origin OTP is retired. Use loginWithRedirect(). */
4
4
  export declare function sendEmailOtp(email: string): Promise<{
5
5
  ok: true;
6
6
  expiresInSeconds?: number;
7
7
  }>;
8
- /** Send a login code by text message. Requires the Bounded issuer to have text OTP explicitly enabled and SMS configured. */
8
+ /** @deprecated Inline app-origin text OTP is retired. Use loginWithRedirect(). */
9
9
  export declare function sendTextOtp(phoneNumber: string): Promise<{
10
10
  ok: true;
11
11
  expiresInSeconds?: number;
12
12
  }>;
13
- /**
14
- * Verify the code for `email` and establish the session. Step 2 of the flow.
15
- * Stores the Bounded id token (the realtime bearer) and sets the current user.
16
- */
13
+ /** @deprecated Inline app-origin OTP is retired. Use hosted loginWithRedirect(). */
17
14
  export declare function verifyEmailOtp(email: string, otp: string): Promise<User>;
18
- /**
19
- * Verify the text-message code for `phoneNumber` and establish the session.
20
- * Phone-only users have `user.email === null`; use `user.id` for ownership.
21
- */
15
+ /** @deprecated Inline app-origin text OTP is retired. Use hosted loginWithRedirect(). */
22
16
  export declare function verifyTextOtp(phoneNumber: string, otp: string): Promise<User>;
23
17
  /**
24
- * UPGRADE an anonymous (guest) session by LINKING an email credential — Firebase
25
- * `linkWithCredential` parity. The guest's `guestToken` is sent to the auth issuer
26
- * which, IF the email is brand-new, makes the new account ADOPT the guest's id so
27
- * `@user.id` is preserved and the guest's data carries over. If the email already
28
- * exists, the user just signs into it (stays separate; `linked:false`). On success
29
- * the upgraded session replaces the guest session and the user is no longer
30
- * anonymous. `guestToken` is captured by the caller BEFORE switching auth methods.
18
+ * @deprecated Inline app-origin guest upgrade is retired. Use hosted login and
19
+ * transfer guest-owned data explicitly.
31
20
  */
32
21
  export declare function linkEmailWithGuest(email: string, otp: string, guestToken: string): Promise<{
33
22
  user: User;
@@ -40,7 +29,7 @@ export declare class EmailAuthProvider implements AuthProvider {
40
29
  logout(): Promise<void>;
41
30
  signMessage(_message: string): Promise<string>;
42
31
  runTransaction(_evm?: EVMTransaction, _sol?: SolTransaction, _options?: SetOptions): Promise<TransactionResult>;
43
- signTransaction(_t: Transaction | VersionedTransaction): Promise<Transaction | VersionedTransaction>;
32
+ signTransaction(_transaction: Transaction | VersionedTransaction): Promise<Transaction | VersionedTransaction>;
44
33
  signAndSubmitTransaction(): Promise<string>;
45
34
  getNativeMethods(): Promise<any>;
46
35
  }
@@ -10,7 +10,7 @@
10
10
  * 1. Install polyfills: fast-text-encoding, react-native-get-random-values
11
11
  * 2. Install @privy-io/expo, @privy-io/expo-native-extensions
12
12
  * 3. Call ReactNativeSessionManager.configure({ storage, atob }) at startup
13
- * 4. Call setPlatform({ ... }) from @bounded-sh/web at startup
13
+ * 4. Call setPlatform({ ... }) from @bounded-sh/client at startup
14
14
  * 5. Wrap their app tree with PrivyProvider from @privy-io/expo
15
15
  * 6. Create this provider and pass the Privy hooks/methods via setPrivyMethods()
16
16
  *
package/dist/global.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { AuthProvider, User, ClientConfig } from '@bounded-sh/core';
2
2
  import { LoginOptions } from './auth';
3
3
  export declare function init(newConfig: Partial<ClientConfig>): Promise<void>;
4
- export declare function onAuthStateChanged(callback: (user: User | null) => void): void;
5
- export declare function onAuthLoadingChanged(callback: (loading: boolean) => void): void;
4
+ export declare function onAuthStateChanged(callback: (user: User | null) => void): () => void;
5
+ export declare function onAuthLoadingChanged(callback: (loading: boolean) => void): () => void;
6
6
  export declare function setAuthLoading(loading: boolean): void;
7
7
  export declare function getAuthLoading(): boolean;
8
8
  export declare function login(options?: LoginOptions): Promise<User | null>;
package/dist/index.d.ts CHANGED
@@ -15,9 +15,6 @@ export { deserializeTransaction } from "./auth/providers/sol/sol-utils";
15
15
  export { getIdToken } from "./utils";
16
16
  export { setPlatform, getPlatform } from "./platform";
17
17
  export type { PlatformAdapter, StorageAdapter } from "./platform";
18
- export { PhantomWalletProvider, PhantomWalletConfig, PhantomProviderType, } from "./auth/providers/phantom-wallet-provider";
19
18
  export { OffchainAuthProvider, OffchainAuthProviderConfig, } from "./auth/providers/offchain-auth-provider";
20
- export { SolanaMobileWalletProvider, SolanaMobileWalletConfig, isMobileWalletAvailable, registerMobileWalletAdapter, } from "./auth/providers/solana-mobile-wallet-provider";
21
- export { PrivyWalletProvider } from "./auth/providers/privy-wallet-provider";
22
19
  export { PrivyExpoProvider } from "./auth/providers/privy-expo-provider";
23
20
  export type { PrivyExpoMethods } from "./auth/providers/privy-expo-provider";