@bounded-sh/client 0.0.36 → 0.0.37
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 +20 -1
- package/dist/auth/hooks/useAuth.d.ts +2 -1
- package/dist/auth/providers/offchain-auth-provider.d.ts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +37 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -4
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.d.ts +2 -0
- package/dist/index.native.js +37 -3
- package/dist/index.native.js.map +1 -1
- package/dist/index.native.mjs +22 -4
- package/dist/index.native.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -111,7 +111,26 @@ const unsubscribe = onAuthStateChanged((user) => {
|
|
|
111
111
|
unsubscribe();
|
|
112
112
|
```
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
### Embedded wallets — signing
|
|
115
|
+
|
|
116
|
+
When an app enables embedded wallets in `policy.json` (`"auth": { "wallets": true }`),
|
|
117
|
+
every email login also gets a non-custodial Solana wallet (`@user.address`). That user
|
|
118
|
+
can approve transactions with it — signing runs in a Bounded-hosted popup that does a
|
|
119
|
+
one-time email verification; Bounded never holds the key.
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
import { signAndSubmitTransaction } from '@bounded-sh/client';
|
|
123
|
+
import { VersionedTransaction } from '@solana/web3.js';
|
|
124
|
+
|
|
125
|
+
// Call from a user gesture (click/tap) — signing opens a popup.
|
|
126
|
+
async function pay(tx: VersionedTransaction) {
|
|
127
|
+
const signature = await signAndSubmitTransaction(tx); // signs + submits, returns the hash
|
|
128
|
+
console.log('submitted', signature);
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
`signMessage` and `signTransaction` (sign without submit) throw for embedded smart
|
|
133
|
+
wallets — they sign and submit atomically, so use `signAndSubmitTransaction`.
|
|
115
134
|
|
|
116
135
|
## Usage
|
|
117
136
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { User } from '@bounded-sh/core';
|
|
2
|
+
import { type LoginOptions } from '../../global';
|
|
2
3
|
export interface UseAuthResult {
|
|
3
|
-
login: () => Promise<void>;
|
|
4
|
+
login: (options?: LoginOptions) => Promise<void>;
|
|
4
5
|
logout: () => Promise<void>;
|
|
5
6
|
loading: boolean;
|
|
6
7
|
user: User | null;
|
|
@@ -18,6 +18,7 @@ export declare class OffchainAuthProvider implements AuthProvider {
|
|
|
18
18
|
private modalContainer;
|
|
19
19
|
constructor(wrappedProvider: AuthProvider, config?: OffchainAuthProviderConfig);
|
|
20
20
|
login(): Promise<User | null>;
|
|
21
|
+
setLoginOverrides(opts: any): void;
|
|
21
22
|
logout(): Promise<void>;
|
|
22
23
|
restoreSession(): Promise<User | null>;
|
|
23
24
|
runTransaction(evmTransactionData?: EVMTransaction, solTransactionData?: SolTransaction, options?: SetOptions): Promise<TransactionResult>;
|
|
@@ -29,6 +30,7 @@ export declare class OffchainAuthProvider implements AuthProvider {
|
|
|
29
30
|
*/
|
|
30
31
|
signAndSubmitTransaction(_transaction: Transaction | VersionedTransaction, _feePayer?: any): Promise<string>;
|
|
31
32
|
getNativeMethods(): Promise<any>;
|
|
33
|
+
exportWallet(address?: string): Promise<void>;
|
|
32
34
|
signMessage(message: string): Promise<string>;
|
|
33
35
|
private showUnsupportedTransactionModal;
|
|
34
36
|
private showTransactionModal;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export type { HostedAuthMethod, OidcLoginOptions, PopupLoginOptions } from "./au
|
|
|
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";
|
|
9
9
|
export { subscribe } from "@bounded-sh/core";
|
|
10
|
+
export { BoundedDeclineError, deriveDecline, dispatchDeclineEvent, DECLINE_EVENT_NAME } from "@bounded-sh/core";
|
|
11
|
+
export type { BoundedDecline, DeclineReason, DeclineBoundary } from "@bounded-sh/core";
|
|
10
12
|
export * from "@bounded-sh/core";
|
|
11
13
|
export { useAuth } from "./auth/hooks/useAuth";
|
|
12
14
|
export { useQuery } from "./hooks/useQuery";
|
package/dist/index.js
CHANGED
|
@@ -165,6 +165,15 @@ class OffchainAuthProvider {
|
|
|
165
165
|
}
|
|
166
166
|
return null;
|
|
167
167
|
}
|
|
168
|
+
// Forward per-call login overrides (theme/title/subtitle and the `method`
|
|
169
|
+
// directive) to the wrapped provider. Without this, the top-level login()
|
|
170
|
+
// forwarder (which duck-types `setLoginOverrides` on the active provider)
|
|
171
|
+
// skips the wrapper and the override — including `method` — is dropped on
|
|
172
|
+
// offchain/Poofnet builds.
|
|
173
|
+
setLoginOverrides(opts) {
|
|
174
|
+
var _a, _b;
|
|
175
|
+
(_b = (_a = this.wrappedProvider).setLoginOverrides) === null || _b === void 0 ? void 0 : _b.call(_a, opts);
|
|
176
|
+
}
|
|
168
177
|
async logout() {
|
|
169
178
|
await this.wrappedProvider.logout();
|
|
170
179
|
}
|
|
@@ -198,6 +207,15 @@ class OffchainAuthProvider {
|
|
|
198
207
|
async getNativeMethods() {
|
|
199
208
|
return this.wrappedProvider.getNativeMethods();
|
|
200
209
|
}
|
|
210
|
+
// Forward wallet export to the wrapped provider (only Privy embedded wallets
|
|
211
|
+
// implement it). Duck-typed so wrappers around non-embedded providers throw
|
|
212
|
+
// a clear error rather than a "not a function" crash.
|
|
213
|
+
async exportWallet(address) {
|
|
214
|
+
if (typeof this.wrappedProvider.exportWallet !== 'function') {
|
|
215
|
+
throw new Error('Wallet export is not available for this wallet.');
|
|
216
|
+
}
|
|
217
|
+
await this.wrappedProvider.exportWallet(address);
|
|
218
|
+
}
|
|
201
219
|
// ============ signMessage delegates to wrapped provider ============
|
|
202
220
|
async signMessage(message) {
|
|
203
221
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -4864,7 +4882,7 @@ function useAuth() {
|
|
|
4864
4882
|
// Provide a fallback so server render doesn't break
|
|
4865
4883
|
if (isSSR$1) {
|
|
4866
4884
|
return {
|
|
4867
|
-
login: async () => undefined,
|
|
4885
|
+
login: async (_options) => undefined,
|
|
4868
4886
|
logout: async () => undefined,
|
|
4869
4887
|
loading: true,
|
|
4870
4888
|
user: null,
|
|
@@ -4886,10 +4904,10 @@ function useAuth() {
|
|
|
4886
4904
|
stopLoading();
|
|
4887
4905
|
};
|
|
4888
4906
|
}, []);
|
|
4889
|
-
const login$1 = async () => {
|
|
4907
|
+
const login$1 = async (options) => {
|
|
4890
4908
|
try {
|
|
4891
4909
|
setLoading(true);
|
|
4892
|
-
const user = await login();
|
|
4910
|
+
const user = await login(options);
|
|
4893
4911
|
setUser(user);
|
|
4894
4912
|
}
|
|
4895
4913
|
catch (error) {
|
|
@@ -5387,6 +5405,14 @@ class PrivyExpoProvider {
|
|
|
5387
5405
|
}
|
|
5388
5406
|
}
|
|
5389
5407
|
|
|
5408
|
+
Object.defineProperty(exports, "BoundedDeclineError", {
|
|
5409
|
+
enumerable: true,
|
|
5410
|
+
get: function () { return core.BoundedDeclineError; }
|
|
5411
|
+
});
|
|
5412
|
+
Object.defineProperty(exports, "DECLINE_EVENT_NAME", {
|
|
5413
|
+
enumerable: true,
|
|
5414
|
+
get: function () { return core.DECLINE_EVENT_NAME; }
|
|
5415
|
+
});
|
|
5390
5416
|
Object.defineProperty(exports, "aggregate", {
|
|
5391
5417
|
enumerable: true,
|
|
5392
5418
|
get: function () { return core.aggregate; }
|
|
@@ -5395,6 +5421,14 @@ Object.defineProperty(exports, "count", {
|
|
|
5395
5421
|
enumerable: true,
|
|
5396
5422
|
get: function () { return core.count; }
|
|
5397
5423
|
});
|
|
5424
|
+
Object.defineProperty(exports, "deriveDecline", {
|
|
5425
|
+
enumerable: true,
|
|
5426
|
+
get: function () { return core.deriveDecline; }
|
|
5427
|
+
});
|
|
5428
|
+
Object.defineProperty(exports, "dispatchDeclineEvent", {
|
|
5429
|
+
enumerable: true,
|
|
5430
|
+
get: function () { return core.dispatchDeclineEvent; }
|
|
5431
|
+
});
|
|
5398
5432
|
Object.defineProperty(exports, "docId", {
|
|
5399
5433
|
enumerable: true,
|
|
5400
5434
|
get: function () { return core.docId; }
|