@bounded-sh/client 0.0.19 → 0.0.21
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 +2 -2
- package/dist/auth/providers/offchain-auth-provider.d.ts +2 -4
- package/dist/index.d.ts +0 -1
- package/dist/index.js +150 -214
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +151 -213
- package/dist/index.mjs.map +1 -1
- package/dist/{index.native-DI_Xgv-n.js → index.native-DdKzAUjN.js} +154 -218
- package/dist/index.native-DdKzAUjN.js.map +1 -0
- package/dist/{index.native-DWI_i6-6.mjs → index.native-N3xLU862.mjs} +155 -217
- package/dist/index.native-N3xLU862.mjs.map +1 -0
- package/dist/index.native.d.ts +0 -1
- package/dist/index.native.js +1 -3
- package/dist/index.native.js.map +1 -1
- package/dist/index.native.mjs +1 -1
- package/dist/{phantom-wallet-provider-DDwgNMg_.mjs → phantom-wallet-provider-DcE4A2_e.mjs} +2 -2
- package/dist/{phantom-wallet-provider-DDwgNMg_.mjs.map → phantom-wallet-provider-DcE4A2_e.mjs.map} +1 -1
- package/dist/{phantom-wallet-provider-fyOrJZP6.js → phantom-wallet-provider-Dz9lQvNv.js} +2 -2
- package/dist/{phantom-wallet-provider-fyOrJZP6.js.map → phantom-wallet-provider-Dz9lQvNv.js.map} +1 -1
- package/dist/{privy-wallet-provider-BIr9lDS7.js → privy-wallet-provider-DUvjxNXK.js} +3 -3
- package/dist/{privy-wallet-provider-BIr9lDS7.js.map → privy-wallet-provider-DUvjxNXK.js.map} +1 -1
- package/dist/{privy-wallet-provider-D7VoQCYf.mjs → privy-wallet-provider-oG3o5vko.mjs} +3 -3
- package/dist/{privy-wallet-provider-D7VoQCYf.mjs.map → privy-wallet-provider-oG3o5vko.mjs.map} +1 -1
- package/dist/{solana-mobile-wallet-provider-Cush-URL.js → solana-mobile-wallet-provider-DdBoG6c2.js} +2 -2
- package/dist/{solana-mobile-wallet-provider-Cush-URL.js.map → solana-mobile-wallet-provider-DdBoG6c2.js.map} +1 -1
- package/dist/{solana-mobile-wallet-provider-DgcGxDoL.mjs → solana-mobile-wallet-provider-aS60_GZR.mjs} +2 -2
- package/dist/{solana-mobile-wallet-provider-DgcGxDoL.mjs.map → solana-mobile-wallet-provider-aS60_GZR.mjs.map} +1 -1
- package/package.json +2 -2
- package/dist/auth/providers/mock-auth-provider.d.ts +0 -49
- package/dist/index.native-DI_Xgv-n.js.map +0 -1
- 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
|
-
*
|
|
296
|
-
*
|
|
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
|
}
|
|
@@ -4106,13 +3968,33 @@ function createEmailModalTree() {
|
|
|
4106
3968
|
close.type = 'button';
|
|
4107
3969
|
close.textContent = '×';
|
|
4108
3970
|
card.appendChild(close);
|
|
3971
|
+
// Brand row — the real Bounded mark (same geometry as bounded.sh) + wordmark.
|
|
4109
3972
|
const brand = document.createElement('div');
|
|
4110
3973
|
brand.className = 'ba-brand';
|
|
4111
|
-
const
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
3974
|
+
const mark = document.createElement('span');
|
|
3975
|
+
mark.className = 'ba-mark';
|
|
3976
|
+
mark.setAttribute('aria-hidden', 'true');
|
|
3977
|
+
mark.innerHTML =
|
|
3978
|
+
'<svg width="24" height="24" viewBox="0 0 32 32" fill="none">' +
|
|
3979
|
+
'<path class="ba-c ba-c1" d="M16 5 H5 V16"/>' +
|
|
3980
|
+
'<path class="ba-c ba-c2" d="M16 5 H27 V16"/>' +
|
|
3981
|
+
'<path class="ba-c ba-c3" d="M5 16 V27 H16"/>' +
|
|
3982
|
+
'<path class="ba-c ba-c4" d="M27 16 V27 H16"/>' +
|
|
3983
|
+
'</svg>';
|
|
3984
|
+
brand.appendChild(mark);
|
|
3985
|
+
const word = document.createElement('span');
|
|
3986
|
+
word.className = 'ba-word';
|
|
3987
|
+
word.textContent = 'bounded';
|
|
3988
|
+
brand.appendChild(word);
|
|
4115
3989
|
card.appendChild(brand);
|
|
3990
|
+
const title = document.createElement('h1');
|
|
3991
|
+
title.className = 'ba-title';
|
|
3992
|
+
title.textContent = 'Sign in';
|
|
3993
|
+
card.appendChild(title);
|
|
3994
|
+
const sub = document.createElement('p');
|
|
3995
|
+
sub.className = 'ba-subtitle';
|
|
3996
|
+
sub.textContent = 'Continue with your email — no wallet needed.';
|
|
3997
|
+
card.appendChild(sub);
|
|
4116
3998
|
const emailStep = document.createElement('div');
|
|
4117
3999
|
emailStep.id = 'ba-email-step';
|
|
4118
4000
|
card.appendChild(emailStep);
|
|
@@ -4133,7 +4015,7 @@ function createEmailModalTree() {
|
|
|
4133
4015
|
emailButton.id = 'ba-email-btn';
|
|
4134
4016
|
emailButton.className = 'ba-btn';
|
|
4135
4017
|
emailButton.type = 'button';
|
|
4136
|
-
emailButton.textContent = 'Continue';
|
|
4018
|
+
emailButton.textContent = 'Continue with email';
|
|
4137
4019
|
emailStep.appendChild(emailButton);
|
|
4138
4020
|
const otpStep = document.createElement('div');
|
|
4139
4021
|
otpStep.id = 'ba-otp-step';
|
|
@@ -4178,37 +4060,67 @@ function createEmailModalTree() {
|
|
|
4178
4060
|
card.appendChild(foot);
|
|
4179
4061
|
return root;
|
|
4180
4062
|
}
|
|
4063
|
+
// Design language matches the hosted Bounded login (auth.bounded.sh) and bounded.sh:
|
|
4064
|
+
// dark editorial panel, green accent, Schibsted Grotesk / Newsreader / JetBrains Mono,
|
|
4065
|
+
// the Bounded mark drawing itself in. Fonts load best-effort (scoped @import); every
|
|
4066
|
+
// rule has a system fallback so the modal looks right even if Google Fonts is blocked.
|
|
4067
|
+
// All selectors are scoped under #bounded-auth-modal so we never leak into the host page.
|
|
4181
4068
|
const MODAL_CSS = `
|
|
4182
|
-
|
|
4069
|
+
@import url('https://fonts.googleapis.com/css2?family=Newsreader:opsz,wght@6..72,400;6..72,500&family=Schibsted+Grotesk:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');
|
|
4070
|
+
#bounded-auth-modal{--ba-bg:#0a0a0b;--ba-panel:#0e0f11;--ba-inset:#060607;--ba-raise:#131416;
|
|
4071
|
+
--ba-line:rgba(232,230,222,.08);--ba-line-strong:rgba(232,230,222,.16);
|
|
4072
|
+
--ba-text:#e8e6de;--ba-dim:#9b9991;--ba-faint:#85837c;--ba-green:#58c98f;
|
|
4073
|
+
--ba-green-bg:rgba(88,201,143,.09);--ba-green-line:rgba(88,201,143,.28);--ba-red:#ec8488;
|
|
4074
|
+
--ba-body:'Schibsted Grotesk',-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif;
|
|
4075
|
+
--ba-display:'Newsreader','Iowan Old Style',Georgia,serif;
|
|
4076
|
+
--ba-mono:'JetBrains Mono',ui-monospace,'SF Mono',Menlo,monospace;}
|
|
4077
|
+
#bounded-auth-modal .ba-overlay{position:fixed;inset:0;background:rgba(6,6,7,.66);backdrop-filter:blur(4px);
|
|
4183
4078
|
display:flex;align-items:center;justify-content:center;z-index:2147483000;opacity:1;transition:opacity .16s ease;
|
|
4184
|
-
font-family
|
|
4079
|
+
font-family:var(--ba-body);padding:16px;}
|
|
4185
4080
|
#bounded-auth-modal .ba-overlay.out{opacity:0;}
|
|
4186
|
-
#bounded-auth-modal
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
#bounded-auth-modal .ba-
|
|
4195
|
-
#bounded-auth-modal .ba-
|
|
4196
|
-
#bounded-auth-modal .ba-
|
|
4197
|
-
#bounded-auth-modal .ba-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
#bounded-auth-modal .ba-
|
|
4201
|
-
#bounded-auth-modal .ba-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
#bounded-auth-modal .ba-
|
|
4205
|
-
#bounded-auth-modal .ba-
|
|
4206
|
-
#bounded-auth-modal .ba-
|
|
4207
|
-
#bounded-auth-modal .ba-
|
|
4208
|
-
#bounded-auth-modal .ba-
|
|
4209
|
-
#bounded-auth-modal .ba-
|
|
4081
|
+
#bounded-auth-modal *{box-sizing:border-box;}
|
|
4082
|
+
#bounded-auth-modal .ba-card{width:100%;max-width:372px;background:var(--ba-panel);color:var(--ba-text);
|
|
4083
|
+
border:1px solid var(--ba-line);border-radius:12px;padding:28px 28px 22px;position:relative;
|
|
4084
|
+
box-shadow:0 1px 0 rgba(232,230,222,.03) inset,0 30px 80px -40px rgba(0,0,0,.8);animation:ba-in .18s ease;}
|
|
4085
|
+
@keyframes ba-in{from{transform:translateY(8px);opacity:.5}to{transform:translateY(0);opacity:1}}
|
|
4086
|
+
#bounded-auth-modal .ba-x{position:absolute;top:14px;right:14px;width:28px;height:28px;border:1px solid var(--ba-line);
|
|
4087
|
+
background:var(--ba-raise);color:var(--ba-faint);border-radius:7px;font-size:18px;line-height:1;cursor:pointer;
|
|
4088
|
+
transition:color .15s,border-color .15s;}
|
|
4089
|
+
#bounded-auth-modal .ba-x:hover{color:var(--ba-text);border-color:var(--ba-faint);}
|
|
4090
|
+
#bounded-auth-modal .ba-brand{display:flex;align-items:center;gap:10px;margin:0 0 24px;}
|
|
4091
|
+
#bounded-auth-modal .ba-mark{display:flex;color:var(--ba-text);}
|
|
4092
|
+
#bounded-auth-modal .ba-mark svg{overflow:visible;display:block;}
|
|
4093
|
+
#bounded-auth-modal .ba-c{stroke:currentColor;stroke-width:2.4;fill:none;}
|
|
4094
|
+
@media (prefers-reduced-motion:no-preference){
|
|
4095
|
+
#bounded-auth-modal .ba-c{stroke-dasharray:23;stroke-dashoffset:23;animation:ba-draw .4s cubic-bezier(.45,0,.2,1) forwards;}
|
|
4096
|
+
#bounded-auth-modal .ba-c1{animation-delay:.1s}#bounded-auth-modal .ba-c2{animation-delay:.38s}
|
|
4097
|
+
#bounded-auth-modal .ba-c3{animation-delay:.66s}#bounded-auth-modal .ba-c4{animation-delay:.94s}}
|
|
4098
|
+
@keyframes ba-draw{to{stroke-dashoffset:0}}
|
|
4099
|
+
#bounded-auth-modal .ba-word{font-family:var(--ba-body);font-weight:500;font-size:15px;letter-spacing:.2px;color:var(--ba-text);}
|
|
4100
|
+
#bounded-auth-modal .ba-title{font-family:var(--ba-display);font-weight:400;font-size:25px;letter-spacing:-.01em;margin:0 0 5px;}
|
|
4101
|
+
#bounded-auth-modal .ba-subtitle{color:var(--ba-dim);font-size:14px;margin:0 0 22px;}
|
|
4102
|
+
#bounded-auth-modal .ba-label{display:block;font-size:12px;color:var(--ba-dim);margin:0 0 7px;}
|
|
4103
|
+
#bounded-auth-modal .ba-em{color:var(--ba-text);font-weight:600;}
|
|
4104
|
+
#bounded-auth-modal .ba-input{width:100%;background:var(--ba-inset);border:1px solid var(--ba-line-strong);color:var(--ba-text);
|
|
4105
|
+
border-radius:6px;padding:11px 13px;font-family:var(--ba-body);font-size:15px;outline:none;transition:border-color .15s,box-shadow .15s;}
|
|
4106
|
+
#bounded-auth-modal .ba-input::placeholder{color:var(--ba-faint);}
|
|
4107
|
+
#bounded-auth-modal .ba-input:focus{border-color:var(--ba-green-line);box-shadow:0 0 0 3px var(--ba-green-bg);}
|
|
4108
|
+
#bounded-auth-modal .ba-code{font-family:var(--ba-mono);letter-spacing:8px;text-align:center;font-size:21px;padding-left:8px;}
|
|
4109
|
+
#bounded-auth-modal .ba-btn{width:100%;margin-top:16px;background:var(--ba-text);color:var(--ba-bg);
|
|
4110
|
+
border:0;border-radius:6px;padding:12px;font-family:var(--ba-body);font-size:14px;font-weight:600;cursor:pointer;
|
|
4111
|
+
transition:opacity .15s,transform .04s;}
|
|
4112
|
+
#bounded-auth-modal .ba-btn:hover{opacity:.9;}
|
|
4113
|
+
#bounded-auth-modal .ba-btn:active{transform:translateY(.5px);}
|
|
4114
|
+
#bounded-auth-modal .ba-btn:disabled{opacity:.45;cursor:default;}
|
|
4115
|
+
#bounded-auth-modal .ba-link{width:100%;margin-top:14px;background:none;border:none;color:var(--ba-dim);
|
|
4116
|
+
font-family:var(--ba-body);font-size:12.5px;cursor:pointer;}
|
|
4117
|
+
#bounded-auth-modal .ba-link:hover{color:var(--ba-text);}
|
|
4118
|
+
#bounded-auth-modal .ba-msg{min-height:16px;margin-top:16px;font-size:12.5px;color:var(--ba-dim);text-align:center;}
|
|
4119
|
+
#bounded-auth-modal .ba-msg.err{color:var(--ba-red);}
|
|
4120
|
+
#bounded-auth-modal .ba-foot{margin-top:26px;padding-top:16px;border-top:1px solid var(--ba-line);
|
|
4121
|
+
text-align:center;font-size:11px;color:var(--ba-faint);}
|
|
4210
4122
|
#bounded-auth-modal .hidden{display:none;}
|
|
4211
|
-
@media (max-width:480px){#bounded-auth-modal .ba-card{max-width:none;
|
|
4123
|
+
@media (max-width:480px){#bounded-auth-modal .ba-card{max-width:none;}}`;
|
|
4212
4124
|
|
|
4213
4125
|
const SURFNET_RPC_URL = "https://surfpool.fly.dev";
|
|
4214
4126
|
const SUPPORTED_SOLANA_NETWORKS = new Set([
|
|
@@ -4255,6 +4167,7 @@ function resolveSolanaRpcUrl(explicitRpcUrl, network, context) {
|
|
|
4255
4167
|
}
|
|
4256
4168
|
|
|
4257
4169
|
const PKCE_STORE_KEY = 'bounded.oidc.pkce';
|
|
4170
|
+
const STORED_AUTH_METHOD_KEY$2 = 'bounded_last_auth_method';
|
|
4258
4171
|
// Active session store (Web on web, RN on React Native) — selected by config,
|
|
4259
4172
|
// not by `typeof window` (truthy on RN). OIDC redirect/popup is web-only, but the
|
|
4260
4173
|
// session it mints is read back through this same selector everywhere.
|
|
@@ -4549,6 +4462,10 @@ async function exchangeCode(code, verifier, redirectUri) {
|
|
|
4549
4462
|
const refreshToken = tokenField(data, 'refresh_token', 'refreshToken');
|
|
4550
4463
|
const user = userFromIdToken(idToken);
|
|
4551
4464
|
await sessionManager().storeSession(String(user.address || ''), accessToken, idToken, refreshToken, base);
|
|
4465
|
+
try {
|
|
4466
|
+
getPlatform().storage.setItem(STORED_AUTH_METHOD_KEY$2, 'email');
|
|
4467
|
+
}
|
|
4468
|
+
catch ( /* storage unavailable */_b) { /* storage unavailable */ }
|
|
4552
4469
|
setCurrentUser(user);
|
|
4553
4470
|
setAuthProviderInstance(oidcProviderSingleton);
|
|
4554
4471
|
return user;
|
|
@@ -4559,7 +4476,10 @@ async function exchangeCode(code, verifier, redirectUri) {
|
|
|
4559
4476
|
// (react-dom) when this module is imported on RN.
|
|
4560
4477
|
let currentAuthProvider = null;
|
|
4561
4478
|
let currentAuthMethod = null;
|
|
4479
|
+
let currentAuthProviderConfigKey = null;
|
|
4562
4480
|
let initConfig = null;
|
|
4481
|
+
const objectIdentityKeys = new WeakMap();
|
|
4482
|
+
let nextObjectIdentityKey = 1;
|
|
4563
4483
|
// --- localStorage helpers: track which auth method created the active session ---
|
|
4564
4484
|
const STORED_AUTH_METHOD_KEY$1 = 'bounded_last_auth_method';
|
|
4565
4485
|
function getStoredAuthMethod() {
|
|
@@ -4583,6 +4503,51 @@ function setStoredAuthMethod(method) {
|
|
|
4583
4503
|
// storage might not be available
|
|
4584
4504
|
}
|
|
4585
4505
|
}
|
|
4506
|
+
function objectIdentityKey(value) {
|
|
4507
|
+
if (!value || (typeof value !== 'object' && typeof value !== 'function'))
|
|
4508
|
+
return null;
|
|
4509
|
+
const obj = value;
|
|
4510
|
+
let id = objectIdentityKeys.get(obj);
|
|
4511
|
+
if (!id) {
|
|
4512
|
+
id = nextObjectIdentityKey++;
|
|
4513
|
+
objectIdentityKeys.set(obj, id);
|
|
4514
|
+
}
|
|
4515
|
+
return `object:${id}`;
|
|
4516
|
+
}
|
|
4517
|
+
function stableConfigValue(value, seen = new WeakSet()) {
|
|
4518
|
+
if (value === null || typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean')
|
|
4519
|
+
return value;
|
|
4520
|
+
if (typeof value === 'function')
|
|
4521
|
+
return '[function]';
|
|
4522
|
+
if (Array.isArray(value))
|
|
4523
|
+
return value.map((item) => stableConfigValue(item, seen));
|
|
4524
|
+
if (typeof value === 'object') {
|
|
4525
|
+
if (seen.has(value))
|
|
4526
|
+
return '[circular]';
|
|
4527
|
+
seen.add(value);
|
|
4528
|
+
const out = {};
|
|
4529
|
+
for (const key of Object.keys(value).sort()) {
|
|
4530
|
+
out[key] = stableConfigValue(value[key], seen);
|
|
4531
|
+
}
|
|
4532
|
+
seen.delete(value);
|
|
4533
|
+
return out;
|
|
4534
|
+
}
|
|
4535
|
+
return String(value);
|
|
4536
|
+
}
|
|
4537
|
+
function authProviderConfigKey(config) {
|
|
4538
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4539
|
+
return JSON.stringify({
|
|
4540
|
+
authMethod: (_a = config.authMethod) !== null && _a !== void 0 ? _a : null,
|
|
4541
|
+
chain: (_b = config.chain) !== null && _b !== void 0 ? _b : null,
|
|
4542
|
+
rpcUrl: normalizeSolanaRpcUrl(config.rpcUrl),
|
|
4543
|
+
name: (_c = config.name) !== null && _c !== void 0 ? _c : null,
|
|
4544
|
+
logoUrl: (_d = config.logoUrl) !== null && _d !== void 0 ? _d : null,
|
|
4545
|
+
phantomConfig: stableConfigValue((_e = config.phantomConfig) !== null && _e !== void 0 ? _e : null),
|
|
4546
|
+
privyConfig: stableConfigValue((_f = config.privyConfig) !== null && _f !== void 0 ? _f : null),
|
|
4547
|
+
mobileWalletConfig: stableConfigValue((_g = config.mobileWalletConfig) !== null && _g !== void 0 ? _g : null),
|
|
4548
|
+
privyExpoProvider: objectIdentityKey((_h = config.privyExpoProvider) !== null && _h !== void 0 ? _h : null),
|
|
4549
|
+
});
|
|
4550
|
+
}
|
|
4586
4551
|
/**
|
|
4587
4552
|
* Clears the session if it was created by a different auth method.
|
|
4588
4553
|
* Returns true if the session was cleared, false if the session is compatible.
|
|
@@ -4664,38 +4629,6 @@ function requireMobileWalletConfig(config) {
|
|
|
4664
4629
|
}
|
|
4665
4630
|
return Object.assign(Object.assign({}, ((_c = config.mobileWalletConfig) !== null && _c !== void 0 ? _c : {})), { cluster });
|
|
4666
4631
|
}
|
|
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
4632
|
async function hotSwapToMWAProvider(config) {
|
|
4700
4633
|
var _a;
|
|
4701
4634
|
const rpcUrl = normalizeSolanaRpcUrl(config.rpcUrl);
|
|
@@ -4720,6 +4653,7 @@ async function hotSwapToMWAProvider(config) {
|
|
|
4720
4653
|
}
|
|
4721
4654
|
currentAuthProvider = provider;
|
|
4722
4655
|
currentAuthMethod = 'mobile-wallet-adapter';
|
|
4656
|
+
currentAuthProviderConfigKey = authProviderConfigKey(Object.assign(Object.assign({}, config), { authMethod: 'mobile-wallet-adapter' }));
|
|
4723
4657
|
const coreConfig = await getConfig();
|
|
4724
4658
|
coreConfig.authProvider = provider;
|
|
4725
4659
|
// Send 'phantom' as authMethod so the server routes to Solana verification.
|
|
@@ -4730,20 +4664,19 @@ async function hotSwapToMWAProvider(config) {
|
|
|
4730
4664
|
}
|
|
4731
4665
|
async function getAuthProvider(config) {
|
|
4732
4666
|
var _a, _b;
|
|
4733
|
-
|
|
4667
|
+
const nextProviderConfigKey = config ? authProviderConfigKey(config) : null;
|
|
4668
|
+
if (currentAuthProvider && (!config || currentAuthProviderConfigKey === nextProviderConfigKey)) {
|
|
4734
4669
|
return currentAuthProvider;
|
|
4735
4670
|
}
|
|
4736
4671
|
if (!config) {
|
|
4737
4672
|
throw new Error("Config is required to initialize auth provider");
|
|
4738
4673
|
}
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
console.log("[MockAuth] Mock authentication enabled");
|
|
4744
|
-
currentAuthProvider = new MockAuthProvider();
|
|
4745
|
-
return currentAuthProvider;
|
|
4674
|
+
if (currentAuthProvider && currentAuthProviderConfigKey !== nextProviderConfigKey) {
|
|
4675
|
+
currentAuthProvider = null;
|
|
4676
|
+
currentAuthMethod = null;
|
|
4677
|
+
currentAuthProviderConfigKey = null;
|
|
4746
4678
|
}
|
|
4679
|
+
initConfig = config;
|
|
4747
4680
|
const authMethod = config.authMethod;
|
|
4748
4681
|
if (!authMethod) {
|
|
4749
4682
|
throw new Error("authMethod is required to initialize auth provider; configure the single intended auth method explicitly.");
|
|
@@ -4825,6 +4758,7 @@ async function getAuthProvider(config) {
|
|
|
4825
4758
|
console.log("[Offchain] Wrapping auth provider for Poofnet transaction tracking");
|
|
4826
4759
|
currentAuthProvider = new OffchainAuthProvider(currentAuthProvider);
|
|
4827
4760
|
}
|
|
4761
|
+
currentAuthProviderConfigKey = nextProviderConfigKey;
|
|
4828
4762
|
return currentAuthProvider;
|
|
4829
4763
|
}
|
|
4830
4764
|
/**
|
|
@@ -4854,6 +4788,7 @@ async function signInAnonymously() {
|
|
|
4854
4788
|
const provider = new GuestAuthProvider();
|
|
4855
4789
|
currentAuthProvider = provider;
|
|
4856
4790
|
currentAuthMethod = 'guest';
|
|
4791
|
+
currentAuthProviderConfigKey = 'direct:guest';
|
|
4857
4792
|
const coreConfig = await getConfig();
|
|
4858
4793
|
coreConfig.authProvider = provider;
|
|
4859
4794
|
coreConfig.authMethod = 'guest';
|
|
@@ -4898,6 +4833,7 @@ async function loginWithPrivy(options) {
|
|
|
4898
4833
|
provider = new OffchainAuthProvider(provider);
|
|
4899
4834
|
}
|
|
4900
4835
|
currentAuthProvider = provider;
|
|
4836
|
+
currentAuthProviderConfigKey = authProviderConfigKey(Object.assign(Object.assign({}, coreConfig), { authMethod: currentAuthMethod }));
|
|
4901
4837
|
coreConfig.authProvider = provider;
|
|
4902
4838
|
coreConfig.authMethod = currentAuthMethod;
|
|
4903
4839
|
setAuthProviderInstance(provider);
|
|
@@ -4914,6 +4850,7 @@ async function activateEmailProvider() {
|
|
|
4914
4850
|
const provider = new EmailAuthProvider();
|
|
4915
4851
|
currentAuthProvider = provider;
|
|
4916
4852
|
currentAuthMethod = 'email';
|
|
4853
|
+
currentAuthProviderConfigKey = 'direct:email';
|
|
4917
4854
|
const coreConfig = await getConfig();
|
|
4918
4855
|
coreConfig.authProvider = provider;
|
|
4919
4856
|
coreConfig.authMethod = 'email';
|
|
@@ -5040,6 +4977,7 @@ async function logout$1() {
|
|
|
5040
4977
|
setStoredAuthMethod(null);
|
|
5041
4978
|
currentAuthProvider = null;
|
|
5042
4979
|
currentAuthMethod = null;
|
|
4980
|
+
currentAuthProviderConfigKey = null;
|
|
5043
4981
|
}
|
|
5044
4982
|
|
|
5045
4983
|
/**
|
|
@@ -9626,5 +9564,5 @@ class PrivyExpoProvider {
|
|
|
9626
9564
|
}
|
|
9627
9565
|
}
|
|
9628
9566
|
|
|
9629
|
-
export {
|
|
9567
|
+
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
9568
|
//# sourceMappingURL=index.mjs.map
|