@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.
@@ -9,8 +9,8 @@
9
9
  */
10
10
  export { init, getCurrentUser, onAuthStateChanged, onAuthLoadingChanged, getAuthLoading, login, logout, } from "./global";
11
11
  export { getConfig } from "@bounded-sh/core";
12
- export { getAuthProvider, signInAnonymously, sendEmailOtp, sendTextOtp, verifyEmailOtp, verifyTextOtp, linkEmail, loginWithPrivy } from "./auth";
13
- export { loginWithRedirect, linkWithRedirect, completeLoginFromRedirect, loginWithPopup, completeLoginInPopup } from "./auth";
12
+ export { getAuthProvider, signInAnonymously, loginWithPrivy } from "./auth";
13
+ export { loginWithRedirect, completeLoginFromRedirect, loginWithPopup, completeLoginInPopup } from "./auth";
14
14
  export type { HostedAuthMethod, OidcLoginOptions, PopupLoginOptions } from "./auth";
15
15
  export { get, getMany, docId, set, setMany, setFile, getFiles, search, queryAggregate, runQuery, runQueryMany, runExpression, runExpressionMany, signMessage, signTransaction, signAndSubmitTransaction, count, aggregate, GetOptions, SearchOptions, SetOptions, CountOptions, AggregateOptions, AggregateOperation, AggregateResult, AggregateSpec, AggregateRow, QueryAggregateOptions, } from "@bounded-sh/core";
16
16
  export type { GetOptions as BoundedGetOptions } from "@bounded-sh/core";
@@ -3791,7 +3791,7 @@ function appendHostedLoginHints(params, opts) {
3791
3791
  // native (expo-web-browser) path. The caller decides where the PkceState lives
3792
3792
  // (web → sessionStorage across the full-page redirect; native → in-memory across
3793
3793
  // the awaited browser session).
3794
- async function buildAuthorize(opts, guestHint) {
3794
+ async function buildAuthorize(opts) {
3795
3795
  const cfg = await core.getConfig();
3796
3796
  if (!cfg.appId)
3797
3797
  throw new Error('appId is not configured (init the SDK with your appId)');
@@ -3808,35 +3808,8 @@ async function buildAuthorize(opts, guestHint) {
3808
3808
  code_challenge: challenge, code_challenge_method: 'S256', state,
3809
3809
  });
3810
3810
  appendHostedLoginHints(params, opts);
3811
- // Anonymous→real UPGRADE (linkWithRedirect): the issuer needs the guest identity bound to
3812
- // this request's PKCE code_challenge so the link completes single-use at the code→token
3813
- // exchange. We do NOT put the raw guest id-token in the URL (it would land in server logs /
3814
- // browser history — a replayable identity-capture primitive). Instead we exchange it for an
3815
- // OPAQUE single-use handle server-side and carry only that.
3816
- if (guestHint)
3817
- params.set('bounded_guest_hint', await guestHintFor(guestHint));
3818
3811
  return { url: `${base}/api/auth/oauth2/authorize?${params.toString()}`, pkce: { verifier, state, redirectUri } };
3819
3812
  }
3820
- /** Exchange a guest id-token for an opaque single-use handle via the issuer, so the raw token
3821
- * never rides the authorize URL. Falls back to the raw token if the mint endpoint is
3822
- * unavailable — the issuer accepts both, so an upgrade never breaks during rollout. */
3823
- async function guestHintFor(guestToken) {
3824
- try {
3825
- const base = await issuerBase();
3826
- const res = await fetch(`${base}/link/guest-handle`, {
3827
- method: 'POST',
3828
- headers: { 'content-type': 'application/json' },
3829
- body: JSON.stringify({ guestToken }),
3830
- });
3831
- if (res.ok) {
3832
- const data = await res.json().catch(() => null);
3833
- if (data && typeof data.handle === 'string' && data.handle)
3834
- return data.handle;
3835
- }
3836
- }
3837
- catch ( /* fall through to the raw-token fallback */_a) { /* fall through to the raw-token fallback */ }
3838
- return guestToken;
3839
- }
3840
3813
  // Are we on React Native (no DOM)? OIDC dispatch uses this to choose the native
3841
3814
  // expo-web-browser driver vs. the web full-page-redirect/popup driver.
3842
3815
  function isNative() {
@@ -3886,9 +3859,9 @@ function parseCallbackParams(callbackUrl) {
3886
3859
  // universal-link callback, verify state, and run the SAME PKCE code→token exchange
3887
3860
  // as web. Returns the signed-in User (native completes inline — there's no separate
3888
3861
  // completeLoginFromRedirect() round-trip the way the web full-page redirect needs).
3889
- async function runNativeLogin(opts, guestHint) {
3862
+ async function runNativeLogin(opts) {
3890
3863
  var _a, _b;
3891
- const { url, pkce } = await buildAuthorize(opts, guestHint);
3864
+ const { url, pkce } = await buildAuthorize(opts);
3892
3865
  const WebBrowser = await loadExpoWebBrowser();
3893
3866
  const openAuthSession = WebBrowser.openAuthSessionAsync || ((_a = WebBrowser.default) === null || _a === void 0 ? void 0 : _a.openAuthSessionAsync);
3894
3867
  if (typeof openAuthSession !== 'function') {
@@ -3941,37 +3914,12 @@ async function loginWithRedirect(opts) {
3941
3914
  setAuthLoading(true); // reflect "signing in…" right up to navigation; the return page's
3942
3915
  window.location.href = url; // completeLoginFromRedirect() keeps it true until the user resolves.
3943
3916
  }
3944
- /** UPGRADE the current anonymous (guest) session by linking a SOCIAL/redirect login
3945
- * (e.g. Google) — Firebase `linkWithPopup`/redirect parity. Carries the guest's signed
3946
- * id-token THROUGH the OIDC authorize request (as a single-use hint bound to the PKCE
3947
- * challenge), then runs the normal redirect login. The issuer completes the link during
3948
- * the standard code→token exchange: if the chosen account is brand-new the guest's
3949
- * `@user.id` is preserved (the returned id_token is minted under it), else the account
3950
- * stays separate (guest id discarded). Requires an active guest session.
3951
- *
3952
- * Works on WEB (navigates, finish with completeLoginFromRedirect) and REACT NATIVE
3953
- * (opens expo-web-browser and resolves with the upgraded User inline). */
3954
- async function linkWithRedirect(opts) {
3955
- const guestToken = sessionManager().getIdToken();
3956
- if (!guestToken)
3957
- throw new Error('linkWithRedirect requires an active anonymous session — call signInAnonymously() first.');
3958
- if (isNative())
3959
- return runNativeLogin(opts, guestToken);
3960
- if (!hasDOM())
3961
- throw new Error('linkWithRedirect requires a browser or a configured React Native platform');
3962
- const { url, pkce } = await buildAuthorize(opts, guestToken);
3963
- sessionStorage.setItem(PKCE_STORE_KEY, JSON.stringify(pkce));
3964
- window.location.href = url;
3965
- }
3966
3917
  /** Finish login on the redirect_uri page (WEB ONLY): exchange ?code= for a token (PKCE-verified),
3967
3918
  * store the session, and return the User. Idempotent: returns null if there's no ?code= in the URL.
3968
- * When the redirect was a guest UPGRADE (linkWithRedirect) and the issuer adopted the guest
3969
- * id, the exchanged id_token already carries the preserved `@user.id`, so the returned User
3970
- * reflects it automatically (no extra round-trip).
3971
3919
  *
3972
3920
  * On REACT NATIVE this returns null and is a no-op: native login completes INLINE inside
3973
- * loginWithRedirect()/linkWithRedirect() (which resolve with the User), so there is no
3974
- * separate redirect page to finish from. Calling it on RN is harmless. */
3921
+ * loginWithRedirect() (which resolves with the User), so there is no separate redirect
3922
+ * page to finish from. Calling it on RN is harmless. */
3975
3923
  async function completeLoginFromRedirect() {
3976
3924
  if (!hasDOM())
3977
3925
  return null;
@@ -4341,12 +4289,6 @@ async function getAuthProvider(config) {
4341
4289
  currentAuthProviderConfigKey = nextProviderConfigKey;
4342
4290
  return currentAuthProvider;
4343
4291
  }
4344
- function retiredInlineAuthError(method) {
4345
- return new Error(`bounded-sh: ${method} is retired. Human login must use the hosted OAuth2 + PKCE flow: ` +
4346
- `loginWithRedirect({ redirectUri }) or loginWithPopup({ redirectUri }). ` +
4347
- `For guests use signInAnonymously(); for guest-to-real-account data continuity, ` +
4348
- `transfer ownership in app data after hosted login.`);
4349
- }
4350
4292
  /**
4351
4293
  * Browser/React-Native-only auth flows (guest, email) persist their session via
4352
4294
  * WebSessionManager, which is gated to environments that have `window` /
@@ -4430,41 +4372,6 @@ async function loginWithPrivy(options) {
4430
4372
  const result = await provider.login();
4431
4373
  return result ? Object.assign(Object.assign({}, result), { provider }) : null;
4432
4374
  }
4433
- /**
4434
- * Retired. Use `loginWithRedirect({ redirectUri, methods: ['email'] })` or
4435
- * `loginWithPopup(...)`; app-origin OTP helpers fail closed.
4436
- */
4437
- async function sendEmailOtp(email) {
4438
- throw retiredInlineAuthError('sendEmailOtp');
4439
- }
4440
- /**
4441
- * Retired. Use hosted login with `methods: ['text']` or `provider: 'text'`
4442
- * when text OTP is enabled for the app.
4443
- */
4444
- async function sendTextOtp(phoneNumber) {
4445
- throw retiredInlineAuthError('sendTextOtp');
4446
- }
4447
- /**
4448
- * Retired. Complete hosted login on the callback page with
4449
- * `completeLoginFromRedirect()`.
4450
- */
4451
- async function verifyEmailOtp(email, code) {
4452
- throw retiredInlineAuthError('verifyEmailOtp');
4453
- }
4454
- /**
4455
- * Retired. Complete hosted login on the callback page with
4456
- * `completeLoginFromRedirect()`.
4457
- */
4458
- async function verifyTextOtp(phoneNumber, code) {
4459
- throw retiredInlineAuthError('verifyTextOtp');
4460
- }
4461
- /**
4462
- * Retired. Guest upgrade is no longer an inline id-preserving auth operation;
4463
- * send the user through hosted login and transfer data explicitly in app state.
4464
- */
4465
- async function linkEmail(email, code) {
4466
- throw retiredInlineAuthError('linkEmail');
4467
- }
4468
4375
  async function login$1(options) {
4469
4376
  // Re-initialize provider if it was cleared by logout
4470
4377
  if (!currentAuthProvider && initConfig) {
@@ -5273,8 +5180,6 @@ exports.getCurrentUser = getCurrentUser;
5273
5180
  exports.getIdToken = getIdToken;
5274
5181
  exports.getPlatform = getPlatform;
5275
5182
  exports.init = init;
5276
- exports.linkEmail = linkEmail;
5277
- exports.linkWithRedirect = linkWithRedirect;
5278
5183
  exports.login = login;
5279
5184
  exports.loginWithPopup = loginWithPopup;
5280
5185
  exports.loginWithPrivy = loginWithPrivy;
@@ -5282,13 +5187,9 @@ exports.loginWithRedirect = loginWithRedirect;
5282
5187
  exports.logout = logout;
5283
5188
  exports.onAuthLoadingChanged = onAuthLoadingChanged;
5284
5189
  exports.onAuthStateChanged = onAuthStateChanged;
5285
- exports.sendEmailOtp = sendEmailOtp;
5286
- exports.sendTextOtp = sendTextOtp;
5287
5190
  exports.setPlatform = setPlatform;
5288
5191
  exports.signInAnonymously = signInAnonymously;
5289
5192
  exports.useAuth = useAuth;
5290
- exports.verifyEmailOtp = verifyEmailOtp;
5291
- exports.verifyTextOtp = verifyTextOtp;
5292
5193
  Object.keys(core).forEach(function (k) {
5293
5194
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
5294
5195
  enumerable: true,