@pafi-dev/core 0.7.7 → 0.7.10

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 (57) hide show
  1. package/dist/abi/index.cjs +4 -2
  2. package/dist/abi/index.cjs.map +1 -1
  3. package/dist/abi/index.js +4 -2
  4. package/dist/auth/index.cjs +6 -2
  5. package/dist/auth/index.cjs.map +1 -1
  6. package/dist/auth/index.d.cts +21 -9
  7. package/dist/auth/index.d.ts +21 -9
  8. package/dist/auth/index.js +5 -1
  9. package/dist/{chunk-6UX2IFA2.js → chunk-4EGXLYMM.js} +20 -2
  10. package/dist/chunk-4EGXLYMM.js.map +1 -0
  11. package/dist/{chunk-M5ULOZ3A.cjs → chunk-4QRHSZZQ.cjs} +55 -3
  12. package/dist/chunk-4QRHSZZQ.cjs.map +1 -0
  13. package/dist/chunk-6WWSKC3Z.cjs +1097 -0
  14. package/dist/chunk-6WWSKC3Z.cjs.map +1 -0
  15. package/dist/{chunk-5254AG3Z.cjs → chunk-75JWR5SA.cjs} +21 -3
  16. package/dist/chunk-75JWR5SA.cjs.map +1 -0
  17. package/dist/{chunk-YDLMVWDH.js → chunk-AEYEFV5G.js} +5 -3
  18. package/dist/{chunk-YDLMVWDH.js.map → chunk-AEYEFV5G.js.map} +1 -1
  19. package/dist/{chunk-5JZOJIBT.js → chunk-B2NDSIAI.js} +1 -1095
  20. package/dist/chunk-B2NDSIAI.js.map +1 -0
  21. package/dist/chunk-JEWSN7Q3.cjs +1059 -0
  22. package/dist/chunk-JEWSN7Q3.cjs.map +1 -0
  23. package/dist/{chunk-WJSIB5GF.js → chunk-QL5COJQI.js} +53 -1
  24. package/dist/chunk-QL5COJQI.js.map +1 -0
  25. package/dist/{chunk-CLPRSQT2.cjs → chunk-REUEMYWB.cjs} +14 -12
  26. package/dist/chunk-REUEMYWB.cjs.map +1 -0
  27. package/dist/chunk-SZMSKZHY.js +1097 -0
  28. package/dist/chunk-SZMSKZHY.js.map +1 -0
  29. package/dist/contract/index.cjs +4 -3
  30. package/dist/contract/index.cjs.map +1 -1
  31. package/dist/contract/index.d.cts +1 -1
  32. package/dist/contract/index.d.ts +1 -1
  33. package/dist/contract/index.js +3 -2
  34. package/dist/eip712/index.cjs +7 -2
  35. package/dist/eip712/index.cjs.map +1 -1
  36. package/dist/eip712/index.d.cts +39 -4
  37. package/dist/eip712/index.d.ts +39 -4
  38. package/dist/eip712/index.js +6 -1
  39. package/dist/index.cjs +96 -31
  40. package/dist/index.cjs.map +1 -1
  41. package/dist/index.d.cts +76 -29
  42. package/dist/index.d.ts +76 -29
  43. package/dist/index.js +85 -20
  44. package/dist/index.js.map +1 -1
  45. package/dist/types-CCvAk-ma.d.cts +159 -0
  46. package/dist/types-CCvAk-ma.d.ts +159 -0
  47. package/package.json +1 -1
  48. package/dist/chunk-5254AG3Z.cjs.map +0 -1
  49. package/dist/chunk-5JZOJIBT.js.map +0 -1
  50. package/dist/chunk-6UX2IFA2.js.map +0 -1
  51. package/dist/chunk-CLPRSQT2.cjs.map +0 -1
  52. package/dist/chunk-LRHY7GOR.cjs +0 -2153
  53. package/dist/chunk-LRHY7GOR.cjs.map +0 -1
  54. package/dist/chunk-M5ULOZ3A.cjs.map +0 -1
  55. package/dist/chunk-WJSIB5GF.js.map +0 -1
  56. package/dist/types-BAkmxgVo.d.cts +0 -99
  57. package/dist/types-BAkmxgVo.d.ts +0 -99
package/dist/index.d.cts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { Address, Hex, TypedDataDomain, PublicClient, WalletClient, TransactionReceipt, HttpTransport } from 'viem';
2
- import { P as PoolKey, C as ChainConfig, a as PafiSDKConfig, b as PointTokenDomainConfig, M as MintRequest, R as ReceiverConsent, E as EIP712Signature, S as SignatureVerification } from './types-BAkmxgVo.cjs';
3
- export { B as BestQuote, c as BurnRequest, I as Issuer, d as PathKey, Q as QuoteResult } from './types-BAkmxgVo.cjs';
2
+ import { P as PoolKey, C as ChainConfig, a as PafiSDKConfig, b as PointTokenDomainConfig, M as MintRequest, R as ReceiverConsent, E as EIP712Signature, S as SignatureVerification } from './types-CCvAk-ma.cjs';
3
+ export { B as BestQuote, c as BlackoutWindow, d as BurnRequest, I as Issuer, e as PathKey, Q as QuoteResult, f as RedemptionDecision, g as RedemptionDenial, h as RedemptionDenialCode, i as RedemptionPolicy, j as RedemptionPolicySource, k as RedemptionPreview } from './types-CCvAk-ma.cjs';
4
4
  export { pointTokenAbi as POINT_TOKEN_V2_ABI, erc20Abi, issuerRegistryAbi, mintingOracleAbi, permit2Abi, pointTokenAbi, pointTokenFactoryAbi, universalRouterAbi, v4QuoterAbi } from './abi/index.cjs';
5
- export { buildBurnRequestTypedData, buildDomain, buildMintRequestTypedData, buildReceiverConsentTypedData, signBurnRequest, signMintRequest, signReceiverConsent, verifyBurnRequest, verifyMintRequest, verifyReceiverConsent } from './eip712/index.cjs';
5
+ export { Eip712DomainMismatchError, assertDomainMatchesContract, buildBurnRequestTypedData, buildDomain, buildMintRequestTypedData, buildReceiverConsentTypedData, signBurnRequest, signMintRequest, signReceiverConsent, verifyBurnRequest, verifyMintRequest, verifyReceiverConsent } from './eip712/index.cjs';
6
6
  export { getBurnRequestNonce, getIssuer, getMintRequestNonce, getPointTokenBalance, getPointTokenIssuer, getPointTokenIssuerAddress, getReceiverConsentNonce, getTokenName, isActiveIssuer, isMinter, issuerRegistryGetIssuerFlatAbi, verifyMintCap } from './contract/index.cjs';
7
7
  import { LoginMessageParams } from './auth/index.cjs';
8
- export { BuildSponsorAuthParams, BuiltSponsorAuth, SPONSOR_AUTH_DOMAIN_NAME, SPONSOR_AUTH_TYPES, SponsorAuthPayload, SponsorAuthVerifyResult, VerifyLoginResult, buildAndSignSponsorAuth, buildSponsorAuthDomain, buildSponsorAuthTypedData, computeCallDataHash, createLoginMessage, generateSponsorAuthNonce, parseLoginMessage, signSponsorAuth, verifyLoginMessage, verifySponsorAuth } from './auth/index.cjs';
8
+ export { BuildSponsorAuthParams, BuiltSponsorAuth, SPONSOR_AUTH_DOMAIN_ANCHOR_BASE_MAINNET, SPONSOR_AUTH_DOMAIN_NAME, SPONSOR_AUTH_TYPES, SponsorAuthPayload, SponsorAuthVerifyResult, VerifyLoginResult, buildAndSignSponsorAuth, buildSponsorAuthDomain, buildSponsorAuthTypedData, computeCallDataHash, createLoginMessage, generateSponsorAuthNonce, getSponsorAuthDomainAnchor, parseLoginMessage, signSponsorAuth, verifyLoginMessage, verifySponsorAuth } from './auth/index.cjs';
9
9
 
10
10
  declare const mintRequestTypes: {
11
11
  readonly MintRequest: readonly [{
@@ -83,15 +83,13 @@ declare const ENTRY_POINT_V08: Address;
83
83
  declare const PERMIT2_ADDRESS: Address;
84
84
 
85
85
  /**
86
- * v0.7.1 — unified error base for the entire SDK (core + issuer +
87
- * trading). Subclasses declare `code` (machine-readable) and
88
- * `httpStatus` (recommended HTTP status for issuer's controller).
86
+ * Unified error base for the entire SDK (core + issuer + trading).
87
+ * Subclasses declare `code` (machine-readable) and `httpStatus`
88
+ * (recommended HTTP status for issuer's controller).
89
89
  *
90
90
  * Issuer's `createSdkErrorMapper` routes any `PafiSdkError` instance
91
91
  * through framework-specific exception factories; non-PafiSdkError
92
92
  * still becomes 500.
93
- *
94
- * See SDK_CORE_TRADING_AUDIT.md H3.
95
93
  */
96
94
  type SdkErrorHttpStatus = "not_found" | "forbidden" | "unprocessable" | "service_unavailable";
97
95
  declare abstract class PafiSdkError extends Error {
@@ -106,11 +104,11 @@ declare abstract class PafiSdkError extends Error {
106
104
  constructor(message: string);
107
105
  }
108
106
  /**
109
- * @deprecated v0.7.1 — use `PafiSdkError` (capital S, lowercase dk).
107
+ * @deprecated Use `PafiSdkError` (capital S, lowercase dk).
110
108
  * The two classes existed in parallel ("PafiSDKError" in core,
111
109
  * "PafiSdkError" in issuer) due to historical drift; consolidating
112
110
  * here. Kept as alias for back-compat through v0.7.x; will be removed
113
- * in v0.8. See SDK_CORE_TRADING_AUDIT.md H3.
111
+ * in v0.8.
114
112
  */
115
113
  declare class PafiSDKError extends Error {
116
114
  constructor(message: string);
@@ -133,11 +131,8 @@ declare class ApiError extends PafiSDKError {
133
131
  /**
134
132
  * Thrown by `quoteOperatorFee*` when an upstream price source
135
133
  * (Chainlink ETH/USD, PAFI subgraph) is unavailable or stale and the
136
- * caller did not opt in to the hardcoded fallback prices.
137
- *
138
- * v0.7.1 — previously `quoteOperatorFeePt` silently fell back to
139
- * ETH=$3000 / PT=$0.10 with `console.warn`. Now opt-in via
140
- * `allowStaleFallback: true`. See SDK_CORE_TRADING_AUDIT.md C2.
134
+ * caller did not opt in to the hardcoded fallback prices via
135
+ * `allowStaleFallback: true`.
141
136
  *
142
137
  * Extends the unified `PafiSdkError` so issuer's `createSdkErrorMapper`
143
138
  * routes it to 503 instead of leaking as a 500.
@@ -156,8 +151,6 @@ declare class OracleStaleError extends PafiSdkError {
156
151
  *
157
152
  * Uses an instance `details` field so subclasses can override the
158
153
  * declaration; matches the issuer-side shape that pre-existed here.
159
- *
160
- * v0.7.4 — added per SDK_CORE_TRADING_AUDIT.md H2/H13.
161
154
  */
162
155
  declare class ValidationError extends PafiSdkError {
163
156
  readonly httpStatus: "unprocessable";
@@ -1392,10 +1385,6 @@ interface SmartAccountSender {
1392
1385
  *
1393
1386
  * Use this to decide whether retrying without a paymaster makes sense.
1394
1387
  * Contract reverts (AA23, AA24, AA25) and bundler errors are NOT matched.
1395
- *
1396
- * v0.7.1 — replaced naive substring matching that false-positived on
1397
- * arbitrary text containing "503"/"403"/"429" (e.g. address/transit ID).
1398
- * See SDK_CORE_TRADING_AUDIT.md C3.
1399
1388
  */
1400
1389
  declare function isPaymasterError(err: unknown): boolean;
1401
1390
  interface SendWithPaymasterFallbackParams {
@@ -1459,8 +1448,7 @@ declare function sendWithPaymasterFallback(params: SendWithPaymasterFallbackPara
1459
1448
  * perp-deposit — `buildPerpDepositViaRelay` 800k (LayerZero msg)
1460
1449
  * delegate — minimal no-op self-call, 200k margin
1461
1450
  *
1462
- * Pass an explicit `gasUnits` to override. v0.7.4 — added per
1463
- * SDK_CORE_TRADING_AUDIT.md H12.
1451
+ * Pass an explicit `gasUnits` to override.
1464
1452
  */
1465
1453
  type FeeScenario = "mint" | "burn" | "swap" | "perp-deposit" | "delegate";
1466
1454
  interface QuoteOperatorFeePtConfig {
@@ -1497,17 +1485,38 @@ interface QuoteOperatorFeePtConfig {
1497
1485
  * `true` AND configure `fallbackEthPriceUsd` / `fallbackPtPriceUsdt`
1498
1486
  * to absorb oracle outages instead of surfacing them.
1499
1487
  *
1500
- * v0.7.1 previously fallback was always-on with hardcoded
1501
- * defaults (ETH=$3000, PT=$0.10), causing under-priced fees during
1502
- * incidents. See SDK_CORE_TRADING_AUDIT.md C2.
1488
+ * When fallback fires, callers SHOULD observe via `onFallback` so
1489
+ * production can flag the under-priced quote (e.g. show "fee priced
1490
+ * against stale oracle" banner in FE; alert on-call).
1503
1491
  */
1504
1492
  allowStaleFallback?: boolean;
1505
1493
  /** Fallback ETH price (USD) when Chainlink is unreachable. Only used when `allowStaleFallback: true`. Default 3000. */
1506
1494
  fallbackEthPriceUsd?: number;
1507
1495
  /** Fallback PT price (USDT per 1 PT) when subgraph is unreachable. Only used when `allowStaleFallback: true`. Default 0.1. */
1508
1496
  fallbackPtPriceUsdt?: number;
1497
+ /**
1498
+ * Observability hook fired when the quoter falls back to stale
1499
+ * prices. Callers SHOULD wire this to their alert pipeline (Sentry,
1500
+ * Datadog, PagerDuty) so under-priced quotes don't go unnoticed.
1501
+ * When omitted, falls back to `console.warn` (kept for back-compat
1502
+ * but invisible in most prod log shippers).
1503
+ */
1504
+ onFallback?: (info: FallbackInfo) => void;
1509
1505
  fetchImpl?: typeof fetch;
1510
1506
  }
1507
+ /**
1508
+ * Detail surfaced via `onFallback` when the quoter substitutes a
1509
+ * stale-fallback price. Callers can format this into a UI banner or
1510
+ * log line.
1511
+ */
1512
+ interface FallbackInfo {
1513
+ /** Which oracle failed. */
1514
+ source: "chainlink" | "subgraph";
1515
+ /** Underlying reason from the oracle call (e.g. RPC error message). */
1516
+ reason: string;
1517
+ /** The fallback value that was used (in source-native units). */
1518
+ fallbackValue: number;
1519
+ }
1511
1520
  /**
1512
1521
  * Subset of `QuoteOperatorFeePtConfig` that doesn't need the V4 pool
1513
1522
  * step — used by `quoteOperatorFeeUsdt` (FE cashout-preview / `/gas-fee`
@@ -1525,10 +1534,12 @@ interface QuoteOperatorFeeUsdtConfig {
1525
1534
  usdtDecimals?: number;
1526
1535
  /**
1527
1536
  * Opt-in fallback price when Chainlink is unavailable. Default
1528
- * `false` — throw `OracleStaleError`. v0.7.1 — see C2.
1537
+ * `false` — throw `OracleStaleError`.
1529
1538
  */
1530
1539
  allowStaleFallback?: boolean;
1531
1540
  fallbackEthPriceUsd?: number;
1541
+ /** See QuoteOperatorFeePtConfig.onFallback. */
1542
+ onFallback?: (info: FallbackInfo) => void;
1532
1543
  }
1533
1544
  /**
1534
1545
  * Operator fee quoted in USDT raw units (default 6 decimals). Returns
@@ -1634,6 +1645,42 @@ declare const POINT_TOKEN_IMPL_ADDRESSES: Record<number, Address>;
1634
1645
  */
1635
1646
  declare function getContractAddresses(chainId: number): ContractAddresses;
1636
1647
 
1648
+ /**
1649
+ * PAFI HTTP service URLs by chainId. Mirrors the `getContractAddresses`
1650
+ * pattern: SDK ships with the URL for each supported chain so issuers
1651
+ * don't pass URLs as env vars / constructor args.
1652
+ *
1653
+ * When PAFI changes URLs (rebrand, re-host, environment migration),
1654
+ * bump the SDK version and re-publish. Issuers pin a version, get the
1655
+ * URLs that match.
1656
+ *
1657
+ * No env override is provided on purpose — different environments use
1658
+ * different SDK versions (e.g. an `@pafi-dev/issuer-dev` channel for
1659
+ * staging). This keeps issuer integration to chainId + creds only.
1660
+ */
1661
+ interface PafiServiceUrls {
1662
+ /**
1663
+ * sponsor-relayer base URL (paymaster proxy). PafiBackendClient
1664
+ * appends `/paymaster/sponsor`, `/bundler/receipt`, etc.
1665
+ */
1666
+ sponsorRelayer: string;
1667
+ /**
1668
+ * issuer-api base URL. SettlementClient appends
1669
+ * `/issuers/:issuerId/redemption-policy`.
1670
+ */
1671
+ issuerApi: string;
1672
+ }
1673
+ /**
1674
+ * Per-chain URL map. URLs follow the pattern
1675
+ * `https://<host>/api/<service>` so Kong gateway can route by path.
1676
+ *
1677
+ * NOTE: placeholder URLs — Phi will swap in real prod/staging hosts
1678
+ * once the deploy targets are finalized. SDK version bump captures
1679
+ * the change.
1680
+ */
1681
+ declare const PAFI_SERVICE_URLS: Record<number, PafiServiceUrls>;
1682
+ declare function getPafiServiceUrls(chainId: number): PafiServiceUrls;
1683
+
1637
1684
  /**
1638
1685
  * Public contract surface for `@pafi-dev/core/contracts`.
1639
1686
  *
@@ -1971,4 +2018,4 @@ declare class PafiSDK {
1971
2018
  signLoginMessage(message: string): Promise<Hex>;
1972
2019
  }
1973
2020
 
1974
- export { ApiError, BATCH_EXECUTOR_7702_IMPL, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, type BuildDelegationUserOpParams, type BuildPartialUserOpParams, type BuildPerpDepositViaRelayParams, type BuildPerpDepositWithGasDeductionParams, COMMON_POOLS, COMMON_TOKENS, CONTRACT_ADDRESSES, ChainConfig, type CheckEthAndBranchParams, ConfigurationError, type ContractAddresses, DUMMY_SIGNATURE_V07, type DelegateDirectParams, type DelegateDirectResult, type DelegateImpl, EIP712Signature, ENTRY_POINT_V07, ENTRY_POINT_V08, type Eip7702AuthorizationJsonRpc, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_RELAY_ABI, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, type Operation, OracleStaleError, type OrderlyRelayDepositRequest, PAFI_SUBGRAPH_URL, PERMIT2_ADDRESS, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_POOLS, type PackedUserOperationMessage, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSDKError, PafiSdkError, type PafiWebModalAdapter, type PafiWebModalHandle, type PartialUserOperation, type PaymasterConfig, type PaymasterFields, PointTokenDomainConfig, PoolKey, type QuoteOperatorFeePtConfig, type QuoteOperatorFeeUsdtConfig, ReceiverConsent, SIMPLE_7702_IMPL_BASE_MAINNET, SUPPORTED_CHAINS, type SdkErrorHttpStatus, type SendWithPaymasterFallbackParams, type SignAuthorizationFn, type SignatureStruct, SignatureVerification, type SignedAuthorization, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, type UserOpReceipt, type UserOpTypedData, type UserOperation, V4_QUOTER_ADDRESSES, ValidationError, type VaultDepositFE, ZERO_VALUE, _resetPaymasterConfigForTests, assembleUserOperation, buildDelegationUserOp, buildEip7702Authorization, buildPartialUserOperation, buildPerpDepositViaRelay, buildPerpDepositWithGasDeduction, buildUserOpTypedData, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, computeAuthorizationHash, computeUserOpHash, createPafiProxyTransport, decodeBatchExecuteCalls, delegateDirect, detectDelegateImpl, encodeBatchExecute, erc20ApproveOp, erc20BurnOp, erc20TransferOp, fetchPafiPools, getAaNonce, getContractAddresses, getDummySignatureFor7702, getPafiWebModalAdapter, getPaymasterConfig, isDelegatedTo, isDelegatedToTarget, isPaymasterConfigured, isPaymasterError, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, quoteOperatorFeePt, quoteOperatorFeeUsdt, rawCallOp, receiverConsentTypes, sendWithPaymasterFallback, serializeUserOpToJsonRpc, setPafiWebModalAdapter, setPaymasterConfig, splitAuthorizationSig, webPopupAdapter };
2021
+ export { ApiError, BATCH_EXECUTOR_7702_IMPL, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, type BuildDelegationUserOpParams, type BuildPartialUserOpParams, type BuildPerpDepositViaRelayParams, type BuildPerpDepositWithGasDeductionParams, COMMON_POOLS, COMMON_TOKENS, CONTRACT_ADDRESSES, ChainConfig, type CheckEthAndBranchParams, ConfigurationError, type ContractAddresses, DUMMY_SIGNATURE_V07, type DelegateDirectParams, type DelegateDirectResult, type DelegateImpl, EIP712Signature, ENTRY_POINT_V07, ENTRY_POINT_V08, type Eip7702AuthorizationJsonRpc, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_RELAY_ABI, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, type Operation, OracleStaleError, type OrderlyRelayDepositRequest, PAFI_SERVICE_URLS, PAFI_SUBGRAPH_URL, PERMIT2_ADDRESS, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_POOLS, type PackedUserOperationMessage, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSDKError, PafiSdkError, type PafiServiceUrls, type PafiWebModalAdapter, type PafiWebModalHandle, type PartialUserOperation, type PaymasterConfig, type PaymasterFields, PointTokenDomainConfig, PoolKey, type QuoteOperatorFeePtConfig, type QuoteOperatorFeeUsdtConfig, ReceiverConsent, SIMPLE_7702_IMPL_BASE_MAINNET, SUPPORTED_CHAINS, type SdkErrorHttpStatus, type SendWithPaymasterFallbackParams, type SignAuthorizationFn, type SignatureStruct, SignatureVerification, type SignedAuthorization, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, type UserOpReceipt, type UserOpTypedData, type UserOperation, V4_QUOTER_ADDRESSES, ValidationError, type VaultDepositFE, ZERO_VALUE, _resetPaymasterConfigForTests, assembleUserOperation, buildDelegationUserOp, buildEip7702Authorization, buildPartialUserOperation, buildPerpDepositViaRelay, buildPerpDepositWithGasDeduction, buildUserOpTypedData, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, computeAuthorizationHash, computeUserOpHash, createPafiProxyTransport, decodeBatchExecuteCalls, delegateDirect, detectDelegateImpl, encodeBatchExecute, erc20ApproveOp, erc20BurnOp, erc20TransferOp, fetchPafiPools, getAaNonce, getContractAddresses, getDummySignatureFor7702, getPafiServiceUrls, getPafiWebModalAdapter, getPaymasterConfig, isDelegatedTo, isDelegatedToTarget, isPaymasterConfigured, isPaymasterError, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, quoteOperatorFeePt, quoteOperatorFeeUsdt, rawCallOp, receiverConsentTypes, sendWithPaymasterFallback, serializeUserOpToJsonRpc, setPafiWebModalAdapter, setPaymasterConfig, splitAuthorizationSig, webPopupAdapter };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { Address, Hex, TypedDataDomain, PublicClient, WalletClient, TransactionReceipt, HttpTransport } from 'viem';
2
- import { P as PoolKey, C as ChainConfig, a as PafiSDKConfig, b as PointTokenDomainConfig, M as MintRequest, R as ReceiverConsent, E as EIP712Signature, S as SignatureVerification } from './types-BAkmxgVo.js';
3
- export { B as BestQuote, c as BurnRequest, I as Issuer, d as PathKey, Q as QuoteResult } from './types-BAkmxgVo.js';
2
+ import { P as PoolKey, C as ChainConfig, a as PafiSDKConfig, b as PointTokenDomainConfig, M as MintRequest, R as ReceiverConsent, E as EIP712Signature, S as SignatureVerification } from './types-CCvAk-ma.js';
3
+ export { B as BestQuote, c as BlackoutWindow, d as BurnRequest, I as Issuer, e as PathKey, Q as QuoteResult, f as RedemptionDecision, g as RedemptionDenial, h as RedemptionDenialCode, i as RedemptionPolicy, j as RedemptionPolicySource, k as RedemptionPreview } from './types-CCvAk-ma.js';
4
4
  export { pointTokenAbi as POINT_TOKEN_V2_ABI, erc20Abi, issuerRegistryAbi, mintingOracleAbi, permit2Abi, pointTokenAbi, pointTokenFactoryAbi, universalRouterAbi, v4QuoterAbi } from './abi/index.js';
5
- export { buildBurnRequestTypedData, buildDomain, buildMintRequestTypedData, buildReceiverConsentTypedData, signBurnRequest, signMintRequest, signReceiverConsent, verifyBurnRequest, verifyMintRequest, verifyReceiverConsent } from './eip712/index.js';
5
+ export { Eip712DomainMismatchError, assertDomainMatchesContract, buildBurnRequestTypedData, buildDomain, buildMintRequestTypedData, buildReceiverConsentTypedData, signBurnRequest, signMintRequest, signReceiverConsent, verifyBurnRequest, verifyMintRequest, verifyReceiverConsent } from './eip712/index.js';
6
6
  export { getBurnRequestNonce, getIssuer, getMintRequestNonce, getPointTokenBalance, getPointTokenIssuer, getPointTokenIssuerAddress, getReceiverConsentNonce, getTokenName, isActiveIssuer, isMinter, issuerRegistryGetIssuerFlatAbi, verifyMintCap } from './contract/index.js';
7
7
  import { LoginMessageParams } from './auth/index.js';
8
- export { BuildSponsorAuthParams, BuiltSponsorAuth, SPONSOR_AUTH_DOMAIN_NAME, SPONSOR_AUTH_TYPES, SponsorAuthPayload, SponsorAuthVerifyResult, VerifyLoginResult, buildAndSignSponsorAuth, buildSponsorAuthDomain, buildSponsorAuthTypedData, computeCallDataHash, createLoginMessage, generateSponsorAuthNonce, parseLoginMessage, signSponsorAuth, verifyLoginMessage, verifySponsorAuth } from './auth/index.js';
8
+ export { BuildSponsorAuthParams, BuiltSponsorAuth, SPONSOR_AUTH_DOMAIN_ANCHOR_BASE_MAINNET, SPONSOR_AUTH_DOMAIN_NAME, SPONSOR_AUTH_TYPES, SponsorAuthPayload, SponsorAuthVerifyResult, VerifyLoginResult, buildAndSignSponsorAuth, buildSponsorAuthDomain, buildSponsorAuthTypedData, computeCallDataHash, createLoginMessage, generateSponsorAuthNonce, getSponsorAuthDomainAnchor, parseLoginMessage, signSponsorAuth, verifyLoginMessage, verifySponsorAuth } from './auth/index.js';
9
9
 
10
10
  declare const mintRequestTypes: {
11
11
  readonly MintRequest: readonly [{
@@ -83,15 +83,13 @@ declare const ENTRY_POINT_V08: Address;
83
83
  declare const PERMIT2_ADDRESS: Address;
84
84
 
85
85
  /**
86
- * v0.7.1 — unified error base for the entire SDK (core + issuer +
87
- * trading). Subclasses declare `code` (machine-readable) and
88
- * `httpStatus` (recommended HTTP status for issuer's controller).
86
+ * Unified error base for the entire SDK (core + issuer + trading).
87
+ * Subclasses declare `code` (machine-readable) and `httpStatus`
88
+ * (recommended HTTP status for issuer's controller).
89
89
  *
90
90
  * Issuer's `createSdkErrorMapper` routes any `PafiSdkError` instance
91
91
  * through framework-specific exception factories; non-PafiSdkError
92
92
  * still becomes 500.
93
- *
94
- * See SDK_CORE_TRADING_AUDIT.md H3.
95
93
  */
96
94
  type SdkErrorHttpStatus = "not_found" | "forbidden" | "unprocessable" | "service_unavailable";
97
95
  declare abstract class PafiSdkError extends Error {
@@ -106,11 +104,11 @@ declare abstract class PafiSdkError extends Error {
106
104
  constructor(message: string);
107
105
  }
108
106
  /**
109
- * @deprecated v0.7.1 — use `PafiSdkError` (capital S, lowercase dk).
107
+ * @deprecated Use `PafiSdkError` (capital S, lowercase dk).
110
108
  * The two classes existed in parallel ("PafiSDKError" in core,
111
109
  * "PafiSdkError" in issuer) due to historical drift; consolidating
112
110
  * here. Kept as alias for back-compat through v0.7.x; will be removed
113
- * in v0.8. See SDK_CORE_TRADING_AUDIT.md H3.
111
+ * in v0.8.
114
112
  */
115
113
  declare class PafiSDKError extends Error {
116
114
  constructor(message: string);
@@ -133,11 +131,8 @@ declare class ApiError extends PafiSDKError {
133
131
  /**
134
132
  * Thrown by `quoteOperatorFee*` when an upstream price source
135
133
  * (Chainlink ETH/USD, PAFI subgraph) is unavailable or stale and the
136
- * caller did not opt in to the hardcoded fallback prices.
137
- *
138
- * v0.7.1 — previously `quoteOperatorFeePt` silently fell back to
139
- * ETH=$3000 / PT=$0.10 with `console.warn`. Now opt-in via
140
- * `allowStaleFallback: true`. See SDK_CORE_TRADING_AUDIT.md C2.
134
+ * caller did not opt in to the hardcoded fallback prices via
135
+ * `allowStaleFallback: true`.
141
136
  *
142
137
  * Extends the unified `PafiSdkError` so issuer's `createSdkErrorMapper`
143
138
  * routes it to 503 instead of leaking as a 500.
@@ -156,8 +151,6 @@ declare class OracleStaleError extends PafiSdkError {
156
151
  *
157
152
  * Uses an instance `details` field so subclasses can override the
158
153
  * declaration; matches the issuer-side shape that pre-existed here.
159
- *
160
- * v0.7.4 — added per SDK_CORE_TRADING_AUDIT.md H2/H13.
161
154
  */
162
155
  declare class ValidationError extends PafiSdkError {
163
156
  readonly httpStatus: "unprocessable";
@@ -1392,10 +1385,6 @@ interface SmartAccountSender {
1392
1385
  *
1393
1386
  * Use this to decide whether retrying without a paymaster makes sense.
1394
1387
  * Contract reverts (AA23, AA24, AA25) and bundler errors are NOT matched.
1395
- *
1396
- * v0.7.1 — replaced naive substring matching that false-positived on
1397
- * arbitrary text containing "503"/"403"/"429" (e.g. address/transit ID).
1398
- * See SDK_CORE_TRADING_AUDIT.md C3.
1399
1388
  */
1400
1389
  declare function isPaymasterError(err: unknown): boolean;
1401
1390
  interface SendWithPaymasterFallbackParams {
@@ -1459,8 +1448,7 @@ declare function sendWithPaymasterFallback(params: SendWithPaymasterFallbackPara
1459
1448
  * perp-deposit — `buildPerpDepositViaRelay` 800k (LayerZero msg)
1460
1449
  * delegate — minimal no-op self-call, 200k margin
1461
1450
  *
1462
- * Pass an explicit `gasUnits` to override. v0.7.4 — added per
1463
- * SDK_CORE_TRADING_AUDIT.md H12.
1451
+ * Pass an explicit `gasUnits` to override.
1464
1452
  */
1465
1453
  type FeeScenario = "mint" | "burn" | "swap" | "perp-deposit" | "delegate";
1466
1454
  interface QuoteOperatorFeePtConfig {
@@ -1497,17 +1485,38 @@ interface QuoteOperatorFeePtConfig {
1497
1485
  * `true` AND configure `fallbackEthPriceUsd` / `fallbackPtPriceUsdt`
1498
1486
  * to absorb oracle outages instead of surfacing them.
1499
1487
  *
1500
- * v0.7.1 previously fallback was always-on with hardcoded
1501
- * defaults (ETH=$3000, PT=$0.10), causing under-priced fees during
1502
- * incidents. See SDK_CORE_TRADING_AUDIT.md C2.
1488
+ * When fallback fires, callers SHOULD observe via `onFallback` so
1489
+ * production can flag the under-priced quote (e.g. show "fee priced
1490
+ * against stale oracle" banner in FE; alert on-call).
1503
1491
  */
1504
1492
  allowStaleFallback?: boolean;
1505
1493
  /** Fallback ETH price (USD) when Chainlink is unreachable. Only used when `allowStaleFallback: true`. Default 3000. */
1506
1494
  fallbackEthPriceUsd?: number;
1507
1495
  /** Fallback PT price (USDT per 1 PT) when subgraph is unreachable. Only used when `allowStaleFallback: true`. Default 0.1. */
1508
1496
  fallbackPtPriceUsdt?: number;
1497
+ /**
1498
+ * Observability hook fired when the quoter falls back to stale
1499
+ * prices. Callers SHOULD wire this to their alert pipeline (Sentry,
1500
+ * Datadog, PagerDuty) so under-priced quotes don't go unnoticed.
1501
+ * When omitted, falls back to `console.warn` (kept for back-compat
1502
+ * but invisible in most prod log shippers).
1503
+ */
1504
+ onFallback?: (info: FallbackInfo) => void;
1509
1505
  fetchImpl?: typeof fetch;
1510
1506
  }
1507
+ /**
1508
+ * Detail surfaced via `onFallback` when the quoter substitutes a
1509
+ * stale-fallback price. Callers can format this into a UI banner or
1510
+ * log line.
1511
+ */
1512
+ interface FallbackInfo {
1513
+ /** Which oracle failed. */
1514
+ source: "chainlink" | "subgraph";
1515
+ /** Underlying reason from the oracle call (e.g. RPC error message). */
1516
+ reason: string;
1517
+ /** The fallback value that was used (in source-native units). */
1518
+ fallbackValue: number;
1519
+ }
1511
1520
  /**
1512
1521
  * Subset of `QuoteOperatorFeePtConfig` that doesn't need the V4 pool
1513
1522
  * step — used by `quoteOperatorFeeUsdt` (FE cashout-preview / `/gas-fee`
@@ -1525,10 +1534,12 @@ interface QuoteOperatorFeeUsdtConfig {
1525
1534
  usdtDecimals?: number;
1526
1535
  /**
1527
1536
  * Opt-in fallback price when Chainlink is unavailable. Default
1528
- * `false` — throw `OracleStaleError`. v0.7.1 — see C2.
1537
+ * `false` — throw `OracleStaleError`.
1529
1538
  */
1530
1539
  allowStaleFallback?: boolean;
1531
1540
  fallbackEthPriceUsd?: number;
1541
+ /** See QuoteOperatorFeePtConfig.onFallback. */
1542
+ onFallback?: (info: FallbackInfo) => void;
1532
1543
  }
1533
1544
  /**
1534
1545
  * Operator fee quoted in USDT raw units (default 6 decimals). Returns
@@ -1634,6 +1645,42 @@ declare const POINT_TOKEN_IMPL_ADDRESSES: Record<number, Address>;
1634
1645
  */
1635
1646
  declare function getContractAddresses(chainId: number): ContractAddresses;
1636
1647
 
1648
+ /**
1649
+ * PAFI HTTP service URLs by chainId. Mirrors the `getContractAddresses`
1650
+ * pattern: SDK ships with the URL for each supported chain so issuers
1651
+ * don't pass URLs as env vars / constructor args.
1652
+ *
1653
+ * When PAFI changes URLs (rebrand, re-host, environment migration),
1654
+ * bump the SDK version and re-publish. Issuers pin a version, get the
1655
+ * URLs that match.
1656
+ *
1657
+ * No env override is provided on purpose — different environments use
1658
+ * different SDK versions (e.g. an `@pafi-dev/issuer-dev` channel for
1659
+ * staging). This keeps issuer integration to chainId + creds only.
1660
+ */
1661
+ interface PafiServiceUrls {
1662
+ /**
1663
+ * sponsor-relayer base URL (paymaster proxy). PafiBackendClient
1664
+ * appends `/paymaster/sponsor`, `/bundler/receipt`, etc.
1665
+ */
1666
+ sponsorRelayer: string;
1667
+ /**
1668
+ * issuer-api base URL. SettlementClient appends
1669
+ * `/issuers/:issuerId/redemption-policy`.
1670
+ */
1671
+ issuerApi: string;
1672
+ }
1673
+ /**
1674
+ * Per-chain URL map. URLs follow the pattern
1675
+ * `https://<host>/api/<service>` so Kong gateway can route by path.
1676
+ *
1677
+ * NOTE: placeholder URLs — Phi will swap in real prod/staging hosts
1678
+ * once the deploy targets are finalized. SDK version bump captures
1679
+ * the change.
1680
+ */
1681
+ declare const PAFI_SERVICE_URLS: Record<number, PafiServiceUrls>;
1682
+ declare function getPafiServiceUrls(chainId: number): PafiServiceUrls;
1683
+
1637
1684
  /**
1638
1685
  * Public contract surface for `@pafi-dev/core/contracts`.
1639
1686
  *
@@ -1971,4 +2018,4 @@ declare class PafiSDK {
1971
2018
  signLoginMessage(message: string): Promise<Hex>;
1972
2019
  }
1973
2020
 
1974
- export { ApiError, BATCH_EXECUTOR_7702_IMPL, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, type BuildDelegationUserOpParams, type BuildPartialUserOpParams, type BuildPerpDepositViaRelayParams, type BuildPerpDepositWithGasDeductionParams, COMMON_POOLS, COMMON_TOKENS, CONTRACT_ADDRESSES, ChainConfig, type CheckEthAndBranchParams, ConfigurationError, type ContractAddresses, DUMMY_SIGNATURE_V07, type DelegateDirectParams, type DelegateDirectResult, type DelegateImpl, EIP712Signature, ENTRY_POINT_V07, ENTRY_POINT_V08, type Eip7702AuthorizationJsonRpc, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_RELAY_ABI, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, type Operation, OracleStaleError, type OrderlyRelayDepositRequest, PAFI_SUBGRAPH_URL, PERMIT2_ADDRESS, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_POOLS, type PackedUserOperationMessage, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSDKError, PafiSdkError, type PafiWebModalAdapter, type PafiWebModalHandle, type PartialUserOperation, type PaymasterConfig, type PaymasterFields, PointTokenDomainConfig, PoolKey, type QuoteOperatorFeePtConfig, type QuoteOperatorFeeUsdtConfig, ReceiverConsent, SIMPLE_7702_IMPL_BASE_MAINNET, SUPPORTED_CHAINS, type SdkErrorHttpStatus, type SendWithPaymasterFallbackParams, type SignAuthorizationFn, type SignatureStruct, SignatureVerification, type SignedAuthorization, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, type UserOpReceipt, type UserOpTypedData, type UserOperation, V4_QUOTER_ADDRESSES, ValidationError, type VaultDepositFE, ZERO_VALUE, _resetPaymasterConfigForTests, assembleUserOperation, buildDelegationUserOp, buildEip7702Authorization, buildPartialUserOperation, buildPerpDepositViaRelay, buildPerpDepositWithGasDeduction, buildUserOpTypedData, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, computeAuthorizationHash, computeUserOpHash, createPafiProxyTransport, decodeBatchExecuteCalls, delegateDirect, detectDelegateImpl, encodeBatchExecute, erc20ApproveOp, erc20BurnOp, erc20TransferOp, fetchPafiPools, getAaNonce, getContractAddresses, getDummySignatureFor7702, getPafiWebModalAdapter, getPaymasterConfig, isDelegatedTo, isDelegatedToTarget, isPaymasterConfigured, isPaymasterError, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, quoteOperatorFeePt, quoteOperatorFeeUsdt, rawCallOp, receiverConsentTypes, sendWithPaymasterFallback, serializeUserOpToJsonRpc, setPafiWebModalAdapter, setPaymasterConfig, splitAuthorizationSig, webPopupAdapter };
2021
+ export { ApiError, BATCH_EXECUTOR_7702_IMPL, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, type BuildDelegationUserOpParams, type BuildPartialUserOpParams, type BuildPerpDepositViaRelayParams, type BuildPerpDepositWithGasDeductionParams, COMMON_POOLS, COMMON_TOKENS, CONTRACT_ADDRESSES, ChainConfig, type CheckEthAndBranchParams, ConfigurationError, type ContractAddresses, DUMMY_SIGNATURE_V07, type DelegateDirectParams, type DelegateDirectResult, type DelegateImpl, EIP712Signature, ENTRY_POINT_V07, ENTRY_POINT_V08, type Eip7702AuthorizationJsonRpc, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_RELAY_ABI, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, type Operation, OracleStaleError, type OrderlyRelayDepositRequest, PAFI_SERVICE_URLS, PAFI_SUBGRAPH_URL, PERMIT2_ADDRESS, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_POOLS, type PackedUserOperationMessage, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSDKError, PafiSdkError, type PafiServiceUrls, type PafiWebModalAdapter, type PafiWebModalHandle, type PartialUserOperation, type PaymasterConfig, type PaymasterFields, PointTokenDomainConfig, PoolKey, type QuoteOperatorFeePtConfig, type QuoteOperatorFeeUsdtConfig, ReceiverConsent, SIMPLE_7702_IMPL_BASE_MAINNET, SUPPORTED_CHAINS, type SdkErrorHttpStatus, type SendWithPaymasterFallbackParams, type SignAuthorizationFn, type SignatureStruct, SignatureVerification, type SignedAuthorization, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, type UserOpReceipt, type UserOpTypedData, type UserOperation, V4_QUOTER_ADDRESSES, ValidationError, type VaultDepositFE, ZERO_VALUE, _resetPaymasterConfigForTests, assembleUserOperation, buildDelegationUserOp, buildEip7702Authorization, buildPartialUserOperation, buildPerpDepositViaRelay, buildPerpDepositWithGasDeduction, buildUserOpTypedData, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, computeAuthorizationHash, computeUserOpHash, createPafiProxyTransport, decodeBatchExecuteCalls, delegateDirect, detectDelegateImpl, encodeBatchExecute, erc20ApproveOp, erc20BurnOp, erc20TransferOp, fetchPafiPools, getAaNonce, getContractAddresses, getDummySignatureFor7702, getPafiServiceUrls, getPafiWebModalAdapter, getPaymasterConfig, isDelegatedTo, isDelegatedToTarget, isPaymasterConfigured, isPaymasterError, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, quoteOperatorFeePt, quoteOperatorFeeUsdt, rawCallOp, receiverConsentTypes, sendWithPaymasterFallback, serializeUserOpToJsonRpc, setPafiWebModalAdapter, setPaymasterConfig, splitAuthorizationSig, webPopupAdapter };
package/dist/index.js CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  v4QuoterAbi
7
7
  } from "./chunk-6CXTFOIH.js";
8
8
  import {
9
+ SPONSOR_AUTH_DOMAIN_ANCHOR_BASE_MAINNET,
9
10
  SPONSOR_AUTH_DOMAIN_NAME,
10
11
  SPONSOR_AUTH_TYPES,
11
12
  buildAndSignSponsorAuth,
@@ -14,11 +15,12 @@ import {
14
15
  computeCallDataHash,
15
16
  createLoginMessage,
16
17
  generateSponsorAuthNonce,
18
+ getSponsorAuthDomainAnchor,
17
19
  parseLoginMessage,
18
20
  signSponsorAuth,
19
21
  verifyLoginMessage,
20
22
  verifySponsorAuth
21
- } from "./chunk-6UX2IFA2.js";
23
+ } from "./chunk-4EGXLYMM.js";
22
24
  import {
23
25
  getBurnRequestNonce,
24
26
  getIssuer,
@@ -32,22 +34,23 @@ import {
32
34
  isMinter,
33
35
  issuerRegistryGetIssuerFlatAbi,
34
36
  verifyMintCap
35
- } from "./chunk-YDLMVWDH.js";
37
+ } from "./chunk-AEYEFV5G.js";
36
38
  import {
37
39
  issuerRegistryAbi,
38
- mintingOracleAbi,
39
- pointTokenAbi
40
- } from "./chunk-5JZOJIBT.js";
40
+ mintingOracleAbi
41
+ } from "./chunk-B2NDSIAI.js";
41
42
  import {
42
43
  COMMON_POOLS,
43
44
  COMMON_TOKENS,
44
45
  ENTRY_POINT_V07,
45
46
  ENTRY_POINT_V08,
47
+ Eip712DomainMismatchError,
46
48
  PERMIT2_ADDRESS,
47
49
  POINT_TOKEN_POOLS,
48
50
  SUPPORTED_CHAINS,
49
51
  UNIVERSAL_ROUTER_ADDRESSES,
50
52
  V4_QUOTER_ADDRESSES,
53
+ assertDomainMatchesContract,
51
54
  buildBurnRequestTypedData,
52
55
  buildDomain,
53
56
  buildMintRequestTypedData,
@@ -61,7 +64,10 @@ import {
61
64
  verifyBurnRequest,
62
65
  verifyMintRequest,
63
66
  verifyReceiverConsent
64
- } from "./chunk-WJSIB5GF.js";
67
+ } from "./chunk-QL5COJQI.js";
68
+ import {
69
+ pointTokenAbi
70
+ } from "./chunk-SZMSKZHY.js";
65
71
  import "./chunk-DGUM43GV.js";
66
72
 
67
73
  // src/index.ts
@@ -582,7 +588,16 @@ function getDummySignatureFor7702(impl) {
582
588
 
583
589
  // src/paymaster/config.ts
584
590
  var _config = null;
591
+ var _deprecationWarned = false;
592
+ function warnDeprecated(fn) {
593
+ if (_deprecationWarned) return;
594
+ _deprecationWarned = true;
595
+ console.warn(
596
+ `[PAFI] DEPRECATION (v0.7.1+): \`${fn}\` from @pafi-dev/core/paymaster is deprecated and will be removed in v0.8. Use \`PafiBackendClient\` from @pafi-dev/issuer/pafi-backend instead.`
597
+ );
598
+ }
585
599
  function setPaymasterConfig(config) {
600
+ warnDeprecated("setPaymasterConfig");
586
601
  if (!config.pafiBackendUrl) {
587
602
  throw new Error("setPaymasterConfig: pafiBackendUrl is required");
588
603
  }
@@ -598,6 +613,7 @@ function setPaymasterConfig(config) {
598
613
  _config = { ...config };
599
614
  }
600
615
  function getPaymasterConfig() {
616
+ warnDeprecated("getPaymasterConfig");
601
617
  if (!_config) {
602
618
  throw new Error(
603
619
  "PaymasterConfig not initialized \u2014 call setPaymasterConfig() at application boot before invoking any batch builder"
@@ -1058,7 +1074,8 @@ async function quoteOperatorFeeUsdt(config) {
1058
1074
  const ethPrice8dec = await getEthPrice8dec(
1059
1075
  provider,
1060
1076
  chainlinkFeedAddress,
1061
- allowStaleFallback ? fallbackEthPriceUsd : null
1077
+ allowStaleFallback ? fallbackEthPriceUsd : null,
1078
+ config.onFallback
1062
1079
  );
1063
1080
  const denomExp = 18 + 8 - usdtDecimals;
1064
1081
  return withPremium * ethPrice8dec / 10n ** BigInt(denomExp);
@@ -1086,18 +1103,20 @@ async function quoteOperatorFeePt(config) {
1086
1103
  getEthPrice8dec(
1087
1104
  provider,
1088
1105
  chainlinkFeedAddress,
1089
- allowStaleFallback ? fallbackEthPriceUsd : null
1106
+ allowStaleFallback ? fallbackEthPriceUsd : null,
1107
+ config.onFallback
1090
1108
  ),
1091
1109
  getPtPerUsdt18dec(
1092
1110
  fetchImpl,
1093
1111
  subgraphUrl,
1094
1112
  pointTokenAddress,
1095
- allowStaleFallback ? fallbackPtPriceUsdt : null
1113
+ allowStaleFallback ? fallbackPtPriceUsdt : null,
1114
+ config.onFallback
1096
1115
  )
1097
1116
  ]);
1098
1117
  return withPremium * ethPrice8dec * ptPerUsdt18dec / 10n ** 26n;
1099
1118
  }
1100
- async function getEthPrice8dec(provider, feed, fallback) {
1119
+ async function getEthPrice8dec(provider, feed, fallback, onFallback) {
1101
1120
  try {
1102
1121
  const result = await provider.readContract({
1103
1122
  address: feed,
@@ -1117,14 +1136,18 @@ async function getEthPrice8dec(provider, feed, fallback) {
1117
1136
  if (fallback === null) {
1118
1137
  throw new OracleStaleError("chainlink", reason);
1119
1138
  }
1120
- console.warn(
1121
- "[quoteOperatorFee] Chainlink unavailable, using opt-in fallback:",
1122
- reason
1123
- );
1139
+ if (onFallback) {
1140
+ onFallback({ source: "chainlink", reason, fallbackValue: fallback });
1141
+ } else {
1142
+ console.warn(
1143
+ "[quoteOperatorFee] Chainlink unavailable, using opt-in fallback:",
1144
+ reason
1145
+ );
1146
+ }
1124
1147
  return BigInt(Math.round(fallback * 1e8));
1125
1148
  }
1126
1149
  }
1127
- async function getPtPerUsdt18dec(fetchImpl, subgraphUrl, pointTokenAddress, fallbackPtPriceUsdt) {
1150
+ async function getPtPerUsdt18dec(fetchImpl, subgraphUrl, pointTokenAddress, fallbackPtPriceUsdt, onFallback) {
1128
1151
  try {
1129
1152
  const response = await fetchImpl(subgraphUrl, {
1130
1153
  method: "POST",
@@ -1156,10 +1179,18 @@ async function getPtPerUsdt18dec(fetchImpl, subgraphUrl, pointTokenAddress, fall
1156
1179
  if (fallbackPtPriceUsdt === null) {
1157
1180
  throw new OracleStaleError("subgraph", reason);
1158
1181
  }
1159
- console.warn(
1160
- "[quoteOperatorFeePt] subgraph unavailable, using opt-in fallback:",
1161
- reason
1162
- );
1182
+ if (onFallback) {
1183
+ onFallback({
1184
+ source: "subgraph",
1185
+ reason,
1186
+ fallbackValue: fallbackPtPriceUsdt
1187
+ });
1188
+ } else {
1189
+ console.warn(
1190
+ "[quoteOperatorFeePt] subgraph unavailable, using opt-in fallback:",
1191
+ reason
1192
+ );
1193
+ }
1163
1194
  const ptPerUsdtHuman = 1 / fallbackPtPriceUsdt;
1164
1195
  return parseBigDecimalTo18(ptPerUsdtHuman.toFixed(18));
1165
1196
  }
@@ -1175,6 +1206,29 @@ function parseBigDecimalTo18(s) {
1175
1206
  var BATCH_EXECUTOR_ADDRESS_BASE_MAINNET = getContractAddresses(8453).batchExecutor;
1176
1207
  var BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA = getContractAddresses(84532).batchExecutor;
1177
1208
 
1209
+ // src/contracts/real/pafi-services.ts
1210
+ var PAFI_SERVICE_URLS = {
1211
+ // Base mainnet
1212
+ 8453: {
1213
+ sponsorRelayer: "https://api-dev.pacificfinance.org/api/sponsor",
1214
+ issuerApi: "https://api-dev.pacificfinance.org/api/issuer"
1215
+ },
1216
+ // Base sepolia
1217
+ 84532: {
1218
+ sponsorRelayer: "https://api-dev.pacificfinance.org/api/sponsor",
1219
+ issuerApi: "https://api-dev.pacificfinance.org/api/issuer"
1220
+ }
1221
+ };
1222
+ function getPafiServiceUrls(chainId) {
1223
+ const urls = PAFI_SERVICE_URLS[chainId];
1224
+ if (!urls) {
1225
+ throw new Error(
1226
+ `getPafiServiceUrls: no PAFI service URLs for chainId ${chainId}. Supported: ${Object.keys(PAFI_SERVICE_URLS).join(", ")}`
1227
+ );
1228
+ }
1229
+ return urls;
1230
+ }
1231
+
1178
1232
  // src/web-handoff/webPopup.ts
1179
1233
  var DEFAULT_WIDTH = 900;
1180
1234
  var DEFAULT_HEIGHT = 700;
@@ -1231,10 +1285,15 @@ function openWebPopup(url, options = {}) {
1231
1285
  }, 500);
1232
1286
  if (options.onMessage) {
1233
1287
  const allowed = options.allowedOrigins ?? [];
1288
+ if (allowed.length === 0) {
1289
+ throw new Error(
1290
+ "openPafiWebModal: `allowedOrigins` is empty/missing while `onMessage` is supplied. The popup-message listener would silently reject every message \u2014 caller must explicitly whitelist PAFI Web's host (e.g. `['https://app.pacificfinance.org']`) before any payload reaches the callback. To accept any origin (insecure), pass an explicit list containing '*' or omit `onMessage` entirely."
1291
+ );
1292
+ }
1234
1293
  const onMessage = options.onMessage;
1235
1294
  messageListener = (event) => {
1236
1295
  if (event.source !== popup) return;
1237
- if (!allowed.includes(event.origin)) return;
1296
+ if (!allowed.includes("*") && !allowed.includes(event.origin)) return;
1238
1297
  onMessage(event.data, event.origin);
1239
1298
  };
1240
1299
  window.addEventListener("message", messageListener);
@@ -1467,11 +1526,13 @@ export {
1467
1526
  DUMMY_SIGNATURE_V07,
1468
1527
  ENTRY_POINT_V07,
1469
1528
  ENTRY_POINT_V08,
1529
+ Eip712DomainMismatchError,
1470
1530
  ORDERLY_RELAY_ABI,
1471
1531
  ORDERLY_VAULT_ABI,
1472
1532
  ORDERLY_VAULT_ADDRESSES,
1473
1533
  ORDERLY_VAULT_BASE_MAINNET,
1474
1534
  OracleStaleError,
1535
+ PAFI_SERVICE_URLS,
1475
1536
  PAFI_SUBGRAPH_URL,
1476
1537
  PERMIT2_ADDRESS,
1477
1538
  POINT_TOKEN_FACTORY_ADDRESSES,
@@ -1482,6 +1543,7 @@ export {
1482
1543
  PafiSDKError,
1483
1544
  PafiSdkError,
1484
1545
  SIMPLE_7702_IMPL_BASE_MAINNET,
1546
+ SPONSOR_AUTH_DOMAIN_ANCHOR_BASE_MAINNET,
1485
1547
  SPONSOR_AUTH_DOMAIN_NAME,
1486
1548
  SPONSOR_AUTH_TYPES,
1487
1549
  SUPPORTED_CHAINS,
@@ -1494,6 +1556,7 @@ export {
1494
1556
  ZERO_VALUE,
1495
1557
  _resetPaymasterConfigForTests,
1496
1558
  assembleUserOperation,
1559
+ assertDomainMatchesContract,
1497
1560
  buildAndSignSponsorAuth,
1498
1561
  buildBurnRequestTypedData,
1499
1562
  buildDelegationUserOp,
@@ -1532,12 +1595,14 @@ export {
1532
1595
  getDummySignatureFor7702,
1533
1596
  getIssuer2 as getIssuer,
1534
1597
  getMintRequestNonce,
1598
+ getPafiServiceUrls,
1535
1599
  getPafiWebModalAdapter,
1536
1600
  getPaymasterConfig,
1537
1601
  getPointTokenBalance,
1538
1602
  getPointTokenIssuer,
1539
1603
  getIssuer as getPointTokenIssuerAddress,
1540
1604
  getReceiverConsentNonce,
1605
+ getSponsorAuthDomainAnchor,
1541
1606
  getTokenName,
1542
1607
  isActiveIssuer,
1543
1608
  isDelegatedTo,