@bounded-sh/client 0.0.33 → 0.0.34

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.
@@ -3771,7 +3771,7 @@ function appendHostedLoginHints(params, opts) {
3771
3771
  // native (expo-web-browser) path. The caller decides where the PkceState lives
3772
3772
  // (web → sessionStorage across the full-page redirect; native → in-memory across
3773
3773
  // the awaited browser session).
3774
- async function buildAuthorize(opts, guestHint) {
3774
+ async function buildAuthorize(opts) {
3775
3775
  const cfg = await getConfig();
3776
3776
  if (!cfg.appId)
3777
3777
  throw new Error('appId is not configured (init the SDK with your appId)');
@@ -3788,35 +3788,8 @@ async function buildAuthorize(opts, guestHint) {
3788
3788
  code_challenge: challenge, code_challenge_method: 'S256', state,
3789
3789
  });
3790
3790
  appendHostedLoginHints(params, opts);
3791
- // Anonymous→real UPGRADE (linkWithRedirect): the issuer needs the guest identity bound to
3792
- // this request's PKCE code_challenge so the link completes single-use at the code→token
3793
- // exchange. We do NOT put the raw guest id-token in the URL (it would land in server logs /
3794
- // browser history — a replayable identity-capture primitive). Instead we exchange it for an
3795
- // OPAQUE single-use handle server-side and carry only that.
3796
- if (guestHint)
3797
- params.set('bounded_guest_hint', await guestHintFor(guestHint));
3798
3791
  return { url: `${base}/api/auth/oauth2/authorize?${params.toString()}`, pkce: { verifier, state, redirectUri } };
3799
3792
  }
3800
- /** Exchange a guest id-token for an opaque single-use handle via the issuer, so the raw token
3801
- * never rides the authorize URL. Falls back to the raw token if the mint endpoint is
3802
- * unavailable — the issuer accepts both, so an upgrade never breaks during rollout. */
3803
- async function guestHintFor(guestToken) {
3804
- try {
3805
- const base = await issuerBase();
3806
- const res = await fetch(`${base}/link/guest-handle`, {
3807
- method: 'POST',
3808
- headers: { 'content-type': 'application/json' },
3809
- body: JSON.stringify({ guestToken }),
3810
- });
3811
- if (res.ok) {
3812
- const data = await res.json().catch(() => null);
3813
- if (data && typeof data.handle === 'string' && data.handle)
3814
- return data.handle;
3815
- }
3816
- }
3817
- catch ( /* fall through to the raw-token fallback */_a) { /* fall through to the raw-token fallback */ }
3818
- return guestToken;
3819
- }
3820
3793
  // Are we on React Native (no DOM)? OIDC dispatch uses this to choose the native
3821
3794
  // expo-web-browser driver vs. the web full-page-redirect/popup driver.
3822
3795
  function isNative() {
@@ -3866,9 +3839,9 @@ function parseCallbackParams(callbackUrl) {
3866
3839
  // universal-link callback, verify state, and run the SAME PKCE code→token exchange
3867
3840
  // as web. Returns the signed-in User (native completes inline — there's no separate
3868
3841
  // completeLoginFromRedirect() round-trip the way the web full-page redirect needs).
3869
- async function runNativeLogin(opts, guestHint) {
3842
+ async function runNativeLogin(opts) {
3870
3843
  var _a, _b;
3871
- const { url, pkce } = await buildAuthorize(opts, guestHint);
3844
+ const { url, pkce } = await buildAuthorize(opts);
3872
3845
  const WebBrowser = await loadExpoWebBrowser();
3873
3846
  const openAuthSession = WebBrowser.openAuthSessionAsync || ((_a = WebBrowser.default) === null || _a === void 0 ? void 0 : _a.openAuthSessionAsync);
3874
3847
  if (typeof openAuthSession !== 'function') {
@@ -3921,37 +3894,12 @@ async function loginWithRedirect(opts) {
3921
3894
  setAuthLoading(true); // reflect "signing in…" right up to navigation; the return page's
3922
3895
  window.location.href = url; // completeLoginFromRedirect() keeps it true until the user resolves.
3923
3896
  }
3924
- /** UPGRADE the current anonymous (guest) session by linking a SOCIAL/redirect login
3925
- * (e.g. Google) — Firebase `linkWithPopup`/redirect parity. Carries the guest's signed
3926
- * id-token THROUGH the OIDC authorize request (as a single-use hint bound to the PKCE
3927
- * challenge), then runs the normal redirect login. The issuer completes the link during
3928
- * the standard code→token exchange: if the chosen account is brand-new the guest's
3929
- * `@user.id` is preserved (the returned id_token is minted under it), else the account
3930
- * stays separate (guest id discarded). Requires an active guest session.
3931
- *
3932
- * Works on WEB (navigates, finish with completeLoginFromRedirect) and REACT NATIVE
3933
- * (opens expo-web-browser and resolves with the upgraded User inline). */
3934
- async function linkWithRedirect(opts) {
3935
- const guestToken = sessionManager().getIdToken();
3936
- if (!guestToken)
3937
- throw new Error('linkWithRedirect requires an active anonymous session — call signInAnonymously() first.');
3938
- if (isNative())
3939
- return runNativeLogin(opts, guestToken);
3940
- if (!hasDOM())
3941
- throw new Error('linkWithRedirect requires a browser or a configured React Native platform');
3942
- const { url, pkce } = await buildAuthorize(opts, guestToken);
3943
- sessionStorage.setItem(PKCE_STORE_KEY, JSON.stringify(pkce));
3944
- window.location.href = url;
3945
- }
3946
3897
  /** Finish login on the redirect_uri page (WEB ONLY): exchange ?code= for a token (PKCE-verified),
3947
3898
  * store the session, and return the User. Idempotent: returns null if there's no ?code= in the URL.
3948
- * When the redirect was a guest UPGRADE (linkWithRedirect) and the issuer adopted the guest
3949
- * id, the exchanged id_token already carries the preserved `@user.id`, so the returned User
3950
- * reflects it automatically (no extra round-trip).
3951
3899
  *
3952
3900
  * On REACT NATIVE this returns null and is a no-op: native login completes INLINE inside
3953
- * loginWithRedirect()/linkWithRedirect() (which resolve with the User), so there is no
3954
- * separate redirect page to finish from. Calling it on RN is harmless. */
3901
+ * loginWithRedirect() (which resolves with the User), so there is no separate redirect
3902
+ * page to finish from. Calling it on RN is harmless. */
3955
3903
  async function completeLoginFromRedirect() {
3956
3904
  if (!hasDOM())
3957
3905
  return null;
@@ -4321,12 +4269,6 @@ async function getAuthProvider(config) {
4321
4269
  currentAuthProviderConfigKey = nextProviderConfigKey;
4322
4270
  return currentAuthProvider;
4323
4271
  }
4324
- function retiredInlineAuthError(method) {
4325
- return new Error(`bounded-sh: ${method} is retired. Human login must use the hosted OAuth2 + PKCE flow: ` +
4326
- `loginWithRedirect({ redirectUri }) or loginWithPopup({ redirectUri }). ` +
4327
- `For guests use signInAnonymously(); for guest-to-real-account data continuity, ` +
4328
- `transfer ownership in app data after hosted login.`);
4329
- }
4330
4272
  /**
4331
4273
  * Browser/React-Native-only auth flows (guest, email) persist their session via
4332
4274
  * WebSessionManager, which is gated to environments that have `window` /
@@ -4410,41 +4352,6 @@ async function loginWithPrivy(options) {
4410
4352
  const result = await provider.login();
4411
4353
  return result ? Object.assign(Object.assign({}, result), { provider }) : null;
4412
4354
  }
4413
- /**
4414
- * Retired. Use `loginWithRedirect({ redirectUri, methods: ['email'] })` or
4415
- * `loginWithPopup(...)`; app-origin OTP helpers fail closed.
4416
- */
4417
- async function sendEmailOtp(email) {
4418
- throw retiredInlineAuthError('sendEmailOtp');
4419
- }
4420
- /**
4421
- * Retired. Use hosted login with `methods: ['text']` or `provider: 'text'`
4422
- * when text OTP is enabled for the app.
4423
- */
4424
- async function sendTextOtp(phoneNumber) {
4425
- throw retiredInlineAuthError('sendTextOtp');
4426
- }
4427
- /**
4428
- * Retired. Complete hosted login on the callback page with
4429
- * `completeLoginFromRedirect()`.
4430
- */
4431
- async function verifyEmailOtp(email, code) {
4432
- throw retiredInlineAuthError('verifyEmailOtp');
4433
- }
4434
- /**
4435
- * Retired. Complete hosted login on the callback page with
4436
- * `completeLoginFromRedirect()`.
4437
- */
4438
- async function verifyTextOtp(phoneNumber, code) {
4439
- throw retiredInlineAuthError('verifyTextOtp');
4440
- }
4441
- /**
4442
- * Retired. Guest upgrade is no longer an inline id-preserving auth operation;
4443
- * send the user through hosted login and transfer data explicitly in app state.
4444
- */
4445
- async function linkEmail(email, code) {
4446
- throw retiredInlineAuthError('linkEmail');
4447
- }
4448
4355
  async function login$1(options) {
4449
4356
  // Re-initialize provider if it was cleared by logout
4450
4357
  if (!currentAuthProvider && initConfig) {
@@ -5162,5 +5069,5 @@ class PrivyExpoProvider {
5162
5069
  }
5163
5070
  }
5164
5071
 
5165
- export { OffchainAuthProvider, PrivyExpoProvider, completeLoginFromRedirect, completeLoginInPopup, deserializeTransaction, getAuthLoading, getAuthProvider, getCurrentUser, getIdToken, getPlatform, init, linkEmail, linkWithRedirect, login, loginWithPopup, loginWithPrivy, loginWithRedirect, logout, onAuthLoadingChanged, onAuthStateChanged, sendEmailOtp, sendTextOtp, setPlatform, signInAnonymously, useAuth, verifyEmailOtp, verifyTextOtp };
5072
+ export { OffchainAuthProvider, PrivyExpoProvider, completeLoginFromRedirect, completeLoginInPopup, deserializeTransaction, getAuthLoading, getAuthProvider, getCurrentUser, getIdToken, getPlatform, init, login, loginWithPopup, loginWithPrivy, loginWithRedirect, logout, onAuthLoadingChanged, onAuthStateChanged, setPlatform, signInAnonymously, useAuth };
5166
5073
  //# sourceMappingURL=index.native.mjs.map