@pepu-chain/sdk 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +565 -2
- package/dist/aa/kernel.cjs +40 -0
- package/dist/aa/kernel.cjs.map +1 -0
- package/dist/aa/kernel.d.cts +88 -0
- package/dist/aa/kernel.d.ts +88 -0
- package/dist/aa/kernel.js +11 -0
- package/dist/aa/kernel.js.map +1 -0
- package/dist/aa/react-direct.cjs +110 -0
- package/dist/aa/react-direct.cjs.map +1 -0
- package/dist/aa/react-direct.d.cts +42 -0
- package/dist/aa/react-direct.d.ts +42 -0
- package/dist/aa/react-direct.js +107 -0
- package/dist/aa/react-direct.js.map +1 -0
- package/dist/aa/react.cjs +151 -0
- package/dist/aa/react.cjs.map +1 -0
- package/dist/aa/react.d.cts +62 -0
- package/dist/aa/react.d.ts +62 -0
- package/dist/aa/react.js +147 -0
- package/dist/aa/react.js.map +1 -0
- package/dist/aa.cjs +84 -0
- package/dist/aa.cjs.map +1 -0
- package/dist/aa.d.cts +85 -0
- package/dist/aa.d.ts +85 -0
- package/dist/aa.js +11 -0
- package/dist/aa.js.map +1 -0
- package/dist/api-Dz4sCHH_.d.cts +654 -0
- package/dist/api-Dz4sCHH_.d.ts +654 -0
- package/dist/calls-BRPjKgjl.d.cts +70 -0
- package/dist/calls-z_EQOtFb.d.ts +70 -0
- package/dist/chains-DK13zGIp.d.cts +235 -0
- package/dist/chains-DK13zGIp.d.ts +235 -0
- package/dist/chunk-3XUGQODR.js +194 -0
- package/dist/chunk-3XUGQODR.js.map +1 -0
- package/dist/chunk-45KSZH26.cjs +145 -0
- package/dist/chunk-45KSZH26.cjs.map +1 -0
- package/dist/chunk-4GINFJO6.cjs +44 -0
- package/dist/chunk-4GINFJO6.cjs.map +1 -0
- package/dist/chunk-62M2LKQW.js +136 -0
- package/dist/chunk-62M2LKQW.js.map +1 -0
- package/dist/chunk-6DSZ4Z2N.js +498 -0
- package/dist/chunk-6DSZ4Z2N.js.map +1 -0
- package/dist/chunk-7MNJF2OB.cjs +72 -0
- package/dist/chunk-7MNJF2OB.cjs.map +1 -0
- package/dist/chunk-A5LP2UCS.cjs +2729 -0
- package/dist/chunk-A5LP2UCS.cjs.map +1 -0
- package/dist/chunk-AJS4UFQX.cjs +121 -0
- package/dist/chunk-AJS4UFQX.cjs.map +1 -0
- package/dist/chunk-C2XW44FI.cjs +200 -0
- package/dist/chunk-C2XW44FI.cjs.map +1 -0
- package/dist/chunk-C7IC36XS.cjs +13 -0
- package/dist/chunk-C7IC36XS.cjs.map +1 -0
- package/dist/chunk-D52PADVY.js +84 -0
- package/dist/chunk-D52PADVY.js.map +1 -0
- package/dist/chunk-DH6BFNVJ.cjs +272 -0
- package/dist/chunk-DH6BFNVJ.cjs.map +1 -0
- package/dist/chunk-DPCZJLB3.cjs +87 -0
- package/dist/chunk-DPCZJLB3.cjs.map +1 -0
- package/dist/chunk-EHBPIYY4.js +262 -0
- package/dist/chunk-EHBPIYY4.js.map +1 -0
- package/dist/chunk-ESMNAXUI.js +86 -0
- package/dist/chunk-ESMNAXUI.js.map +1 -0
- package/dist/chunk-ET3P6TX6.cjs +49 -0
- package/dist/chunk-ET3P6TX6.cjs.map +1 -0
- package/dist/chunk-FCXSP2YF.js +219 -0
- package/dist/chunk-FCXSP2YF.js.map +1 -0
- package/dist/chunk-IB2FSPMJ.js +66 -0
- package/dist/chunk-IB2FSPMJ.js.map +1 -0
- package/dist/chunk-IG7RSL2Y.cjs +178 -0
- package/dist/chunk-IG7RSL2Y.cjs.map +1 -0
- package/dist/chunk-IY3ALPUJ.js +2716 -0
- package/dist/chunk-IY3ALPUJ.js.map +1 -0
- package/dist/chunk-J3O2ZGG3.cjs +93 -0
- package/dist/chunk-J3O2ZGG3.cjs.map +1 -0
- package/dist/chunk-J6UXXHBE.js +37 -0
- package/dist/chunk-J6UXXHBE.js.map +1 -0
- package/dist/chunk-JLZ4LZ4Z.js +22 -0
- package/dist/chunk-JLZ4LZ4Z.js.map +1 -0
- package/dist/chunk-KIIFL4VM.js +274 -0
- package/dist/chunk-KIIFL4VM.js.map +1 -0
- package/dist/chunk-KVG3AYYR.js +99 -0
- package/dist/chunk-KVG3AYYR.js.map +1 -0
- package/dist/chunk-MBA4CLA5.js +45 -0
- package/dist/chunk-MBA4CLA5.js.map +1 -0
- package/dist/chunk-NE3QKDOB.cjs +24 -0
- package/dist/chunk-NE3QKDOB.cjs.map +1 -0
- package/dist/chunk-NVOPDXTA.cjs +95 -0
- package/dist/chunk-NVOPDXTA.cjs.map +1 -0
- package/dist/chunk-OH3QMAIB.js +11 -0
- package/dist/chunk-OH3QMAIB.js.map +1 -0
- package/dist/chunk-PHM3ZORG.cjs +110 -0
- package/dist/chunk-PHM3ZORG.cjs.map +1 -0
- package/dist/chunk-R5PXQNO3.cjs +209 -0
- package/dist/chunk-R5PXQNO3.cjs.map +1 -0
- package/dist/chunk-SLW7FRTL.cjs +285 -0
- package/dist/chunk-SLW7FRTL.cjs.map +1 -0
- package/dist/chunk-SVWRRALU.cjs +17 -0
- package/dist/chunk-SVWRRALU.cjs.map +1 -0
- package/dist/chunk-T43PQXJD.js +202 -0
- package/dist/chunk-T43PQXJD.js.map +1 -0
- package/dist/chunk-TIEAZYHF.cjs +225 -0
- package/dist/chunk-TIEAZYHF.cjs.map +1 -0
- package/dist/chunk-VBH3JLQ5.js +116 -0
- package/dist/chunk-VBH3JLQ5.js.map +1 -0
- package/dist/chunk-VF3D6KLQ.cjs +94 -0
- package/dist/chunk-VF3D6KLQ.cjs.map +1 -0
- package/dist/chunk-VTQIHMF3.js +82 -0
- package/dist/chunk-VTQIHMF3.js.map +1 -0
- package/dist/chunk-W3JN3YIW.js +15 -0
- package/dist/chunk-W3JN3YIW.js.map +1 -0
- package/dist/chunk-WANILJZQ.cjs +87 -0
- package/dist/chunk-WANILJZQ.cjs.map +1 -0
- package/dist/chunk-XC4IBCI2.js +86 -0
- package/dist/chunk-XC4IBCI2.js.map +1 -0
- package/dist/chunk-YKEWWQEJ.js +165 -0
- package/dist/chunk-YKEWWQEJ.js.map +1 -0
- package/dist/chunk-YQL7NISX.cjs +515 -0
- package/dist/chunk-YQL7NISX.cjs.map +1 -0
- package/dist/chunk-ZB6SVBK4.js +89 -0
- package/dist/chunk-ZB6SVBK4.js.map +1 -0
- package/dist/combo/react.cjs +235 -0
- package/dist/combo/react.cjs.map +1 -0
- package/dist/combo/react.d.cts +148 -0
- package/dist/combo/react.d.ts +148 -0
- package/dist/combo/react.js +230 -0
- package/dist/combo/react.js.map +1 -0
- package/dist/combo.cjs +262 -0
- package/dist/combo.cjs.map +1 -0
- package/dist/combo.d.cts +139 -0
- package/dist/combo.d.ts +139 -0
- package/dist/combo.js +249 -0
- package/dist/combo.js.map +1 -0
- package/dist/config-CHjz7ZjZ.d.cts +57 -0
- package/dist/config-COjhIZTh.d.ts +57 -0
- package/dist/doctor.cjs +354 -0
- package/dist/doctor.cjs.map +1 -0
- package/dist/doctor.d.cts +177 -0
- package/dist/doctor.d.ts +177 -0
- package/dist/doctor.js +345 -0
- package/dist/doctor.js.map +1 -0
- package/dist/erc7677-DOW58QBE.d.cts +111 -0
- package/dist/erc7677-DOW58QBE.d.ts +111 -0
- package/dist/errors-CgX1vNj7.d.cts +100 -0
- package/dist/errors-CgX1vNj7.d.ts +100 -0
- package/dist/index.cjs +802 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2398 -0
- package/dist/index.d.ts +2398 -0
- package/dist/index.js +559 -0
- package/dist/index.js.map +1 -0
- package/dist/paymaster/server.cjs +38 -0
- package/dist/paymaster/server.cjs.map +1 -0
- package/dist/paymaster/server.d.cts +57 -0
- package/dist/paymaster/server.d.ts +57 -0
- package/dist/paymaster/server.js +36 -0
- package/dist/paymaster/server.js.map +1 -0
- package/dist/paymaster.cjs +356 -0
- package/dist/paymaster.cjs.map +1 -0
- package/dist/paymaster.d.cts +1851 -0
- package/dist/paymaster.d.ts +1851 -0
- package/dist/paymaster.js +289 -0
- package/dist/paymaster.js.map +1 -0
- package/dist/privy/react.cjs +48 -0
- package/dist/privy/react.cjs.map +1 -0
- package/dist/privy/react.d.cts +194 -0
- package/dist/privy/react.d.ts +194 -0
- package/dist/privy/react.js +7 -0
- package/dist/privy/react.js.map +1 -0
- package/dist/privy/server.cjs +43 -0
- package/dist/privy/server.cjs.map +1 -0
- package/dist/privy/server.d.cts +192 -0
- package/dist/privy/server.d.ts +192 -0
- package/dist/privy/server.js +6 -0
- package/dist/privy/server.js.map +1 -0
- package/dist/privy/wagmi.d.ts +90 -0
- package/dist/privy/wagmi.js +55 -0
- package/dist/privy/wagmi.js.map +1 -0
- package/dist/privy.cjs +34 -0
- package/dist/privy.cjs.map +1 -0
- package/dist/privy.d.cts +4 -0
- package/dist/privy.d.ts +4 -0
- package/dist/privy.js +5 -0
- package/dist/privy.js.map +1 -0
- package/dist/react.cjs +72 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +66 -0
- package/dist/react.d.ts +66 -0
- package/dist/react.js +68 -0
- package/dist/react.js.map +1 -0
- package/dist/requirements-C-QiJkL9.d.cts +134 -0
- package/dist/requirements-C-QiJkL9.d.ts +134 -0
- package/dist/scope-DBRkN7bR.d.cts +94 -0
- package/dist/scope-DBRkN7bR.d.ts +94 -0
- package/dist/server.cjs +59 -0
- package/dist/server.cjs.map +1 -0
- package/dist/server.d.cts +208 -0
- package/dist/server.d.ts +208 -0
- package/dist/server.js +8 -0
- package/dist/server.js.map +1 -0
- package/dist/session/kernel.cjs +82 -0
- package/dist/session/kernel.cjs.map +1 -0
- package/dist/session/kernel.d.cts +131 -0
- package/dist/session/kernel.d.ts +131 -0
- package/dist/session/kernel.js +13 -0
- package/dist/session/kernel.js.map +1 -0
- package/dist/session/react.cjs +37 -0
- package/dist/session/react.cjs.map +1 -0
- package/dist/session/react.d.cts +119 -0
- package/dist/session/react.d.ts +119 -0
- package/dist/session/react.js +8 -0
- package/dist/session/react.js.map +1 -0
- package/dist/session/server.cjs +267 -0
- package/dist/session/server.cjs.map +1 -0
- package/dist/session/server.d.cts +151 -0
- package/dist/session/server.d.ts +151 -0
- package/dist/session/server.js +252 -0
- package/dist/session/server.js.map +1 -0
- package/dist/session.cjs +74 -0
- package/dist/session.cjs.map +1 -0
- package/dist/session.d.cts +3 -0
- package/dist/session.d.ts +3 -0
- package/dist/session.js +5 -0
- package/dist/session.js.map +1 -0
- package/dist/status-CmOsyPmO.d.cts +295 -0
- package/dist/status-DwkkOrGQ.d.ts +295 -0
- package/dist/store-CjmLgp9g.d.cts +64 -0
- package/dist/store-CjmLgp9g.d.ts +64 -0
- package/dist/types-BEEM7WdG.d.cts +25 -0
- package/dist/types-BEEM7WdG.d.ts +25 -0
- package/dist/types-BilBTDqK.d.cts +27 -0
- package/dist/types-BilBTDqK.d.ts +27 -0
- package/package.json +209 -3
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { ReactNode, ComponentType, ReactElement } from 'react';
|
|
2
|
+
import { ConnectedWallet } from '@privy-io/react-auth';
|
|
3
|
+
import { Address } from 'viem';
|
|
4
|
+
import { P as PepuError } from '../errors-CgX1vNj7.js';
|
|
5
|
+
import { C as CreatePepuPrivyConfigOptions } from '../config-COjhIZTh.js';
|
|
6
|
+
import '../chains-DK13zGIp.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* POST to the ensure-wallet route with the user's Privy access token and return
|
|
10
|
+
* the wallet address. Bounded by a timeout. Never leaks the token in errors.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const { address } = await requestEnsureWallet({ getAccessToken, endpoint: "/api/wallet/ensure" });
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
declare function requestEnsureWallet(o: {
|
|
18
|
+
getAccessToken: () => Promise<string | null>;
|
|
19
|
+
endpoint?: string;
|
|
20
|
+
timeoutMs?: number;
|
|
21
|
+
fetch?: typeof fetch;
|
|
22
|
+
signal?: AbortSignal;
|
|
23
|
+
}): Promise<{
|
|
24
|
+
address: Address;
|
|
25
|
+
created: boolean;
|
|
26
|
+
}>;
|
|
27
|
+
|
|
28
|
+
interface PepuPrivyProviderProps {
|
|
29
|
+
/** Privy app id. When missing, `fallback` renders instead of throwing deep inside Privy. */
|
|
30
|
+
appId: string | undefined;
|
|
31
|
+
/** Overrides for {@link createPepuPrivyConfig}. */
|
|
32
|
+
config?: Partial<CreatePepuPrivyConfigOptions> | undefined;
|
|
33
|
+
/** Shown when `appId` is empty. Defaults to a short notice naming the env variable. */
|
|
34
|
+
fallback?: ReactNode;
|
|
35
|
+
/**
|
|
36
|
+
* Extra providers rendered inside PrivyProvider (used by `/privy/wagmi`).
|
|
37
|
+
* Build one with {@link composeProviders}.
|
|
38
|
+
*/
|
|
39
|
+
wrapper?: ComponentType<{
|
|
40
|
+
children?: ReactNode;
|
|
41
|
+
}> | undefined;
|
|
42
|
+
children?: ReactNode;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Compose providers (outermost first) into one wrapper component, with optional
|
|
46
|
+
* leaf components rendered next to `children` in the innermost position. A
|
|
47
|
+
* building block for `/privy/wagmi`; it keeps `react` imports in this entry.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* const Wrapper = composeProviders([[QueryClientProvider, { client }]], [MyEffectOnlyComponent]);
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
declare function composeProviders(layers: readonly (readonly [ComponentType<any>, Record<string, unknown>])[], // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
55
|
+
leaves?: readonly ComponentType<Record<string, never>>[]): ComponentType<{
|
|
56
|
+
children?: ReactNode;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* `<PrivyProvider>` preconfigured for PEPU: mainnet only, Coinbase pinned to
|
|
60
|
+
* `eoaOnly`, wallet creation off (the server provisions it, see
|
|
61
|
+
* {@link WalletGate}). Renders `fallback` instead of crashing when `appId` is
|
|
62
|
+
* missing.
|
|
63
|
+
*
|
|
64
|
+
* Ported from templates/consumer-app/app/providers.tsx.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```tsx
|
|
68
|
+
* <PepuPrivyProvider appId={process.env.NEXT_PUBLIC_PRIVY_APP_ID} config={{ loginMethods: ["email", "google"] }}>
|
|
69
|
+
* <App />
|
|
70
|
+
* </PepuPrivyProvider>
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
declare function PepuPrivyProvider(props: PepuPrivyProviderProps): ReactElement;
|
|
74
|
+
/**
|
|
75
|
+
* This user's Privy embedded wallet, separated from any external wallet Privy
|
|
76
|
+
* is tracking (an installed MetaMask or Phantom). Never re-implements the
|
|
77
|
+
* embedded filter: it calls Privy's `getEmbeddedConnectedWallet`.
|
|
78
|
+
*
|
|
79
|
+
* Ported from templates/consumer-app/lib/wallet.ts (`useWalletSnapshot`).
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```tsx
|
|
83
|
+
* const { ready, address, external } = useEmbeddedWallet();
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
declare function useEmbeddedWallet(): {
|
|
87
|
+
ready: boolean;
|
|
88
|
+
wallet: ConnectedWallet | null;
|
|
89
|
+
address?: Address;
|
|
90
|
+
external: ConnectedWallet[];
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Pure decision behind the pin hooks: pin only when enabled, hydrated, an
|
|
94
|
+
* embedded wallet exists and the active account is not already it. The address
|
|
95
|
+
* comparison is what prevents a render loop.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* shouldPinEmbeddedWallet({ enabled: true, ready: true, embeddedAddress: "0xA", activeAddress: "0xB" }); // true
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
declare function shouldPinEmbeddedWallet(o: {
|
|
103
|
+
enabled: boolean;
|
|
104
|
+
ready: boolean;
|
|
105
|
+
embeddedAddress: string | undefined;
|
|
106
|
+
activeAddress: string | undefined;
|
|
107
|
+
}): boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Generic half of the active-wallet pin: re-asserts the embedded wallet whenever
|
|
110
|
+
* the active account drifts away from it. `useActiveWalletPin` in
|
|
111
|
+
* `/privy/wagmi` supplies wagmi's active address and `setActiveWallet`.
|
|
112
|
+
*
|
|
113
|
+
* Ported from templates/consumer-app/lib/wallet.ts (`useActiveWalletSync`).
|
|
114
|
+
* A user with no embedded wallet is left alone on purpose.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* usePinEmbeddedWallet({ enabled: true, activeAddress, setActiveWallet });
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
declare function usePinEmbeddedWallet(o: {
|
|
122
|
+
enabled: boolean;
|
|
123
|
+
activeAddress: string | undefined;
|
|
124
|
+
setActiveWallet: (wallet: ConnectedWallet) => Promise<unknown> | void;
|
|
125
|
+
}): void;
|
|
126
|
+
type FetchInput = Parameters<typeof fetch>[0];
|
|
127
|
+
type EnsureWalletStatus = "idle" | "checking" | "creating" | "ready" | "stalled" | "error";
|
|
128
|
+
/**
|
|
129
|
+
* Provision this user's embedded wallet through the ensure-wallet route (see
|
|
130
|
+
* `createEnsureWalletRoute` in `/privy/server`), not Privy's client-side
|
|
131
|
+
* creation, which hangs for apps with the dashboard's creation setting off.
|
|
132
|
+
* Gates on the EMBEDDED wallet, never on "any connected wallet".
|
|
133
|
+
*
|
|
134
|
+
* Ported from templates/consumer-app/components/wallet-gate.tsx.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```tsx
|
|
138
|
+
* const { status, address, error, retry } = useEnsureWallet();
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
declare function useEnsureWallet(o?: {
|
|
142
|
+
endpoint?: string;
|
|
143
|
+
requestTimeoutMs?: number;
|
|
144
|
+
appearTimeoutMs?: number;
|
|
145
|
+
}): {
|
|
146
|
+
status: EnsureWalletStatus;
|
|
147
|
+
address?: Address;
|
|
148
|
+
error?: PepuError;
|
|
149
|
+
retry(): void;
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Renders `children` once the user's embedded wallet exists, provisioning it
|
|
153
|
+
* first through the ensure-wallet route. Shows `loading`, an error (with
|
|
154
|
+
* retry) or a reload prompt when the wallet exists but has not synced yet.
|
|
155
|
+
* Each of the three states takes a render prop (`loading`, `error`, `stalled`)
|
|
156
|
+
* so an app can use the gate directly with its own markup and classes.
|
|
157
|
+
*
|
|
158
|
+
* Ported from templates/consumer-app/components/wallet-gate.tsx.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```tsx
|
|
162
|
+
* <WalletGate
|
|
163
|
+
* loading={<Spinner />}
|
|
164
|
+
* error={(e, retry) => <button onClick={retry}>{e.message}</button>}
|
|
165
|
+
* stalled={(address, reload) => <button onClick={reload}>Reload ({address})</button>}
|
|
166
|
+
* >
|
|
167
|
+
* <Dashboard />
|
|
168
|
+
* </WalletGate>
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
declare function WalletGate(p: {
|
|
172
|
+
endpoint?: string;
|
|
173
|
+
loading?: ReactNode;
|
|
174
|
+
error?: (e: PepuError, retry: () => void) => ReactNode;
|
|
175
|
+
/**
|
|
176
|
+
* The server confirmed the wallet but this session has not seen it after a
|
|
177
|
+
* bounded wait (a client sync delay). `reload` reloads the page.
|
|
178
|
+
*/
|
|
179
|
+
stalled?: (address: Address, reload: () => void) => ReactNode;
|
|
180
|
+
children: ReactNode;
|
|
181
|
+
}): ReactElement;
|
|
182
|
+
/**
|
|
183
|
+
* A `fetch` that attaches `Authorization: Bearer <Privy access token>`. Throws
|
|
184
|
+
* {@link PepuAuthError} when there is no token (signed out or expired).
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```tsx
|
|
188
|
+
* const authFetch = usePepuAuthFetch();
|
|
189
|
+
* const res = await authFetch("/api/session/status");
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
declare function usePepuAuthFetch(): (input: FetchInput, init?: RequestInit) => Promise<Response>;
|
|
193
|
+
|
|
194
|
+
export { type EnsureWalletStatus, PepuPrivyProvider, type PepuPrivyProviderProps, WalletGate, composeProviders, requestEnsureWallet, shouldPinEmbeddedWallet, useEmbeddedWallet, useEnsureWallet, usePepuAuthFetch, usePinEmbeddedWallet };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { PepuPrivyProvider, WalletGate, composeProviders, requestEnsureWallet, shouldPinEmbeddedWallet, useEmbeddedWallet, useEnsureWallet, usePepuAuthFetch, usePinEmbeddedWallet } from '../chunk-EHBPIYY4.js';
|
|
2
|
+
import '../chunk-JLZ4LZ4Z.js';
|
|
3
|
+
import '../chunk-VTQIHMF3.js';
|
|
4
|
+
import '../chunk-3XUGQODR.js';
|
|
5
|
+
import '../chunk-6DSZ4Z2N.js';
|
|
6
|
+
//# sourceMappingURL=react.js.map
|
|
7
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"react.js"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk45KSZH26_cjs = require('../chunk-45KSZH26.cjs');
|
|
4
|
+
require('../chunk-SVWRRALU.cjs');
|
|
5
|
+
require('../chunk-C2XW44FI.cjs');
|
|
6
|
+
require('../chunk-YQL7NISX.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, "createEnsureWalletRoute", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () { return chunk45KSZH26_cjs.createEnsureWalletRoute; }
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "createPrivyServer", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return chunk45KSZH26_cjs.createPrivyServer; }
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "findDelegatedEthereumWallet", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return chunk45KSZH26_cjs.findDelegatedEthereumWallet; }
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(exports, "findEmbeddedEthereumWallet", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () { return chunk45KSZH26_cjs.findEmbeddedEthereumWallet; }
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(exports, "privyEnvVar", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function () { return chunk45KSZH26_cjs.privyEnvVar; }
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "readPrivyServerEnv", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () { return chunk45KSZH26_cjs.readPrivyServerEnv; }
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(exports, "requireUser", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function () { return chunk45KSZH26_cjs.requireUser; }
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(exports, "verifyRequestUser", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () { return chunk45KSZH26_cjs.verifyRequestUser; }
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=server.cjs.map
|
|
43
|
+
//# sourceMappingURL=server.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"server.cjs"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { LinkedAccountEmbeddedWallet, LinkedAccount, PrivyClient } from '@privy-io/node';
|
|
2
|
+
import { Address } from 'viem';
|
|
3
|
+
import { a as PRIVY_ENV } from '../requirements-C-QiJkL9.cjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `@pepu-chain/sdk/privy/server` (server). Privy server client, access-token
|
|
7
|
+
* verification and the ensure-wallet route factory. Never import it from
|
|
8
|
+
* client code: it calls `assertServerOnly()` at import.
|
|
9
|
+
*
|
|
10
|
+
* Optional peer: `@privy-io/node`.
|
|
11
|
+
*/
|
|
12
|
+
/** A Privy linked embedded-wallet account. */
|
|
13
|
+
type LinkedWallet = LinkedAccountEmbeddedWallet;
|
|
14
|
+
/** The part of a Privy user object these helpers read. */
|
|
15
|
+
interface PrivyUser {
|
|
16
|
+
linked_accounts: readonly LinkedAccount[];
|
|
17
|
+
}
|
|
18
|
+
/** The authenticated caller, as returned by {@link requireUser}. */
|
|
19
|
+
interface PepuUser {
|
|
20
|
+
/** The Privy user id, only ever taken from a verified access token. */
|
|
21
|
+
userId: string;
|
|
22
|
+
/** The user's embedded Ethereum wallet address, `null` if not provisioned yet. */
|
|
23
|
+
address: Address | null;
|
|
24
|
+
/** The Privy user object the address was read from. */
|
|
25
|
+
privyUser: PrivyUser;
|
|
26
|
+
}
|
|
27
|
+
/** Server-side Privy configuration read from the environment. */
|
|
28
|
+
interface PrivyServerEnv {
|
|
29
|
+
appId: string;
|
|
30
|
+
appSecret: string;
|
|
31
|
+
/** Private half of the authorization key. Only sessions need it. */
|
|
32
|
+
authorizationKey?: string;
|
|
33
|
+
/** The key quorum id sessions grant. Only sessions need it. */
|
|
34
|
+
keyQuorumId?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The single reader for the Privy variables ({@link PRIVY_ENV}, then its
|
|
38
|
+
* aliases). Trimmed; `undefined` when unset or blank. Session routes use it
|
|
39
|
+
* too, so every module agrees on names.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* const quorum = privyEnvVar("keyQuorumId");
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
declare function privyEnvVar(name: keyof typeof PRIVY_ENV): string | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Read the Privy server variables ({@link PRIVY_ENV}), explicit options winning.
|
|
49
|
+
* Throws a `PepuConfigError` that lists every missing variable by NAME only.
|
|
50
|
+
* `PRIVY_AUTHORIZATION_KEY` is optional here (ensure-wallet never needs it).
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* const { appId, appSecret } = readPrivyServerEnv();
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
declare function readPrivyServerEnv(o?: {
|
|
58
|
+
appId?: string;
|
|
59
|
+
appSecret?: string;
|
|
60
|
+
authorizationKey?: string;
|
|
61
|
+
keyQuorumId?: string;
|
|
62
|
+
}): PrivyServerEnv;
|
|
63
|
+
/**
|
|
64
|
+
* A cached `PrivyClient` (`@privy-io/node`) built from {@link PRIVY_ENV}. One
|
|
65
|
+
* instance per distinct credential set. The authorization key is not given to
|
|
66
|
+
* the client: Privy takes it per request (`authorization_context`), see
|
|
67
|
+
* {@link readPrivyServerEnv}.
|
|
68
|
+
*
|
|
69
|
+
* Ported from templates/consumer-app/lib/privy-server.ts.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* const privy = createPrivyServer();
|
|
74
|
+
* const user = await privy.users()._get(userId);
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
declare function createPrivyServer(o?: {
|
|
78
|
+
appId?: string;
|
|
79
|
+
appSecret?: string;
|
|
80
|
+
authorizationKey?: string;
|
|
81
|
+
keyQuorumId?: string;
|
|
82
|
+
}): PrivyClient;
|
|
83
|
+
/**
|
|
84
|
+
* Verify the `Authorization: Bearer <token>` header against Privy and return the
|
|
85
|
+
* caller's Privy user id and claims. Throws `PepuAuthError` (`AUTH_INVALID_TOKEN`,
|
|
86
|
+
* HTTP 401) when the header is missing or the token does not verify. The reason
|
|
87
|
+
* Privy gave goes in `details.reason` (token redacted): a verification failure
|
|
88
|
+
* caused by a mismatched `PRIVY_APP_SECRET` looks exactly like an expired
|
|
89
|
+
* session, so check it first.
|
|
90
|
+
*
|
|
91
|
+
* Note `verifyAccessToken(token)` on `privy.utils().auth()` takes a bare string,
|
|
92
|
+
* not `{ access_token }` (that is the standalone function's signature).
|
|
93
|
+
*
|
|
94
|
+
* Ported from templates/consumer-app/lib/privy-auth.ts.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```ts
|
|
98
|
+
* const { userId } = await verifyRequestUser(request);
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
declare function verifyRequestUser(request: Request, o?: {
|
|
102
|
+
privy?: PrivyClient;
|
|
103
|
+
}): Promise<{
|
|
104
|
+
userId: string;
|
|
105
|
+
claims: unknown;
|
|
106
|
+
}>;
|
|
107
|
+
/**
|
|
108
|
+
* The user's Ethereum embedded wallet (delegated or not), or `null`. This is
|
|
109
|
+
* what makes ensure-wallet idempotent.
|
|
110
|
+
*
|
|
111
|
+
* Ported from templates/consumer-app/lib/privy-user.ts.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```ts
|
|
115
|
+
* const wallet = findEmbeddedEthereumWallet(user);
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
declare function findEmbeddedEthereumWallet(user: PrivyUser): LinkedWallet | null;
|
|
119
|
+
/**
|
|
120
|
+
* The user's Ethereum embedded wallet that has been delegated (granted a
|
|
121
|
+
* session signer), or `null`.
|
|
122
|
+
*
|
|
123
|
+
* Ported from templates/game-app/lib/privy-user.ts.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```ts
|
|
127
|
+
* const wallet = findDelegatedEthereumWallet(user);
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
declare function findDelegatedEthereumWallet(user: PrivyUser): LinkedWallet | null;
|
|
131
|
+
/**
|
|
132
|
+
* Authenticate a request for a route handler. On success returns the user id
|
|
133
|
+
* (from the verified token only) and the user's embedded wallet address. On
|
|
134
|
+
* failure returns a ready JSON `Response` (`{ error: { code, message, hint } }`:
|
|
135
|
+
* 401 for a bad token, 500 for missing config, 502 if Privy cannot be reached).
|
|
136
|
+
* Never throws.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```ts
|
|
140
|
+
* export async function POST(request: Request) {
|
|
141
|
+
* const auth = await requireUser(request);
|
|
142
|
+
* if (!auth.ok) return auth.response;
|
|
143
|
+
* return Response.json({ userId: auth.user.userId });
|
|
144
|
+
* }
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
declare function requireUser(request: Request, o?: {
|
|
148
|
+
privy?: PrivyClient;
|
|
149
|
+
}): Promise<{
|
|
150
|
+
ok: true;
|
|
151
|
+
user: PepuUser;
|
|
152
|
+
} | {
|
|
153
|
+
ok: false;
|
|
154
|
+
response: Response;
|
|
155
|
+
}>;
|
|
156
|
+
/**
|
|
157
|
+
* Next.js route handler that creates the signed-in user's Ethereum embedded
|
|
158
|
+
* wallet server-side if they have none. Drop-in:
|
|
159
|
+
* `export const { POST } = createEnsureWalletRoute();` in
|
|
160
|
+
* `app/api/wallet/ensure/route.ts`.
|
|
161
|
+
*
|
|
162
|
+
* Why: Privy's own client-side creation hangs forever for apps whose dashboard
|
|
163
|
+
* creation setting is off; pair it with `createOnLogin: "off"` (the default of
|
|
164
|
+
* `createPepuPrivyConfig`) and `WalletGate`.
|
|
165
|
+
*
|
|
166
|
+
* - CUSTODY: the wallet is created with `owner: { user_id }`. This backend holds
|
|
167
|
+
* no signing authority over it. Do not add a session signer here.
|
|
168
|
+
* - SECURITY: the user id comes only from the verified access token, never from
|
|
169
|
+
* the body or query string.
|
|
170
|
+
* - IDEMPOTENT: it looks for an existing wallet first and re-checks after a
|
|
171
|
+
* failed create, so a double submit never makes a second wallet.
|
|
172
|
+
*
|
|
173
|
+
* Ported from templates/consumer-app/app/api/wallet/ensure/route.ts.
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```ts
|
|
177
|
+
* // app/api/wallet/ensure/route.ts
|
|
178
|
+
* import { createEnsureWalletRoute } from "@pepu-chain/sdk/privy/server";
|
|
179
|
+
* export const { POST } = createEnsureWalletRoute();
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
declare function createEnsureWalletRoute(o?: {
|
|
183
|
+
privy?: PrivyClient;
|
|
184
|
+
onCreated?: (c: {
|
|
185
|
+
userId: string;
|
|
186
|
+
address: Address;
|
|
187
|
+
}) => Promise<void>;
|
|
188
|
+
}): {
|
|
189
|
+
POST(request: Request): Promise<Response>;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export { type LinkedWallet, type PepuUser, type PrivyServerEnv, type PrivyUser, createEnsureWalletRoute, createPrivyServer, findDelegatedEthereumWallet, findEmbeddedEthereumWallet, privyEnvVar, readPrivyServerEnv, requireUser, verifyRequestUser };
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { LinkedAccountEmbeddedWallet, LinkedAccount, PrivyClient } from '@privy-io/node';
|
|
2
|
+
import { Address } from 'viem';
|
|
3
|
+
import { a as PRIVY_ENV } from '../requirements-C-QiJkL9.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `@pepu-chain/sdk/privy/server` (server). Privy server client, access-token
|
|
7
|
+
* verification and the ensure-wallet route factory. Never import it from
|
|
8
|
+
* client code: it calls `assertServerOnly()` at import.
|
|
9
|
+
*
|
|
10
|
+
* Optional peer: `@privy-io/node`.
|
|
11
|
+
*/
|
|
12
|
+
/** A Privy linked embedded-wallet account. */
|
|
13
|
+
type LinkedWallet = LinkedAccountEmbeddedWallet;
|
|
14
|
+
/** The part of a Privy user object these helpers read. */
|
|
15
|
+
interface PrivyUser {
|
|
16
|
+
linked_accounts: readonly LinkedAccount[];
|
|
17
|
+
}
|
|
18
|
+
/** The authenticated caller, as returned by {@link requireUser}. */
|
|
19
|
+
interface PepuUser {
|
|
20
|
+
/** The Privy user id, only ever taken from a verified access token. */
|
|
21
|
+
userId: string;
|
|
22
|
+
/** The user's embedded Ethereum wallet address, `null` if not provisioned yet. */
|
|
23
|
+
address: Address | null;
|
|
24
|
+
/** The Privy user object the address was read from. */
|
|
25
|
+
privyUser: PrivyUser;
|
|
26
|
+
}
|
|
27
|
+
/** Server-side Privy configuration read from the environment. */
|
|
28
|
+
interface PrivyServerEnv {
|
|
29
|
+
appId: string;
|
|
30
|
+
appSecret: string;
|
|
31
|
+
/** Private half of the authorization key. Only sessions need it. */
|
|
32
|
+
authorizationKey?: string;
|
|
33
|
+
/** The key quorum id sessions grant. Only sessions need it. */
|
|
34
|
+
keyQuorumId?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The single reader for the Privy variables ({@link PRIVY_ENV}, then its
|
|
38
|
+
* aliases). Trimmed; `undefined` when unset or blank. Session routes use it
|
|
39
|
+
* too, so every module agrees on names.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* const quorum = privyEnvVar("keyQuorumId");
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
declare function privyEnvVar(name: keyof typeof PRIVY_ENV): string | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Read the Privy server variables ({@link PRIVY_ENV}), explicit options winning.
|
|
49
|
+
* Throws a `PepuConfigError` that lists every missing variable by NAME only.
|
|
50
|
+
* `PRIVY_AUTHORIZATION_KEY` is optional here (ensure-wallet never needs it).
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* const { appId, appSecret } = readPrivyServerEnv();
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
declare function readPrivyServerEnv(o?: {
|
|
58
|
+
appId?: string;
|
|
59
|
+
appSecret?: string;
|
|
60
|
+
authorizationKey?: string;
|
|
61
|
+
keyQuorumId?: string;
|
|
62
|
+
}): PrivyServerEnv;
|
|
63
|
+
/**
|
|
64
|
+
* A cached `PrivyClient` (`@privy-io/node`) built from {@link PRIVY_ENV}. One
|
|
65
|
+
* instance per distinct credential set. The authorization key is not given to
|
|
66
|
+
* the client: Privy takes it per request (`authorization_context`), see
|
|
67
|
+
* {@link readPrivyServerEnv}.
|
|
68
|
+
*
|
|
69
|
+
* Ported from templates/consumer-app/lib/privy-server.ts.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* const privy = createPrivyServer();
|
|
74
|
+
* const user = await privy.users()._get(userId);
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
declare function createPrivyServer(o?: {
|
|
78
|
+
appId?: string;
|
|
79
|
+
appSecret?: string;
|
|
80
|
+
authorizationKey?: string;
|
|
81
|
+
keyQuorumId?: string;
|
|
82
|
+
}): PrivyClient;
|
|
83
|
+
/**
|
|
84
|
+
* Verify the `Authorization: Bearer <token>` header against Privy and return the
|
|
85
|
+
* caller's Privy user id and claims. Throws `PepuAuthError` (`AUTH_INVALID_TOKEN`,
|
|
86
|
+
* HTTP 401) when the header is missing or the token does not verify. The reason
|
|
87
|
+
* Privy gave goes in `details.reason` (token redacted): a verification failure
|
|
88
|
+
* caused by a mismatched `PRIVY_APP_SECRET` looks exactly like an expired
|
|
89
|
+
* session, so check it first.
|
|
90
|
+
*
|
|
91
|
+
* Note `verifyAccessToken(token)` on `privy.utils().auth()` takes a bare string,
|
|
92
|
+
* not `{ access_token }` (that is the standalone function's signature).
|
|
93
|
+
*
|
|
94
|
+
* Ported from templates/consumer-app/lib/privy-auth.ts.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```ts
|
|
98
|
+
* const { userId } = await verifyRequestUser(request);
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
declare function verifyRequestUser(request: Request, o?: {
|
|
102
|
+
privy?: PrivyClient;
|
|
103
|
+
}): Promise<{
|
|
104
|
+
userId: string;
|
|
105
|
+
claims: unknown;
|
|
106
|
+
}>;
|
|
107
|
+
/**
|
|
108
|
+
* The user's Ethereum embedded wallet (delegated or not), or `null`. This is
|
|
109
|
+
* what makes ensure-wallet idempotent.
|
|
110
|
+
*
|
|
111
|
+
* Ported from templates/consumer-app/lib/privy-user.ts.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```ts
|
|
115
|
+
* const wallet = findEmbeddedEthereumWallet(user);
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
declare function findEmbeddedEthereumWallet(user: PrivyUser): LinkedWallet | null;
|
|
119
|
+
/**
|
|
120
|
+
* The user's Ethereum embedded wallet that has been delegated (granted a
|
|
121
|
+
* session signer), or `null`.
|
|
122
|
+
*
|
|
123
|
+
* Ported from templates/game-app/lib/privy-user.ts.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```ts
|
|
127
|
+
* const wallet = findDelegatedEthereumWallet(user);
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
declare function findDelegatedEthereumWallet(user: PrivyUser): LinkedWallet | null;
|
|
131
|
+
/**
|
|
132
|
+
* Authenticate a request for a route handler. On success returns the user id
|
|
133
|
+
* (from the verified token only) and the user's embedded wallet address. On
|
|
134
|
+
* failure returns a ready JSON `Response` (`{ error: { code, message, hint } }`:
|
|
135
|
+
* 401 for a bad token, 500 for missing config, 502 if Privy cannot be reached).
|
|
136
|
+
* Never throws.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```ts
|
|
140
|
+
* export async function POST(request: Request) {
|
|
141
|
+
* const auth = await requireUser(request);
|
|
142
|
+
* if (!auth.ok) return auth.response;
|
|
143
|
+
* return Response.json({ userId: auth.user.userId });
|
|
144
|
+
* }
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
declare function requireUser(request: Request, o?: {
|
|
148
|
+
privy?: PrivyClient;
|
|
149
|
+
}): Promise<{
|
|
150
|
+
ok: true;
|
|
151
|
+
user: PepuUser;
|
|
152
|
+
} | {
|
|
153
|
+
ok: false;
|
|
154
|
+
response: Response;
|
|
155
|
+
}>;
|
|
156
|
+
/**
|
|
157
|
+
* Next.js route handler that creates the signed-in user's Ethereum embedded
|
|
158
|
+
* wallet server-side if they have none. Drop-in:
|
|
159
|
+
* `export const { POST } = createEnsureWalletRoute();` in
|
|
160
|
+
* `app/api/wallet/ensure/route.ts`.
|
|
161
|
+
*
|
|
162
|
+
* Why: Privy's own client-side creation hangs forever for apps whose dashboard
|
|
163
|
+
* creation setting is off; pair it with `createOnLogin: "off"` (the default of
|
|
164
|
+
* `createPepuPrivyConfig`) and `WalletGate`.
|
|
165
|
+
*
|
|
166
|
+
* - CUSTODY: the wallet is created with `owner: { user_id }`. This backend holds
|
|
167
|
+
* no signing authority over it. Do not add a session signer here.
|
|
168
|
+
* - SECURITY: the user id comes only from the verified access token, never from
|
|
169
|
+
* the body or query string.
|
|
170
|
+
* - IDEMPOTENT: it looks for an existing wallet first and re-checks after a
|
|
171
|
+
* failed create, so a double submit never makes a second wallet.
|
|
172
|
+
*
|
|
173
|
+
* Ported from templates/consumer-app/app/api/wallet/ensure/route.ts.
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```ts
|
|
177
|
+
* // app/api/wallet/ensure/route.ts
|
|
178
|
+
* import { createEnsureWalletRoute } from "@pepu-chain/sdk/privy/server";
|
|
179
|
+
* export const { POST } = createEnsureWalletRoute();
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
declare function createEnsureWalletRoute(o?: {
|
|
183
|
+
privy?: PrivyClient;
|
|
184
|
+
onCreated?: (c: {
|
|
185
|
+
userId: string;
|
|
186
|
+
address: Address;
|
|
187
|
+
}) => Promise<void>;
|
|
188
|
+
}): {
|
|
189
|
+
POST(request: Request): Promise<Response>;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export { type LinkedWallet, type PepuUser, type PrivyServerEnv, type PrivyUser, createEnsureWalletRoute, createPrivyServer, findDelegatedEthereumWallet, findEmbeddedEthereumWallet, privyEnvVar, readPrivyServerEnv, requireUser, verifyRequestUser };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { createEnsureWalletRoute, createPrivyServer, findDelegatedEthereumWallet, findEmbeddedEthereumWallet, privyEnvVar, readPrivyServerEnv, requireUser, verifyRequestUser } from '../chunk-62M2LKQW.js';
|
|
2
|
+
import '../chunk-W3JN3YIW.js';
|
|
3
|
+
import '../chunk-3XUGQODR.js';
|
|
4
|
+
import '../chunk-6DSZ4Z2N.js';
|
|
5
|
+
//# sourceMappingURL=server.js.map
|
|
6
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"server.js"}
|