@pafi-dev/issuer 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # @pafi/issuer
1
+ # @pafi-dev/issuer
2
2
 
3
3
  Issuer backend boilerplate for the PAFI point token system. Wraps
4
- `@pafi/core` with everything a partner needs to run the off-chain side
4
+ `@pafi-dev/core` with everything a partner needs to run the off-chain side
5
5
  of the mint-and-cash-out flow: authentication, point ledger, policy
6
6
  engine, EIP-712 issuer signing, relay submission, mint event indexing,
7
7
  and framework-agnostic HTTP handlers.
@@ -9,15 +9,15 @@ and framework-agnostic HTTP handlers.
9
9
  ## Install
10
10
 
11
11
  ```bash
12
- pnpm add @pafi/issuer @pafi/core viem
12
+ pnpm add @pafi-dev/issuer @pafi-dev/core viem
13
13
  ```
14
14
 
15
- Peer deps: `viem ^2.0`, `@pafi/core` (workspace), `jose ^5` (transitive).
15
+ Peer deps: `viem ^2.0`, `@pafi-dev/core` (workspace), `jose ^5` (transitive).
16
16
 
17
17
  ## At a glance
18
18
 
19
19
  ```ts
20
- import { createIssuerService, PrivateKeySigner } from "@pafi/issuer";
20
+ import { createIssuerService, PrivateKeySigner } from "@pafi-dev/issuer";
21
21
  import { createPublicClient, createWalletClient, http } from "viem";
22
22
  import { privateKeyToAccount } from "viem/accounts";
23
23
  import { base } from "viem/chains";
@@ -74,7 +74,7 @@ which runs the full 11-step flow documented in
74
74
 
75
75
  ```
76
76
  1. Validate request fields (cheap rejects)
77
- 2. Verify ReceiverConsent signature via @pafi/core
77
+ 2. Verify ReceiverConsent signature via @pafi-dev/core
78
78
  3. Check off-chain balance via ledger
79
79
  4. Check locked requests via ledger
80
80
  5. Run policy engine (balance + cap + issuer rules)
@@ -126,7 +126,7 @@ Frontend Issuer backend
126
126
  ← { nonce }
127
127
  2. Build EIP-4361 message with
128
128
  nonce (via PafiSDK or
129
- @pafi/core createLoginMessage)
129
+ @pafi-dev/core createLoginMessage)
130
130
  3. Sign with wallet
131
131
  4. POST /auth/login → authService.login(message, sig)
132
132
  { message, signature } → parse → verify → consume nonce
@@ -172,7 +172,7 @@ The package ships with 142 unit tests covering every collaborator + the
172
172
  full gateway flow through mocked providers. Run them with:
173
173
 
174
174
  ```bash
175
- pnpm --filter @pafi/issuer test
175
+ pnpm --filter @pafi-dev/issuer test
176
176
  ```
177
177
 
178
178
  No network or on-chain state is required — all tests are hermetic.
@@ -253,12 +253,12 @@ import {
253
253
  type ApiClaimAndSwapRequest,
254
254
  type ApiClaimAndSwapResponse,
255
255
  type PoolsProvider,
256
- } from "@pafi/issuer";
256
+ } from "@pafi-dev/issuer";
257
257
  ```
258
258
 
259
259
  ### HTTP contract ownership
260
260
 
261
- `@pafi/issuer` is the **single source of truth** for the HTTP API contract
261
+ `@pafi-dev/issuer` is the **single source of truth** for the HTTP API contract
262
262
  between the issuer backend and any frontend / mobile / SDK consumer. The
263
263
  request/response types above are defined once here, then imported
264
264
  **type-only** by frontend code so browser bundles never pull in server
@@ -270,7 +270,7 @@ import type {
270
270
  ApiLoginRequest,
271
271
  ApiClaimAndSwapRequest,
272
272
  ApiUserResponse,
273
- } from "@pafi/issuer";
273
+ } from "@pafi-dev/issuer";
274
274
 
275
275
  // Build your own fetch call with full type safety
276
276
  const res = await fetch(`${API_URL}/claim-and-swap`, {
@@ -284,11 +284,11 @@ const res = await fetch(`${API_URL}/claim-and-swap`, {
284
284
  const body = (await res.json()) as ApiClaimAndSwapResponse;
285
285
  ```
286
286
 
287
- **`@pafi/core` deliberately does NOT ship an HTTP client** — it handles
287
+ **`@pafi-dev/core` deliberately does NOT ship an HTTP client** — it handles
288
288
  only cryptography (EIP-712 / EIP-4361), contract reads, and V4 quoting.
289
289
  That's what keeps the frontend bundle small and keeps the protocol
290
290
  contract in exactly one place.
291
291
 
292
292
  ## License
293
293
 
294
- UNLICENSED — internal use by PAFI issuers.
294
+ Apache-2.0
package/dist/index.cjs CHANGED
@@ -1310,16 +1310,21 @@ var IssuerApiHandlers = class {
1310
1310
  `handleUser: unsupported pointToken ${pointToken}`
1311
1311
  );
1312
1312
  }
1313
- const [mintRequestNonce, receiverConsentNonce, balance, minter] = await Promise.all([
1313
+ const [mintRequestNonce, receiverConsentNonce, offChainBalance, onChainBalance, minter] = await Promise.all([
1314
1314
  (0, import_core5.getMintRequestNonce)(this.provider, pointToken, normalizedAuthed),
1315
1315
  (0, import_core5.getReceiverConsentNonce)(this.provider, pointToken, normalizedAuthed),
1316
1316
  this.ledger.getBalance(normalizedAuthed),
1317
+ (0, import_core5.getPointTokenBalance)(this.provider, pointToken, normalizedAuthed),
1317
1318
  (0, import_core5.isMinter)(this.provider, pointToken, normalizedAuthed)
1318
1319
  ]);
1319
1320
  return {
1320
1321
  mintRequestNonce,
1321
1322
  receiverConsentNonce,
1322
- balance,
1323
+ offChainBalance,
1324
+ onChainBalance,
1325
+ totalBalance: offChainBalance + onChainBalance,
1326
+ balance: offChainBalance,
1327
+ // deprecated alias
1323
1328
  isMinter: minter
1324
1329
  };
1325
1330
  }