@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,131 @@
|
|
|
1
|
+
import { Policy } from '@zerodev/permissions';
|
|
2
|
+
import { Address, PublicClient, Hex } from 'viem';
|
|
3
|
+
import { KernelOwner, KernelSmartAccount } from '../aa/kernel.js';
|
|
4
|
+
export { KERNEL_VERSION, getKernelAddress } from '../aa/kernel.js';
|
|
5
|
+
import { K as KernelSessionCall } from '../scope-DBRkN7bR.js';
|
|
6
|
+
export { A as ApprovalCheck, a as KernelSessionScope, P as ParsedApproval, c as checkApproval, d as describeKernelSessionScope, i as isCallInScope, p as parseApproval } from '../scope-DBRkN7bR.js';
|
|
7
|
+
export { a as SessionRecord, S as SessionStore, c as createMemoryStore, i as isLive } from '../store-CjmLgp9g.js';
|
|
8
|
+
import '@zerodev/sdk/types';
|
|
9
|
+
import '@zerodev/sdk';
|
|
10
|
+
import '../erc7677-DOW58QBE.js';
|
|
11
|
+
import '../types-BilBTDqK.js';
|
|
12
|
+
import '../calls-z_EQOtFb.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* `@pepu-chain/sdk/session/kernel`: on-chain session keys with ZeroDev Kernel
|
|
16
|
+
* permissions. Extracted from templates/sponsored-session-app/lib/{kernel,
|
|
17
|
+
* session-policy,approval}.ts and built on `toPepuKernelAccount`
|
|
18
|
+
* (`plugins.regular`).
|
|
19
|
+
*
|
|
20
|
+
* The scope is enforced ON-CHAIN by ZeroDev's policy contracts, which the
|
|
21
|
+
* user's Kernel account calls during UserOperation validation:
|
|
22
|
+
*
|
|
23
|
+
* - Call policy v0.0.4: only the listed targets and function selectors, with a
|
|
24
|
+
* native value no larger than `valueLimit` (default 0).
|
|
25
|
+
* - Timestamp policy: the permission is invalid outside `validAfter`..`validUntil`.
|
|
26
|
+
*
|
|
27
|
+
* A UserOperation outside this scope is rejected by the EntryPoint itself, no
|
|
28
|
+
* matter who relays it or what the app backend does.
|
|
29
|
+
*
|
|
30
|
+
* Deployed on PEPU mainnet (eth_getCode verified 2026-10-02): Kernel v3.1
|
|
31
|
+
* factory 0xaac5D4240AF87249B3f71BC8E4A2cae074A3E419, ECDSA validator
|
|
32
|
+
* 0x845ADb2C711129d4f3966735eD98a9F09fC4cE57, ECDSA signer module
|
|
33
|
+
* 0x6A6F069E2a08c2468e7724Ab3250CdBFBA14D4FF, call policy v0.0.4 and the
|
|
34
|
+
* timestamp policy below. Call policy v0.0.5 is NOT deployed on PEPU, so the
|
|
35
|
+
* version is pinned.
|
|
36
|
+
*
|
|
37
|
+
* Optional peers: `@zerodev/sdk`, `@zerodev/permissions`, `@zerodev/ecdsa-validator`.
|
|
38
|
+
*/
|
|
39
|
+
/** Call policy v0.0.4. Pinned: v0.0.5 is not deployed on PEPU mainnet. */
|
|
40
|
+
declare const CALL_POLICY_V0_0_4_ADDRESS: Address;
|
|
41
|
+
/** ZeroDev timestamp policy on PEPU mainnet. */
|
|
42
|
+
declare const TIMESTAMP_POLICY_ADDRESS: Address;
|
|
43
|
+
/**
|
|
44
|
+
* Worst-case gas the paymaster policy service RESERVES per sponsored operation,
|
|
45
|
+
* measured on PEPU mainnet with the sponsored-session-app template: the first
|
|
46
|
+
* operation of a session (account deploy plus enabling the permission) about
|
|
47
|
+
* 20.5 PEPU, later operations about 6.9 PEPU. The real first-session cost was
|
|
48
|
+
* about 12.8 PEPU for two operations. Size per-user hourly and daily spend
|
|
49
|
+
* caps above these, or users hit `trailing-hour spend ... would exceed cap`
|
|
50
|
+
* after their first action.
|
|
51
|
+
*/
|
|
52
|
+
declare const SESSION_GAS_RESERVATION_PEPU: {
|
|
53
|
+
readonly firstOperation: 20.5;
|
|
54
|
+
readonly laterOperation: 6.9;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* The on-chain policies for one session: call policy v0.0.4 plus the timestamp
|
|
58
|
+
* policy. Pure and deterministic given its input. Only the named function
|
|
59
|
+
* fragments go into the policy, which keeps the grant small.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* const policies = buildKernelSessionPolicies({
|
|
63
|
+
* calls: [{ target: tapScore, abi: tapScoreAbi, functionName: "tap" }],
|
|
64
|
+
* validUntil: Math.floor(Date.now() / 1000) + 900,
|
|
65
|
+
* });
|
|
66
|
+
*/
|
|
67
|
+
declare function buildKernelSessionPolicies(p: {
|
|
68
|
+
calls: readonly KernelSessionCall[];
|
|
69
|
+
validUntil: number;
|
|
70
|
+
validAfter?: number;
|
|
71
|
+
}): Policy[];
|
|
72
|
+
/**
|
|
73
|
+
* A fresh random session key. SERVER ONLY: the private key must never reach
|
|
74
|
+
* the browser. Only the address is sent to the owner for approval.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* const { privateKey, address } = generateSessionKey();
|
|
78
|
+
*/
|
|
79
|
+
declare function generateSessionKey(): {
|
|
80
|
+
privateKey: Hex;
|
|
81
|
+
address: Address;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* The permission id the chain derives for this session key plus these
|
|
85
|
+
* policies. The server compares it with a browser-supplied approval.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* const permissionId = await expectedPermissionId({ publicClient, sessionKeyAddress, policies });
|
|
89
|
+
*/
|
|
90
|
+
declare function expectedPermissionId(p: {
|
|
91
|
+
publicClient: PublicClient;
|
|
92
|
+
sessionKeyAddress: Address;
|
|
93
|
+
policies: Policy[];
|
|
94
|
+
}): Promise<string>;
|
|
95
|
+
/**
|
|
96
|
+
* In the user's browser: the owner (the Privy embedded wallet, the only thing
|
|
97
|
+
* that can authorize a session) signs ONE EIP-712 message that enables a
|
|
98
|
+
* permission validator on their Kernel account. That signature is the whole
|
|
99
|
+
* grant. It names the session key's public address (never its private key)
|
|
100
|
+
* and the policies. The returned `approval` holds no secret: it is the enable
|
|
101
|
+
* signature plus the policy parameters, useless without the session key.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* const { approval, kernelAddress } = await approveKernelSession({
|
|
105
|
+
* publicClient, owner: walletClient, sessionKeyAddress, policies,
|
|
106
|
+
* });
|
|
107
|
+
*/
|
|
108
|
+
declare function approveKernelSession(p: {
|
|
109
|
+
publicClient: PublicClient;
|
|
110
|
+
owner: KernelOwner;
|
|
111
|
+
sessionKeyAddress: Address;
|
|
112
|
+
policies: Policy[];
|
|
113
|
+
}): Promise<{
|
|
114
|
+
approval: string;
|
|
115
|
+
kernelAddress: Address;
|
|
116
|
+
}>;
|
|
117
|
+
/**
|
|
118
|
+
* On the server: rebuild the session's Kernel account from the approval and
|
|
119
|
+
* the server-held session key (an ECDSA signer for that key). No owner
|
|
120
|
+
* signature is involved. Pass the result to `createPepuSponsoredClient`.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* const account = await loadKernelSessionAccount({ publicClient, approval, sessionPrivateKey });
|
|
124
|
+
*/
|
|
125
|
+
declare function loadKernelSessionAccount(p: {
|
|
126
|
+
publicClient: PublicClient;
|
|
127
|
+
approval: string;
|
|
128
|
+
sessionPrivateKey: Hex;
|
|
129
|
+
}): Promise<KernelSmartAccount>;
|
|
130
|
+
|
|
131
|
+
export { CALL_POLICY_V0_0_4_ADDRESS, KernelOwner, KernelSessionCall, KernelSmartAccount, SESSION_GAS_RESERVATION_PEPU, TIMESTAMP_POLICY_ADDRESS, approveKernelSession, buildKernelSessionPolicies, expectedPermissionId, generateSessionKey, loadKernelSessionAccount };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { CALL_POLICY_V0_0_4_ADDRESS, SESSION_GAS_RESERVATION_PEPU, TIMESTAMP_POLICY_ADDRESS, approveKernelSession, buildKernelSessionPolicies, createMemoryStore, expectedPermissionId, generateSessionKey, isLive, loadKernelSessionAccount } from '../chunk-KVG3AYYR.js';
|
|
2
|
+
export { KERNEL_VERSION, getKernelAddress } from '../chunk-ZB6SVBK4.js';
|
|
3
|
+
import '../chunk-IB2FSPMJ.js';
|
|
4
|
+
import '../chunk-VBH3JLQ5.js';
|
|
5
|
+
import '../chunk-IY3ALPUJ.js';
|
|
6
|
+
import '../chunk-D52PADVY.js';
|
|
7
|
+
export { checkApproval, describeKernelSessionScope, isCallInScope, parseApproval } from '../chunk-ESMNAXUI.js';
|
|
8
|
+
import '../chunk-J6UXXHBE.js';
|
|
9
|
+
import '../chunk-XC4IBCI2.js';
|
|
10
|
+
import '../chunk-VTQIHMF3.js';
|
|
11
|
+
import '../chunk-6DSZ4Z2N.js';
|
|
12
|
+
//# sourceMappingURL=kernel.js.map
|
|
13
|
+
//# sourceMappingURL=kernel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"kernel.js"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkR5PXQNO3_cjs = require('../chunk-R5PXQNO3.cjs');
|
|
4
|
+
require('../chunk-DH6BFNVJ.cjs');
|
|
5
|
+
require('../chunk-NE3QKDOB.cjs');
|
|
6
|
+
require('../chunk-DPCZJLB3.cjs');
|
|
7
|
+
require('../chunk-C2XW44FI.cjs');
|
|
8
|
+
require('../chunk-YQL7NISX.cjs');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
Object.defineProperty(exports, "deriveSessionState", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunkR5PXQNO3_cjs.deriveSessionState; }
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, "errorFromResponse", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return chunkR5PXQNO3_cjs.errorFromResponse; }
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "useSessionAct", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return chunkR5PXQNO3_cjs.useSessionAct; }
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "useSessionGrant", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () { return chunkR5PXQNO3_cjs.useSessionGrant; }
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports, "useSessionRevoke", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function () { return chunkR5PXQNO3_cjs.useSessionRevoke; }
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports, "useSessionStatus", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () { return chunkR5PXQNO3_cjs.useSessionStatus; }
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=react.cjs.map
|
|
37
|
+
//# sourceMappingURL=react.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"react.cjs"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { P as PepuError } from '../errors-CgX1vNj7.cjs';
|
|
2
|
+
import 'viem';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Client hooks for the Privy-mode session. Ported from
|
|
6
|
+
* templates/game-app/components/session-consent-screen.tsx and
|
|
7
|
+
* session-status-card.tsx. Auth defaults to `usePepuAuthFetch` from
|
|
8
|
+
* `@pepu-chain/sdk/privy/react` (Privy bearer token); pass `authFetch` to use
|
|
9
|
+
* your own.
|
|
10
|
+
*/
|
|
11
|
+
/** A fetch that adds the user's Privy bearer token. */
|
|
12
|
+
type AuthFetch = (url: string, init?: RequestInit) => Promise<Response>;
|
|
13
|
+
interface BaseOptions {
|
|
14
|
+
/** Custom authenticated fetch. Default: `usePepuAuthFetch()` (Privy bearer token). */
|
|
15
|
+
authFetch?: AuthFetch;
|
|
16
|
+
/** The embedded wallet address. Default: the Privy user's wallet. */
|
|
17
|
+
address?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Turn a non-OK route response into a typed error. Reads the
|
|
21
|
+
* `{ error: { code, message, hint } }` body the SDK route factories return.
|
|
22
|
+
* Only a 409 means "no session" (`SESSION_NONE`).
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* if (!res.ok) throw await errorFromResponse(res);
|
|
26
|
+
*/
|
|
27
|
+
declare function errorFromResponse(res: Response): Promise<PepuError>;
|
|
28
|
+
/** Session state from the server's `delegated` flag and the locally tracked expiry. */
|
|
29
|
+
type SessionState = "none" | "active" | "expired";
|
|
30
|
+
/**
|
|
31
|
+
* Derive the session state. A delegated signer with a known expiry in the
|
|
32
|
+
* past is `expired` (Privy denies it, but the signer still exists until
|
|
33
|
+
* revoked). Pure.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* deriveSessionState({ delegated: true, expiresAt: 100, nowSeconds: 200 }); // { state: "expired", secondsLeft: 0 }
|
|
37
|
+
*/
|
|
38
|
+
declare function deriveSessionState(p: {
|
|
39
|
+
delegated: boolean;
|
|
40
|
+
expiresAt?: number | undefined;
|
|
41
|
+
nowSeconds: number;
|
|
42
|
+
}): {
|
|
43
|
+
state: SessionState;
|
|
44
|
+
secondsLeft?: number;
|
|
45
|
+
};
|
|
46
|
+
type SessionGrantStatus = "idle" | "creating-policy" | "awaiting-consent" | "granted" | "error";
|
|
47
|
+
/**
|
|
48
|
+
* Grant a session: POST the grant route, then ask the user to approve with
|
|
49
|
+
* Privy's `addSigners`. Skips `addSigners` when the server says
|
|
50
|
+
* `alreadyGranted`, and swallows Privy's "duplicate signer" error.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* const { grant, status, error } = useSessionGrant();
|
|
54
|
+
* <button onClick={grant} disabled={status === "creating-policy"}>Grant</button>
|
|
55
|
+
*/
|
|
56
|
+
declare function useSessionGrant(o?: BaseOptions & {
|
|
57
|
+
grantEndpoint?: string;
|
|
58
|
+
}): {
|
|
59
|
+
grant(): Promise<void>;
|
|
60
|
+
status: SessionGrantStatus;
|
|
61
|
+
error?: PepuError;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Current session state. Asks the status route whether a signer is attached
|
|
65
|
+
* and combines it with the expiry tracked from the grant. Ticks every second
|
|
66
|
+
* for `secondsLeft`; re-polls every `pollMs` if given.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* const { state, secondsLeft } = useSessionStatus({ pollMs: 30_000 });
|
|
70
|
+
*/
|
|
71
|
+
declare function useSessionStatus(o?: BaseOptions & {
|
|
72
|
+
statusEndpoint?: string;
|
|
73
|
+
pollMs?: number;
|
|
74
|
+
}): {
|
|
75
|
+
state: SessionState;
|
|
76
|
+
/**
|
|
77
|
+
* True until the first status response (or failure) has been applied. Show a
|
|
78
|
+
* spinner while it is true so the "start a session" UI does not flash on reload.
|
|
79
|
+
*/
|
|
80
|
+
loading: boolean;
|
|
81
|
+
expiresAt?: number;
|
|
82
|
+
secondsLeft?: number;
|
|
83
|
+
refetch(): void;
|
|
84
|
+
};
|
|
85
|
+
type SessionRevokeStatus = "idle" | "revoking" | "revoked" | "error";
|
|
86
|
+
/**
|
|
87
|
+
* Revoke the session. The Privy `removeSigners` call is the real revoke; the
|
|
88
|
+
* server revoke route afterwards is best-effort cleanup of the policy.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* const { revoke, status } = useSessionRevoke();
|
|
92
|
+
*/
|
|
93
|
+
declare function useSessionRevoke(o?: BaseOptions & {
|
|
94
|
+
revokeEndpoint?: string;
|
|
95
|
+
}): {
|
|
96
|
+
revoke(): Promise<void>;
|
|
97
|
+
status: SessionRevokeStatus;
|
|
98
|
+
error?: PepuError;
|
|
99
|
+
};
|
|
100
|
+
type SessionActStatus = "idle" | "pending" | "success" | "error";
|
|
101
|
+
/**
|
|
102
|
+
* Call a session action route (built with `createSessionActionRoute`). A 409
|
|
103
|
+
* is the only "no session" signal and surfaces as `error.code ===
|
|
104
|
+
* "SESSION_NONE"`; any other failure is a failed transaction, so do not send
|
|
105
|
+
* the user back to the consent screen for it.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* const { act } = useSessionAct<{}, { hash: string }>({ endpoint: "/api/game/tap" });
|
|
109
|
+
* const { hash } = await act({});
|
|
110
|
+
*/
|
|
111
|
+
declare function useSessionAct<I, O>(o: BaseOptions & {
|
|
112
|
+
endpoint: string;
|
|
113
|
+
}): {
|
|
114
|
+
act(input: I): Promise<O>;
|
|
115
|
+
status: SessionActStatus;
|
|
116
|
+
error?: PepuError;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export { type AuthFetch, type SessionActStatus, type SessionGrantStatus, type SessionRevokeStatus, type SessionState, deriveSessionState, errorFromResponse, useSessionAct, useSessionGrant, useSessionRevoke, useSessionStatus };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { P as PepuError } from '../errors-CgX1vNj7.js';
|
|
2
|
+
import 'viem';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Client hooks for the Privy-mode session. Ported from
|
|
6
|
+
* templates/game-app/components/session-consent-screen.tsx and
|
|
7
|
+
* session-status-card.tsx. Auth defaults to `usePepuAuthFetch` from
|
|
8
|
+
* `@pepu-chain/sdk/privy/react` (Privy bearer token); pass `authFetch` to use
|
|
9
|
+
* your own.
|
|
10
|
+
*/
|
|
11
|
+
/** A fetch that adds the user's Privy bearer token. */
|
|
12
|
+
type AuthFetch = (url: string, init?: RequestInit) => Promise<Response>;
|
|
13
|
+
interface BaseOptions {
|
|
14
|
+
/** Custom authenticated fetch. Default: `usePepuAuthFetch()` (Privy bearer token). */
|
|
15
|
+
authFetch?: AuthFetch;
|
|
16
|
+
/** The embedded wallet address. Default: the Privy user's wallet. */
|
|
17
|
+
address?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Turn a non-OK route response into a typed error. Reads the
|
|
21
|
+
* `{ error: { code, message, hint } }` body the SDK route factories return.
|
|
22
|
+
* Only a 409 means "no session" (`SESSION_NONE`).
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* if (!res.ok) throw await errorFromResponse(res);
|
|
26
|
+
*/
|
|
27
|
+
declare function errorFromResponse(res: Response): Promise<PepuError>;
|
|
28
|
+
/** Session state from the server's `delegated` flag and the locally tracked expiry. */
|
|
29
|
+
type SessionState = "none" | "active" | "expired";
|
|
30
|
+
/**
|
|
31
|
+
* Derive the session state. A delegated signer with a known expiry in the
|
|
32
|
+
* past is `expired` (Privy denies it, but the signer still exists until
|
|
33
|
+
* revoked). Pure.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* deriveSessionState({ delegated: true, expiresAt: 100, nowSeconds: 200 }); // { state: "expired", secondsLeft: 0 }
|
|
37
|
+
*/
|
|
38
|
+
declare function deriveSessionState(p: {
|
|
39
|
+
delegated: boolean;
|
|
40
|
+
expiresAt?: number | undefined;
|
|
41
|
+
nowSeconds: number;
|
|
42
|
+
}): {
|
|
43
|
+
state: SessionState;
|
|
44
|
+
secondsLeft?: number;
|
|
45
|
+
};
|
|
46
|
+
type SessionGrantStatus = "idle" | "creating-policy" | "awaiting-consent" | "granted" | "error";
|
|
47
|
+
/**
|
|
48
|
+
* Grant a session: POST the grant route, then ask the user to approve with
|
|
49
|
+
* Privy's `addSigners`. Skips `addSigners` when the server says
|
|
50
|
+
* `alreadyGranted`, and swallows Privy's "duplicate signer" error.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* const { grant, status, error } = useSessionGrant();
|
|
54
|
+
* <button onClick={grant} disabled={status === "creating-policy"}>Grant</button>
|
|
55
|
+
*/
|
|
56
|
+
declare function useSessionGrant(o?: BaseOptions & {
|
|
57
|
+
grantEndpoint?: string;
|
|
58
|
+
}): {
|
|
59
|
+
grant(): Promise<void>;
|
|
60
|
+
status: SessionGrantStatus;
|
|
61
|
+
error?: PepuError;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Current session state. Asks the status route whether a signer is attached
|
|
65
|
+
* and combines it with the expiry tracked from the grant. Ticks every second
|
|
66
|
+
* for `secondsLeft`; re-polls every `pollMs` if given.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* const { state, secondsLeft } = useSessionStatus({ pollMs: 30_000 });
|
|
70
|
+
*/
|
|
71
|
+
declare function useSessionStatus(o?: BaseOptions & {
|
|
72
|
+
statusEndpoint?: string;
|
|
73
|
+
pollMs?: number;
|
|
74
|
+
}): {
|
|
75
|
+
state: SessionState;
|
|
76
|
+
/**
|
|
77
|
+
* True until the first status response (or failure) has been applied. Show a
|
|
78
|
+
* spinner while it is true so the "start a session" UI does not flash on reload.
|
|
79
|
+
*/
|
|
80
|
+
loading: boolean;
|
|
81
|
+
expiresAt?: number;
|
|
82
|
+
secondsLeft?: number;
|
|
83
|
+
refetch(): void;
|
|
84
|
+
};
|
|
85
|
+
type SessionRevokeStatus = "idle" | "revoking" | "revoked" | "error";
|
|
86
|
+
/**
|
|
87
|
+
* Revoke the session. The Privy `removeSigners` call is the real revoke; the
|
|
88
|
+
* server revoke route afterwards is best-effort cleanup of the policy.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* const { revoke, status } = useSessionRevoke();
|
|
92
|
+
*/
|
|
93
|
+
declare function useSessionRevoke(o?: BaseOptions & {
|
|
94
|
+
revokeEndpoint?: string;
|
|
95
|
+
}): {
|
|
96
|
+
revoke(): Promise<void>;
|
|
97
|
+
status: SessionRevokeStatus;
|
|
98
|
+
error?: PepuError;
|
|
99
|
+
};
|
|
100
|
+
type SessionActStatus = "idle" | "pending" | "success" | "error";
|
|
101
|
+
/**
|
|
102
|
+
* Call a session action route (built with `createSessionActionRoute`). A 409
|
|
103
|
+
* is the only "no session" signal and surfaces as `error.code ===
|
|
104
|
+
* "SESSION_NONE"`; any other failure is a failed transaction, so do not send
|
|
105
|
+
* the user back to the consent screen for it.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* const { act } = useSessionAct<{}, { hash: string }>({ endpoint: "/api/game/tap" });
|
|
109
|
+
* const { hash } = await act({});
|
|
110
|
+
*/
|
|
111
|
+
declare function useSessionAct<I, O>(o: BaseOptions & {
|
|
112
|
+
endpoint: string;
|
|
113
|
+
}): {
|
|
114
|
+
act(input: I): Promise<O>;
|
|
115
|
+
status: SessionActStatus;
|
|
116
|
+
error?: PepuError;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export { type AuthFetch, type SessionActStatus, type SessionGrantStatus, type SessionRevokeStatus, type SessionState, deriveSessionState, errorFromResponse, useSessionAct, useSessionGrant, useSessionRevoke, useSessionStatus };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { deriveSessionState, errorFromResponse, useSessionAct, useSessionGrant, useSessionRevoke, useSessionStatus } from '../chunk-T43PQXJD.js';
|
|
2
|
+
import '../chunk-EHBPIYY4.js';
|
|
3
|
+
import '../chunk-JLZ4LZ4Z.js';
|
|
4
|
+
import '../chunk-VTQIHMF3.js';
|
|
5
|
+
import '../chunk-3XUGQODR.js';
|
|
6
|
+
import '../chunk-6DSZ4Z2N.js';
|
|
7
|
+
//# sourceMappingURL=react.js.map
|
|
8
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"react.js"}
|