@pepu-chain/sdk 0.2.0 → 0.2.2

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.
Files changed (110) hide show
  1. package/README.md +26 -2
  2. package/dist/aa/kernel.cjs +11 -9
  3. package/dist/aa/kernel.guard.js +15 -0
  4. package/dist/aa/kernel.js +5 -4
  5. package/dist/aa/react-direct.cjs +14 -12
  6. package/dist/aa/react-direct.cjs.map +1 -1
  7. package/dist/aa/react-direct.guard.js +15 -0
  8. package/dist/aa/react-direct.js +7 -6
  9. package/dist/aa/react-direct.js.map +1 -1
  10. package/dist/aa/react.cjs +7 -5
  11. package/dist/aa/react.cjs.map +1 -1
  12. package/dist/aa/react.d.cts +1 -1
  13. package/dist/aa/react.d.ts +1 -1
  14. package/dist/aa/react.guard.js +15 -0
  15. package/dist/aa/react.js +4 -3
  16. package/dist/aa/react.js.map +1 -1
  17. package/dist/aa.cjs +19 -18
  18. package/dist/aa.d.cts +1 -1
  19. package/dist/aa.d.ts +1 -1
  20. package/dist/aa.js +6 -5
  21. package/dist/chunk-4GEC7GUU.cjs +283 -0
  22. package/dist/chunk-4GEC7GUU.cjs.map +1 -0
  23. package/dist/{chunk-PHM3ZORG.cjs → chunk-4L4CHIXE.cjs} +9 -9
  24. package/dist/{chunk-PHM3ZORG.cjs.map → chunk-4L4CHIXE.cjs.map} +1 -1
  25. package/dist/{chunk-A5LP2UCS.cjs → chunk-65Y5UCQ7.cjs} +2 -276
  26. package/dist/chunk-65Y5UCQ7.cjs.map +1 -0
  27. package/dist/{chunk-MBA4CLA5.js → chunk-7PVR7QSE.js} +3 -3
  28. package/dist/{chunk-MBA4CLA5.js.map → chunk-7PVR7QSE.js.map} +1 -1
  29. package/dist/{chunk-7MNJF2OB.cjs → chunk-DNWWZWUW.cjs} +4 -4
  30. package/dist/{chunk-7MNJF2OB.cjs.map → chunk-DNWWZWUW.cjs.map} +1 -1
  31. package/dist/{chunk-D52PADVY.js → chunk-GFKIM7HT.js} +25 -2
  32. package/dist/chunk-GFKIM7HT.js.map +1 -0
  33. package/dist/{chunk-IY3ALPUJ.js → chunk-GIZNH65Q.js} +5 -273
  34. package/dist/chunk-GIZNH65Q.js.map +1 -0
  35. package/dist/{chunk-WANILJZQ.cjs → chunk-HTCX46RJ.cjs} +25 -2
  36. package/dist/chunk-HTCX46RJ.cjs.map +1 -0
  37. package/dist/{chunk-TIEAZYHF.cjs → chunk-K7JSQPZO.cjs} +8 -2
  38. package/dist/chunk-K7JSQPZO.cjs.map +1 -0
  39. package/dist/{chunk-FCXSP2YF.js → chunk-KJYNF5KH.js} +8 -3
  40. package/dist/chunk-KJYNF5KH.js.map +1 -0
  41. package/dist/{chunk-KVG3AYYR.js → chunk-NHPWXIA2.js} +4 -4
  42. package/dist/{chunk-KVG3AYYR.js.map → chunk-NHPWXIA2.js.map} +1 -1
  43. package/dist/{chunk-ZB6SVBK4.js → chunk-QIDMFFAQ.js} +4 -4
  44. package/dist/{chunk-ZB6SVBK4.js.map → chunk-QIDMFFAQ.js.map} +1 -1
  45. package/dist/{chunk-IB2FSPMJ.js → chunk-QZKUPCUD.js} +3 -3
  46. package/dist/{chunk-IB2FSPMJ.js.map → chunk-QZKUPCUD.js.map} +1 -1
  47. package/dist/{chunk-ET3P6TX6.cjs → chunk-RCMKPJZO.cjs} +4 -4
  48. package/dist/{chunk-ET3P6TX6.cjs.map → chunk-RCMKPJZO.cjs.map} +1 -1
  49. package/dist/chunk-RSPAN44L.js +276 -0
  50. package/dist/chunk-RSPAN44L.js.map +1 -0
  51. package/dist/{chunk-NVOPDXTA.cjs → chunk-UQH4ZAXD.cjs} +10 -10
  52. package/dist/{chunk-NVOPDXTA.cjs.map → chunk-UQH4ZAXD.cjs.map} +1 -1
  53. package/dist/{chunk-SLW7FRTL.cjs → chunk-VYMAZVIK.cjs} +52 -22
  54. package/dist/chunk-VYMAZVIK.cjs.map +1 -0
  55. package/dist/{chunk-KIIFL4VM.js → chunk-XR5ONV2Y.js} +42 -12
  56. package/dist/chunk-XR5ONV2Y.js.map +1 -0
  57. package/dist/combo/react.cjs +62 -13
  58. package/dist/combo/react.cjs.map +1 -1
  59. package/dist/combo/react.d.cts +14 -2
  60. package/dist/combo/react.d.ts +14 -2
  61. package/dist/combo/react.guard.js +15 -0
  62. package/dist/combo/react.js +58 -11
  63. package/dist/combo/react.js.map +1 -1
  64. package/dist/combo.cjs +45 -29
  65. package/dist/combo.cjs.map +1 -1
  66. package/dist/combo.d.cts +11 -0
  67. package/dist/combo.d.ts +11 -0
  68. package/dist/combo.guard.js +15 -0
  69. package/dist/combo.js +33 -18
  70. package/dist/combo.js.map +1 -1
  71. package/dist/index.cjs +28 -23
  72. package/dist/index.cjs.map +1 -1
  73. package/dist/index.d.cts +2 -2
  74. package/dist/index.d.ts +2 -2
  75. package/dist/index.js +6 -5
  76. package/dist/index.js.map +1 -1
  77. package/dist/paymaster.cjs +39 -38
  78. package/dist/paymaster.cjs.map +1 -1
  79. package/dist/paymaster.js +4 -3
  80. package/dist/paymaster.js.map +1 -1
  81. package/dist/privy/react.cjs +1 -0
  82. package/dist/privy/react.guard.js +15 -0
  83. package/dist/privy/server.cjs +1 -0
  84. package/dist/privy/server.guard.js +15 -0
  85. package/dist/privy/wagmi.guard.js +15 -0
  86. package/dist/react.cjs +6 -4
  87. package/dist/react.cjs.map +1 -1
  88. package/dist/react.d.cts +1 -1
  89. package/dist/react.d.ts +1 -1
  90. package/dist/react.guard.js +15 -0
  91. package/dist/react.js +4 -3
  92. package/dist/react.js.map +1 -1
  93. package/dist/session/kernel.cjs +19 -17
  94. package/dist/session/kernel.guard.js +15 -0
  95. package/dist/session/kernel.js +6 -5
  96. package/dist/session/react.cjs +1 -0
  97. package/dist/session/react.guard.js +15 -0
  98. package/dist/session/server.cjs +1 -0
  99. package/dist/session/server.guard.js +15 -0
  100. package/dist/{status-DwkkOrGQ.d.ts → status-Dx9zAFo9.d.ts} +42 -10
  101. package/dist/{status-CmOsyPmO.d.cts → status-wgTM26V7.d.cts} +42 -10
  102. package/package.json +38 -2
  103. package/dist/chunk-A5LP2UCS.cjs.map +0 -1
  104. package/dist/chunk-D52PADVY.js.map +0 -1
  105. package/dist/chunk-FCXSP2YF.js.map +0 -1
  106. package/dist/chunk-IY3ALPUJ.js.map +0 -1
  107. package/dist/chunk-KIIFL4VM.js.map +0 -1
  108. package/dist/chunk-SLW7FRTL.cjs.map +0 -1
  109. package/dist/chunk-TIEAZYHF.cjs.map +0 -1
  110. package/dist/chunk-WANILJZQ.cjs.map +0 -1
package/dist/combo.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/combo/server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqCA,gBAAA,CAAiB,uBAAuB,CAAA;AA0FxC,SAAS,IAAA,CAAK,IAAA,EAAe,MAAA,GAAS,GAAA,EAAe;AACnD,EAAA,OAAO,IAAI,QAAA,CAAS,IAAA,CAAK,SAAA,CAAU,IAAI,CAAA,EAAG,EAAE,MAAA,EAAQ,OAAA,EAAS,EAAE,cAAA,EAAgB,kBAAA,IAAsB,CAAA;AACvG;AAGA,SAAS,QAAA,CAAS,GAAY,EAAA,EAAuB;AACnD,EAAA,MAAM,GAAA,GAAM,WAAA,CAAY,CAAA,EAAG,EAAE,IAAI,CAAA;AACjC,EAAA,IAAI,GAAA,CAAI,IAAA,KAAS,SAAA,IAAa,EAAE,aAAa,SAAA,CAAA,EAAY;AACvD,IAAA,OAAO,IAAI,cAAA,CAAe,SAAA,EAAW,GAAA,CAAI,OAAA,EAAS,EAAE,MAAA,EAAQ,GAAA,EAAK,KAAA,EAAO,CAAA,EAAG,CAAA;AAAA,EAC7E;AACA,EAAA,OAAO,GAAA;AACT;AAEA,eAAe,KAAA,CAAM,IAAY,EAAA,EAAgD;AAC/E,EAAA,IAAI;AACF,IAAA,OAAO,MAAM,EAAA,EAAG;AAAA,EAClB,SAAS,CAAA,EAAG;AACV,IAAA,OAAO,eAAA,CAAgB,QA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,GAAA;AAAA,QACR,IAAA,EAAM;AAAA,OACP,CAAA;AAAA,IACH;AAAA,EACF;AACF","file":"combo.js","sourcesContent":["import type { PrivyClient } from \"@privy-io/node\";\nimport { createPublicClient, http } from \"viem\";\nimport type { Address, PublicClient } from \"viem\";\nimport type { SponsoredActResult } from \"./types.js\";\nimport { createPepuSponsoredClient, sendSponsored } from \"../aa/kernel.js\";\nimport { normalizeCalls } from \"../aa/calls.js\";\nimport type { Call } from \"../aa/types.js\";\nimport { pepuMainnet } from \"../chains.js\";\nimport { resolvePepuEndpoints } from \"../endpoints.js\";\nimport { buildPaymasterContext } from \"../erc7677.js\";\nimport {\n PepuAuthError,\n PepuChainError,\n PepuConfigError,\n PepuError,\n PepuPolicyError,\n PepuSessionError,\n toErrorResponse,\n toPepuError,\n} from \"../errors.js\";\nimport { assertServerOnly } from \"../internal/assert-server.js\";\nimport { createPrivyServer, requireUser } from \"../privy/server.js\";\nimport { resolveSessionMinutes, sessionExpiry } from \"../session/policy.js\";\nimport {\n buildKernelSessionPolicies,\n checkApproval,\n describeKernelSessionScope,\n expectedPermissionId,\n generateSessionKey,\n getKernelAddress,\n isCallInScope,\n loadKernelSessionAccount,\n} from \"../session/kernel.js\";\nimport type { KernelSessionCall, KernelSessionScope } from \"../session/kernel.js\";\nimport { isLive } from \"../session/store.js\";\nimport type { SessionRecord, SessionStore } from \"../session/store.js\";\n\nassertServerOnly(\"@pepu-chain/sdk/combo\");\n\n/**\n * `@pepu-chain/sdk/combo` (server): the combined flow. Google sign-in (Privy),\n * a ONE-TIME on-chain session, and sponsored gas. Route factories for the\n * Kernel session lifecycle: prepare, activate, status, act, revoke.\n *\n * Extracted from templates/sponsored-session-app/app/api/session/* and\n * lib/{kernel,session-auth}.ts.\n *\n * Trust model: the chain, not these routes, enforces scope. The owner's single\n * EIP-712 signature enables a permission whose call policy (targets,\n * selectors, zero value) and timestamp policy the Kernel account verifies on\n * every UserOperation. The checks here only fail fast.\n *\n * Optional peers: `@privy-io/node`, `@zerodev/*`.\n */\n\nexport { createMemoryStore, isLive } from \"../session/store.js\";\nexport type { SessionRecord, SessionStore } from \"../session/store.js\";\nexport type { KernelSessionCall, KernelSessionScope } from \"../session/kernel.js\";\nexport type { SponsoredActResult } from \"./types.js\";\n/** Session length from `SESSION_DURATION_MINUTES` (default 15, clamped to 1..1440), the same rule the routes use. */\nexport { resolveSessionMinutes } from \"../session/policy.js\";\n\n/** The authenticated caller of a combo route. */\nexport interface ComboUser {\n userId: string;\n /** The user's Privy embedded wallet: the owner of their Kernel account. From Privy, never the request. */\n ownerAddress: Address;\n}\n\n/** Authenticate a request. Throw a `PepuError` (or return `null`) when it is not valid. */\nexport type ComboAuthenticate = (request: Request) => Promise<ComboUser | null>;\n\n/** Options for {@link createSponsoredSessionRoutes}. */\nexport interface SponsoredSessionRoutesOptions<I> {\n /** What the session may call. Enforced on-chain by the call policy. */\n scope: {\n calls: readonly KernelSessionCall[];\n /** Env variable named in the `CONFIG_MISSING_ENV` message when a call target is empty (unset). */\n targetEnv?: string;\n };\n /**\n * Where session records (including the session private key) live. Use\n * `createMemoryStore()` for development only: production needs a persistent\n * store with the key encrypted at rest.\n */\n store: SessionStore;\n /**\n * Bundler and paymaster. The bundler defaults to env `PEPU_BUNDLER_URL`, then the hosted bundler. The paymaster\n * needs a complete ERC-7677 URL (env `PEPU_PAYMASTER_URL`, or `paymasterUrl`) or a project `paymasterToken`\n * (built against the hosted paymaster base).\n */\n endpoints?: { bundlerUrl?: string; paymasterUrl?: string; paymasterToken?: string };\n /**\n * Forward the caller's Privy access token (the request's `Authorization: Bearer`) to the paymaster as ERC-7677\n * `context.privyAccessToken`. The v2 FREE TIER requires it; a project paying from its own deposit does not.\n * Default `true`. Set `false` if your paymaster URL is not a PEPU policy service you trust with the token.\n */\n forwardPrivyToken?: boolean;\n /** Session length. Default env `SESSION_DURATION_MINUTES`, then 15; clamped to 1..1440. */\n minutes?: number;\n /** The one action users take with their session. */\n act: {\n /** Validate the client body. Throw to reject with 400. */\n parse(body: unknown): I;\n /** The calls to send. Each is re-checked against `scope` before sponsoring. */\n buildCalls(input: I, ctx: { kernelAddress: Address; ownerAddress: Address }): Call[];\n };\n /** Privy client for the default authentication. Default `createPrivyServer()`. */\n privy?: PrivyClient;\n /**\n * Custom authentication. Default: B1's `requireUser` (verifies the Privy\n * bearer token and reads the user's embedded wallet from Privy).\n */\n authenticate?: ComboAuthenticate;\n /** Chain reads. Default: viem on the PEPU RPC (`PEPU_RPC_URL` aware). */\n publicClient?: PublicClient;\n}\n\n/** The five route handlers returned by {@link createSponsoredSessionRoutes}. */\nexport interface SponsoredSessionRoutes {\n prepare: { POST(request: Request): Promise<Response> };\n activate: { POST(request: Request): Promise<Response> };\n status: { GET(request: Request): Promise<Response> };\n act: { POST(request: Request): Promise<Response> };\n revoke: { POST(request: Request): Promise<Response> };\n}\n\nfunction json(body: unknown, status = 200): Response {\n return new Response(JSON.stringify(body), { status, headers: { \"content-type\": \"application/json\" } });\n}\n\n/** Anything unclassified that reaches a route is an upstream failure, not our 500. */\nfunction upstream(e: unknown, op: string): PepuError {\n const err = toPepuError(e, { op });\n if (err.code === \"UNKNOWN\" && !(e instanceof PepuError)) {\n return new PepuChainError(\"UNKNOWN\", err.message, { status: 502, cause: e });\n }\n return err;\n}\n\nasync function guard(op: string, fn: () => Promise<Response>): Promise<Response> {\n try {\n return await fn();\n } catch (e) {\n return toErrorResponse(upstream(e, op));\n }\n}\n\n/** The bearer token on a request, or `\"\"`. */\nfunction bearerToken(request: Request): string {\n return (request.headers.get(\"authorization\") ?? \"\").replace(/^Bearer\\s+/i, \"\").trim();\n}\n\nconst nowSeconds = (): number => Math.floor(Date.now() / 1000);\n\nfunction defaultPublicClient(): PublicClient {\n return createPublicClient({ chain: pepuMainnet, transport: http(resolvePepuEndpoints().rpcUrl) }) as PublicClient;\n}\n\n/**\n * Route handlers for the Kernel session lifecycle.\n *\n * - `prepare.POST`: the server creates a fresh session key and decides the\n * expiry. The private key stays on the server; the response carries only the\n * key's address, the expiry and the scope, so the browser can ask the owner\n * for the ONE signature that grants exactly that. Calling it again replaces\n * any pending or active session (the old key is dropped).\n * - `activate.POST` `{ approval }`: checks the approval is for this user's\n * smart account and for exactly the key, scope and expiry issued in\n * `prepare`, then stores it. 409 `SESSION_NONE` when nothing is pending,\n * 410 `SESSION_EXPIRED` for an expired offer, 400 `SESSION_APPROVAL_MISMATCH`.\n * - `status.GET`: `{ active: false }` or `{ active: true, validUntil, ... }`.\n * Never returns the session key or approval.\n * - `act.POST`: signs ONE sponsored UserOperation with the session key. 409\n * `SESSION_NONE` without a live session, 429 while another action runs.\n * - `revoke.POST`: deletes the session key and approval from the server, so\n * the app can no longer act, immediately. It does NOT uninstall the\n * permission on-chain: that grant stays valid until its expiry, but only the\n * deleted key can use it and only within the scope. An on-chain uninstall is\n * an owner-signed call to the user's own account, which a paymaster\n * destination allowlist rightly does not sponsor.\n *\n * Gas: the paymaster policy service reserves worst-case cost per operation:\n * about 20.5 PEPU for a session's first operation and about 6.9 PEPU for later\n * ones (`SESSION_GAS_RESERVATION_PEPU`). Size spend caps above that. Fees come\n * from the chain with 20% headroom.\n *\n * @example\n * // lib/session-routes.ts\n * export const routes = createSponsoredSessionRoutes({\n * scope: { calls: [{ target: tapScore, abi: tapScoreAbi, functionName: \"tap\" }] },\n * store: createMemoryStore(), // DEV ONLY\n * act: {\n * parse: () => ({}),\n * buildCalls: () => [{ to: tapScore, abi: tapScoreAbi, functionName: \"tap\" }],\n * },\n * });\n * // app/api/session/prepare/route.ts: export const { POST } = routes.prepare;\n */\nexport function createSponsoredSessionRoutes<I>(o: SponsoredSessionRoutesOptions<I>): SponsoredSessionRoutes {\n // A call whose target is empty or undefined (an unset env variable) is \"not configured yet\":\n // every route then answers CONFIG_MISSING_ENV at request time. A malformed non-empty scope\n // still fails at startup, not on the first request.\n const unconfigured = o.scope.calls.some((c) => !c.target || String(c.target).trim() === \"\");\n if (unconfigured) {\n const unset = async (): Promise<Response> =>\n toErrorResponse(\n new PepuConfigError(\n \"CONFIG_MISSING_ENV\",\n `${o.scope.targetEnv ?? \"A session target contract address\"} is not set to a valid address. See .env.example.`,\n { hint: \"Set it and restart the server.\" },\n ),\n );\n return {\n prepare: { POST: unset },\n activate: { POST: unset },\n status: { GET: unset },\n act: { POST: unset },\n revoke: { POST: unset },\n };\n }\n buildKernelSessionPolicies({ calls: o.scope.calls, validUntil: 1 });\n let publicClient = o.publicClient;\n const client = (): PublicClient => (publicClient ??= defaultPublicClient());\n\n const authenticate = async (request: Request): Promise<ComboUser | Response> => {\n if (o.authenticate) {\n const user = await o.authenticate(request);\n if (!user) throw new PepuAuthError(\"AUTH_INVALID_TOKEN\", \"Missing or invalid Privy access token.\");\n return user;\n }\n const auth = await requireUser(request, { privy: o.privy ?? createPrivyServer() });\n if (!auth.ok) return auth.response;\n if (!auth.user.address) {\n throw new PepuAuthError(\"WALLET_NOT_PROVISIONED\", \"No embedded wallet yet. Create it first (ensure-wallet route).\", {\n status: 409,\n });\n }\n return { userId: auth.user.userId, ownerAddress: auth.user.address };\n };\n\n const minutes = (): number => o.minutes ?? resolveSessionMinutes(process.env.SESSION_DURATION_MINUTES);\n const policiesFor = (validUntil: number) => buildKernelSessionPolicies({ calls: o.scope.calls, validUntil });\n\n return {\n prepare: {\n POST: (request) =>\n guard(\"combo prepare\", async () => {\n const user = await authenticate(request);\n if (user instanceof Response) return user;\n const { userId, ownerAddress } = user;\n const mins = minutes();\n const validUntil = sessionExpiry(nowSeconds(), mins);\n const key = generateSessionKey();\n const policies = policiesFor(validUntil);\n const [kernelAddress, permissionId] = await Promise.all([\n getKernelAddress(client(), ownerAddress),\n expectedPermissionId({ publicClient: client(), sessionKeyAddress: key.address, policies }),\n ]);\n const record: SessionRecord = {\n userId,\n ownerAddress,\n kernelAddress,\n sessionPrivateKey: key.privateKey,\n sessionKeyAddress: key.address,\n permissionId,\n validUntil,\n approval: null,\n actions: 0,\n };\n await o.store.set(record);\n return json({\n ownerAddress,\n kernelAddress,\n sessionKeyAddress: key.address,\n validUntil,\n minutes: mins,\n scope: describeKernelSessionScope({ calls: o.scope.calls, validUntil }),\n });\n }),\n },\n\n activate: {\n POST: (request) =>\n guard(\"combo activate\", async () => {\n const user = await authenticate(request);\n if (user instanceof Response) return user;\n const body = (await request.json().catch(() => null)) as { approval?: unknown } | null;\n if (typeof body?.approval !== \"string\") {\n throw new PepuPolicyError(\"UNKNOWN\", \"Missing approval.\", { status: 400, hint: \"Send { approval }.\" });\n }\n const record = await o.store.get(user.userId);\n if (!record || record.approval !== null) {\n throw new PepuSessionError(\"SESSION_NONE\", \"No pending session. Start again.\");\n }\n if (nowSeconds() >= record.validUntil) {\n await o.store.delete(record.userId);\n throw new PepuSessionError(\"SESSION_EXPIRED\", \"The session offer expired. Start again.\");\n }\n const check = checkApproval(body.approval, {\n kernelAddress: record.kernelAddress,\n permissionId: record.permissionId,\n });\n if (!check.ok) throw new PepuSessionError(\"SESSION_APPROVAL_MISMATCH\", check.reason, { status: 400 });\n await o.store.set({ ...record, approval: body.approval });\n return json({ active: true, validUntil: record.validUntil });\n }),\n },\n\n status: {\n GET: (request) =>\n guard(\"combo status\", async () => {\n const user = await authenticate(request);\n if (user instanceof Response) return user;\n const record = await o.store.get(user.userId);\n if (!record || !isLive(record, nowSeconds())) return json({ active: false });\n return json({\n active: true,\n validUntil: record.validUntil,\n kernelAddress: record.kernelAddress,\n ownerAddress: record.ownerAddress,\n sessionKeyAddress: record.sessionKeyAddress,\n actions: record.actions,\n });\n }),\n },\n\n act: {\n POST: (request) =>\n guard(\"combo act\", async () => {\n const user = await authenticate(request);\n if (user instanceof Response) return user;\n const record = await o.store.get(user.userId);\n if (!record || !record.approval || !isLive(record, nowSeconds())) {\n throw new PepuSessionError(\"SESSION_NONE\", \"No active session. Start one first.\");\n }\n\n let input: I;\n try {\n input = o.act.parse(await request.json().catch(() => ({})));\n } catch (e) {\n throw new PepuPolicyError(\"UNKNOWN\", e instanceof Error ? e.message : \"Invalid request body.\", {\n status: 400,\n hint: \"Fix the request body.\",\n cause: e,\n });\n }\n const calls = o.act.buildCalls(input, {\n kernelAddress: record.kernelAddress,\n ownerAddress: record.ownerAddress,\n });\n // Fail fast; the chain is the real enforcement (see the file comment).\n assertCallsInScope(describeKernelSessionScope({ calls: o.scope.calls, validUntil: record.validUntil }), calls);\n\n if (!(await o.store.tryLock(user.userId))) {\n throw new PepuChainError(\"UNKNOWN\", \"An action is already in flight.\", {\n status: 429,\n retryable: true,\n hint: \"Wait for the current action to finish.\",\n });\n }\n const privyToken = o.forwardPrivyToken === false ? \"\" : bearerToken(request);\n try {\n const account = await loadKernelSessionAccount({\n publicClient: client(),\n approval: record.approval,\n sessionPrivateKey: record.sessionPrivateKey,\n });\n const kernel = createPepuSponsoredClient({\n account,\n publicClient: client(),\n ...(o.endpoints?.bundlerUrl !== undefined ? { bundlerUrl: o.endpoints.bundlerUrl } : {}),\n ...(o.endpoints?.paymasterUrl !== undefined ? { paymasterUrl: o.endpoints.paymasterUrl } : {}),\n ...(o.endpoints?.paymasterToken !== undefined ? { paymasterToken: o.endpoints.paymasterToken } : {}),\n ...(privyToken ? { paymasterContext: buildPaymasterContext({ privyAccessToken: privyToken }) } : {}),\n });\n const result = await sendSponsored({ client: kernel, calls });\n const actions = record.actions + (result.success ? 1 : 0);\n if (result.success) await o.store.set({ ...record, actions });\n const out: SponsoredActResult = {\n userOpHash: result.userOpHash,\n transactionHash: result.transactionHash,\n kernelAddress: record.kernelAddress,\n success: result.success,\n paymaster: result.paymaster,\n actualGasCostWei: result.actualGasCostWei.toString(),\n explorerUrl: result.explorerUrl,\n actions,\n };\n return json(out);\n } finally {\n await o.store.unlock(user.userId);\n }\n }),\n },\n\n revoke: {\n POST: (request) =>\n guard(\"combo revoke\", async () => {\n const user = await authenticate(request);\n if (user instanceof Response) return user;\n await o.store.delete(user.userId);\n return json({ active: false });\n }),\n },\n };\n}\n\n/**\n * Throws `POLICY_UNSCOPED` (403) unless every call targets an allowed contract\n * and function selector with a value within the limit. Pure; used by the act\n * route and exported for custom routes.\n *\n * @example\n * assertCallsInScope(describeKernelSessionScope({ calls, validUntil }), [{ to, abi, functionName: \"tap\" }]);\n */\nexport function assertCallsInScope(scope: Pick<KernelSessionScope, \"calls\">, calls: readonly Call[]): void {\n for (const c of normalizeCalls(calls)) {\n if (!isCallInScope(scope, c)) {\n throw new PepuPolicyError(\"POLICY_UNSCOPED\", \"A call is outside the session scope.\", {\n status: 403,\n hint: \"Only the contracts and functions the user approved can be called.\",\n });\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/combo/server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqCA,gBAAA,CAAiB,uBAAuB,CAAA;AAkGxC,SAAS,IAAA,CAAK,IAAA,EAAe,MAAA,GAAS,GAAA,EAAe;AACnD,EAAA,OAAO,IAAI,QAAA,CAAS,IAAA,CAAK,SAAA,CAAU,IAAI,CAAA,EAAG,EAAE,MAAA,EAAQ,OAAA,EAAS,EAAE,cAAA,EAAgB,kBAAA,IAAsB,CAAA;AACvG;AAGA,SAAS,QAAA,CAAS,GAAY,EAAA,EAAuB;AACnD,EAAA,MAAM,GAAA,GAAM,WAAA,CAAY,CAAA,EAAG,EAAE,IAAI,CAAA;AACjC,EAAA,IAAI,GAAA,CAAI,IAAA,KAAS,SAAA,IAAa,EAAE,aAAa,SAAA,CAAA,EAAY;AACvD,IAAA,OAAO,IAAI,cAAA,CAAe,SAAA,EAAW,GAAA,CAAI,OAAA,EAAS,EAAE,MAAA,EAAQ,GAAA,EAAK,KAAA,EAAO,CAAA,EAAG,CAAA;AAAA,EAC7E;AACA,EAAA,OAAO,GAAA;AACT;AAEA,eAAe,KAAA,CAAM,IAAY,EAAA,EAAgD;AAC/E,EAAA,IAAI;AACF,IAAA,OAAO,MAAM,EAAA,EAAG;AAAA,EAClB,SAAS,CAAA,EAAG;AACV,IAAA,OAAO,eAAA,CAAgB,QAAA,CAAS,CAAA,EAAG,EAAE,CAAC,CAA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AAA;AAAA,QACjB,CAAA,SAAE;AACA,UAAA,MAAM,CAAA,CAAE,KAAA,CAAM,MAAA,CAAO,IAAA,CAAK,MAAM,CAAA;AAAA,QAClC;AAAA,MACF,CAAC;AAAA,KACL;AAAA,IAEA,MAAA,EAAQ;AAAA,MACN,IAAA,EAAM,CAAC,OAAA,KACL,KAAA,CAAM,gBAAgB,YAAY;AAChC,QAAA,MAAM,IAAA,GAAO,MAAM,YAAA,CAAa,OAAO,CAAA;AACvC,QAAA,IAAI,IAAA,YAAgB,UAAU,OAAO,IAAA;AACrC,QAAA,MAAM,CAAA,CAAE,KAAA,CAAM,MAAA,CAAO,IAAA,CAAK,MAAM,CAAA;AAChC,QAAA,OAAO,IAAA,CAAK,EAAE,MAAA,EAAQ,KAAA,EAAO,CAAA;AAAA,MAC/B,CAAC;AAAA;AACL,GACF;AACF;AAUO,SAAS,kBAAA,CAAmB,OAA0C,KAAA,EAA8B;AACzG,EAAA,KAAA,MAAW,CAAA,IAAK,cAAA,CAAe,KAAK,CAAA,EAAG;AACrC,IAAA,IAAI,CAAC,aAAA,CAAc,KAAA,EAAO,CAAC,CAAA,EAAG;AAC5B,MAAA,MAAM,IAAI,eAAA,CAAgB,iBAAA,EAAmB,sCAAA,EAAwC;AAAA,QACnF,MAAA,EAAQ,GAAA;AAAA,QACR,IAAA,EAAM;AAAA,OACP,CAAA;AAAA,IACH;AAAA,EACF;AACF","file":"combo.js","sourcesContent":["import type { PrivyClient } from \"@privy-io/node\";\nimport { createPublicClient, http } from \"viem\";\nimport type { Address, PublicClient } from \"viem\";\nimport type { SponsoredActResult } from \"./types.js\";\nimport { createPepuSponsoredClient, sendSponsored } from \"../aa/kernel.js\";\nimport { normalizeCalls } from \"../aa/calls.js\";\nimport type { Call } from \"../aa/types.js\";\nimport { pepuMainnet } from \"../chains.js\";\nimport { resolvePepuEndpoints } from \"../endpoints.js\";\nimport { buildPaymasterContext } from \"../erc7677.js\";\nimport {\n PepuAuthError,\n PepuChainError,\n PepuConfigError,\n PepuError,\n PepuPolicyError,\n PepuSessionError,\n toErrorResponse,\n toPepuError,\n} from \"../errors.js\";\nimport { assertServerOnly } from \"../internal/assert-server.js\";\nimport { createPrivyServer, requireUser } from \"../privy/server.js\";\nimport { resolveSessionMinutes, sessionExpiry } from \"../session/policy.js\";\nimport {\n buildKernelSessionPolicies,\n checkApproval,\n describeKernelSessionScope,\n expectedPermissionId,\n generateSessionKey,\n getKernelAddress,\n isCallInScope,\n loadKernelSessionAccount,\n} from \"../session/kernel.js\";\nimport type { KernelSessionCall, KernelSessionScope } from \"../session/kernel.js\";\nimport { isLive } from \"../session/store.js\";\nimport type { SessionRecord, SessionStore } from \"../session/store.js\";\n\nassertServerOnly(\"@pepu-chain/sdk/combo\");\n\n/**\n * `@pepu-chain/sdk/combo` (server): the combined flow. Google sign-in (Privy),\n * a ONE-TIME on-chain session, and sponsored gas. Route factories for the\n * Kernel session lifecycle: prepare, activate, status, act, revoke.\n *\n * Extracted from templates/sponsored-session-app/app/api/session/* and\n * lib/{kernel,session-auth}.ts.\n *\n * Trust model: the chain, not these routes, enforces scope. The owner's single\n * EIP-712 signature enables a permission whose call policy (targets,\n * selectors, zero value) and timestamp policy the Kernel account verifies on\n * every UserOperation. The checks here only fail fast.\n *\n * Optional peers: `@privy-io/node`, `@zerodev/*`.\n */\n\nexport { createMemoryStore, isLive } from \"../session/store.js\";\nexport type { SessionRecord, SessionStore } from \"../session/store.js\";\nexport type { KernelSessionCall, KernelSessionScope } from \"../session/kernel.js\";\nexport type { SponsoredActResult } from \"./types.js\";\n/** Session length from `SESSION_DURATION_MINUTES` (default 15, clamped to 1..1440), the same rule the routes use. */\nexport { resolveSessionMinutes } from \"../session/policy.js\";\n\n/** The authenticated caller of a combo route. */\nexport interface ComboUser {\n userId: string;\n /** The user's Privy embedded wallet: the owner of their Kernel account. From Privy, never the request. */\n ownerAddress: Address;\n}\n\n/** Authenticate a request. Throw a `PepuError` (or return `null`) when it is not valid. */\nexport type ComboAuthenticate = (request: Request) => Promise<ComboUser | null>;\n\n/** Options for {@link createSponsoredSessionRoutes}. */\nexport interface SponsoredSessionRoutesOptions<I> {\n /** What the session may call. Enforced on-chain by the call policy. */\n scope: {\n calls: readonly KernelSessionCall[];\n /** Env variable named in the `CONFIG_MISSING_ENV` message when a call target is empty (unset). */\n targetEnv?: string;\n };\n /**\n * Where session records (including the session private key) live. Use\n * `createMemoryStore()` for development only: production needs a persistent\n * store with the key encrypted at rest.\n */\n store: SessionStore;\n /**\n * Bundler and paymaster. The bundler defaults to env `PEPU_BUNDLER_URL`, then the hosted bundler. The paymaster\n * needs a complete ERC-7677 URL (env `PEPU_PAYMASTER_URL`, or `paymasterUrl`) or a project `paymasterToken`\n * (built against the hosted paymaster base).\n */\n endpoints?: { bundlerUrl?: string; paymasterUrl?: string; paymasterToken?: string };\n /**\n * Forward the caller's Privy access token (the request's `Authorization: Bearer`) to the paymaster as ERC-7677\n * `context.privyAccessToken`. The v2 FREE TIER requires it; a project paying from its own deposit does not.\n * Default `true`. Set `false` if your paymaster URL is not a PEPU policy service you trust with the token.\n */\n forwardPrivyToken?: boolean;\n /** Session length. Default env `SESSION_DURATION_MINUTES`, then 15; clamped to 1..1440. */\n minutes?: number;\n /** The one action users take with their session. */\n act: {\n /** Validate the client body. Throw to reject with 400. */\n parse(body: unknown): I;\n /** The calls to send. Each is re-checked against `scope` before sponsoring. */\n buildCalls(input: I, ctx: { kernelAddress: Address; ownerAddress: Address }): Call[];\n };\n /** Privy client for the default authentication. Default `createPrivyServer()`. */\n privy?: PrivyClient;\n /**\n * Custom authentication. Default: B1's `requireUser` (verifies the Privy\n * bearer token and reads the user's embedded wallet from Privy).\n */\n authenticate?: ComboAuthenticate;\n /** Chain reads. Default: viem on the PEPU RPC (`PEPU_RPC_URL` aware). */\n publicClient?: PublicClient;\n /**\n * A brand-new user's embedded wallet exists in the browser a moment before Privy's server reports it. With the\n * default authentication, a signed-in user whose wallet is not visible yet is looked up again this many times\n * (`attempts`, default 3), waiting `delayMs` * attempt number between lookups (default 400 ms). If it is still\n * not visible, `status` answers `{ active: false, provisioning: true }` (a normal state, not an error) and the other\n * routes answer a retryable 409 `WALLET_NOT_PROVISIONED`.\n */\n provisioningWait?: { attempts?: number; delayMs?: number };\n}\n\n/** The five route handlers returned by {@link createSponsoredSessionRoutes}. */\nexport interface SponsoredSessionRoutes {\n prepare: { POST(request: Request): Promise<Response> };\n activate: { POST(request: Request): Promise<Response> };\n status: { GET(request: Request): Promise<Response> };\n act: { POST(request: Request): Promise<Response> };\n revoke: { POST(request: Request): Promise<Response> };\n}\n\nfunction json(body: unknown, status = 200): Response {\n return new Response(JSON.stringify(body), { status, headers: { \"content-type\": \"application/json\" } });\n}\n\n/** Anything unclassified that reaches a route is an upstream failure, not our 500. */\nfunction upstream(e: unknown, op: string): PepuError {\n const err = toPepuError(e, { op });\n if (err.code === \"UNKNOWN\" && !(e instanceof PepuError)) {\n return new PepuChainError(\"UNKNOWN\", err.message, { status: 502, cause: e });\n }\n return err;\n}\n\nasync function guard(op: string, fn: () => Promise<Response>): Promise<Response> {\n try {\n return await fn();\n } catch (e) {\n return toErrorResponse(upstream(e, op));\n }\n}\n\n/** The bearer token on a request, or `\"\"`. */\nfunction bearerToken(request: Request): string {\n return (request.headers.get(\"authorization\") ?? \"\").replace(/^Bearer\\s+/i, \"\").trim();\n}\n\n/** Marker: signed in, but Privy's server does not list an embedded wallet yet. */\nconst PROVISIONING = Symbol(\"wallet-provisioning\");\n\nconst nowSeconds = (): number => Math.floor(Date.now() / 1000);\n\nfunction defaultPublicClient(): PublicClient {\n return createPublicClient({ chain: pepuMainnet, transport: http(resolvePepuEndpoints().rpcUrl) }) as PublicClient;\n}\n\n/**\n * Route handlers for the Kernel session lifecycle.\n *\n * - `prepare.POST`: the server creates a fresh session key and decides the\n * expiry. The private key stays on the server; the response carries only the\n * key's address, the expiry and the scope, so the browser can ask the owner\n * for the ONE signature that grants exactly that. Calling it again replaces\n * any pending or active session (the old key is dropped).\n * - `activate.POST` `{ approval }`: checks the approval is for this user's\n * smart account and for exactly the key, scope and expiry issued in\n * `prepare`, then stores it. 409 `SESSION_NONE` when nothing is pending,\n * 410 `SESSION_EXPIRED` for an expired offer, 400 `SESSION_APPROVAL_MISMATCH`.\n * - `status.GET`: `{ active: false }` or `{ active: true, validUntil, ... }`.\n * Never returns the session key or approval.\n * - `act.POST`: signs ONE sponsored UserOperation with the session key. 409\n * `SESSION_NONE` without a live session, 429 while another action runs.\n * - `revoke.POST`: deletes the session key and approval from the server, so\n * the app can no longer act, immediately. It does NOT uninstall the\n * permission on-chain: that grant stays valid until its expiry, but only the\n * deleted key can use it and only within the scope. An on-chain uninstall is\n * an owner-signed call to the user's own account, which a paymaster\n * destination allowlist rightly does not sponsor.\n *\n * Gas: the paymaster policy service reserves worst-case cost per operation:\n * about 20.5 PEPU for a session's first operation and about 6.9 PEPU for later\n * ones (`SESSION_GAS_RESERVATION_PEPU`). Size spend caps above that. Fees come\n * from the chain with 20% headroom.\n *\n * @example\n * // lib/session-routes.ts\n * export const routes = createSponsoredSessionRoutes({\n * scope: { calls: [{ target: tapScore, abi: tapScoreAbi, functionName: \"tap\" }] },\n * store: createMemoryStore(), // DEV ONLY\n * act: {\n * parse: () => ({}),\n * buildCalls: () => [{ to: tapScore, abi: tapScoreAbi, functionName: \"tap\" }],\n * },\n * });\n * // app/api/session/prepare/route.ts: export const { POST } = routes.prepare;\n */\nexport function createSponsoredSessionRoutes<I>(o: SponsoredSessionRoutesOptions<I>): SponsoredSessionRoutes {\n // A call whose target is empty or undefined (an unset env variable) is \"not configured yet\":\n // every route then answers CONFIG_MISSING_ENV at request time. A malformed non-empty scope\n // still fails at startup, not on the first request.\n const unconfigured = o.scope.calls.some((c) => !c.target || String(c.target).trim() === \"\");\n if (unconfigured) {\n const unset = async (): Promise<Response> =>\n toErrorResponse(\n new PepuConfigError(\n \"CONFIG_MISSING_ENV\",\n `${o.scope.targetEnv ?? \"A session target contract address\"} is not set to a valid address. See .env.example.`,\n { hint: \"Set it and restart the server.\" },\n ),\n );\n return {\n prepare: { POST: unset },\n activate: { POST: unset },\n status: { GET: unset },\n act: { POST: unset },\n revoke: { POST: unset },\n };\n }\n buildKernelSessionPolicies({ calls: o.scope.calls, validUntil: 1 });\n let publicClient = o.publicClient;\n const client = (): PublicClient => (publicClient ??= defaultPublicClient());\n\n const wait = { attempts: o.provisioningWait?.attempts ?? 3, delayMs: o.provisioningWait?.delayMs ?? 400 };\n\n /**\n * Authenticate. A signed-in user whose wallet Privy's server does not list yet is looked up again (bounded), then\n * reported as `PROVISIONING` so the caller decides: `status` makes it a normal state, the rest throw a retryable 409.\n */\n const authenticateOrProvisioning = async (request: Request): Promise<ComboUser | Response | typeof PROVISIONING> => {\n if (o.authenticate) {\n const user = await o.authenticate(request);\n if (!user) throw new PepuAuthError(\"AUTH_INVALID_TOKEN\", \"Missing or invalid Privy access token.\");\n return user;\n }\n const privy = o.privy ?? createPrivyServer();\n for (let attempt = 0; ; attempt++) {\n const auth = await requireUser(request, { privy });\n if (!auth.ok) return auth.response;\n if (auth.user.address) return { userId: auth.user.userId, ownerAddress: auth.user.address };\n if (attempt >= wait.attempts) return PROVISIONING;\n await new Promise((resolve) => setTimeout(resolve, wait.delayMs * (attempt + 1)));\n }\n };\n\n const authenticate = async (request: Request): Promise<ComboUser | Response> => {\n const user = await authenticateOrProvisioning(request);\n if (user === PROVISIONING) {\n throw new PepuAuthError(\n \"WALLET_NOT_PROVISIONED\",\n \"Your wallet is still being set up. This usually takes a few seconds; retrying.\",\n { status: 409, retryable: true },\n );\n }\n return user;\n };\n\n const minutes = (): number => o.minutes ?? resolveSessionMinutes(process.env.SESSION_DURATION_MINUTES);\n const policiesFor = (validUntil: number) => buildKernelSessionPolicies({ calls: o.scope.calls, validUntil });\n\n return {\n prepare: {\n POST: (request) =>\n guard(\"combo prepare\", async () => {\n const user = await authenticate(request);\n if (user instanceof Response) return user;\n const { userId, ownerAddress } = user;\n const mins = minutes();\n const validUntil = sessionExpiry(nowSeconds(), mins);\n const key = generateSessionKey();\n const policies = policiesFor(validUntil);\n const [kernelAddress, permissionId] = await Promise.all([\n getKernelAddress(client(), ownerAddress),\n expectedPermissionId({ publicClient: client(), sessionKeyAddress: key.address, policies }),\n ]);\n const record: SessionRecord = {\n userId,\n ownerAddress,\n kernelAddress,\n sessionPrivateKey: key.privateKey,\n sessionKeyAddress: key.address,\n permissionId,\n validUntil,\n approval: null,\n actions: 0,\n };\n await o.store.set(record);\n return json({\n ownerAddress,\n kernelAddress,\n sessionKeyAddress: key.address,\n validUntil,\n minutes: mins,\n scope: describeKernelSessionScope({ calls: o.scope.calls, validUntil }),\n });\n }),\n },\n\n activate: {\n POST: (request) =>\n guard(\"combo activate\", async () => {\n const user = await authenticate(request);\n if (user instanceof Response) return user;\n const body = (await request.json().catch(() => null)) as { approval?: unknown } | null;\n if (typeof body?.approval !== \"string\") {\n throw new PepuPolicyError(\"UNKNOWN\", \"Missing approval.\", { status: 400, hint: \"Send { approval }.\" });\n }\n const record = await o.store.get(user.userId);\n if (!record || record.approval !== null) {\n throw new PepuSessionError(\"SESSION_NONE\", \"No pending session. Start again.\");\n }\n if (nowSeconds() >= record.validUntil) {\n await o.store.delete(record.userId);\n throw new PepuSessionError(\"SESSION_EXPIRED\", \"The session offer expired. Start again.\");\n }\n const check = checkApproval(body.approval, {\n kernelAddress: record.kernelAddress,\n permissionId: record.permissionId,\n });\n if (!check.ok) throw new PepuSessionError(\"SESSION_APPROVAL_MISMATCH\", check.reason, { status: 400 });\n await o.store.set({ ...record, approval: body.approval });\n return json({ active: true, validUntil: record.validUntil });\n }),\n },\n\n status: {\n GET: (request) =>\n guard(\"combo status\", async () => {\n const user = await authenticateOrProvisioning(request);\n if (user instanceof Response) return user;\n if (user === PROVISIONING) return json({ active: false, provisioning: true });\n const record = await o.store.get(user.userId);\n if (!record || !isLive(record, nowSeconds())) return json({ active: false });\n return json({\n active: true,\n validUntil: record.validUntil,\n kernelAddress: record.kernelAddress,\n ownerAddress: record.ownerAddress,\n sessionKeyAddress: record.sessionKeyAddress,\n actions: record.actions,\n });\n }),\n },\n\n act: {\n POST: (request) =>\n guard(\"combo act\", async () => {\n const user = await authenticate(request);\n if (user instanceof Response) return user;\n const record = await o.store.get(user.userId);\n if (!record || !record.approval || !isLive(record, nowSeconds())) {\n throw new PepuSessionError(\"SESSION_NONE\", \"No active session. Start one first.\");\n }\n\n let input: I;\n try {\n input = o.act.parse(await request.json().catch(() => ({})));\n } catch (e) {\n throw new PepuPolicyError(\"UNKNOWN\", e instanceof Error ? e.message : \"Invalid request body.\", {\n status: 400,\n hint: \"Fix the request body.\",\n cause: e,\n });\n }\n const calls = o.act.buildCalls(input, {\n kernelAddress: record.kernelAddress,\n ownerAddress: record.ownerAddress,\n });\n // Fail fast; the chain is the real enforcement (see the file comment).\n assertCallsInScope(describeKernelSessionScope({ calls: o.scope.calls, validUntil: record.validUntil }), calls);\n\n if (!(await o.store.tryLock(user.userId))) {\n throw new PepuChainError(\"UNKNOWN\", \"An action is already in flight.\", {\n status: 429,\n retryable: true,\n hint: \"Wait for the current action to finish.\",\n });\n }\n const privyToken = o.forwardPrivyToken === false ? \"\" : bearerToken(request);\n try {\n const account = await loadKernelSessionAccount({\n publicClient: client(),\n approval: record.approval,\n sessionPrivateKey: record.sessionPrivateKey,\n });\n const kernel = createPepuSponsoredClient({\n account,\n publicClient: client(),\n ...(o.endpoints?.bundlerUrl !== undefined ? { bundlerUrl: o.endpoints.bundlerUrl } : {}),\n ...(o.endpoints?.paymasterUrl !== undefined ? { paymasterUrl: o.endpoints.paymasterUrl } : {}),\n ...(o.endpoints?.paymasterToken !== undefined ? { paymasterToken: o.endpoints.paymasterToken } : {}),\n ...(privyToken ? { paymasterContext: buildPaymasterContext({ privyAccessToken: privyToken }) } : {}),\n });\n const result = await sendSponsored({ client: kernel, calls });\n const actions = record.actions + (result.success ? 1 : 0);\n if (result.success) await o.store.set({ ...record, actions });\n const out: SponsoredActResult = {\n userOpHash: result.userOpHash,\n transactionHash: result.transactionHash,\n kernelAddress: record.kernelAddress,\n success: result.success,\n paymaster: result.paymaster,\n actualGasCostWei: result.actualGasCostWei.toString(),\n explorerUrl: result.explorerUrl,\n actions,\n };\n return json(out);\n } finally {\n await o.store.unlock(user.userId);\n }\n }),\n },\n\n revoke: {\n POST: (request) =>\n guard(\"combo revoke\", async () => {\n const user = await authenticate(request);\n if (user instanceof Response) return user;\n await o.store.delete(user.userId);\n return json({ active: false });\n }),\n },\n };\n}\n\n/**\n * Throws `POLICY_UNSCOPED` (403) unless every call targets an allowed contract\n * and function selector with a value within the limit. Pure; used by the act\n * route and exported for custom routes.\n *\n * @example\n * assertCallsInScope(describeKernelSessionScope({ calls, validUntil }), [{ to, abi, functionName: \"tap\" }]);\n */\nexport function assertCallsInScope(scope: Pick<KernelSessionScope, \"calls\">, calls: readonly Call[]): void {\n for (const c of normalizeCalls(calls)) {\n if (!isCallInScope(scope, c)) {\n throw new PepuPolicyError(\"POLICY_UNSCOPED\", \"A call is outside the session scope.\", {\n status: 403,\n hint: \"Only the contracts and functions the user approved can be called.\",\n });\n }\n }\n}\n"]}
package/dist/index.cjs CHANGED
@@ -1,9 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunkET3P6TX6_cjs = require('./chunk-ET3P6TX6.cjs');
4
- var chunkSLW7FRTL_cjs = require('./chunk-SLW7FRTL.cjs');
5
- require('./chunk-WANILJZQ.cjs');
6
- var chunkTIEAZYHF_cjs = require('./chunk-TIEAZYHF.cjs');
3
+ var chunkRCMKPJZO_cjs = require('./chunk-RCMKPJZO.cjs');
4
+ var chunkVYMAZVIK_cjs = require('./chunk-VYMAZVIK.cjs');
5
+ require('./chunk-HTCX46RJ.cjs');
6
+ var chunkK7JSQPZO_cjs = require('./chunk-K7JSQPZO.cjs');
7
+ require('./chunk-65Y5UCQ7.cjs');
7
8
  var chunkC7IC36XS_cjs = require('./chunk-C7IC36XS.cjs');
8
9
  var chunk4GINFJO6_cjs = require('./chunk-4GINFJO6.cjs');
9
10
  var chunkVF3D6KLQ_cjs = require('./chunk-VF3D6KLQ.cjs');
@@ -435,8 +436,8 @@ function assertNotCanonicalMulticall3(address) {
435
436
  }
436
437
  }
437
438
  function getMulticall3(chainId = chunkDPCZJLB3_cjs.pepuMainnet.id) {
438
- const entry = chunkTIEAZYHF_cjs.getContract(chainId, "multicall3");
439
- if (!chunkTIEAZYHF_cjs.isDeployed(entry)) {
439
+ const entry = chunkK7JSQPZO_cjs.getContract(chainId, "multicall3");
440
+ if (!chunkK7JSQPZO_cjs.isDeployed(entry)) {
440
441
  throw new chunkYQL7NISX_cjs.PepuChainError("UNKNOWN", "Multicall3 is not deployed on the requested chain.");
441
442
  }
442
443
  assertNotCanonicalMulticall3(entry.address);
@@ -476,8 +477,8 @@ function decodeAggregate3Result(data) {
476
477
 
477
478
  // src/permit2.ts
478
479
  function getPermit2(chainId = chunkDPCZJLB3_cjs.pepuMainnet.id) {
479
- const entry = chunkTIEAZYHF_cjs.getContract(chainId, "permit2");
480
- if (!chunkTIEAZYHF_cjs.isDeployed(entry)) {
480
+ const entry = chunkK7JSQPZO_cjs.getContract(chainId, "permit2");
481
+ if (!chunkK7JSQPZO_cjs.isDeployed(entry)) {
481
482
  throw new chunkYQL7NISX_cjs.PepuChainError("UNKNOWN", "Permit2 is not deployed on the requested chain.");
482
483
  }
483
484
  return entry;
@@ -554,63 +555,67 @@ async function readPermit2Allowance(client, o) {
554
555
 
555
556
  Object.defineProperty(exports, "buildPaymasterContext", {
556
557
  enumerable: true,
557
- get: function () { return chunkET3P6TX6_cjs.buildPaymasterContext; }
558
+ get: function () { return chunkRCMKPJZO_cjs.buildPaymasterContext; }
558
559
  });
559
560
  Object.defineProperty(exports, "buildPaymasterDataRequest", {
560
561
  enumerable: true,
561
- get: function () { return chunkET3P6TX6_cjs.buildPaymasterDataRequest; }
562
+ get: function () { return chunkRCMKPJZO_cjs.buildPaymasterDataRequest; }
562
563
  });
563
564
  Object.defineProperty(exports, "buildPaymasterStubDataRequest", {
564
565
  enumerable: true,
565
- get: function () { return chunkET3P6TX6_cjs.buildPaymasterStubDataRequest; }
566
+ get: function () { return chunkRCMKPJZO_cjs.buildPaymasterStubDataRequest; }
566
567
  });
567
568
  Object.defineProperty(exports, "KERNEL_V3_1_IMPLEMENTATION_ADDRESS", {
568
569
  enumerable: true,
569
- get: function () { return chunkSLW7FRTL_cjs.KERNEL_V3_1_IMPLEMENTATION_ADDRESS; }
570
+ get: function () { return chunkVYMAZVIK_cjs.KERNEL_V3_1_IMPLEMENTATION_ADDRESS; }
570
571
  });
571
572
  Object.defineProperty(exports, "checkSponsorship", {
572
573
  enumerable: true,
573
- get: function () { return chunkSLW7FRTL_cjs.checkSponsorship; }
574
+ get: function () { return chunkVYMAZVIK_cjs.checkSponsorship; }
574
575
  });
575
576
  Object.defineProperty(exports, "entryPointV07Abi", {
576
577
  enumerable: true,
577
- get: function () { return chunkSLW7FRTL_cjs.entryPointV07Abi; }
578
+ get: function () { return chunkVYMAZVIK_cjs.entryPointV07Abi; }
578
579
  });
579
580
  Object.defineProperty(exports, "getKernelAccountAddress", {
580
581
  enumerable: true,
581
- get: function () { return chunkSLW7FRTL_cjs.getKernelAccountAddress; }
582
+ get: function () { return chunkVYMAZVIK_cjs.getKernelAccountAddress; }
582
583
  });
583
584
  Object.defineProperty(exports, "getPepuKernelStack", {
584
585
  enumerable: true,
585
- get: function () { return chunkSLW7FRTL_cjs.getPepuKernelStack; }
586
+ get: function () { return chunkVYMAZVIK_cjs.getPepuKernelStack; }
586
587
  });
587
588
  Object.defineProperty(exports, "getSponsorshipStatus", {
588
589
  enumerable: true,
589
- get: function () { return chunkSLW7FRTL_cjs.getSponsorshipStatus; }
590
+ get: function () { return chunkVYMAZVIK_cjs.getSponsorshipStatus; }
590
591
  });
591
592
  Object.defineProperty(exports, "kernelFactoryAbi", {
592
593
  enumerable: true,
593
- get: function () { return chunkSLW7FRTL_cjs.kernelFactoryAbi; }
594
+ get: function () { return chunkVYMAZVIK_cjs.kernelFactoryAbi; }
594
595
  });
595
596
  Object.defineProperty(exports, "getContract", {
596
597
  enumerable: true,
597
- get: function () { return chunkTIEAZYHF_cjs.getContract; }
598
+ get: function () { return chunkK7JSQPZO_cjs.getContract; }
599
+ });
600
+ Object.defineProperty(exports, "getPepuAddressMap", {
601
+ enumerable: true,
602
+ get: function () { return chunkK7JSQPZO_cjs.getPepuAddressMap; }
598
603
  });
599
604
  Object.defineProperty(exports, "getPepuAddresses", {
600
605
  enumerable: true,
601
- get: function () { return chunkTIEAZYHF_cjs.getPepuAddresses; }
606
+ get: function () { return chunkK7JSQPZO_cjs.getPepuAddresses; }
602
607
  });
603
608
  Object.defineProperty(exports, "isDeployed", {
604
609
  enumerable: true,
605
- get: function () { return chunkTIEAZYHF_cjs.isDeployed; }
610
+ get: function () { return chunkK7JSQPZO_cjs.isDeployed; }
606
611
  });
607
612
  Object.defineProperty(exports, "listContracts", {
608
613
  enumerable: true,
609
- get: function () { return chunkTIEAZYHF_cjs.listContracts; }
614
+ get: function () { return chunkK7JSQPZO_cjs.listContracts; }
610
615
  });
611
616
  Object.defineProperty(exports, "pepuContracts", {
612
617
  enumerable: true,
613
- get: function () { return chunkTIEAZYHF_cjs.pepuContracts; }
618
+ get: function () { return chunkK7JSQPZO_cjs.pepuContracts; }
614
619
  });
615
620
  Object.defineProperty(exports, "getPublicClient", {
616
621
  enumerable: true,