@pepu-chain/sdk 0.0.0-stage → 0.2.1

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 (244) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +590 -2
  3. package/dist/aa/kernel.cjs +41 -0
  4. package/dist/aa/kernel.cjs.map +1 -0
  5. package/dist/aa/kernel.d.cts +88 -0
  6. package/dist/aa/kernel.d.ts +88 -0
  7. package/dist/aa/kernel.guard.js +15 -0
  8. package/dist/aa/kernel.js +11 -0
  9. package/dist/aa/kernel.js.map +1 -0
  10. package/dist/aa/react-direct.cjs +111 -0
  11. package/dist/aa/react-direct.cjs.map +1 -0
  12. package/dist/aa/react-direct.d.cts +42 -0
  13. package/dist/aa/react-direct.d.ts +42 -0
  14. package/dist/aa/react-direct.guard.js +15 -0
  15. package/dist/aa/react-direct.js +107 -0
  16. package/dist/aa/react-direct.js.map +1 -0
  17. package/dist/aa/react.cjs +152 -0
  18. package/dist/aa/react.cjs.map +1 -0
  19. package/dist/aa/react.d.cts +62 -0
  20. package/dist/aa/react.d.ts +62 -0
  21. package/dist/aa/react.guard.js +15 -0
  22. package/dist/aa/react.js +147 -0
  23. package/dist/aa/react.js.map +1 -0
  24. package/dist/aa.cjs +84 -0
  25. package/dist/aa.cjs.map +1 -0
  26. package/dist/aa.d.cts +85 -0
  27. package/dist/aa.d.ts +85 -0
  28. package/dist/aa.js +11 -0
  29. package/dist/aa.js.map +1 -0
  30. package/dist/api-Dz4sCHH_.d.cts +654 -0
  31. package/dist/api-Dz4sCHH_.d.ts +654 -0
  32. package/dist/calls-BRPjKgjl.d.cts +70 -0
  33. package/dist/calls-z_EQOtFb.d.ts +70 -0
  34. package/dist/chains-DK13zGIp.d.cts +235 -0
  35. package/dist/chains-DK13zGIp.d.ts +235 -0
  36. package/dist/chunk-3XUGQODR.js +194 -0
  37. package/dist/chunk-3XUGQODR.js.map +1 -0
  38. package/dist/chunk-45KSZH26.cjs +145 -0
  39. package/dist/chunk-45KSZH26.cjs.map +1 -0
  40. package/dist/chunk-4GINFJO6.cjs +44 -0
  41. package/dist/chunk-4GINFJO6.cjs.map +1 -0
  42. package/dist/chunk-62M2LKQW.js +136 -0
  43. package/dist/chunk-62M2LKQW.js.map +1 -0
  44. package/dist/chunk-6DSZ4Z2N.js +498 -0
  45. package/dist/chunk-6DSZ4Z2N.js.map +1 -0
  46. package/dist/chunk-7MNJF2OB.cjs +72 -0
  47. package/dist/chunk-7MNJF2OB.cjs.map +1 -0
  48. package/dist/chunk-7PVR7QSE.js +45 -0
  49. package/dist/chunk-7PVR7QSE.js.map +1 -0
  50. package/dist/chunk-A5LP2UCS.cjs +2729 -0
  51. package/dist/chunk-A5LP2UCS.cjs.map +1 -0
  52. package/dist/chunk-AJS4UFQX.cjs +121 -0
  53. package/dist/chunk-AJS4UFQX.cjs.map +1 -0
  54. package/dist/chunk-BGALSKAF.cjs +315 -0
  55. package/dist/chunk-BGALSKAF.cjs.map +1 -0
  56. package/dist/chunk-C2XW44FI.cjs +200 -0
  57. package/dist/chunk-C2XW44FI.cjs.map +1 -0
  58. package/dist/chunk-C7IC36XS.cjs +13 -0
  59. package/dist/chunk-C7IC36XS.cjs.map +1 -0
  60. package/dist/chunk-D52PADVY.js +84 -0
  61. package/dist/chunk-D52PADVY.js.map +1 -0
  62. package/dist/chunk-DH6BFNVJ.cjs +272 -0
  63. package/dist/chunk-DH6BFNVJ.cjs.map +1 -0
  64. package/dist/chunk-DPCZJLB3.cjs +87 -0
  65. package/dist/chunk-DPCZJLB3.cjs.map +1 -0
  66. package/dist/chunk-EHBPIYY4.js +262 -0
  67. package/dist/chunk-EHBPIYY4.js.map +1 -0
  68. package/dist/chunk-ESMNAXUI.js +86 -0
  69. package/dist/chunk-ESMNAXUI.js.map +1 -0
  70. package/dist/chunk-F2R473FR.js +304 -0
  71. package/dist/chunk-F2R473FR.js.map +1 -0
  72. package/dist/chunk-IB2FSPMJ.js +66 -0
  73. package/dist/chunk-IB2FSPMJ.js.map +1 -0
  74. package/dist/chunk-IG7RSL2Y.cjs +178 -0
  75. package/dist/chunk-IG7RSL2Y.cjs.map +1 -0
  76. package/dist/chunk-IY3ALPUJ.js +2716 -0
  77. package/dist/chunk-IY3ALPUJ.js.map +1 -0
  78. package/dist/chunk-J3O2ZGG3.cjs +93 -0
  79. package/dist/chunk-J3O2ZGG3.cjs.map +1 -0
  80. package/dist/chunk-J6UXXHBE.js +37 -0
  81. package/dist/chunk-J6UXXHBE.js.map +1 -0
  82. package/dist/chunk-JLZ4LZ4Z.js +22 -0
  83. package/dist/chunk-JLZ4LZ4Z.js.map +1 -0
  84. package/dist/chunk-K7JSQPZO.cjs +231 -0
  85. package/dist/chunk-K7JSQPZO.cjs.map +1 -0
  86. package/dist/chunk-KJYNF5KH.js +224 -0
  87. package/dist/chunk-KJYNF5KH.js.map +1 -0
  88. package/dist/chunk-KVG3AYYR.js +99 -0
  89. package/dist/chunk-KVG3AYYR.js.map +1 -0
  90. package/dist/chunk-NE3QKDOB.cjs +24 -0
  91. package/dist/chunk-NE3QKDOB.cjs.map +1 -0
  92. package/dist/chunk-NVOPDXTA.cjs +95 -0
  93. package/dist/chunk-NVOPDXTA.cjs.map +1 -0
  94. package/dist/chunk-OH3QMAIB.js +11 -0
  95. package/dist/chunk-OH3QMAIB.js.map +1 -0
  96. package/dist/chunk-PHM3ZORG.cjs +110 -0
  97. package/dist/chunk-PHM3ZORG.cjs.map +1 -0
  98. package/dist/chunk-R5PXQNO3.cjs +209 -0
  99. package/dist/chunk-R5PXQNO3.cjs.map +1 -0
  100. package/dist/chunk-RCMKPJZO.cjs +49 -0
  101. package/dist/chunk-RCMKPJZO.cjs.map +1 -0
  102. package/dist/chunk-SVWRRALU.cjs +17 -0
  103. package/dist/chunk-SVWRRALU.cjs.map +1 -0
  104. package/dist/chunk-T43PQXJD.js +202 -0
  105. package/dist/chunk-T43PQXJD.js.map +1 -0
  106. package/dist/chunk-VBH3JLQ5.js +116 -0
  107. package/dist/chunk-VBH3JLQ5.js.map +1 -0
  108. package/dist/chunk-VF3D6KLQ.cjs +94 -0
  109. package/dist/chunk-VF3D6KLQ.cjs.map +1 -0
  110. package/dist/chunk-VTQIHMF3.js +82 -0
  111. package/dist/chunk-VTQIHMF3.js.map +1 -0
  112. package/dist/chunk-W3JN3YIW.js +15 -0
  113. package/dist/chunk-W3JN3YIW.js.map +1 -0
  114. package/dist/chunk-WANILJZQ.cjs +87 -0
  115. package/dist/chunk-WANILJZQ.cjs.map +1 -0
  116. package/dist/chunk-XC4IBCI2.js +86 -0
  117. package/dist/chunk-XC4IBCI2.js.map +1 -0
  118. package/dist/chunk-YKEWWQEJ.js +165 -0
  119. package/dist/chunk-YKEWWQEJ.js.map +1 -0
  120. package/dist/chunk-YQL7NISX.cjs +515 -0
  121. package/dist/chunk-YQL7NISX.cjs.map +1 -0
  122. package/dist/chunk-ZB6SVBK4.js +89 -0
  123. package/dist/chunk-ZB6SVBK4.js.map +1 -0
  124. package/dist/combo/react.cjs +236 -0
  125. package/dist/combo/react.cjs.map +1 -0
  126. package/dist/combo/react.d.cts +148 -0
  127. package/dist/combo/react.d.ts +148 -0
  128. package/dist/combo/react.guard.js +15 -0
  129. package/dist/combo/react.js +230 -0
  130. package/dist/combo/react.js.map +1 -0
  131. package/dist/combo.cjs +263 -0
  132. package/dist/combo.cjs.map +1 -0
  133. package/dist/combo.d.cts +139 -0
  134. package/dist/combo.d.ts +139 -0
  135. package/dist/combo.guard.js +15 -0
  136. package/dist/combo.js +249 -0
  137. package/dist/combo.js.map +1 -0
  138. package/dist/config-CHjz7ZjZ.d.cts +57 -0
  139. package/dist/config-COjhIZTh.d.ts +57 -0
  140. package/dist/doctor.cjs +354 -0
  141. package/dist/doctor.cjs.map +1 -0
  142. package/dist/doctor.d.cts +177 -0
  143. package/dist/doctor.d.ts +177 -0
  144. package/dist/doctor.js +345 -0
  145. package/dist/doctor.js.map +1 -0
  146. package/dist/erc7677-DOW58QBE.d.cts +111 -0
  147. package/dist/erc7677-DOW58QBE.d.ts +111 -0
  148. package/dist/errors-CgX1vNj7.d.cts +100 -0
  149. package/dist/errors-CgX1vNj7.d.ts +100 -0
  150. package/dist/index.cjs +806 -0
  151. package/dist/index.cjs.map +1 -0
  152. package/dist/index.d.cts +2398 -0
  153. package/dist/index.d.ts +2398 -0
  154. package/dist/index.js +559 -0
  155. package/dist/index.js.map +1 -0
  156. package/dist/paymaster/server.cjs +38 -0
  157. package/dist/paymaster/server.cjs.map +1 -0
  158. package/dist/paymaster/server.d.cts +57 -0
  159. package/dist/paymaster/server.d.ts +57 -0
  160. package/dist/paymaster/server.js +36 -0
  161. package/dist/paymaster/server.js.map +1 -0
  162. package/dist/paymaster.cjs +356 -0
  163. package/dist/paymaster.cjs.map +1 -0
  164. package/dist/paymaster.d.cts +1851 -0
  165. package/dist/paymaster.d.ts +1851 -0
  166. package/dist/paymaster.js +289 -0
  167. package/dist/paymaster.js.map +1 -0
  168. package/dist/privy/react.cjs +49 -0
  169. package/dist/privy/react.cjs.map +1 -0
  170. package/dist/privy/react.d.cts +194 -0
  171. package/dist/privy/react.d.ts +194 -0
  172. package/dist/privy/react.guard.js +15 -0
  173. package/dist/privy/react.js +7 -0
  174. package/dist/privy/react.js.map +1 -0
  175. package/dist/privy/server.cjs +44 -0
  176. package/dist/privy/server.cjs.map +1 -0
  177. package/dist/privy/server.d.cts +192 -0
  178. package/dist/privy/server.d.ts +192 -0
  179. package/dist/privy/server.guard.js +15 -0
  180. package/dist/privy/server.js +6 -0
  181. package/dist/privy/server.js.map +1 -0
  182. package/dist/privy/wagmi.d.ts +90 -0
  183. package/dist/privy/wagmi.guard.js +15 -0
  184. package/dist/privy/wagmi.js +55 -0
  185. package/dist/privy/wagmi.js.map +1 -0
  186. package/dist/privy.cjs +34 -0
  187. package/dist/privy.cjs.map +1 -0
  188. package/dist/privy.d.cts +4 -0
  189. package/dist/privy.d.ts +4 -0
  190. package/dist/privy.js +5 -0
  191. package/dist/privy.js.map +1 -0
  192. package/dist/react.cjs +73 -0
  193. package/dist/react.cjs.map +1 -0
  194. package/dist/react.d.cts +66 -0
  195. package/dist/react.d.ts +66 -0
  196. package/dist/react.guard.js +15 -0
  197. package/dist/react.js +68 -0
  198. package/dist/react.js.map +1 -0
  199. package/dist/requirements-C-QiJkL9.d.cts +134 -0
  200. package/dist/requirements-C-QiJkL9.d.ts +134 -0
  201. package/dist/scope-DBRkN7bR.d.cts +94 -0
  202. package/dist/scope-DBRkN7bR.d.ts +94 -0
  203. package/dist/server.cjs +59 -0
  204. package/dist/server.cjs.map +1 -0
  205. package/dist/server.d.cts +208 -0
  206. package/dist/server.d.ts +208 -0
  207. package/dist/server.js +8 -0
  208. package/dist/server.js.map +1 -0
  209. package/dist/session/kernel.cjs +83 -0
  210. package/dist/session/kernel.cjs.map +1 -0
  211. package/dist/session/kernel.d.cts +131 -0
  212. package/dist/session/kernel.d.ts +131 -0
  213. package/dist/session/kernel.guard.js +15 -0
  214. package/dist/session/kernel.js +13 -0
  215. package/dist/session/kernel.js.map +1 -0
  216. package/dist/session/react.cjs +38 -0
  217. package/dist/session/react.cjs.map +1 -0
  218. package/dist/session/react.d.cts +119 -0
  219. package/dist/session/react.d.ts +119 -0
  220. package/dist/session/react.guard.js +15 -0
  221. package/dist/session/react.js +8 -0
  222. package/dist/session/react.js.map +1 -0
  223. package/dist/session/server.cjs +268 -0
  224. package/dist/session/server.cjs.map +1 -0
  225. package/dist/session/server.d.cts +151 -0
  226. package/dist/session/server.d.ts +151 -0
  227. package/dist/session/server.guard.js +15 -0
  228. package/dist/session/server.js +252 -0
  229. package/dist/session/server.js.map +1 -0
  230. package/dist/session.cjs +74 -0
  231. package/dist/session.cjs.map +1 -0
  232. package/dist/session.d.cts +3 -0
  233. package/dist/session.d.ts +3 -0
  234. package/dist/session.js +5 -0
  235. package/dist/session.js.map +1 -0
  236. package/dist/status-Dx9zAFo9.d.ts +327 -0
  237. package/dist/status-wgTM26V7.d.cts +327 -0
  238. package/dist/store-CjmLgp9g.d.cts +64 -0
  239. package/dist/store-CjmLgp9g.d.ts +64 -0
  240. package/dist/types-BEEM7WdG.d.cts +25 -0
  241. package/dist/types-BEEM7WdG.d.ts +25 -0
  242. package/dist/types-BilBTDqK.d.cts +27 -0
  243. package/dist/types-BilBTDqK.d.ts +27 -0
  244. package/package.json +245 -3
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/privy/server.ts"],"names":[],"mappings":";;;;;AAOA,gBAAA,CAAiB,8BAA8B,CAAA;AAgDxC,SAAS,YAAY,IAAA,EAAkD;AAC5E,EAAA,MAAM,MAAM,OAAO,OAAA,KAAY,WAAA,GAAc,OAAA,CAAQ,MAAM,EAAC;AAC5D,EAAA,KAAA,MAAW,CAAA,IAAK,CAAC,SAAA,CAAU,IAAI,GAAG,GAAG,iBAAA,CAAkB,IAAI,CAAC,CAAA,EAAG;AAC7D,IAAA,MAAM,CAAA,GAAI,GAAA,CAAI,CAAC,CAAA,EAAG,IAAA,EAAK;AACvB,IAAA,IAAI,GAAG,OAAO,CAAA;AAAA,EAChB;AACA,EAAA,OAAO,MAAA;AACT;AAYO,SAAS,kBAAA,CAAmB,CAAA,GAA6F,EAAC,EAAmB;AAClJ,EAAA,MAAM,SAAS,CAAA,CAAE,KAAA,IAAS,YAAY,OAAO,CAAA,IAAK,IAAI,IAAA,EAAK;AAC3D,EAAA,MAAM,aAAa,CAAA,CAAE,SAAA,IAAa,YAAY,WAAW,CAAA,IAAK,IAAI,IAAA,EAAK;AACvE,EAAA,MAAM,oBAAoB,CAAA,CAAE,gBAAA,IAAoB,YAAY,kBAAkB,CAAA,IAAK,IAAI,IAAA,EAAK;AAC5F,EAAA,MAAM,eAAe,CAAA,CAAE,WAAA,IAAe,YAAY,aAAa,CAAA,IAAK,IAAI,IAAA,EAAK;AAC7E,EAAA,MAAM,UAAoB,EAAC;AAC3B,EAAA,IAAI,CAAC,KAAA,EAAO,OAAA,CAAQ,IAAA,CAAK,UAAU,KAAK,CAAA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EAAQ,GAAA;AAAA,YACR,KAAA,EAAO,YAAY,WAAW;AAAA,WAC/B;AAAA,SACH;AAAA,MACF;AAAA,IACF;AAAA,GACF;AACF","file":"chunk-62M2LKQW.js","sourcesContent":["import { isEmbeddedWalletLinkedAccount, PrivyClient } from \"@privy-io/node\";\nimport type { LinkedAccount, LinkedAccountEmbeddedWallet } from \"@privy-io/node\";\nimport type { Address } from \"viem\";\nimport { assertServerOnly } from \"../internal/assert-server.js\";\nimport { PepuAuthError, PepuConfigError, PepuError, toErrorResponse, toPepuError } from \"../errors.js\";\nimport { PRIVY_ENV, PRIVY_ENV_ALIASES } from \"./requirements.js\";\n\nassertServerOnly(\"@pepu-chain/sdk/privy/server\");\n\n/**\n * `@pepu-chain/sdk/privy/server` (server). Privy server client, access-token\n * verification and the ensure-wallet route factory. Never import it from\n * client code: it calls `assertServerOnly()` at import.\n *\n * Optional peer: `@privy-io/node`.\n */\n\n/** A Privy linked embedded-wallet account. */\nexport type LinkedWallet = LinkedAccountEmbeddedWallet;\n\n/** The part of a Privy user object these helpers read. */\nexport interface PrivyUser {\n linked_accounts: readonly LinkedAccount[];\n}\n\n/** The authenticated caller, as returned by {@link requireUser}. */\nexport interface PepuUser {\n /** The Privy user id, only ever taken from a verified access token. */\n userId: string;\n /** The user's embedded Ethereum wallet address, `null` if not provisioned yet. */\n address: Address | null;\n /** The Privy user object the address was read from. */\n privyUser: PrivyUser;\n}\n\n/** Server-side Privy configuration read from the environment. */\nexport interface PrivyServerEnv {\n appId: string;\n appSecret: string;\n /** Private half of the authorization key. Only sessions need it. */\n authorizationKey?: string;\n /** The key quorum id sessions grant. Only sessions need it. */\n keyQuorumId?: string;\n}\n\n/**\n * The single reader for the Privy variables ({@link PRIVY_ENV}, then its\n * aliases). Trimmed; `undefined` when unset or blank. Session routes use it\n * too, so every module agrees on names.\n *\n * @example\n * ```ts\n * const quorum = privyEnvVar(\"keyQuorumId\");\n * ```\n */\nexport function privyEnvVar(name: keyof typeof PRIVY_ENV): string | undefined {\n const env = typeof process !== \"undefined\" ? process.env : {};\n for (const n of [PRIVY_ENV[name], ...PRIVY_ENV_ALIASES[name]]) {\n const v = env[n]?.trim();\n if (v) return v;\n }\n return undefined;\n}\n\n/**\n * Read the Privy server variables ({@link PRIVY_ENV}), explicit options winning.\n * Throws a `PepuConfigError` that lists every missing variable by NAME only.\n * `PRIVY_AUTHORIZATION_KEY` is optional here (ensure-wallet never needs it).\n *\n * @example\n * ```ts\n * const { appId, appSecret } = readPrivyServerEnv();\n * ```\n */\nexport function readPrivyServerEnv(o: { appId?: string; appSecret?: string; authorizationKey?: string; keyQuorumId?: string } = {}): PrivyServerEnv {\n const appId = (o.appId ?? privyEnvVar(\"appId\") ?? \"\").trim();\n const appSecret = (o.appSecret ?? privyEnvVar(\"appSecret\") ?? \"\").trim();\n const authorizationKey = (o.authorizationKey ?? privyEnvVar(\"authorizationKey\") ?? \"\").trim();\n const keyQuorumId = (o.keyQuorumId ?? privyEnvVar(\"keyQuorumId\") ?? \"\").trim();\n const missing: string[] = [];\n if (!appId) missing.push(PRIVY_ENV.appId);\n if (!appSecret) missing.push(PRIVY_ENV.appSecret);\n if (missing.length > 0) {\n throw new PepuConfigError(\"CONFIG_MISSING_ENV\", `Missing required env: ${missing.join(\", \")}. See .env.example.`, {\n details: { missing },\n });\n }\n return {\n appId,\n appSecret,\n ...(authorizationKey ? { authorizationKey } : {}),\n ...(keyQuorumId ? { keyQuorumId } : {}),\n };\n}\n\nconst clientCache = new Map<string, PrivyClient>();\n\n/**\n * A cached `PrivyClient` (`@privy-io/node`) built from {@link PRIVY_ENV}. One\n * instance per distinct credential set. The authorization key is not given to\n * the client: Privy takes it per request (`authorization_context`), see\n * {@link readPrivyServerEnv}.\n *\n * Ported from templates/consumer-app/lib/privy-server.ts.\n *\n * @example\n * ```ts\n * const privy = createPrivyServer();\n * const user = await privy.users()._get(userId);\n * ```\n */\nexport function createPrivyServer(o: { appId?: string; appSecret?: string; authorizationKey?: string; keyQuorumId?: string } = {}): PrivyClient {\n const { appId, appSecret } = readPrivyServerEnv(o);\n const key = `${appId}\\u0000${appSecret}`;\n let client = clientCache.get(key);\n if (!client) {\n client = new PrivyClient({ appId, appSecret });\n clientCache.set(key, client);\n }\n return client;\n}\n\nconst redact = (text: string, secret: string): string => (secret ? text.split(secret).join(\"[redacted]\") : text);\n\n/**\n * Verify the `Authorization: Bearer <token>` header against Privy and return the\n * caller's Privy user id and claims. Throws `PepuAuthError` (`AUTH_INVALID_TOKEN`,\n * HTTP 401) when the header is missing or the token does not verify. The reason\n * Privy gave goes in `details.reason` (token redacted): a verification failure\n * caused by a mismatched `PRIVY_APP_SECRET` looks exactly like an expired\n * session, so check it first.\n *\n * Note `verifyAccessToken(token)` on `privy.utils().auth()` takes a bare string,\n * not `{ access_token }` (that is the standalone function's signature).\n *\n * Ported from templates/consumer-app/lib/privy-auth.ts.\n *\n * @example\n * ```ts\n * const { userId } = await verifyRequestUser(request);\n * ```\n */\nexport async function verifyRequestUser(\n request: Request,\n o: { privy?: PrivyClient } = {},\n): Promise<{ userId: string; claims: unknown }> {\n const header = request.headers.get(\"authorization\") ?? \"\";\n const token = header.replace(/^Bearer\\s+/i, \"\").trim();\n if (!token) {\n throw new PepuAuthError(\"AUTH_INVALID_TOKEN\", \"Missing Privy access token. Send Authorization: Bearer <token>.\");\n }\n const privy = o.privy ?? createPrivyServer();\n try {\n const claims = await privy.utils().auth().verifyAccessToken(token);\n return { userId: claims.user_id, claims };\n } catch (e) {\n const reason = redact(e instanceof Error ? e.message : String(e), token);\n throw new PepuAuthError(\"AUTH_INVALID_TOKEN\", \"Invalid or expired Privy access token.\", {\n details: { reason },\n });\n }\n}\n\n/**\n * The user's Ethereum embedded wallet (delegated or not), or `null`. This is\n * what makes ensure-wallet idempotent.\n *\n * Ported from templates/consumer-app/lib/privy-user.ts.\n *\n * @example\n * ```ts\n * const wallet = findEmbeddedEthereumWallet(user);\n * ```\n */\nexport function findEmbeddedEthereumWallet(user: PrivyUser): LinkedWallet | null {\n for (const account of user.linked_accounts) {\n if (isEmbeddedWalletLinkedAccount(account) && account.chain_type === \"ethereum\") return account;\n }\n return null;\n}\n\n/**\n * The user's Ethereum embedded wallet that has been delegated (granted a\n * session signer), or `null`.\n *\n * Ported from templates/game-app/lib/privy-user.ts.\n *\n * @example\n * ```ts\n * const wallet = findDelegatedEthereumWallet(user);\n * ```\n */\nexport function findDelegatedEthereumWallet(user: PrivyUser): LinkedWallet | null {\n for (const account of user.linked_accounts) {\n if (isEmbeddedWalletLinkedAccount(account) && account.chain_type === \"ethereum\" && account.delegated) {\n return account;\n }\n }\n return null;\n}\n\n/**\n * Authenticate a request for a route handler. On success returns the user id\n * (from the verified token only) and the user's embedded wallet address. On\n * failure returns a ready JSON `Response` (`{ error: { code, message, hint } }`:\n * 401 for a bad token, 500 for missing config, 502 if Privy cannot be reached).\n * Never throws.\n *\n * @example\n * ```ts\n * export async function POST(request: Request) {\n * const auth = await requireUser(request);\n * if (!auth.ok) return auth.response;\n * return Response.json({ userId: auth.user.userId });\n * }\n * ```\n */\nexport async function requireUser(\n request: Request,\n o: { privy?: PrivyClient } = {},\n): Promise<{ ok: true; user: PepuUser } | { ok: false; response: Response }> {\n try {\n const privy = o.privy ?? createPrivyServer();\n const { userId } = await verifyRequestUser(request, { privy });\n let privyUser: PrivyUser;\n try {\n privyUser = await privy.users()._get(userId);\n } catch (e) {\n throw new PepuError(\"UNKNOWN\", \"Could not look up the user in Privy.\", { status: 502, retryable: true, cause: e });\n }\n const wallet = findEmbeddedEthereumWallet(privyUser);\n return { ok: true, user: { userId, address: (wallet?.address as Address | undefined) ?? null, privyUser } };\n } catch (e) {\n return { ok: false, response: toErrorResponse(e) };\n }\n}\n\n/**\n * Next.js route handler that creates the signed-in user's Ethereum embedded\n * wallet server-side if they have none. Drop-in:\n * `export const { POST } = createEnsureWalletRoute();` in\n * `app/api/wallet/ensure/route.ts`.\n *\n * Why: Privy's own client-side creation hangs forever for apps whose dashboard\n * creation setting is off; pair it with `createOnLogin: \"off\"` (the default of\n * `createPepuPrivyConfig`) and `WalletGate`.\n *\n * - CUSTODY: the wallet is created with `owner: { user_id }`. This backend holds\n * no signing authority over it. Do not add a session signer here.\n * - SECURITY: the user id comes only from the verified access token, never from\n * the body or query string.\n * - IDEMPOTENT: it looks for an existing wallet first and re-checks after a\n * failed create, so a double submit never makes a second wallet.\n *\n * Ported from templates/consumer-app/app/api/wallet/ensure/route.ts.\n *\n * @example\n * ```ts\n * // app/api/wallet/ensure/route.ts\n * import { createEnsureWalletRoute } from \"@pepu-chain/sdk/privy/server\";\n * export const { POST } = createEnsureWalletRoute();\n * ```\n */\nexport function createEnsureWalletRoute(\n o: {\n privy?: PrivyClient;\n onCreated?: (c: { userId: string; address: Address }) => Promise<void>;\n } = {},\n): { POST(request: Request): Promise<Response> } {\n return {\n async POST(request: Request): Promise<Response> {\n let privy: PrivyClient;\n try {\n privy = o.privy ?? createPrivyServer();\n } catch (e) {\n return toErrorResponse(e);\n }\n const auth = await requireUser(request, { privy });\n if (!auth.ok) return auth.response;\n const { userId, address } = auth.user;\n if (address) return Response.json({ address, created: false });\n\n try {\n const wallet = await privy.wallets().create({ chain_type: \"ethereum\", owner: { user_id: userId } });\n const created = wallet.address as Address;\n if (o.onCreated) {\n try {\n await o.onCreated({ userId, address: created });\n } catch {\n // The wallet exists; a failing hook must not turn that into an error.\n }\n }\n return Response.json({ address: created, created: true });\n } catch (createError) {\n // Race guard: a concurrent request may have created the wallet between\n // the check above and this call. Re-check before surfacing a failure.\n try {\n const again = findEmbeddedEthereumWallet(await privy.users()._get(userId));\n if (again) return Response.json({ address: again.address, created: false });\n } catch {\n // fall through to the create error\n }\n return toErrorResponse(\n new PepuError(\"WALLET_NOT_PROVISIONED\", \"Could not create a wallet.\", {\n status: 502,\n cause: toPepuError(createError),\n }),\n );\n }\n },\n };\n}\n"]}
@@ -0,0 +1,498 @@
1
+ import { isHex, decodeErrorResult } from 'viem';
2
+
3
+ // src/errors.ts
4
+ var PEPU_ERRORS_DOCS_URL = "https://guide.pepeunchained.com/reference/errors";
5
+ var PEPU_ERROR_CATALOG = [
6
+ {
7
+ code: "PRIVY_KEY_QUORUM_MISMATCH",
8
+ title: "Privy authorization key does not match the wallet owner",
9
+ cause: "Privy returned 401 'No valid authorization keys or user signing keys available': the server's PRIVY_AUTHORIZATION_KEY is not a signer on the wallet, or the key quorum id differs from the one the user granted.",
10
+ fix: "Make sure PRIVY_AUTHORIZATION_KEY is the private half of the key whose quorum id is NEXT_PUBLIC_PRIVY_KEY_QUORUM_ID, and that the user granted that quorum as a signer.",
11
+ status: 500,
12
+ retryable: false,
13
+ matchers: [/No valid authorization keys or user signing keys available/i]
14
+ },
15
+ {
16
+ code: "POLICY_NAME_TOO_LONG",
17
+ title: "Privy policy or rule name is too long",
18
+ cause: "Privy rejects policy and rule names of 50 or more characters (the real limit is 49).",
19
+ fix: "Shorten the policy or rule name to 49 characters or fewer.",
20
+ status: 400,
21
+ retryable: false,
22
+ matchers: [/must be fewer than 50 characters/i, /name[^.\n]{0,40}\b(50|49) characters/i]
23
+ },
24
+ {
25
+ code: "WALLET_COINBASE_UNSUPPORTED_CHAIN",
26
+ title: "Coinbase Smart Wallet does not support PEPU",
27
+ cause: "Coinbase Smart Wallet is a smart-contract wallet on chains it knows; PEPU (97741) is not one of them, and it floods the console with unsupported-chain errors.",
28
+ fix: "Pin Coinbase to eoaOnly via createPepuPrivyConfig() from @pepu-chain/sdk/privy.",
29
+ status: 400,
30
+ retryable: false,
31
+ matchers: [
32
+ /coinbase[\s\S]{0,120}(unsupported|not supported)[\s\S]{0,60}chain/i,
33
+ /(unsupported|not supported) chain[\s\S]{0,120}coinbase/i
34
+ ]
35
+ },
36
+ {
37
+ code: "PRIVY_CHAIN_REJECTED_97741",
38
+ title: "Privy rejects server-side eth_sendTransaction on PEPU",
39
+ cause: "Privy's server-side send path does not know chain 97741 and rejects it. Signing works; sending does not.",
40
+ fix: "Sign with eth_signTransaction on the server and broadcast the raw transaction yourself (signAndBroadcast from @pepu-chain/sdk/session).",
41
+ status: 502,
42
+ retryable: false,
43
+ matchers: [
44
+ /eip155:97741[\s\S]{0,160}(unsupported|not supported|invalid|unknown|not found)/i,
45
+ /(unsupported|not supported|unknown|invalid) (chain|network|caip2)[\s\S]{0,80}97741/i
46
+ ]
47
+ },
48
+ {
49
+ code: "PAYMASTER_ORIGIN_NOT_ALLOWED",
50
+ title: "Paymaster refused the request origin",
51
+ cause: "The request Origin is not on the project's allowlist.",
52
+ fix: "Add the exact origin (scheme, host and port) to the project's allowed origins.",
53
+ status: 403,
54
+ retryable: false,
55
+ matchers: [/origin_not_allowed/i]
56
+ },
57
+ {
58
+ code: "PAYMASTER_DESTINATION_NOT_ALLOWED",
59
+ title: "Paymaster refused the call destination",
60
+ cause: "The UserOperation targets a contract that is not on the project's target allowlist.",
61
+ fix: "Add the contract to the project's targets, or sponsor only calls to allowed targets.",
62
+ status: 403,
63
+ retryable: false,
64
+ matchers: [/(destination|target)_not_allowed/i]
65
+ },
66
+ {
67
+ code: "PAYMASTER_PROJECT_NOT_CLAIMED",
68
+ title: "Sponsorship project is not claimed on-chain",
69
+ cause: "Deposits can sit in an unclaimed project, but nothing is sponsored until its owner has claimed it on-chain (the contract reports ProjectNotClaimed, the service project_not_claimed_onchain).",
70
+ fix: "Prove the Privy app (requestClaimAttestation from @pepu-chain/sdk/paymaster/server), call claimProject, then configureProject (setTargets, setDailyLimit, setSenderDailyLimit).",
71
+ status: 409,
72
+ retryable: false,
73
+ matchers: [/project_not_claimed_onchain/i, /ProjectNotClaimed/i]
74
+ },
75
+ {
76
+ code: "PAYMASTER_PROJECT_OWNER_CHANGED",
77
+ title: "Project owner changed since the credentials were issued",
78
+ cause: "The on-chain owner of the project is no longer the address the off-chain credentials were issued to (an ownership transfer or re-claim completed).",
79
+ fix: "As the new owner, sign in with SIWE, register the project again and rotate the client token and server key.",
80
+ status: 403,
81
+ retryable: false,
82
+ matchers: [/project_owner_changed/i]
83
+ },
84
+ {
85
+ code: "PAYMASTER_PROJECT_PAUSED",
86
+ title: "Sponsorship project is paused",
87
+ cause: "The project owner paused sponsorship on-chain.",
88
+ fix: "The owner can resume it with setPaused(projectId, false).",
89
+ status: 403,
90
+ retryable: false,
91
+ matchers: [/project_paused/i, /SponsorPaused/i]
92
+ },
93
+ {
94
+ code: "PAYMASTER_IDENTITY_REQUIRED",
95
+ title: "A verified Privy account is required",
96
+ cause: "The free tier (and any project with requireIdentity on) only sponsors users with a verified Privy access token.",
97
+ fix: "Send the user's Privy access token as Authorization: Bearer (or context.privyAccessToken for ERC-7677).",
98
+ status: 401,
99
+ retryable: false,
100
+ matchers: [/(project|free_tier)_identity_required/i]
101
+ },
102
+ {
103
+ code: "PAYMASTER_FREE_TIER_UNAVAILABLE",
104
+ title: "Free tier cannot sponsor this operation",
105
+ cause: "The free tier is disabled, its pool is empty, or the operation is larger than the per-op cap.",
106
+ fix: "Deposit into your own project and use its credentials, or retry later.",
107
+ status: 429,
108
+ retryable: true,
109
+ matchers: [/free_tier_disabled/i, /free_pool_(empty|op_too_large)/i]
110
+ },
111
+ {
112
+ code: "PAYMASTER_RATE_LIMITED",
113
+ title: "Paymaster API rate limit",
114
+ cause: "Too many requests to the paymaster API from this IP or account.",
115
+ fix: "Back off for the Retry-After interval (error.details.retryAfterSeconds when present).",
116
+ status: 429,
117
+ retryable: true,
118
+ matchers: [/\brate_limited\b/i]
119
+ },
120
+ {
121
+ code: "PAYMASTER_SESSION_REQUIRED",
122
+ title: "Paymaster owner session missing or expired",
123
+ cause: "Owner endpoints need a SIWE session token (1 h lifetime) for the project's current on-chain owner.",
124
+ fix: "Call loginWithWallet() on the paymaster API client, then retry.",
125
+ status: 401,
126
+ retryable: false,
127
+ matchers: []
128
+ },
129
+ {
130
+ code: "PAYMASTER_API_ERROR",
131
+ title: "Paymaster API request failed",
132
+ cause: "The paymaster API returned an error that has no more specific PEPU code.",
133
+ fix: "Read error.details (HTTP status and the service's error code) and the OpenAPI spec for that route.",
134
+ status: 502,
135
+ retryable: false,
136
+ matchers: []
137
+ },
138
+ {
139
+ code: "PAYMASTER_DENIED",
140
+ title: "Paymaster denied the sponsorship",
141
+ cause: "The paymaster rejected the credential or the sender (for example unknown_or_invalid_app_credential or sender_not_owned_by_token_user).",
142
+ fix: "Check the app credential or token, and that the smart account belongs to the user whose access token you sent.",
143
+ status: 403,
144
+ retryable: false,
145
+ matchers: [
146
+ /unknown_or_invalid_app_credential/i,
147
+ /sender_not_owned_by_token_user/i,
148
+ /paymaster[\s\S]{0,40}(denied|rejected)/i
149
+ ]
150
+ },
151
+ {
152
+ code: "PAYMASTER_NO_BALANCE",
153
+ title: "Sponsorship project has no balance",
154
+ cause: "The project's paymaster deposit cannot cover this operation.",
155
+ fix: "Deposit more PEPU to the project, then retry.",
156
+ status: 429,
157
+ retryable: true,
158
+ matchers: [/(project_)?(no|insufficient)_balance/i, /project_balance_exhausted/i, /InsufficientSponsorBalance/i, /insufficient (project )?(balance|deposit)[\s\S]{0,40}paymaster/i]
159
+ },
160
+ {
161
+ code: "PAYMASTER_CAP",
162
+ title: "Sponsorship cap reached",
163
+ cause: "A daily, per-sender or per-operation sponsorship cap was hit.",
164
+ fix: "Wait for the cap window to reset, or raise the project's daily and sender limits.",
165
+ status: 429,
166
+ retryable: true,
167
+ matchers: [/(daily|sender|per_sender)[_ -]?(cap|limit)[_ ]?(exceeded|reached)/i, /cap_exceeded|limit_exceeded/i, /free_tier_[a-z_]*_(exceeded|reached)/i, /fee_above_onchain_cap/i]
168
+ },
169
+ {
170
+ code: "BUNDLER_AA_FAILED",
171
+ title: "EntryPoint rejected the UserOperation",
172
+ cause: "The EntryPoint reported FailedOp with an AAxx code during validation or execution.",
173
+ fix: "Read the AAxx code: AA21 prefund missing, AA23 signature or validation reverted, AA25 invalid nonce, AA31/AA33/AA34 paymaster problems.",
174
+ status: 502,
175
+ retryable: false,
176
+ matchers: [/\bAA(1\d|2\d|3\d|4\d|5\d|9\d)\b/, /FailedOp(WithRevert)?/]
177
+ },
178
+ {
179
+ code: "BUNDLER_UNREACHABLE",
180
+ title: "Bundler or paymaster is unreachable",
181
+ cause: "The request to the bundler or paymaster URL failed before any response.",
182
+ fix: "Check PEPU_BUNDLER_URL and PEPU_PAYMASTER_URL. The hosted services may not be live yet; use checkSponsorship().",
183
+ status: 502,
184
+ retryable: true,
185
+ matchers: [/ECONNREFUSED|ENOTFOUND|ETIMEDOUT|fetch failed|bundler[\s\S]{0,30}unreachable/i]
186
+ },
187
+ {
188
+ code: "TX_NONCE_RACE",
189
+ title: "Nonce conflict",
190
+ cause: "Two transactions raced for one nonce, or a replacement was underpriced.",
191
+ fix: "Serialize sends per account (a lock), re-read the pending nonce, and retry.",
192
+ status: 409,
193
+ retryable: true,
194
+ matchers: [/nonce too (low|high)/i, /replacement transaction underpriced/i, /already known/i]
195
+ },
196
+ {
197
+ code: "TX_GAS_UNDERSHOOT",
198
+ title: "Gas limit too low",
199
+ cause: "Nitro gas estimation undershoots on PEPU: the L1 data component is not covered by the plain estimate.",
200
+ fix: "Add headroom to the estimate, 20% via withGasLimitBuffer() from @pepu-chain/sdk/session.",
201
+ status: 502,
202
+ retryable: true,
203
+ matchers: [/intrinsic gas too low/i, /gas required exceeds allowance/i, /gas limit too low/i]
204
+ },
205
+ {
206
+ code: "TX_REVERTED",
207
+ title: "Transaction reverted",
208
+ cause: "The contract call reverted.",
209
+ fix: "Decode the revert reason with explainError(<revert data>) and check arguments, allowances and balances.",
210
+ status: 502,
211
+ retryable: false,
212
+ matchers: [/execution reverted/i, /transaction (has )?reverted/i]
213
+ },
214
+ {
215
+ code: "MULTICALL3_CANONICAL_ADDRESS",
216
+ title: "Canonical Multicall3 address used on PEPU",
217
+ cause: "PEPU's Multicall3 is not at the canonical 0xcA11...CA11 address.",
218
+ fix: "Use getMulticall3() or pepuMulticall() from @pepu-chain/sdk, or the pepuMainnet chain object, which carries the right address.",
219
+ status: 500,
220
+ retryable: false,
221
+ matchers: [/0xcA11bde05977b3631167028862bE2a173976CA11/i]
222
+ },
223
+ {
224
+ code: "WALLET_INJECTED_ACTIVE",
225
+ title: "An injected browser wallet is the active account",
226
+ cause: "wagmi's active account is a browser extension rather than the Privy embedded wallet.",
227
+ fix: "Pin the embedded wallet with useActiveWalletPin() from @pepu-chain/sdk/privy/wagmi.",
228
+ status: 400,
229
+ retryable: false,
230
+ matchers: [/ConnectorNotConnectedError/i, /chrome-extension:\/\//i, /injected (wallet|provider|connector)/i]
231
+ },
232
+ {
233
+ code: "CONFIG_PRIVY_CREATE_ON_LOGIN",
234
+ title: "Embedded wallet never appears after login",
235
+ cause: "The dashboard's automatic embedded wallet creation is off, so createOnLogin never resolves.",
236
+ fix: "Create the wallet server-side with the ensure-wallet route (createEnsureWalletRoute), or enable creation in the Privy dashboard.",
237
+ status: 500,
238
+ retryable: false,
239
+ matchers: [/createOnLogin/i, /embedded wallet[\s\S]{0,60}(never|did not|didn't) (appear|created)/i]
240
+ },
241
+ {
242
+ code: "CONFIG_ORIGIN_MISMATCH",
243
+ title: "Origin is not allowed by Privy",
244
+ cause: "The page origin (scheme, host and port) is not in the Privy app's allowed origins. A different dev port is the usual cause.",
245
+ fix: "Add the exact origin, including the port, to Privy dashboard Allowed origins.",
246
+ status: 500,
247
+ retryable: false,
248
+ matchers: [/origin[^.\n]{0,60}(not allowed|not configured|not in (the )?allowed)/i, /allowed origins?/i]
249
+ },
250
+ {
251
+ code: "CONFIG_PRIVY_DASHBOARD",
252
+ title: "Privy dashboard misconfiguration",
253
+ cause: "A required Privy dashboard setting is missing.",
254
+ fix: "Run checkPrivyDashboardConfig() and follow its fix list.",
255
+ status: 500,
256
+ retryable: false,
257
+ matchers: []
258
+ },
259
+ {
260
+ code: "CONFIG_MISSING_ENV",
261
+ title: "Missing environment variable",
262
+ cause: "A required environment variable is not set.",
263
+ fix: "Set the listed variables (see .env.example) and restart the process.",
264
+ status: 500,
265
+ retryable: false,
266
+ matchers: [/missing required env/i]
267
+ },
268
+ {
269
+ code: "CONFIG_BAD_URL",
270
+ title: "Invalid endpoint URL",
271
+ cause: "A configured bundler, paymaster or RPC URL is not a valid http(s) URL.",
272
+ fix: "Use a full URL such as https://bundler.example.com.",
273
+ status: 500,
274
+ retryable: false,
275
+ matchers: []
276
+ },
277
+ {
278
+ code: "CONFIG_SERVER_ONLY",
279
+ title: "Server-only module imported in the browser",
280
+ cause: "A server entry point was bundled into client code.",
281
+ fix: "Import server entries only from route handlers, server actions and scripts.",
282
+ status: 500,
283
+ retryable: false,
284
+ matchers: []
285
+ },
286
+ {
287
+ code: "AUTH_INVALID_TOKEN",
288
+ title: "Invalid or missing Privy access token",
289
+ cause: "The request carried no bearer token, or Privy could not verify it.",
290
+ fix: "Send Authorization: Bearer <getAccessToken()> and verify the token server-side.",
291
+ status: 401,
292
+ retryable: false,
293
+ matchers: [/invalid (auth(orization)?|access|jwt|id) token/i, /\bjwt (expired|malformed|invalid)/i]
294
+ },
295
+ {
296
+ code: "WALLET_NOT_PROVISIONED",
297
+ title: "User has no embedded wallet yet",
298
+ cause: "The user is signed in but no embedded Ethereum wallet exists.",
299
+ fix: "Call the ensure-wallet route (useEnsureWallet or WalletGate) before acting.",
300
+ status: 409,
301
+ retryable: true,
302
+ matchers: []
303
+ },
304
+ {
305
+ code: "POLICY_UNSCOPED",
306
+ title: "Session policy is not scoped",
307
+ cause: "A session policy needs a target contract, at least one function and an expiry.",
308
+ fix: "Pass contractAddress, functions and expiresAtUnixSeconds to buildSessionPolicy().",
309
+ status: 400,
310
+ retryable: false,
311
+ matchers: []
312
+ },
313
+ {
314
+ code: "SESSION_EXPIRED",
315
+ title: "Session expired",
316
+ cause: "The session's expiry has passed.",
317
+ fix: "Grant a new session.",
318
+ status: 410,
319
+ retryable: false,
320
+ matchers: []
321
+ },
322
+ {
323
+ code: "SESSION_NONE",
324
+ title: "No active session",
325
+ cause: "The user has not granted a session, or it was revoked.",
326
+ fix: "Ask the user to grant a session first.",
327
+ status: 409,
328
+ retryable: false,
329
+ matchers: []
330
+ },
331
+ {
332
+ code: "SESSION_APPROVAL_MISMATCH",
333
+ title: "Session approval does not match",
334
+ cause: "The approval was made for another account, permission id or mode.",
335
+ fix: "Re-run prepare, have the owner sign again, then activate.",
336
+ status: 409,
337
+ retryable: false,
338
+ matchers: []
339
+ },
340
+ {
341
+ code: "UNKNOWN",
342
+ title: "Unknown error",
343
+ cause: "The error did not match any known PEPU failure.",
344
+ fix: "Read the original message. Run pepu_known_gotchas in the MCP server, or search the docs.",
345
+ status: 500,
346
+ retryable: false,
347
+ matchers: []
348
+ }
349
+ ];
350
+ var catalogByCode = new Map(
351
+ PEPU_ERROR_CATALOG.map((e) => [e.code, e])
352
+ );
353
+ function getErrorEntry(code) {
354
+ const entry = catalogByCode.get(code) ?? catalogByCode.get("UNKNOWN");
355
+ if (!entry) throw new Error("PEPU_ERROR_CATALOG is missing the UNKNOWN entry");
356
+ return entry;
357
+ }
358
+ function errorDocsUrl(code) {
359
+ return `${PEPU_ERRORS_DOCS_URL}#${code}`;
360
+ }
361
+ var PepuError = class extends Error {
362
+ code;
363
+ hint;
364
+ docsUrl;
365
+ retryable;
366
+ status;
367
+ details;
368
+ constructor(code, message, options = {}) {
369
+ const entry = getErrorEntry(code);
370
+ super(message ?? entry.title, options.cause === void 0 ? void 0 : { cause: options.cause });
371
+ this.name = new.target.name;
372
+ this.code = code;
373
+ this.hint = options.hint ?? entry.fix;
374
+ this.docsUrl = options.docsUrl ?? errorDocsUrl(code);
375
+ this.retryable = options.retryable ?? entry.retryable;
376
+ this.status = options.status ?? entry.status;
377
+ if (options.details !== void 0) this.details = options.details;
378
+ }
379
+ };
380
+ var PepuConfigError = class extends PepuError {
381
+ };
382
+ var PepuAuthError = class extends PepuError {
383
+ };
384
+ var PepuPolicyError = class extends PepuError {
385
+ };
386
+ var PepuSessionError = class extends PepuError {
387
+ };
388
+ var PepuBundlerError = class extends PepuError {
389
+ };
390
+ var PepuPaymasterError = class extends PepuError {
391
+ };
392
+ var PepuChainError = class extends PepuError {
393
+ };
394
+ function classForCode(code) {
395
+ if (code.startsWith("CONFIG_") || code.startsWith("PRIVY_")) return PepuConfigError;
396
+ if (code === "AUTH_INVALID_TOKEN" || code === "WALLET_NOT_PROVISIONED") return PepuAuthError;
397
+ if (code.startsWith("POLICY_")) return PepuPolicyError;
398
+ if (code.startsWith("SESSION_")) return PepuSessionError;
399
+ if (code.startsWith("BUNDLER_")) return PepuBundlerError;
400
+ if (code.startsWith("PAYMASTER_")) return PepuPaymasterError;
401
+ if (code.startsWith("TX_") || code.startsWith("MULTICALL3_") || code.startsWith("WALLET_")) return PepuChainError;
402
+ return PepuError;
403
+ }
404
+ var REVERT_ABI = [
405
+ { type: "error", name: "Error", inputs: [{ name: "message", type: "string" }] },
406
+ { type: "error", name: "Panic", inputs: [{ name: "code", type: "uint256" }] },
407
+ {
408
+ type: "error",
409
+ name: "FailedOp",
410
+ inputs: [
411
+ { name: "opIndex", type: "uint256" },
412
+ { name: "reason", type: "string" }
413
+ ]
414
+ },
415
+ {
416
+ type: "error",
417
+ name: "FailedOpWithRevert",
418
+ inputs: [
419
+ { name: "opIndex", type: "uint256" },
420
+ { name: "reason", type: "string" },
421
+ { name: "inner", type: "bytes" }
422
+ ]
423
+ }
424
+ ];
425
+ function flatten(e) {
426
+ const seen = /* @__PURE__ */ new Set();
427
+ const parts = [];
428
+ let cur = e;
429
+ for (let depth = 0; depth < 6 && cur !== void 0 && cur !== null && !seen.has(cur); depth++) {
430
+ seen.add(cur);
431
+ if (typeof cur === "object") {
432
+ const o = cur;
433
+ for (const k of ["shortMessage", "message", "details", "reason"]) {
434
+ const v = o[k];
435
+ if (typeof v === "string") parts.push(v);
436
+ }
437
+ cur = o["cause"];
438
+ } else {
439
+ parts.push(String(cur));
440
+ break;
441
+ }
442
+ }
443
+ return parts.join("\n");
444
+ }
445
+ function matchCatalog(text) {
446
+ return PEPU_ERROR_CATALOG.find((entry) => entry.matchers.some((m) => m.test(text)));
447
+ }
448
+ function explanation(entry, matched) {
449
+ return {
450
+ code: entry.code,
451
+ title: entry.title,
452
+ cause: entry.cause,
453
+ fix: entry.fix,
454
+ docsUrl: errorDocsUrl(entry.code),
455
+ matched
456
+ };
457
+ }
458
+ function explainError(e) {
459
+ if (e instanceof PepuError) return explanation(getErrorEntry(e.code), "catalog");
460
+ if (typeof e === "string" && isHex(e) && e.length >= 10) {
461
+ try {
462
+ const decoded = decodeErrorResult({ abi: REVERT_ABI, data: e });
463
+ const argText = (decoded.args ?? []).map((a) => typeof a === "string" ? a : "").join("\n");
464
+ const hit2 = matchCatalog(`${argText}
465
+ ${decoded.errorName}`);
466
+ if (hit2) return explanation(hit2, "abi-decode");
467
+ return explanation(getErrorEntry("TX_REVERTED"), "abi-decode");
468
+ } catch {
469
+ return explanation(getErrorEntry("UNKNOWN"), "unknown");
470
+ }
471
+ }
472
+ const text = typeof e === "string" ? e : flatten(e);
473
+ const hit = matchCatalog(text);
474
+ return hit ? explanation(hit, "catalog") : explanation(getErrorEntry("UNKNOWN"), "unknown");
475
+ }
476
+ function toPepuError(e, ctx) {
477
+ if (e instanceof PepuError) return e;
478
+ const explained = explainError(e);
479
+ const original = (typeof e === "string" ? e : flatten(e)) || "Unknown error";
480
+ const message = ctx ? `${ctx.op}: ${original}` : original;
481
+ const Cls = classForCode(explained.code);
482
+ return new Cls(explained.code, message, { cause: e });
483
+ }
484
+ function toErrorBody(e) {
485
+ const err = toPepuError(e);
486
+ return { error: { code: err.code, message: err.message, hint: err.hint } };
487
+ }
488
+ function toErrorResponse(e) {
489
+ const err = toPepuError(e);
490
+ return new Response(JSON.stringify(toErrorBody(err)), {
491
+ status: err.status,
492
+ headers: { "content-type": "application/json" }
493
+ });
494
+ }
495
+
496
+ export { PEPU_ERRORS_DOCS_URL, PEPU_ERROR_CATALOG, PepuAuthError, PepuBundlerError, PepuChainError, PepuConfigError, PepuError, PepuPaymasterError, PepuPolicyError, PepuSessionError, errorDocsUrl, explainError, getErrorEntry, toErrorBody, toErrorResponse, toPepuError };
497
+ //# sourceMappingURL=chunk-6DSZ4Z2N.js.map
498
+ //# sourceMappingURL=chunk-6DSZ4Z2N.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.ts"],"names":["hit"],"mappings":";;;AAUO,IAAM,oBAAA,GAAuB;AA4D7B,IAAM,kBAAA,GAAmD;AAAA,EAC9D;AAAA,IACE,IAAA,EAAM,2BAAA;AAAA,IACN,KAAA,EAAO,yDAAA;AAAA,IACP,KAAA,EACE,kNAAA;AAAA,IACF,GAAA,EAAK,yKAAA;AAAA,IACL,MAAA,EAAQ,GAAA;AAAA,IACR,SAAA,EAAW,KAAA;AAAA,IACX,QAAA,EAAU,CAAC,6DAA6D;AAAA,GAC1E;AAAA,EACA;AAAA,IACE,IAAA,EAAM,sBAAA;AAAA,IACN,KAAA,EAAO,uCAAA;AAAA,IACP,KAAA,EAAO,sFAAA;AAAA,IACP,GAAA,EAAK,4DAAA;AAAA,IACL,MAAA,EAAQ,GAAA;AAAA,IACR,SAAA,EAAW,KAAA;AAAA,IACX,QAAA,EAAU,CAAC,mCAAA,EAAqC,uCAAuC;AAAA,GACzF;AAAA,EACA;AAAA,IACE,IAAA,EAAM,mCAAA;AAAA,IACN,KAAA,EAAO,6CAAA;AAAA,IACP,KAAA,EACE,gKAAA;AAAA,IACF,GAAA,EAAK,iFAAA;AAAA,IACL,MAAA,EAAQ,GAAA;AAAA,IACR,SAAA,EAAW,KAAA;AAAA,IACX,QAAA,EAAU;AAAA,MACR,oEAAA;AAAA,MACA;AAAA;AACF,GACF;AAAA,EACA;AAAA,IACE,IAAA,EAAM,4BAAA;AAAA,IACN,KAAA,EAAO,uDAAA;AAAA,IACP,KAAA,EAAO,0GAAA;AAAA,IACP,GAAA,EAAK,yIAAA;AAAA,IACL,MAAA,EAAQ,GAAA;AAAA,IACR,SAAA,EAAW,KAAA;AAAA,IACX,QAAA,EAAU;AAAA,MACR,iFAAA;AAAA,MACA;AAAA;AACF,GACF;AAAA,EACA;AAAA,IAC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CAAA,EAAG;AAAA,IACpD,QAAQ,GAAA,CAAI,MAAA;AAAA,IACZ,OAAA,EAAS,EAAE,cAAA,EAAgB,kBAAA;AAAmB,GAC/C,CAAA;AACH","file":"chunk-6DSZ4Z2N.js","sourcesContent":["import { decodeErrorResult, isHex } from \"viem\";\nimport type { Abi, Hex } from \"viem\";\n\n/**\n * The SDK error model. Everything the SDK throws is a {@link PepuError}\n * subclass carrying a stable `code`, a one-sentence `hint` and a `docsUrl`.\n * Messages never contain secrets: they name environment variables, never\n * their values.\n */\n\nexport const PEPU_ERRORS_DOCS_URL = \"https://guide.pepeunchained.com/reference/errors\";\n\nexport type PepuErrorCode =\n | \"CONFIG_MISSING_ENV\"\n | \"CONFIG_BAD_URL\"\n | \"CONFIG_SERVER_ONLY\"\n | \"CONFIG_PRIVY_DASHBOARD\"\n | \"CONFIG_PRIVY_CREATE_ON_LOGIN\"\n | \"CONFIG_ORIGIN_MISMATCH\"\n | \"AUTH_INVALID_TOKEN\"\n | \"WALLET_NOT_PROVISIONED\"\n | \"WALLET_COINBASE_UNSUPPORTED_CHAIN\"\n | \"WALLET_INJECTED_ACTIVE\"\n | \"POLICY_UNSCOPED\"\n | \"POLICY_NAME_TOO_LONG\"\n | \"SESSION_EXPIRED\"\n | \"SESSION_NONE\"\n | \"SESSION_APPROVAL_MISMATCH\"\n | \"PRIVY_CHAIN_REJECTED_97741\"\n | \"PRIVY_KEY_QUORUM_MISMATCH\"\n | \"BUNDLER_UNREACHABLE\"\n | \"BUNDLER_AA_FAILED\"\n | \"PAYMASTER_DENIED\"\n | \"PAYMASTER_NO_BALANCE\"\n | \"PAYMASTER_CAP\"\n | \"PAYMASTER_ORIGIN_NOT_ALLOWED\"\n | \"PAYMASTER_DESTINATION_NOT_ALLOWED\"\n | \"PAYMASTER_PROJECT_NOT_CLAIMED\"\n | \"PAYMASTER_PROJECT_OWNER_CHANGED\"\n | \"PAYMASTER_PROJECT_PAUSED\"\n | \"PAYMASTER_IDENTITY_REQUIRED\"\n | \"PAYMASTER_FREE_TIER_UNAVAILABLE\"\n | \"PAYMASTER_RATE_LIMITED\"\n | \"PAYMASTER_SESSION_REQUIRED\"\n | \"PAYMASTER_API_ERROR\"\n | \"TX_REVERTED\"\n | \"TX_NONCE_RACE\"\n | \"TX_GAS_UNDERSHOOT\"\n | \"MULTICALL3_CANONICAL_ADDRESS\"\n | \"UNKNOWN\";\n\nexport interface ErrorCatalogEntry {\n readonly code: PepuErrorCode;\n readonly title: string;\n /** What went wrong, in one or two sentences. */\n readonly cause: string;\n /** How to fix it. */\n readonly fix: string;\n /** Suggested HTTP status for route factories. */\n readonly status: number;\n readonly retryable: boolean;\n /** Tested, in order, against the flattened error text. Empty for code-only entries. */\n readonly matchers: readonly RegExp[];\n}\n\n/**\n * Single source for the SDK `explainError`, the MCP `pepu_explain_error` tool\n * and the generated docs error page. ORDER MATTERS: the first entry whose\n * matcher hits wins, so specific entries come before general ones.\n */\nexport const PEPU_ERROR_CATALOG: readonly ErrorCatalogEntry[] = [\n {\n code: \"PRIVY_KEY_QUORUM_MISMATCH\",\n title: \"Privy authorization key does not match the wallet owner\",\n cause:\n \"Privy returned 401 'No valid authorization keys or user signing keys available': the server's PRIVY_AUTHORIZATION_KEY is not a signer on the wallet, or the key quorum id differs from the one the user granted.\",\n fix: \"Make sure PRIVY_AUTHORIZATION_KEY is the private half of the key whose quorum id is NEXT_PUBLIC_PRIVY_KEY_QUORUM_ID, and that the user granted that quorum as a signer.\",\n status: 500,\n retryable: false,\n matchers: [/No valid authorization keys or user signing keys available/i],\n },\n {\n code: \"POLICY_NAME_TOO_LONG\",\n title: \"Privy policy or rule name is too long\",\n cause: \"Privy rejects policy and rule names of 50 or more characters (the real limit is 49).\",\n fix: \"Shorten the policy or rule name to 49 characters or fewer.\",\n status: 400,\n retryable: false,\n matchers: [/must be fewer than 50 characters/i, /name[^.\\n]{0,40}\\b(50|49) characters/i],\n },\n {\n code: \"WALLET_COINBASE_UNSUPPORTED_CHAIN\",\n title: \"Coinbase Smart Wallet does not support PEPU\",\n cause:\n \"Coinbase Smart Wallet is a smart-contract wallet on chains it knows; PEPU (97741) is not one of them, and it floods the console with unsupported-chain errors.\",\n fix: \"Pin Coinbase to eoaOnly via createPepuPrivyConfig() from @pepu-chain/sdk/privy.\",\n status: 400,\n retryable: false,\n matchers: [\n /coinbase[\\s\\S]{0,120}(unsupported|not supported)[\\s\\S]{0,60}chain/i,\n /(unsupported|not supported) chain[\\s\\S]{0,120}coinbase/i,\n ],\n },\n {\n code: \"PRIVY_CHAIN_REJECTED_97741\",\n title: \"Privy rejects server-side eth_sendTransaction on PEPU\",\n cause: \"Privy's server-side send path does not know chain 97741 and rejects it. Signing works; sending does not.\",\n fix: \"Sign with eth_signTransaction on the server and broadcast the raw transaction yourself (signAndBroadcast from @pepu-chain/sdk/session).\",\n status: 502,\n retryable: false,\n matchers: [\n /eip155:97741[\\s\\S]{0,160}(unsupported|not supported|invalid|unknown|not found)/i,\n /(unsupported|not supported|unknown|invalid) (chain|network|caip2)[\\s\\S]{0,80}97741/i,\n ],\n },\n {\n code: \"PAYMASTER_ORIGIN_NOT_ALLOWED\",\n title: \"Paymaster refused the request origin\",\n cause: \"The request Origin is not on the project's allowlist.\",\n fix: \"Add the exact origin (scheme, host and port) to the project's allowed origins.\",\n status: 403,\n retryable: false,\n matchers: [/origin_not_allowed/i],\n },\n {\n code: \"PAYMASTER_DESTINATION_NOT_ALLOWED\",\n title: \"Paymaster refused the call destination\",\n cause: \"The UserOperation targets a contract that is not on the project's target allowlist.\",\n fix: \"Add the contract to the project's targets, or sponsor only calls to allowed targets.\",\n status: 403,\n retryable: false,\n matchers: [/(destination|target)_not_allowed/i],\n },\n {\n code: \"PAYMASTER_PROJECT_NOT_CLAIMED\",\n title: \"Sponsorship project is not claimed on-chain\",\n cause:\n \"Deposits can sit in an unclaimed project, but nothing is sponsored until its owner has claimed it on-chain (the contract reports ProjectNotClaimed, the service project_not_claimed_onchain).\",\n fix: \"Prove the Privy app (requestClaimAttestation from @pepu-chain/sdk/paymaster/server), call claimProject, then configureProject (setTargets, setDailyLimit, setSenderDailyLimit).\",\n status: 409,\n retryable: false,\n matchers: [/project_not_claimed_onchain/i, /ProjectNotClaimed/i],\n },\n {\n code: \"PAYMASTER_PROJECT_OWNER_CHANGED\",\n title: \"Project owner changed since the credentials were issued\",\n cause:\n \"The on-chain owner of the project is no longer the address the off-chain credentials were issued to (an ownership transfer or re-claim completed).\",\n fix: \"As the new owner, sign in with SIWE, register the project again and rotate the client token and server key.\",\n status: 403,\n retryable: false,\n matchers: [/project_owner_changed/i],\n },\n {\n code: \"PAYMASTER_PROJECT_PAUSED\",\n title: \"Sponsorship project is paused\",\n cause: \"The project owner paused sponsorship on-chain.\",\n fix: \"The owner can resume it with setPaused(projectId, false).\",\n status: 403,\n retryable: false,\n matchers: [/project_paused/i, /SponsorPaused/i],\n },\n {\n code: \"PAYMASTER_IDENTITY_REQUIRED\",\n title: \"A verified Privy account is required\",\n cause: \"The free tier (and any project with requireIdentity on) only sponsors users with a verified Privy access token.\",\n fix: \"Send the user's Privy access token as Authorization: Bearer (or context.privyAccessToken for ERC-7677).\",\n status: 401,\n retryable: false,\n matchers: [/(project|free_tier)_identity_required/i],\n },\n {\n code: \"PAYMASTER_FREE_TIER_UNAVAILABLE\",\n title: \"Free tier cannot sponsor this operation\",\n cause: \"The free tier is disabled, its pool is empty, or the operation is larger than the per-op cap.\",\n fix: \"Deposit into your own project and use its credentials, or retry later.\",\n status: 429,\n retryable: true,\n matchers: [/free_tier_disabled/i, /free_pool_(empty|op_too_large)/i],\n },\n {\n code: \"PAYMASTER_RATE_LIMITED\",\n title: \"Paymaster API rate limit\",\n cause: \"Too many requests to the paymaster API from this IP or account.\",\n fix: \"Back off for the Retry-After interval (error.details.retryAfterSeconds when present).\",\n status: 429,\n retryable: true,\n matchers: [/\\brate_limited\\b/i],\n },\n {\n code: \"PAYMASTER_SESSION_REQUIRED\",\n title: \"Paymaster owner session missing or expired\",\n cause: \"Owner endpoints need a SIWE session token (1 h lifetime) for the project's current on-chain owner.\",\n fix: \"Call loginWithWallet() on the paymaster API client, then retry.\",\n status: 401,\n retryable: false,\n matchers: [],\n },\n {\n code: \"PAYMASTER_API_ERROR\",\n title: \"Paymaster API request failed\",\n cause: \"The paymaster API returned an error that has no more specific PEPU code.\",\n fix: \"Read error.details (HTTP status and the service's error code) and the OpenAPI spec for that route.\",\n status: 502,\n retryable: false,\n matchers: [],\n },\n {\n code: \"PAYMASTER_DENIED\",\n title: \"Paymaster denied the sponsorship\",\n cause:\n \"The paymaster rejected the credential or the sender (for example unknown_or_invalid_app_credential or sender_not_owned_by_token_user).\",\n fix: \"Check the app credential or token, and that the smart account belongs to the user whose access token you sent.\",\n status: 403,\n retryable: false,\n matchers: [\n /unknown_or_invalid_app_credential/i,\n /sender_not_owned_by_token_user/i,\n /paymaster[\\s\\S]{0,40}(denied|rejected)/i,\n ],\n },\n {\n code: \"PAYMASTER_NO_BALANCE\",\n title: \"Sponsorship project has no balance\",\n cause: \"The project's paymaster deposit cannot cover this operation.\",\n fix: \"Deposit more PEPU to the project, then retry.\",\n status: 429,\n retryable: true,\n matchers: [/(project_)?(no|insufficient)_balance/i, /project_balance_exhausted/i, /InsufficientSponsorBalance/i, /insufficient (project )?(balance|deposit)[\\s\\S]{0,40}paymaster/i],\n },\n {\n code: \"PAYMASTER_CAP\",\n title: \"Sponsorship cap reached\",\n cause: \"A daily, per-sender or per-operation sponsorship cap was hit.\",\n fix: \"Wait for the cap window to reset, or raise the project's daily and sender limits.\",\n status: 429,\n retryable: true,\n matchers: [/(daily|sender|per_sender)[_ -]?(cap|limit)[_ ]?(exceeded|reached)/i, /cap_exceeded|limit_exceeded/i, /free_tier_[a-z_]*_(exceeded|reached)/i, /fee_above_onchain_cap/i],\n },\n {\n code: \"BUNDLER_AA_FAILED\",\n title: \"EntryPoint rejected the UserOperation\",\n cause: \"The EntryPoint reported FailedOp with an AAxx code during validation or execution.\",\n fix: \"Read the AAxx code: AA21 prefund missing, AA23 signature or validation reverted, AA25 invalid nonce, AA31/AA33/AA34 paymaster problems.\",\n status: 502,\n retryable: false,\n matchers: [/\\bAA(1\\d|2\\d|3\\d|4\\d|5\\d|9\\d)\\b/, /FailedOp(WithRevert)?/],\n },\n {\n code: \"BUNDLER_UNREACHABLE\",\n title: \"Bundler or paymaster is unreachable\",\n cause: \"The request to the bundler or paymaster URL failed before any response.\",\n fix: \"Check PEPU_BUNDLER_URL and PEPU_PAYMASTER_URL. The hosted services may not be live yet; use checkSponsorship().\",\n status: 502,\n retryable: true,\n matchers: [/ECONNREFUSED|ENOTFOUND|ETIMEDOUT|fetch failed|bundler[\\s\\S]{0,30}unreachable/i],\n },\n {\n code: \"TX_NONCE_RACE\",\n title: \"Nonce conflict\",\n cause: \"Two transactions raced for one nonce, or a replacement was underpriced.\",\n fix: \"Serialize sends per account (a lock), re-read the pending nonce, and retry.\",\n status: 409,\n retryable: true,\n matchers: [/nonce too (low|high)/i, /replacement transaction underpriced/i, /already known/i],\n },\n {\n code: \"TX_GAS_UNDERSHOOT\",\n title: \"Gas limit too low\",\n cause: \"Nitro gas estimation undershoots on PEPU: the L1 data component is not covered by the plain estimate.\",\n fix: \"Add headroom to the estimate, 20% via withGasLimitBuffer() from @pepu-chain/sdk/session.\",\n status: 502,\n retryable: true,\n matchers: [/intrinsic gas too low/i, /gas required exceeds allowance/i, /gas limit too low/i],\n },\n {\n code: \"TX_REVERTED\",\n title: \"Transaction reverted\",\n cause: \"The contract call reverted.\",\n fix: \"Decode the revert reason with explainError(<revert data>) and check arguments, allowances and balances.\",\n status: 502,\n retryable: false,\n matchers: [/execution reverted/i, /transaction (has )?reverted/i],\n },\n {\n code: \"MULTICALL3_CANONICAL_ADDRESS\",\n title: \"Canonical Multicall3 address used on PEPU\",\n cause: \"PEPU's Multicall3 is not at the canonical 0xcA11...CA11 address.\",\n fix: \"Use getMulticall3() or pepuMulticall() from @pepu-chain/sdk, or the pepuMainnet chain object, which carries the right address.\",\n status: 500,\n retryable: false,\n matchers: [/0xcA11bde05977b3631167028862bE2a173976CA11/i],\n },\n {\n code: \"WALLET_INJECTED_ACTIVE\",\n title: \"An injected browser wallet is the active account\",\n cause: \"wagmi's active account is a browser extension rather than the Privy embedded wallet.\",\n fix: \"Pin the embedded wallet with useActiveWalletPin() from @pepu-chain/sdk/privy/wagmi.\",\n status: 400,\n retryable: false,\n matchers: [/ConnectorNotConnectedError/i, /chrome-extension:\\/\\//i, /injected (wallet|provider|connector)/i],\n },\n {\n code: \"CONFIG_PRIVY_CREATE_ON_LOGIN\",\n title: \"Embedded wallet never appears after login\",\n cause: \"The dashboard's automatic embedded wallet creation is off, so createOnLogin never resolves.\",\n fix: \"Create the wallet server-side with the ensure-wallet route (createEnsureWalletRoute), or enable creation in the Privy dashboard.\",\n status: 500,\n retryable: false,\n matchers: [/createOnLogin/i, /embedded wallet[\\s\\S]{0,60}(never|did not|didn't) (appear|created)/i],\n },\n {\n code: \"CONFIG_ORIGIN_MISMATCH\",\n title: \"Origin is not allowed by Privy\",\n cause:\n \"The page origin (scheme, host and port) is not in the Privy app's allowed origins. A different dev port is the usual cause.\",\n fix: \"Add the exact origin, including the port, to Privy dashboard Allowed origins.\",\n status: 500,\n retryable: false,\n matchers: [/origin[^.\\n]{0,60}(not allowed|not configured|not in (the )?allowed)/i, /allowed origins?/i],\n },\n {\n code: \"CONFIG_PRIVY_DASHBOARD\",\n title: \"Privy dashboard misconfiguration\",\n cause: \"A required Privy dashboard setting is missing.\",\n fix: \"Run checkPrivyDashboardConfig() and follow its fix list.\",\n status: 500,\n retryable: false,\n matchers: [],\n },\n {\n code: \"CONFIG_MISSING_ENV\",\n title: \"Missing environment variable\",\n cause: \"A required environment variable is not set.\",\n fix: \"Set the listed variables (see .env.example) and restart the process.\",\n status: 500,\n retryable: false,\n matchers: [/missing required env/i],\n },\n {\n code: \"CONFIG_BAD_URL\",\n title: \"Invalid endpoint URL\",\n cause: \"A configured bundler, paymaster or RPC URL is not a valid http(s) URL.\",\n fix: \"Use a full URL such as https://bundler.example.com.\",\n status: 500,\n retryable: false,\n matchers: [],\n },\n {\n code: \"CONFIG_SERVER_ONLY\",\n title: \"Server-only module imported in the browser\",\n cause: \"A server entry point was bundled into client code.\",\n fix: \"Import server entries only from route handlers, server actions and scripts.\",\n status: 500,\n retryable: false,\n matchers: [],\n },\n {\n code: \"AUTH_INVALID_TOKEN\",\n title: \"Invalid or missing Privy access token\",\n cause: \"The request carried no bearer token, or Privy could not verify it.\",\n fix: \"Send Authorization: Bearer <getAccessToken()> and verify the token server-side.\",\n status: 401,\n retryable: false,\n matchers: [/invalid (auth(orization)?|access|jwt|id) token/i, /\\bjwt (expired|malformed|invalid)/i],\n },\n {\n code: \"WALLET_NOT_PROVISIONED\",\n title: \"User has no embedded wallet yet\",\n cause: \"The user is signed in but no embedded Ethereum wallet exists.\",\n fix: \"Call the ensure-wallet route (useEnsureWallet or WalletGate) before acting.\",\n status: 409,\n retryable: true,\n matchers: [],\n },\n {\n code: \"POLICY_UNSCOPED\",\n title: \"Session policy is not scoped\",\n cause: \"A session policy needs a target contract, at least one function and an expiry.\",\n fix: \"Pass contractAddress, functions and expiresAtUnixSeconds to buildSessionPolicy().\",\n status: 400,\n retryable: false,\n matchers: [],\n },\n {\n code: \"SESSION_EXPIRED\",\n title: \"Session expired\",\n cause: \"The session's expiry has passed.\",\n fix: \"Grant a new session.\",\n status: 410,\n retryable: false,\n matchers: [],\n },\n {\n code: \"SESSION_NONE\",\n title: \"No active session\",\n cause: \"The user has not granted a session, or it was revoked.\",\n fix: \"Ask the user to grant a session first.\",\n status: 409,\n retryable: false,\n matchers: [],\n },\n {\n code: \"SESSION_APPROVAL_MISMATCH\",\n title: \"Session approval does not match\",\n cause: \"The approval was made for another account, permission id or mode.\",\n fix: \"Re-run prepare, have the owner sign again, then activate.\",\n status: 409,\n retryable: false,\n matchers: [],\n },\n {\n code: \"UNKNOWN\",\n title: \"Unknown error\",\n cause: \"The error did not match any known PEPU failure.\",\n fix: \"Read the original message. Run pepu_known_gotchas in the MCP server, or search the docs.\",\n status: 500,\n retryable: false,\n matchers: [],\n },\n];\n\nconst catalogByCode: ReadonlyMap<PepuErrorCode, ErrorCatalogEntry> = new Map(\n PEPU_ERROR_CATALOG.map((e) => [e.code, e]),\n);\n\n/** Look up a catalog entry by code. */\nexport function getErrorEntry(code: PepuErrorCode): ErrorCatalogEntry {\n const entry = catalogByCode.get(code) ?? catalogByCode.get(\"UNKNOWN\");\n if (!entry) throw new Error(\"PEPU_ERROR_CATALOG is missing the UNKNOWN entry\");\n return entry;\n}\n\n/** `https://guide.pepeunchained.com/reference/errors#<CODE>` */\nexport function errorDocsUrl(code: PepuErrorCode): string {\n return `${PEPU_ERRORS_DOCS_URL}#${code}`;\n}\n\nexport interface PepuErrorOptions {\n hint?: string;\n docsUrl?: string;\n retryable?: boolean;\n status?: number;\n details?: unknown;\n cause?: unknown;\n}\n\nexport class PepuError extends Error {\n readonly code: PepuErrorCode;\n readonly hint: string;\n readonly docsUrl: string;\n readonly retryable: boolean;\n readonly status: number;\n readonly details?: unknown;\n\n constructor(code: PepuErrorCode, message?: string, options: PepuErrorOptions = {}) {\n const entry = getErrorEntry(code);\n super(message ?? entry.title, options.cause === undefined ? undefined : { cause: options.cause });\n this.name = new.target.name;\n this.code = code;\n this.hint = options.hint ?? entry.fix;\n this.docsUrl = options.docsUrl ?? errorDocsUrl(code);\n this.retryable = options.retryable ?? entry.retryable;\n this.status = options.status ?? entry.status;\n if (options.details !== undefined) this.details = options.details;\n }\n}\n\n/** Missing env, bad URL, dashboard misconfiguration. */\nexport class PepuConfigError extends PepuError {}\n/** Bad or missing Privy token, wrong owner. */\nexport class PepuAuthError extends PepuError {}\n/** Unscoped policy, name too long, expiry, denied by policy. */\nexport class PepuPolicyError extends PepuError {}\n/** No session, expired, mismatched approval. */\nexport class PepuSessionError extends PepuError {}\n/** AAxx, JSON-RPC errors, timeouts. */\nexport class PepuBundlerError extends PepuError {}\n/** Reason codes, caps, balance, origin. */\nexport class PepuPaymasterError extends PepuError {}\n/** Revert, nonce race, gas, rpc rate limit. */\nexport class PepuChainError extends PepuError {}\n\ntype PepuErrorClass = new (code: PepuErrorCode, message?: string, options?: PepuErrorOptions) => PepuError;\n\nfunction classForCode(code: PepuErrorCode): PepuErrorClass {\n if (code.startsWith(\"CONFIG_\") || code.startsWith(\"PRIVY_\")) return PepuConfigError;\n if (code === \"AUTH_INVALID_TOKEN\" || code === \"WALLET_NOT_PROVISIONED\") return PepuAuthError;\n if (code.startsWith(\"POLICY_\")) return PepuPolicyError;\n if (code.startsWith(\"SESSION_\")) return PepuSessionError;\n if (code.startsWith(\"BUNDLER_\")) return PepuBundlerError;\n if (code.startsWith(\"PAYMASTER_\")) return PepuPaymasterError;\n if (code.startsWith(\"TX_\") || code.startsWith(\"MULTICALL3_\") || code.startsWith(\"WALLET_\")) return PepuChainError;\n return PepuError;\n}\n\nconst REVERT_ABI = [\n { type: \"error\", name: \"Error\", inputs: [{ name: \"message\", type: \"string\" }] },\n { type: \"error\", name: \"Panic\", inputs: [{ name: \"code\", type: \"uint256\" }] },\n {\n type: \"error\",\n name: \"FailedOp\",\n inputs: [\n { name: \"opIndex\", type: \"uint256\" },\n { name: \"reason\", type: \"string\" },\n ],\n },\n {\n type: \"error\",\n name: \"FailedOpWithRevert\",\n inputs: [\n { name: \"opIndex\", type: \"uint256\" },\n { name: \"reason\", type: \"string\" },\n { name: \"inner\", type: \"bytes\" },\n ],\n },\n] as const satisfies Abi;\n\nfunction flatten(e: unknown): string {\n const seen = new Set<unknown>();\n const parts: string[] = [];\n let cur: unknown = e;\n for (let depth = 0; depth < 6 && cur !== undefined && cur !== null && !seen.has(cur); depth++) {\n seen.add(cur);\n if (typeof cur === \"object\") {\n const o = cur as Record<string, unknown>;\n for (const k of [\"shortMessage\", \"message\", \"details\", \"reason\"]) {\n const v = o[k];\n if (typeof v === \"string\") parts.push(v);\n }\n cur = o[\"cause\"];\n } else {\n parts.push(String(cur));\n break;\n }\n }\n return parts.join(\"\\n\");\n}\n\nexport interface ErrorExplanation {\n code: PepuErrorCode;\n title: string;\n cause: string;\n fix: string;\n docsUrl: string;\n matched: \"catalog\" | \"abi-decode\" | \"unknown\";\n}\n\nfunction matchCatalog(text: string): ErrorCatalogEntry | undefined {\n return PEPU_ERROR_CATALOG.find((entry) => entry.matchers.some((m) => m.test(text)));\n}\n\nfunction explanation(entry: ErrorCatalogEntry, matched: ErrorExplanation[\"matched\"]): ErrorExplanation {\n return {\n code: entry.code,\n title: entry.title,\n cause: entry.cause,\n fix: entry.fix,\n docsUrl: errorDocsUrl(entry.code),\n matched,\n };\n}\n\n/**\n * Explain an error, an error message, or raw revert data (`0x...`). Pure and\n * synchronous; never throws.\n */\nexport function explainError(e: unknown | string | Hex): ErrorExplanation {\n if (e instanceof PepuError) return explanation(getErrorEntry(e.code), \"catalog\");\n\n if (typeof e === \"string\" && isHex(e) && e.length >= 10) {\n try {\n const decoded = decodeErrorResult({ abi: REVERT_ABI, data: e });\n const argText = (decoded.args ?? []).map((a) => (typeof a === \"string\" ? a : \"\")).join(\"\\n\");\n const hit = matchCatalog(`${argText}\\n${decoded.errorName}`);\n if (hit) return explanation(hit, \"abi-decode\");\n return explanation(getErrorEntry(\"TX_REVERTED\"), \"abi-decode\");\n } catch {\n return explanation(getErrorEntry(\"UNKNOWN\"), \"unknown\");\n }\n }\n\n const text = typeof e === \"string\" ? e : flatten(e);\n const hit = matchCatalog(text);\n return hit ? explanation(hit, \"catalog\") : explanation(getErrorEntry(\"UNKNOWN\"), \"unknown\");\n}\n\n/** Wrap anything thrown into a typed {@link PepuError}. PepuErrors pass through. */\nexport function toPepuError(e: unknown, ctx?: { op: string }): PepuError {\n if (e instanceof PepuError) return e;\n const explained = explainError(e);\n const original = (typeof e === \"string\" ? e : flatten(e)) || \"Unknown error\";\n const message = ctx ? `${ctx.op}: ${original}` : original;\n const Cls = classForCode(explained.code);\n return new Cls(explained.code, message, { cause: e });\n}\n\n/** The `{ error: { code, message, hint } }` body route factories return. */\nexport function toErrorBody(e: unknown): { error: { code: PepuErrorCode; message: string; hint: string } } {\n const err = toPepuError(e);\n return { error: { code: err.code, message: err.message, hint: err.hint } };\n}\n\n/** A JSON `Response` with the error body and the status from the error model. */\nexport function toErrorResponse(e: unknown): Response {\n const err = toPepuError(e);\n return new Response(JSON.stringify(toErrorBody(err)), {\n status: err.status,\n headers: { \"content-type\": \"application/json\" },\n });\n}\n"]}