@bounded-sh/client 0.0.33 → 0.0.35
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/REACT_NATIVE.md +3 -3
- package/dist/auth/index.d.ts +1 -32
- package/dist/auth/oidc-auth.d.ts +2 -16
- package/dist/auth/providers/email-auth-provider.d.ts +0 -27
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -104
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -99
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.d.ts +2 -2
- package/dist/index.native.js +5 -104
- package/dist/index.native.js.map +1 -1
- package/dist/index.native.mjs +6 -99
- package/dist/index.native.mjs.map +1 -1
- package/package.json +5 -3
package/REACT_NATIVE.md
CHANGED
|
@@ -33,9 +33,9 @@ requests.
|
|
|
33
33
|
|
|
34
34
|
## 2. Hosted email / social login
|
|
35
35
|
|
|
36
|
-
Human login runs through the hosted Bounded issuer.
|
|
37
|
-
helpers (`sendEmailOtp`, `verifyEmailOtp`, `sendTextOtp`, `verifyTextOtp`)
|
|
38
|
-
|
|
36
|
+
Human login runs through the hosted Bounded issuer. Retired app-origin OTP
|
|
37
|
+
helpers (`sendEmailOtp`, `verifyEmailOtp`, `sendTextOtp`, `verifyTextOtp`) are
|
|
38
|
+
not exported by the package.
|
|
39
39
|
|
|
40
40
|
Install the Expo optional peers if your RN app uses hosted login:
|
|
41
41
|
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -42,39 +42,8 @@ export declare function signInAnonymously(): Promise<User | null>;
|
|
|
42
42
|
* (web localStorage / RN storage) and identity model. `init()` must have run first.
|
|
43
43
|
*/
|
|
44
44
|
export declare function loginWithPrivy(options?: LoginOptions): Promise<User | null>;
|
|
45
|
-
/**
|
|
46
|
-
* Retired. Use `loginWithRedirect({ redirectUri, methods: ['email'] })` or
|
|
47
|
-
* `loginWithPopup(...)`; app-origin OTP helpers fail closed.
|
|
48
|
-
*/
|
|
49
|
-
export declare function sendEmailOtp(email: string): Promise<{
|
|
50
|
-
ok: true;
|
|
51
|
-
expiresInSeconds?: number;
|
|
52
|
-
}>;
|
|
53
|
-
/**
|
|
54
|
-
* Retired. Use hosted login with `methods: ['text']` or `provider: 'text'`
|
|
55
|
-
* when text OTP is enabled for the app.
|
|
56
|
-
*/
|
|
57
|
-
export declare function sendTextOtp(phoneNumber: string): Promise<{
|
|
58
|
-
ok: true;
|
|
59
|
-
expiresInSeconds?: number;
|
|
60
|
-
}>;
|
|
61
|
-
/**
|
|
62
|
-
* Retired. Complete hosted login on the callback page with
|
|
63
|
-
* `completeLoginFromRedirect()`.
|
|
64
|
-
*/
|
|
65
|
-
export declare function verifyEmailOtp(email: string, code: string): Promise<User | null>;
|
|
66
|
-
/**
|
|
67
|
-
* Retired. Complete hosted login on the callback page with
|
|
68
|
-
* `completeLoginFromRedirect()`.
|
|
69
|
-
*/
|
|
70
|
-
export declare function verifyTextOtp(phoneNumber: string, code: string): Promise<User | null>;
|
|
71
|
-
/**
|
|
72
|
-
* Retired. Guest upgrade is no longer an inline id-preserving auth operation;
|
|
73
|
-
* send the user through hosted login and transfer data explicitly in app state.
|
|
74
|
-
*/
|
|
75
|
-
export declare function linkEmail(email: string, code: string): Promise<User | null>;
|
|
76
45
|
export declare function login(options?: LoginOptions): Promise<User | null>;
|
|
77
46
|
export declare function getCurrentAuthMethod(): string | null;
|
|
78
47
|
export declare function logout(): Promise<void>;
|
|
79
|
-
export { loginWithRedirect,
|
|
48
|
+
export { loginWithRedirect, completeLoginFromRedirect, loginWithPopup, completeLoginInPopup } from './oidc-auth';
|
|
80
49
|
export type { HostedAuthMethod, OidcLoginOptions, PopupLoginOptions } from './oidc-auth';
|
package/dist/auth/oidc-auth.d.ts
CHANGED
|
@@ -46,26 +46,12 @@ export interface PopupLoginOptions extends OidcLoginOptions {
|
|
|
46
46
|
* (custom `myapp://` schemes are rejected by the issuer). Needs the optional peer deps
|
|
47
47
|
* expo-web-browser + (expo-crypto or react-native-get-random-values). */
|
|
48
48
|
export declare function loginWithRedirect(opts: OidcLoginOptions): Promise<User | void>;
|
|
49
|
-
/** UPGRADE the current anonymous (guest) session by linking a SOCIAL/redirect login
|
|
50
|
-
* (e.g. Google) — Firebase `linkWithPopup`/redirect parity. Carries the guest's signed
|
|
51
|
-
* id-token THROUGH the OIDC authorize request (as a single-use hint bound to the PKCE
|
|
52
|
-
* challenge), then runs the normal redirect login. The issuer completes the link during
|
|
53
|
-
* the standard code→token exchange: if the chosen account is brand-new the guest's
|
|
54
|
-
* `@user.id` is preserved (the returned id_token is minted under it), else the account
|
|
55
|
-
* stays separate (guest id discarded). Requires an active guest session.
|
|
56
|
-
*
|
|
57
|
-
* Works on WEB (navigates, finish with completeLoginFromRedirect) and REACT NATIVE
|
|
58
|
-
* (opens expo-web-browser and resolves with the upgraded User inline). */
|
|
59
|
-
export declare function linkWithRedirect(opts: OidcLoginOptions): Promise<User | void>;
|
|
60
49
|
/** Finish login on the redirect_uri page (WEB ONLY): exchange ?code= for a token (PKCE-verified),
|
|
61
50
|
* store the session, and return the User. Idempotent: returns null if there's no ?code= in the URL.
|
|
62
|
-
* When the redirect was a guest UPGRADE (linkWithRedirect) and the issuer adopted the guest
|
|
63
|
-
* id, the exchanged id_token already carries the preserved `@user.id`, so the returned User
|
|
64
|
-
* reflects it automatically (no extra round-trip).
|
|
65
51
|
*
|
|
66
52
|
* On REACT NATIVE this returns null and is a no-op: native login completes INLINE inside
|
|
67
|
-
* loginWithRedirect()
|
|
68
|
-
*
|
|
53
|
+
* loginWithRedirect() (which resolves with the User), so there is no separate redirect
|
|
54
|
+
* page to finish from. Calling it on RN is harmless. */
|
|
69
55
|
export declare function completeLoginFromRedirect(): Promise<User | null>;
|
|
70
56
|
/** Popup variant: open the hosted login in a popup; resolves with the User once the popup's
|
|
71
57
|
* redirect_uri page posts the code back. The redirect_uri page just calls the usual
|
|
@@ -1,32 +1,5 @@
|
|
|
1
1
|
import type { AuthProvider, User, TransactionResult, SolTransaction, EVMTransaction, SetOptions } from '@bounded-sh/core';
|
|
2
2
|
import { Transaction, VersionedTransaction } from '@solana/web3.js';
|
|
3
|
-
/** @internal Legacy issuer-owned helper. App code must use hosted login instead. */
|
|
4
|
-
export declare function sendEmailOtp(email: string): Promise<{
|
|
5
|
-
ok: true;
|
|
6
|
-
expiresInSeconds?: number;
|
|
7
|
-
}>;
|
|
8
|
-
/** @internal Legacy issuer-owned helper. App code must use hosted login instead. */
|
|
9
|
-
export declare function sendTextOtp(phoneNumber: string): Promise<{
|
|
10
|
-
ok: true;
|
|
11
|
-
expiresInSeconds?: number;
|
|
12
|
-
}>;
|
|
13
|
-
/**
|
|
14
|
-
* @internal Legacy issuer-owned helper. App code must use hosted login instead.
|
|
15
|
-
*/
|
|
16
|
-
export declare function verifyEmailOtp(email: string, otp: string): Promise<User>;
|
|
17
|
-
/**
|
|
18
|
-
* @internal Legacy issuer-owned helper. App code must use hosted login instead.
|
|
19
|
-
*/
|
|
20
|
-
export declare function verifyTextOtp(phoneNumber: string, otp: string): Promise<User>;
|
|
21
|
-
/**
|
|
22
|
-
* @internal Legacy issuer-owned helper. Guest-to-real-account continuity should
|
|
23
|
-
* be modeled as explicit app-data transfer after hosted login.
|
|
24
|
-
*/
|
|
25
|
-
export declare function linkEmailWithGuest(email: string, otp: string, guestToken: string): Promise<{
|
|
26
|
-
user: User;
|
|
27
|
-
linked: boolean;
|
|
28
|
-
isNewAccount: boolean;
|
|
29
|
-
}>;
|
|
30
3
|
export declare class EmailAuthProvider implements AuthProvider {
|
|
31
4
|
login(): Promise<User | null>;
|
|
32
5
|
restoreSession(): Promise<User | null>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { init, getCurrentUser, onAuthStateChanged, onAuthLoadingChanged, getAuthLoading, login, logout, } from "./global";
|
|
2
2
|
export type { LoginOptions } from "./global";
|
|
3
3
|
export { getConfig } from "@bounded-sh/core";
|
|
4
|
-
export { getAuthProvider, signInAnonymously,
|
|
5
|
-
export { loginWithRedirect,
|
|
4
|
+
export { getAuthProvider, signInAnonymously, loginWithPrivy } from "./auth";
|
|
5
|
+
export { loginWithRedirect, completeLoginFromRedirect, loginWithPopup, completeLoginInPopup } from "./auth";
|
|
6
6
|
export type { HostedAuthMethod, OidcLoginOptions, PopupLoginOptions } from "./auth";
|
|
7
7
|
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";
|
|
8
8
|
export type { GetOptions as BoundedGetOptions } from "@bounded-sh/core";
|
package/dist/index.js
CHANGED
|
@@ -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
|
|
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
|
|
3862
|
+
async function runNativeLogin(opts) {
|
|
3890
3863
|
var _a, _b;
|
|
3891
|
-
const { url, pkce } = await buildAuthorize(opts
|
|
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()
|
|
3974
|
-
*
|
|
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) {
|
|
@@ -5333,8 +5240,6 @@ exports.getCurrentUser = getCurrentUser;
|
|
|
5333
5240
|
exports.getIdToken = getIdToken;
|
|
5334
5241
|
exports.getPlatform = getPlatform;
|
|
5335
5242
|
exports.init = init;
|
|
5336
|
-
exports.linkEmail = linkEmail;
|
|
5337
|
-
exports.linkWithRedirect = linkWithRedirect;
|
|
5338
5243
|
exports.login = login;
|
|
5339
5244
|
exports.loginWithPopup = loginWithPopup;
|
|
5340
5245
|
exports.loginWithPrivy = loginWithPrivy;
|
|
@@ -5342,14 +5247,10 @@ exports.loginWithRedirect = loginWithRedirect;
|
|
|
5342
5247
|
exports.logout = logout;
|
|
5343
5248
|
exports.onAuthLoadingChanged = onAuthLoadingChanged;
|
|
5344
5249
|
exports.onAuthStateChanged = onAuthStateChanged;
|
|
5345
|
-
exports.sendEmailOtp = sendEmailOtp;
|
|
5346
|
-
exports.sendTextOtp = sendTextOtp;
|
|
5347
5250
|
exports.setPlatform = setPlatform;
|
|
5348
5251
|
exports.signInAnonymously = signInAnonymously;
|
|
5349
5252
|
exports.useAuth = useAuth;
|
|
5350
5253
|
exports.useQuery = useQuery;
|
|
5351
|
-
exports.verifyEmailOtp = verifyEmailOtp;
|
|
5352
|
-
exports.verifyTextOtp = verifyTextOtp;
|
|
5353
5254
|
Object.keys(core).forEach(function (k) {
|
|
5354
5255
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
5355
5256
|
enumerable: true,
|