payid 0.6.0 → 1.0.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 (38) hide show
  1. package/dist/{chunk-2VO4XLTT.js → chunk-7YVJJEON.js} +22 -17
  2. package/dist/{chunk-BLIRABV7.js → chunk-AUW7WDAB.js} +11 -20
  3. package/dist/{chunk-SSO66YQI.js → chunk-E6VQETBC.js} +13 -0
  4. package/dist/chunk-FZNMDGVK.js +24 -0
  5. package/dist/chunk-MSQM7KDN.js +752 -0
  6. package/dist/chunk-X7NYQ47Y.js +27 -0
  7. package/dist/{chunk-Q4UZCGU4.js → chunk-XMUHMJRD.js} +1 -1
  8. package/dist/{chunk-TQJUKEFO.js → chunk-YWH7WOMP.js} +24 -21
  9. package/dist/context/index.d.ts +3 -2
  10. package/dist/context.v1-C1m-tz0o.d.ts +39 -0
  11. package/dist/context.v2-DIzPotmW.d.ts +37 -0
  12. package/dist/core/client/index.d.ts +5 -4
  13. package/dist/core/client/index.js +9 -5
  14. package/dist/core/server/index.d.ts +4 -3
  15. package/dist/core/server/index.js +7 -4
  16. package/dist/{index-2JCvey4-.d.ts → index-CDnE3SGM.d.ts} +18 -3
  17. package/dist/index-CsynGAGv.d.ts +53 -0
  18. package/dist/{index-Dj9IEios.d.ts → index-CubM9whW.d.ts} +4 -17
  19. package/dist/{index-C1DHMQA0.d.ts → index-DSxDlF9J.d.ts} +45 -68
  20. package/dist/{index-BEvnPzzt.d.ts → index-Dm2VdDEB.d.ts} +2 -1
  21. package/dist/{index-DSHZvYii.d.ts → index-G_1SiZJo.d.ts} +8 -7
  22. package/dist/index.d.ts +407 -72
  23. package/dist/index.js +586 -81
  24. package/dist/issuer/index.d.ts +3 -2
  25. package/dist/issuer/index.js +4 -1
  26. package/dist/rule/index.d.ts +2 -2
  27. package/dist/rule/index.js +4 -3
  28. package/dist/rule-a_5ed-93.d.ts +39 -0
  29. package/dist/sessionPolicy/index.d.ts +3 -3
  30. package/dist/sessionPolicy/index.js +2 -2
  31. package/dist/{types-CpXiPRYs.d.ts → types-D2o6XS7a.d.ts} +1 -1
  32. package/dist/types-i4eTkhWa.d.ts +50 -0
  33. package/package.json +22 -9
  34. package/src/rule/engine/rule_engine.wasm +0 -0
  35. package/dist/chunk-DZ6GVRER.js +0 -309
  36. package/dist/chunk-QC24X74O.js +0 -41
  37. package/dist/index-CtdogR8X.d.ts +0 -82
  38. package/dist/types-B8pJQdMQ.d.ts +0 -26
@@ -0,0 +1,27 @@
1
+ // src/decision-proof/hash.ts
2
+ import { keccak256 } from "ethers";
3
+ function stableStringify(obj) {
4
+ if (Array.isArray(obj)) {
5
+ return `[${obj.map(stableStringify).join(",")}]`;
6
+ }
7
+ if (obj && typeof obj === "object") {
8
+ return `{${Object.keys(obj).sort().map(
9
+ (k) => `"${k}":${stableStringify(obj[k])}`
10
+ ).join(",")}}`;
11
+ }
12
+ return JSON.stringify(obj);
13
+ }
14
+ function toUtf8Bytes(str) {
15
+ return new TextEncoder().encode(str);
16
+ }
17
+ function hashContext(context) {
18
+ return keccak256(toUtf8Bytes(stableStringify(context)));
19
+ }
20
+ function hashRuleSet(ruleConfig) {
21
+ return keccak256(toUtf8Bytes(stableStringify(ruleConfig)));
22
+ }
23
+
24
+ export {
25
+ hashContext,
26
+ hashRuleSet
27
+ };
@@ -7,7 +7,7 @@ import {
7
7
  decodeSessionPolicyV2,
8
8
  decodeSessionPolicyV2QR,
9
9
  encodeSessionPolicyV2QR
10
- } from "./chunk-BLIRABV7.js";
10
+ } from "./chunk-AUW7WDAB.js";
11
11
  import {
12
12
  __export
13
13
  } from "./chunk-MLKGABMK.js";
@@ -2,7 +2,7 @@ import {
2
2
  evaluate,
3
3
  generateDecisionProof,
4
4
  resolveRule
5
- } from "./chunk-DZ6GVRER.js";
5
+ } from "./chunk-MSQM7KDN.js";
6
6
  import {
7
7
  __export
8
8
  } from "./chunk-MLKGABMK.js";
@@ -10,20 +10,20 @@ import {
10
10
  // src/core/server/index.ts
11
11
  var server_exports = {};
12
12
  __export(server_exports, {
13
- createPayID: () => createPayID
13
+ PayIDServer: () => PayIDServer,
14
+ createPayIDServer: () => createPayIDServer
14
15
  });
15
16
 
16
17
  // src/erc4337/build.ts
17
18
  import { ethers } from "ethers";
19
+ var DECISION_TUPLE = "bytes32 version,bytes32 payId,address payer,address receiver,address asset,uint256 amount,bytes32 contextHash,bytes32 ruleSetHash,address ruleAuthority,uint64 issuedAt,uint64 expiresAt,bytes32 nonce,bool requiresAttestation,bytes32 attestationUIDsHash";
18
20
  var PAY_WITH_PAYID_ABI = [
19
- // ETH payment attestationUIDs adalah EAS UIDs, pass [] jika tidak perlu
20
- "function payETH((bytes32 version, bytes32 payId, address payer, address receiver, address asset, uint256 amount, bytes32 contextHash, bytes32 ruleSetHash, address ruleAuthority, uint64 issuedAt, uint64 expiresAt, bytes32 nonce, bool requiresAttestation) d, bytes sig, bytes32[] attestationUIDs) payable",
21
- // ERC20 payment
22
- "function payERC20((bytes32 version, bytes32 payId, address payer, address receiver, address asset, uint256 amount, bytes32 contextHash, bytes32 ruleSetHash, address ruleAuthority, uint64 issuedAt, uint64 expiresAt, bytes32 nonce, bool requiresAttestation) d, bytes sig, bytes32[] attestationUIDs)"
21
+ `function payNative((${DECISION_TUPLE}) d, bytes sig, bytes32[] attestationUIDs) payable`,
22
+ `function payERC20((${DECISION_TUPLE}) d, bytes sig, bytes32[] attestationUIDs)`
23
23
  ];
24
- function buildPayETHCallData(contractAddress, proof, attestationUIDs = []) {
24
+ function buildPayNativeCallData(contractAddress, proof, attestationUIDs = []) {
25
25
  const iface = new ethers.Interface(PAY_WITH_PAYID_ABI);
26
- return iface.encodeFunctionData("payETH", [
26
+ return iface.encodeFunctionData("payNative", [
27
27
  proof.payload,
28
28
  proof.signature,
29
29
  attestationUIDs
@@ -61,14 +61,22 @@ function isRuleSource(rule) {
61
61
  return typeof rule === "object" && rule !== null && "uri" in rule;
62
62
  }
63
63
  var PayIDServer = class {
64
- constructor(signer, trustedIssuers, debugTrace, wasm) {
64
+ constructor(signer, trustedIssuers, debugTrace, wasm, storage, resolverOptions) {
65
65
  this.signer = signer;
66
66
  this.trustedIssuers = trustedIssuers;
67
67
  this.debugTrace = debugTrace;
68
68
  this.wasm = wasm;
69
+ this.storage = storage;
70
+ this.resolverOptions = resolverOptions;
69
71
  }
72
+ signer;
73
+ trustedIssuers;
74
+ debugTrace;
75
+ wasm;
76
+ storage;
77
+ resolverOptions;
70
78
  async evaluateAndProve(params) {
71
- const authorityConfig = isRuleSource(params.authorityRule) ? (await resolveRule(params.authorityRule)).config : params.authorityRule;
79
+ const authorityConfig = isRuleSource(params.authorityRule) ? (await resolveRule(params.authorityRule, this.resolverOptions)).config : params.authorityRule;
72
80
  const evalConfig = params.evaluationRule ?? authorityConfig;
73
81
  const result = await evaluate(
74
82
  params.context,
@@ -100,11 +108,8 @@ var PayIDServer = class {
100
108
  return { result, proof };
101
109
  }
102
110
  buildUserOperation(params) {
103
- const callData = buildPayERC20CallData(
104
- params.targetContract,
105
- params.proof,
106
- params.attestationUIDs ?? []
107
- );
111
+ const isETH = params.paymentType === "eth";
112
+ const callData = isETH ? buildPayNativeCallData(params.targetContract, params.proof, params.attestationUIDs ?? []) : buildPayERC20CallData(params.targetContract, params.proof, params.attestationUIDs ?? []);
108
113
  return buildUserOperation({
109
114
  sender: params.smartAccount,
110
115
  nonce: params.nonce,
@@ -116,19 +121,17 @@ var PayIDServer = class {
116
121
  };
117
122
 
118
123
  // src/core/server/index.ts
119
- function createPayID(params) {
124
+ function createPayIDServer(params) {
120
125
  return new PayIDServer(
121
126
  params.signer,
122
127
  params.trustedIssuers,
123
- params.debugTrace ?? false,
128
+ params.debugTrace,
124
129
  params.wasm
125
130
  );
126
131
  }
127
132
 
128
133
  export {
129
- buildPayETHCallData,
130
- buildPayERC20CallData,
131
- buildUserOperation,
132
- createPayID,
134
+ PayIDServer,
135
+ createPayIDServer,
133
136
  server_exports
134
137
  };
@@ -1,3 +1,4 @@
1
- export { b as buildContextV2 } from '../index-BEvnPzzt.js';
1
+ export { b as buildContextV2 } from '../index-Dm2VdDEB.js';
2
2
  import 'ethers';
3
- import 'payid-types';
3
+ import '../context.v1-C1m-tz0o.js';
4
+ import '../context.v2-DIzPotmW.js';
@@ -0,0 +1,39 @@
1
+ interface RuleContext {
2
+ tx: {
3
+ sender?: string;
4
+ asset: string;
5
+ amount: string;
6
+ amountUsd?: string;
7
+ chainId: number;
8
+ receiver?: string;
9
+ };
10
+ payId?: {
11
+ id: string;
12
+ owner: string;
13
+ };
14
+ intent?: {
15
+ type: "QR" | "DIRECT" | "API";
16
+ expiresAt?: number;
17
+ nonce?: string;
18
+ issuer?: string;
19
+ };
20
+ }
21
+ interface TxContext {
22
+ sender: string;
23
+ receiver: string;
24
+ asset: string;
25
+ amount: string;
26
+ amountUsd?: string;
27
+ chainId: number;
28
+ memo?: string;
29
+ }
30
+ interface PayIdContext {
31
+ id: string;
32
+ owner: string;
33
+ }
34
+ interface ContextV1 {
35
+ tx: TxContext;
36
+ payId: PayIdContext;
37
+ }
38
+
39
+ export type { ContextV1 as C, PayIdContext as P, RuleContext as R, TxContext as T };
@@ -0,0 +1,37 @@
1
+ import { C as ContextV1 } from './context.v1-C1m-tz0o.js';
2
+
3
+ interface Attestation {
4
+ issuer: string;
5
+ issuedAt: number;
6
+ expiresAt: number;
7
+ signature: string;
8
+ }
9
+
10
+ interface EnvContext {
11
+ timestamp: number;
12
+ proof: Attestation;
13
+ }
14
+ interface StateContext {
15
+ spentToday: string;
16
+ period: string;
17
+ proof: Attestation;
18
+ }
19
+ interface OracleContext {
20
+ [key: string]: string | number | Attestation;
21
+ proof: Attestation;
22
+ }
23
+ interface RiskContext {
24
+ score: number;
25
+ category: string;
26
+ proof: Attestation & {
27
+ modelHash: string;
28
+ };
29
+ }
30
+ interface ContextV2 extends ContextV1 {
31
+ env?: EnvContext;
32
+ state?: StateContext;
33
+ oracle?: OracleContext;
34
+ risk?: RiskContext;
35
+ }
36
+
37
+ export type { Attestation as A, ContextV2 as C, EnvContext as E, OracleContext as O, RiskContext as R, StateContext as S };
@@ -1,5 +1,6 @@
1
- export { c as createPayID } from '../../index-CtdogR8X.js';
2
- import 'payid-types';
1
+ export { P as PayIDClient, c as createPayID, c as createPayIDClient } from '../../index-CsynGAGv.js';
2
+ import '../../rule-a_5ed-93.js';
3
+ import '../../context.v1-C1m-tz0o.js';
4
+ import '../../types-i4eTkhWa.js';
3
5
  import 'ethers';
4
- import '../../types-B8pJQdMQ.js';
5
- import '../../types-CpXiPRYs.js';
6
+ import '../../types-D2o6XS7a.js';
@@ -1,12 +1,16 @@
1
1
  import {
2
- createPayID
3
- } from "../../chunk-2VO4XLTT.js";
2
+ PayIDClient,
3
+ createPayIDClient
4
+ } from "../../chunk-7YVJJEON.js";
5
+ import "../../chunk-AUW7WDAB.js";
4
6
  import "../../chunk-GG34PNTF.js";
5
- import "../../chunk-BLIRABV7.js";
6
7
  import "../../chunk-6VPSJFO4.js";
7
- import "../../chunk-DZ6GVRER.js";
8
+ import "../../chunk-MSQM7KDN.js";
8
9
  import "../../chunk-KDC67LIN.js";
10
+ import "../../chunk-X7NYQ47Y.js";
9
11
  import "../../chunk-MLKGABMK.js";
10
12
  export {
11
- createPayID
13
+ PayIDClient,
14
+ createPayIDClient as createPayID,
15
+ createPayIDClient
12
16
  };
@@ -1,4 +1,5 @@
1
- export { c as createPayID } from '../../index-C1DHMQA0.js';
1
+ export { P as PayIDServer, c as createPayIDServer } from '../../index-DSxDlF9J.js';
2
2
  import 'ethers';
3
- import 'payid-types';
4
- import '../../types-B8pJQdMQ.js';
3
+ import '../../rule-a_5ed-93.js';
4
+ import '../../context.v1-C1m-tz0o.js';
5
+ import '../../types-i4eTkhWa.js';
@@ -1,9 +1,12 @@
1
1
  import {
2
- createPayID
3
- } from "../../chunk-TQJUKEFO.js";
4
- import "../../chunk-DZ6GVRER.js";
2
+ PayIDServer,
3
+ createPayIDServer
4
+ } from "../../chunk-YWH7WOMP.js";
5
+ import "../../chunk-MSQM7KDN.js";
5
6
  import "../../chunk-KDC67LIN.js";
7
+ import "../../chunk-X7NYQ47Y.js";
6
8
  import "../../chunk-MLKGABMK.js";
7
9
  export {
8
- createPayID
10
+ PayIDServer,
11
+ createPayIDServer
9
12
  };
@@ -1,4 +1,4 @@
1
- import { EnvContext, OracleContext, RiskContext, StateContext, Attestation } from 'payid-types';
1
+ import { E as EnvContext, O as OracleContext, R as RiskContext, S as StateContext, A as Attestation } from './context.v2-DIzPotmW.js';
2
2
  import { Wallet } from 'ethers';
3
3
 
4
4
  declare function issueEnvContext(wallet: Wallet): Promise<EnvContext>;
@@ -9,15 +9,30 @@ declare function issueRiskContext(wallet: Wallet, score: number, category: strin
9
9
 
10
10
  declare function issueStateContext(wallet: Wallet, spentToday: string, period: string): Promise<StateContext>;
11
11
 
12
+ /**
13
+ * Issues token price context with USD equivalent calculation
14
+ *
15
+ * @param wallet - Signer wallet for attestation
16
+ * @param tokenPrice - Token price in USD (8 decimals, e.g., 100000000 = $1.00)
17
+ * @param tokenAmount - Raw token amount in token units
18
+ * @param tokenDecimals - Token decimals (e.g., 6 for USDC, 18 for ETH)
19
+ * @returns Token price context with attestation proof
20
+ */
21
+ declare function issueTokenPriceContext(wallet: Wallet, tokenPrice: bigint, tokenAmount: bigint, tokenDecimals: number): Promise<{
22
+ amountUsd: string;
23
+ proof: Attestation;
24
+ }>;
25
+
12
26
  declare function signAttestation(issuerWallet: Wallet, payload: object, ttlSeconds?: number): Promise<Attestation>;
13
27
 
14
28
  declare const index_issueEnvContext: typeof issueEnvContext;
15
29
  declare const index_issueOracleContext: typeof issueOracleContext;
16
30
  declare const index_issueRiskContext: typeof issueRiskContext;
17
31
  declare const index_issueStateContext: typeof issueStateContext;
32
+ declare const index_issueTokenPriceContext: typeof issueTokenPriceContext;
18
33
  declare const index_signAttestation: typeof signAttestation;
19
34
  declare namespace index {
20
- export { index_issueEnvContext as issueEnvContext, index_issueOracleContext as issueOracleContext, index_issueRiskContext as issueRiskContext, index_issueStateContext as issueStateContext, index_signAttestation as signAttestation };
35
+ export { index_issueEnvContext as issueEnvContext, index_issueOracleContext as issueOracleContext, index_issueRiskContext as issueRiskContext, index_issueStateContext as issueStateContext, index_issueTokenPriceContext as issueTokenPriceContext, index_signAttestation as signAttestation };
21
36
  }
22
37
 
23
- export { issueEnvContext as a, issueOracleContext as b, issueRiskContext as c, issueStateContext as d, index as i, signAttestation as s };
38
+ export { issueEnvContext as a, issueOracleContext as b, issueRiskContext as c, issueStateContext as d, issueTokenPriceContext as e, index as i, signAttestation as s };
@@ -0,0 +1,53 @@
1
+ import { b as RuleConfig } from './rule-a_5ed-93.js';
2
+ import { R as RuleContext } from './context.v1-C1m-tz0o.js';
3
+ import { R as ResolverOptions, e as RuleSource, c as RuleResult, a as DecisionProof } from './types-i4eTkhWa.js';
4
+ import { ethers } from 'ethers';
5
+ import { P as PayIDSessionPolicyPayloadV1, S as SessionPolicyV2 } from './types-D2o6XS7a.js';
6
+
7
+ declare class PayIDClient {
8
+ private readonly debugTrace?;
9
+ private readonly wasm?;
10
+ private readonly resolverOptions?;
11
+ private readonly _ready;
12
+ constructor(debugTrace?: boolean | undefined, wasm?: Uint8Array | undefined, resolverOptions?: ResolverOptions | undefined);
13
+ ready(): Promise<void>;
14
+ evaluate(context: RuleContext, rule: RuleConfig | RuleSource): Promise<RuleResult>;
15
+ evaluateAndProve(params: {
16
+ context: RuleContext;
17
+ authorityRule: RuleConfig | RuleSource;
18
+ evaluationRule?: RuleConfig;
19
+ sessionPolicy?: PayIDSessionPolicyPayloadV1;
20
+ sessionPolicyV2?: SessionPolicyV2;
21
+ payId: string;
22
+ payer: string;
23
+ receiver: string;
24
+ asset: string;
25
+ amount: bigint;
26
+ signer: ethers.Signer;
27
+ verifyingContract: string;
28
+ ruleAuthority: string;
29
+ ruleSetHashOverride?: string;
30
+ ttlSeconds?: number;
31
+ chainId: number;
32
+ blockTimestamp: number;
33
+ attestationUIDs?: string[];
34
+ }): Promise<{
35
+ result: RuleResult;
36
+ proof: DecisionProof | null;
37
+ }>;
38
+ }
39
+
40
+ /** Browser/edge-safe factory for the `payid/client` sub-path import. */
41
+ declare function createPayIDClient(params?: {
42
+ wasm?: Uint8Array;
43
+ debugTrace?: boolean;
44
+ }): PayIDClient;
45
+
46
+ type index_PayIDClient = PayIDClient;
47
+ declare const index_PayIDClient: typeof PayIDClient;
48
+ declare const index_createPayIDClient: typeof createPayIDClient;
49
+ declare namespace index {
50
+ export { index_PayIDClient as PayIDClient, createPayIDClient as createPayID, index_createPayIDClient as createPayIDClient };
51
+ }
52
+
53
+ export { PayIDClient as P, createPayIDClient as c, index as i };
@@ -1,5 +1,4 @@
1
- import * as payid_types from 'payid-types';
2
- import { RuleConfig, AnyRule } from 'payid-types';
1
+ import { b as RuleConfig, A as AnyRule } from './rule-a_5ed-93.js';
3
2
 
4
3
  /**
5
4
  * Combine an authoritative rule set with additional ephemeral rules
@@ -43,7 +42,7 @@ import { RuleConfig, AnyRule } from 'payid-types';
43
42
  declare function combineRules(defaultRuleSet: RuleConfig, sessionRule: any[]): {
44
43
  version: string;
45
44
  logic: "AND" | "OR";
46
- rules: payid_types.AnyRule[];
45
+ rules: AnyRule[];
47
46
  };
48
47
 
49
48
  /**
@@ -64,19 +63,7 @@ declare function canonicalizeRuleSet(ruleSet: {
64
63
  rules: AnyRule[];
65
64
  };
66
65
 
67
- /**
68
- * Compute a deterministic hash of a canonicalized rule set.
69
- *
70
- * PENTING: Fungsi ini HARUS menggunakan stableStringify (bukan JSON.stringify)
71
- * agar menghasilkan hash yang sama dengan:
72
- * - register-combined-rule.ts (canonicalize + keccak256)
73
- * - decision-proof/hash.ts (hashRuleSet)
74
- * - CombinedRuleStorage.sol (ruleSetHash tersimpan on-chain)
75
- *
76
- * Menggunakan JSON.stringify biasa akan menghasilkan key order berbeda
77
- * → hash berbeda → getRuleByHash revert dengan RULE_NOT_ACTIVE.
78
- */
79
- declare function hashRuleSet(ruleSet: any): string;
66
+ declare function hashRuleSet(ruleConfig: any): string;
80
67
 
81
68
  declare const index_canonicalizeRuleSet: typeof canonicalizeRuleSet;
82
69
  declare const index_combineRules: typeof combineRules;
@@ -85,4 +72,4 @@ declare namespace index {
85
72
  export { index_canonicalizeRuleSet as canonicalizeRuleSet, index_combineRules as combineRules, index_hashRuleSet as hashRuleSet };
86
73
  }
87
74
 
88
- export { canonicalizeRuleSet as a, combineRules as c, hashRuleSet as h, index as i };
75
+ export { combineRules as a, canonicalizeRuleSet as c, hashRuleSet as h, index as i };
@@ -1,6 +1,7 @@
1
1
  import { ethers } from 'ethers';
2
- import { RuleContext, RuleConfig, RuleResult } from 'payid-types';
3
- import { R as RuleSource, D as DecisionProof } from './types-B8pJQdMQ.js';
2
+ import { b as RuleConfig } from './rule-a_5ed-93.js';
3
+ import { R as RuleContext } from './context.v1-C1m-tz0o.js';
4
+ import { R as ResolverOptions, e as RuleSource, c as RuleResult, a as DecisionProof } from './types-i4eTkhWa.js';
4
5
 
5
6
  interface UserOperation {
6
7
  sender: string;
@@ -16,6 +17,36 @@ interface UserOperation {
16
17
  signature: string;
17
18
  }
18
19
 
20
+ interface ZGStorageConfig {
21
+ nodeUrl: string;
22
+ indexerUrl: string;
23
+ privateKey: string;
24
+ }
25
+ declare class ZGStorage {
26
+ private config;
27
+ private indexer;
28
+ constructor(config: ZGStorageConfig);
29
+ /**
30
+ * Uploads data to 0G Storage
31
+ * @param data The data to upload (string or object)
32
+ * @returns The Merkle root hash of the uploaded data
33
+ */
34
+ upload(data: any): Promise<string>;
35
+ /**
36
+ * Downloads data from 0G Storage
37
+ * @param rootHash The Merkle root hash
38
+ * @returns The downloaded data as string
39
+ */
40
+ download(rootHash: string): Promise<string>;
41
+ }
42
+
43
+ type zgStorage_ZGStorage = ZGStorage;
44
+ declare const zgStorage_ZGStorage: typeof ZGStorage;
45
+ type zgStorage_ZGStorageConfig = ZGStorageConfig;
46
+ declare namespace zgStorage {
47
+ export { zgStorage_ZGStorage as ZGStorage, type zgStorage_ZGStorageConfig as ZGStorageConfig };
48
+ }
49
+
19
50
  /**
20
51
  * @class PayIDServer
21
52
  * @description Server-side PayID engine.
@@ -49,7 +80,9 @@ declare class PayIDServer {
49
80
  private readonly trustedIssuers?;
50
81
  private readonly debugTrace?;
51
82
  private readonly wasm?;
52
- constructor(signer: ethers.Signer, trustedIssuers?: Set<string> | undefined, debugTrace?: boolean | undefined, wasm?: Uint8Array | undefined);
83
+ private readonly storage?;
84
+ private readonly resolverOptions?;
85
+ constructor(signer: ethers.Signer, trustedIssuers?: Set<string> | undefined, debugTrace?: boolean | undefined, wasm?: Uint8Array | undefined, storage?: ZGStorage | undefined, resolverOptions?: ResolverOptions | undefined);
53
86
  evaluateAndProve(params: {
54
87
  context: RuleContext;
55
88
  authorityRule: RuleConfig | RuleSource;
@@ -76,79 +109,23 @@ declare class PayIDServer {
76
109
  targetContract: string;
77
110
  paymasterAndData?: string;
78
111
  attestationUIDs?: string[];
112
+ paymentType?: "eth" | "erc20";
79
113
  }): UserOperation;
80
114
  }
81
115
 
82
- /**
83
- * Create a PayID policy engine instance backed by a WASM rule evaluator.
84
- *
85
- * ## Responsibility
86
- *
87
- * - Holds the WASM binary used for rule execution
88
- * - Defines the trust boundary for context attestation verification
89
- * - Acts as the primary entry point for PayID rule evaluation
90
- *
91
- * ## Trust model
92
- *
93
- * - If `trustedIssuers` is provided, Context V2 attestation
94
- * verification is ENFORCED.
95
- * - If `trustedIssuers` is omitted, the engine runs in
96
- * legacy (Context V1) mode without cryptographic verification.
97
- *
98
- * ## Environment
99
- *
100
- * This class is safe to instantiate in:
101
- * - Browsers
102
- * - Mobile apps
103
- * - Edge runtimes
104
- * - Backend services
105
- *
106
- * @param wasm
107
- * Compiled PayID WASM rule engine binary.
108
- *
109
- * @param signer
110
- * Signer account
111
- *
112
- * @param debugTrace
113
- * Optional flag to enable decision trace generation for debugging.
114
- *
115
- * @param trustedIssuers
116
- * Optional set of trusted attestation issuer addresses.
117
- *
118
- * When provided, Context V2 attestation verification is ENFORCED:
119
- * - Only attestations issued by addresses in this set are accepted.
120
- * - Missing, expired, or invalid attestations cause evaluation to fail.
121
- *
122
- * When omitted, the engine runs in legacy (Context V1) mode
123
- * without cryptographic verification.
124
- *
125
- * ⚠️ Important:
126
- * - Do NOT pass an empty Set.
127
- * An empty set means "no issuer is trusted" and will
128
- * cause all attestations to be rejected.
129
- *
130
- * @example
131
- * ```ts
132
- * const trustedIssuers = new Set([
133
- * TIME_ISSUER,
134
- * STATE_ISSUER,
135
- * ORACLE_ISSUER,
136
- * RISK_ISSUER
137
- * ]);
138
- *
139
- * const payid = new PayID(wasmBinary, ethers.Signer, debugTrace, trustedIssuers);
140
- * ```
141
- */
142
- declare function createPayID(params: {
143
- wasm?: Uint8Array;
116
+ /** Server/backend factory for the `payid/server` sub-path import. */
117
+ declare function createPayIDServer(params: {
144
118
  signer: ethers.Signer;
119
+ wasm?: Uint8Array;
145
120
  debugTrace?: boolean;
146
121
  trustedIssuers?: Set<string>;
147
122
  }): PayIDServer;
148
123
 
149
- declare const index_createPayID: typeof createPayID;
124
+ type index_PayIDServer = PayIDServer;
125
+ declare const index_PayIDServer: typeof PayIDServer;
126
+ declare const index_createPayIDServer: typeof createPayIDServer;
150
127
  declare namespace index {
151
- export { index_createPayID as createPayID };
128
+ export { index_PayIDServer as PayIDServer, index_createPayIDServer as createPayIDServer };
152
129
  }
153
130
 
154
- export { type UserOperation as U, createPayID as c, index as i };
131
+ export { PayIDServer as P, type UserOperation as U, ZGStorage as Z, createPayIDServer as c, index as i, zgStorage as z };
@@ -1,5 +1,6 @@
1
1
  import { Wallet } from 'ethers';
2
- import { ContextV1, ContextV2 } from 'payid-types';
2
+ import { C as ContextV1 } from './context.v1-C1m-tz0o.js';
3
+ import { C as ContextV2 } from './context.v2-DIzPotmW.js';
3
4
 
4
5
  /**
5
6
  * Build an attested Context V2 object from a base execution context
@@ -1,12 +1,13 @@
1
- import { ethers, TypedDataField } from 'ethers';
2
- import { RuleConfig } from 'payid-types';
3
- import { P as PayIDSessionPolicyPayloadV1, S as SessionPolicyV2 } from './types-CpXiPRYs.js';
1
+ import { TypedDataField, ethers } from 'ethers';
2
+ import { b as RuleConfig } from './rule-a_5ed-93.js';
3
+ import { P as PayIDSessionPolicyPayloadV1, S as SessionPolicyV2 } from './types-D2o6XS7a.js';
4
4
 
5
5
  /**
6
- * Create and sign an ephemeral PayID session policy payload (V1).
7
- * @deprecated Use createSessionPolicyV2 for new implementations.
6
+ * @deprecated V1 session policies have no chain binding and are vulnerable to
7
+ * cross-chain signature replay attacks. Use createSessionPolicyV2 instead.
8
+ * This function now throws to prevent creation of new V1 policies.
8
9
  */
9
- declare function createSessionPolicyPayload(params: {
10
+ declare function createSessionPolicyPayload(_params: {
10
11
  receiver: string;
11
12
  rule: RuleConfig;
12
13
  expiresAt: number;
@@ -100,4 +101,4 @@ declare namespace index {
100
101
  export { index_PayIDSessionPolicyPayloadV1 as PayIDSessionPolicyPayloadV1, index_SESSION_POLICY_V2_TYPES as SESSION_POLICY_V2_TYPES, index_SessionPolicyV2 as SessionPolicyV2, index_buildSessionPolicyV2Domain as buildSessionPolicyV2Domain, index_createSessionPolicyPayload as createSessionPolicyPayload, index_createSessionPolicyV2 as createSessionPolicyV2, index_decodeSessionPolicy as decodeSessionPolicy, index_decodeSessionPolicyV2 as decodeSessionPolicyV2, index_decodeSessionPolicyV2QR as decodeSessionPolicyV2QR, index_encodeSessionPolicyV2QR as encodeSessionPolicyV2QR };
101
102
  }
102
103
 
103
- export { SESSION_POLICY_V2_TYPES as S, createSessionPolicyV2 as a, buildSessionPolicyV2Domain as b, createSessionPolicyPayload as c, decodeSessionPolicy as d, decodeSessionPolicyV2 as e, encodeSessionPolicyV2QR as f, decodeSessionPolicyV2QR as g, index as i };
104
+ export { SESSION_POLICY_V2_TYPES as S, createSessionPolicyV2 as a, buildSessionPolicyV2Domain as b, createSessionPolicyPayload as c, decodeSessionPolicy as d, decodeSessionPolicyV2 as e, decodeSessionPolicyV2QR as f, encodeSessionPolicyV2QR as g, index as i };