@bounded-sh/client 0.0.19 → 0.0.20

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 (30) hide show
  1. package/dist/auth/providers/offchain-auth-provider.d.ts +2 -4
  2. package/dist/index.d.ts +0 -1
  3. package/dist/index.js +2 -181
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +3 -180
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/{index.native-DI_Xgv-n.js → index.native-BtM38BVP.js} +6 -185
  8. package/dist/index.native-BtM38BVP.js.map +1 -0
  9. package/dist/{index.native-DWI_i6-6.mjs → index.native-w12aoVNW.mjs} +7 -184
  10. package/dist/index.native-w12aoVNW.mjs.map +1 -0
  11. package/dist/index.native.d.ts +0 -1
  12. package/dist/index.native.js +1 -3
  13. package/dist/index.native.js.map +1 -1
  14. package/dist/index.native.mjs +1 -1
  15. package/dist/{phantom-wallet-provider-fyOrJZP6.js → phantom-wallet-provider-BJWelaiH.js} +2 -2
  16. package/dist/{phantom-wallet-provider-fyOrJZP6.js.map → phantom-wallet-provider-BJWelaiH.js.map} +1 -1
  17. package/dist/{phantom-wallet-provider-DDwgNMg_.mjs → phantom-wallet-provider-BT2V4EU5.mjs} +2 -2
  18. package/dist/{phantom-wallet-provider-DDwgNMg_.mjs.map → phantom-wallet-provider-BT2V4EU5.mjs.map} +1 -1
  19. package/dist/{privy-wallet-provider-BIr9lDS7.js → privy-wallet-provider-BSh0aZVL.js} +3 -3
  20. package/dist/{privy-wallet-provider-BIr9lDS7.js.map → privy-wallet-provider-BSh0aZVL.js.map} +1 -1
  21. package/dist/{privy-wallet-provider-D7VoQCYf.mjs → privy-wallet-provider-LV1X7hZe.mjs} +3 -3
  22. package/dist/{privy-wallet-provider-D7VoQCYf.mjs.map → privy-wallet-provider-LV1X7hZe.mjs.map} +1 -1
  23. package/dist/{solana-mobile-wallet-provider-Cush-URL.js → solana-mobile-wallet-provider-CKsfiyDd.js} +2 -2
  24. package/dist/{solana-mobile-wallet-provider-Cush-URL.js.map → solana-mobile-wallet-provider-CKsfiyDd.js.map} +1 -1
  25. package/dist/{solana-mobile-wallet-provider-DgcGxDoL.mjs → solana-mobile-wallet-provider-NLe9_mEn.mjs} +2 -2
  26. package/dist/{solana-mobile-wallet-provider-DgcGxDoL.mjs.map → solana-mobile-wallet-provider-NLe9_mEn.mjs.map} +1 -1
  27. package/package.json +2 -2
  28. package/dist/auth/providers/mock-auth-provider.d.ts +0 -49
  29. package/dist/index.native-DI_Xgv-n.js.map +0 -1
  30. package/dist/index.native-DWI_i6-6.mjs.map +0 -1
package/dist/index.mjs CHANGED
@@ -159,142 +159,11 @@ function detectAndroid() {
159
159
  return false;
160
160
  }
161
161
 
162
- // Default test wallet address (Solana devnet address)
163
- const DEFAULT_TEST_ADDRESS = 'HKbZbRR7jWWR5VRN8KFjvTCHEzJQgameYxKQxh2gPoof';
164
- // Session storage key to track if user explicitly called login()
165
- const EXPLICIT_LOGIN_KEY = 'mock-auth-explicit-login';
166
- /**
167
- * MockAuthProvider bypasses real wallet authentication for testing purposes.
168
- * Uses session storage to simulate logged-in user, with fallback to default test address.
169
- *
170
- * This is enabled by passing mockAuth: true to init()
171
- */
172
- class MockAuthProvider {
173
- /**
174
- * Mock login - reads user from session storage or uses default test address
175
- */
176
- async login() {
177
- let address = getPlatform().sessionStorage.getItem('test-user-address');
178
- if (!address) {
179
- address = DEFAULT_TEST_ADDRESS;
180
- // Store default address in session storage so it gets used in API calls
181
- getPlatform().sessionStorage.setItem('test-user-address', DEFAULT_TEST_ADDRESS);
182
- console.log('[MockAuth] Using default test address:', address);
183
- }
184
- // Mark that user explicitly called login() - allows restoreSession on refresh
185
- getPlatform().sessionStorage.setItem(EXPLICIT_LOGIN_KEY, 'true');
186
- console.log('[MockAuth] Mock login successful:', address);
187
- return {
188
- address,
189
- provider: this
190
- };
191
- }
192
- /**
193
- * Mock transaction - returns fake signature without actual blockchain interaction
194
- * The real transaction will be handled by the backend using test headers
195
- */
196
- async runTransaction(evmTransactionData, solTransactionData, options) {
197
- const address = getPlatform().sessionStorage.getItem('test-user-address') || DEFAULT_TEST_ADDRESS;
198
- // Generate a fake transaction signature
199
- const fakeSignature = `mock_tx_${Math.random().toString(36).substring(2, 15)}`;
200
- console.log('[MockAuth] Mock transaction executed:', {
201
- address,
202
- signature: fakeSignature,
203
- evmTx: evmTransactionData,
204
- solTx: solTransactionData
205
- });
206
- return {
207
- transactionSignature: fakeSignature,
208
- signedTransaction: fakeSignature,
209
- blockNumber: 0,
210
- gasUsed: '0'
211
- };
212
- }
213
- /**
214
- * Mock message signing
215
- */
216
- async signMessage(message) {
217
- const address = getPlatform().sessionStorage.getItem('test-user-address') || DEFAULT_TEST_ADDRESS;
218
- // Generate a fake signature
219
- const fakeSignature = `mock_sig_${Math.random().toString(36).substring(2, 15)}`;
220
- console.log('[MockAuth] Mock message signed:', {
221
- address,
222
- message,
223
- signature: fakeSignature
224
- });
225
- return fakeSignature;
226
- }
227
- async signMessageMock(message) {
228
- const address = getPlatform().sessionStorage.getItem('test-user-address') || DEFAULT_TEST_ADDRESS;
229
- const signature = `mock_sig_${Math.random().toString(36).substring(2, 15)}`;
230
- console.log('[MockAuth] Mock message signed:', {
231
- address,
232
- message,
233
- signature
234
- });
235
- return signature;
236
- }
237
- /**
238
- * Mock transaction signing - returns the transaction as-is (no actual signing)
239
- */
240
- async signTransaction(transaction) {
241
- console.log('[MockAuth] Mock transaction signing (no-op)');
242
- return transaction;
243
- }
244
- /**
245
- * Sign and submit transaction - not supported in mock environment.
246
- * See the real providers (PhantomWalletProvider, SolanaKeypairProvider)
247
- * for the full implementation with blockhash handling and feePayer support.
248
- */
249
- async signAndSubmitTransaction(_transaction, _feePayer) {
250
- throw new Error('signAndSubmitTransaction is not supported in the mock environment');
251
- }
252
- /**
253
- * Restore session - only restores if user previously called login() explicitly.
254
- * This prevents auto-login on first page load, but allows session persistence after login.
255
- */
256
- async restoreSession() {
257
- const explicitlyLoggedIn = getPlatform().sessionStorage.getItem(EXPLICIT_LOGIN_KEY);
258
- if (!explicitlyLoggedIn) {
259
- console.log('[MockAuth] No explicit login found. Call login() to authenticate.');
260
- return null;
261
- }
262
- const address = getPlatform().sessionStorage.getItem('test-user-address');
263
- if (!address) {
264
- console.log('[MockAuth] No previous session found');
265
- return null;
266
- }
267
- console.log('[MockAuth] Session restored:', address);
268
- return {
269
- address,
270
- provider: this
271
- };
272
- }
273
- /**
274
- * Mock logout - clears test user from session storage
275
- */
276
- async logout() {
277
- getPlatform().sessionStorage.removeItem('test-user-address');
278
- getPlatform().sessionStorage.removeItem('test-user-id');
279
- getPlatform().sessionStorage.removeItem(EXPLICIT_LOGIN_KEY);
280
- console.log('[MockAuth] Mock logout successful');
281
- }
282
- /**
283
- * Get native wallet methods (not needed for mock auth)
284
- */
285
- async getNativeMethods() {
286
- return {
287
- // Return empty object - no native methods needed for mock auth
288
- };
289
- }
290
- }
291
-
292
162
  /**
293
163
  * OffchainAuthProvider wraps a real auth provider (e.g., Phantom) for the poofnet environment.
294
164
  *
295
- * For signMessageMock, this shows a custom confirmation modal and then delegates
296
- * to the wrapped provider for a real detached signature over the exact offchain
297
- * transaction message.
165
+ * signMessage shows a custom confirmation modal and then delegates to the wrapped
166
+ * provider for a real detached signature over the exact offchain transaction message.
298
167
  */
299
168
  class OffchainAuthProvider {
300
169
  constructor(wrappedProvider, config = {}) {
@@ -345,13 +214,7 @@ class OffchainAuthProvider {
345
214
  }
346
215
  // ============ signMessage delegates to wrapped provider ============
347
216
  async signMessage(message) {
348
- // Delegate to wrapped provider for real wallet signing
349
- return this.wrappedProvider.signMessage(message);
350
- }
351
- // ============ Mock signMessage with Custom Modal for Offchain Transactions ============
352
- async signMessageMock(message) {
353
217
  var _a, _b, _c, _d, _e, _f;
354
- // Callback: signing started
355
218
  (_b = (_a = this.config).onSigningStart) === null || _b === void 0 ? void 0 : _b.call(_a);
356
219
  try {
357
220
  // On RN (no DOM), auto-confirm — there's no modal to show.
@@ -368,7 +231,6 @@ class OffchainAuthProvider {
368
231
  return signature;
369
232
  }
370
233
  catch (error) {
371
- // Callback: signing error
372
234
  (_f = (_e = this.config).onSigningError) === null || _f === void 0 ? void 0 : _f.call(_e, error);
373
235
  throw error;
374
236
  }
@@ -4664,38 +4526,6 @@ function requireMobileWalletConfig(config) {
4664
4526
  }
4665
4527
  return Object.assign(Object.assign({}, ((_c = config.mobileWalletConfig) !== null && _c !== void 0 ? _c : {})), { cluster });
4666
4528
  }
4667
- function isLocalOrTestUrl(value) {
4668
- if (!value)
4669
- return false;
4670
- try {
4671
- const hostname = new URL(value).hostname.toLowerCase();
4672
- return hostname === 'localhost' ||
4673
- hostname === '127.0.0.1' ||
4674
- hostname === '::1' ||
4675
- hostname.endsWith('.localhost') ||
4676
- hostname.endsWith('.test');
4677
- }
4678
- catch (_a) {
4679
- return false;
4680
- }
4681
- }
4682
- function assertMockAuthLocalOnly(config) {
4683
- const requiredEndpoints = [
4684
- config.apiUrl,
4685
- config.wsApiUrl,
4686
- config.authApiUrl,
4687
- ];
4688
- const optionalEndpoints = [
4689
- config.rpcUrl,
4690
- config.humanAuthApiUrl,
4691
- config.functionsUrl,
4692
- ].filter((value) => typeof value === 'string' && value.trim() !== '');
4693
- if (requiredEndpoints.every(isLocalOrTestUrl) && optionalEndpoints.every(isLocalOrTestUrl)) {
4694
- return;
4695
- }
4696
- throw new Error("mockAuth is local/test-only. Pass explicit localhost/.test apiUrl, wsApiUrl, and authApiUrl values; " +
4697
- "mockAuth cannot be used with Bounded production or staging endpoints.");
4698
- }
4699
4529
  async function hotSwapToMWAProvider(config) {
4700
4530
  var _a;
4701
4531
  const rpcUrl = normalizeSolanaRpcUrl(config.rpcUrl);
@@ -4737,13 +4567,6 @@ async function getAuthProvider(config) {
4737
4567
  throw new Error("Config is required to initialize auth provider");
4738
4568
  }
4739
4569
  initConfig = config;
4740
- // If mockAuth is enabled, use MockAuthProvider regardless of authMethod
4741
- if (config.mockAuth) {
4742
- assertMockAuthLocalOnly(config);
4743
- console.log("[MockAuth] Mock authentication enabled");
4744
- currentAuthProvider = new MockAuthProvider();
4745
- return currentAuthProvider;
4746
- }
4747
4570
  const authMethod = config.authMethod;
4748
4571
  if (!authMethod) {
4749
4572
  throw new Error("authMethod is required to initialize auth provider; configure the single intended auth method explicitly.");
@@ -9626,5 +9449,5 @@ class PrivyExpoProvider {
9626
9449
  }
9627
9450
  }
9628
9451
 
9629
- export { DEFAULT_TEST_ADDRESS, MockAuthProvider, OffchainAuthProvider, PhantomWalletProvider, PrivyExpoProvider, PrivyWalletProvider, SolanaMobileWalletProvider, completeLoginFromRedirect, completeLoginInPopup, deserializeTransaction, getAuthLoading, getAuthProvider, getCurrentUser, getIdToken, getPlatform, init, isMobileWalletAvailable, linkEmail, linkWithRedirect, login, loginWithPopup, loginWithPrivy, loginWithRedirect, logout, onAuthLoadingChanged, onAuthStateChanged, registerMobileWalletAdapter, sendEmailOtp, sendTextOtp, setPlatform, signInAnonymously, useAuth, useQuery, verifyEmailOtp, verifyTextOtp };
9452
+ export { OffchainAuthProvider, PhantomWalletProvider, PrivyExpoProvider, PrivyWalletProvider, SolanaMobileWalletProvider, completeLoginFromRedirect, completeLoginInPopup, deserializeTransaction, getAuthLoading, getAuthProvider, getCurrentUser, getIdToken, getPlatform, init, isMobileWalletAvailable, linkEmail, linkWithRedirect, login, loginWithPopup, loginWithPrivy, loginWithRedirect, logout, onAuthLoadingChanged, onAuthStateChanged, registerMobileWalletAdapter, sendEmailOtp, sendTextOtp, setPlatform, signInAnonymously, useAuth, useQuery, verifyEmailOtp, verifyTextOtp };
9630
9453
  //# sourceMappingURL=index.mjs.map