payid 0.5.9 → 1.0.0

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 (42) hide show
  1. package/dist/chunk-AUW7WDAB.js +198 -0
  2. package/dist/{chunk-SSO66YQI.js → chunk-E6VQETBC.js} +13 -0
  3. package/dist/{chunk-AYJYFAXJ.js → chunk-ESTGPUEQ.js} +24 -21
  4. package/dist/{chunk-ROBSNIIZ.js → chunk-EZ3BGZ7G.js} +25 -16
  5. package/dist/chunk-FZNMDGVK.js +24 -0
  6. package/dist/chunk-HKHRYRD6.js +752 -0
  7. package/dist/chunk-X7NYQ47Y.js +27 -0
  8. package/dist/chunk-XMUHMJRD.js +30 -0
  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-G_1SiZJo.d.ts +104 -0
  22. package/dist/index.d.ts +407 -72
  23. package/dist/index.js +582 -77
  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 +17 -6
  31. package/dist/types-D2o6XS7a.d.ts +66 -0
  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-IQNCMOIE.js +0 -47
  36. package/dist/chunk-MXKZJKXE.js +0 -33
  37. package/dist/chunk-PAJYP7JI.js +0 -308
  38. package/dist/chunk-QC24X74O.js +0 -41
  39. package/dist/index-BPJ_oOfy.d.ts +0 -81
  40. package/dist/index-BQQnMG2H.d.ts +0 -114
  41. package/dist/types-B8pJQdMQ.d.ts +0 -26
  42. package/dist/types-BmMf7udp.d.ts +0 -13
@@ -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
+ };
@@ -0,0 +1,30 @@
1
+ import {
2
+ SESSION_POLICY_V2_TYPES,
3
+ buildSessionPolicyV2Domain,
4
+ createSessionPolicyPayload,
5
+ createSessionPolicyV2,
6
+ decodeSessionPolicy,
7
+ decodeSessionPolicyV2,
8
+ decodeSessionPolicyV2QR,
9
+ encodeSessionPolicyV2QR
10
+ } from "./chunk-AUW7WDAB.js";
11
+ import {
12
+ __export
13
+ } from "./chunk-MLKGABMK.js";
14
+
15
+ // src/sessionPolicy/index.ts
16
+ var sessionPolicy_exports = {};
17
+ __export(sessionPolicy_exports, {
18
+ SESSION_POLICY_V2_TYPES: () => SESSION_POLICY_V2_TYPES,
19
+ buildSessionPolicyV2Domain: () => buildSessionPolicyV2Domain,
20
+ createSessionPolicyPayload: () => createSessionPolicyPayload,
21
+ createSessionPolicyV2: () => createSessionPolicyV2,
22
+ decodeSessionPolicy: () => decodeSessionPolicy,
23
+ decodeSessionPolicyV2: () => decodeSessionPolicyV2,
24
+ decodeSessionPolicyV2QR: () => decodeSessionPolicyV2QR,
25
+ encodeSessionPolicyV2QR: () => encodeSessionPolicyV2QR
26
+ });
27
+
28
+ export {
29
+ sessionPolicy_exports
30
+ };
@@ -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-BPJ_oOfy.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-BmMf7udp.js';
6
+ import '../../types-D2o6XS7a.js';
@@ -1,12 +1,16 @@
1
1
  import {
2
- createPayID
3
- } from "../../chunk-ROBSNIIZ.js";
2
+ PayIDClient,
3
+ createPayIDClient
4
+ } from "../../chunk-EZ3BGZ7G.js";
4
5
  import "../../chunk-GG34PNTF.js";
5
- import "../../chunk-MXKZJKXE.js";
6
+ import "../../chunk-AUW7WDAB.js";
6
7
  import "../../chunk-6VPSJFO4.js";
7
- import "../../chunk-PAJYP7JI.js";
8
+ import "../../chunk-HKHRYRD6.js";
9
+ import "../../chunk-X7NYQ47Y.js";
8
10
  import "../../chunk-KDC67LIN.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-AYJYFAXJ.js";
4
- import "../../chunk-PAJYP7JI.js";
2
+ PayIDServer,
3
+ createPayIDServer
4
+ } from "../../chunk-ESTGPUEQ.js";
5
+ import "../../chunk-HKHRYRD6.js";
6
+ import "../../chunk-X7NYQ47Y.js";
5
7
  import "../../chunk-KDC67LIN.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
@@ -0,0 +1,104 @@
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
+
5
+ /**
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.
9
+ */
10
+ declare function createSessionPolicyPayload(_params: {
11
+ receiver: string;
12
+ rule: RuleConfig;
13
+ expiresAt: number;
14
+ signer: ethers.Signer;
15
+ }): Promise<PayIDSessionPolicyPayloadV1>;
16
+
17
+ declare const SESSION_POLICY_V2_TYPES: Record<string, TypedDataField[]>;
18
+ /**
19
+ * Build EIP-712 domain untuk SessionPolicyV2.
20
+ * Bind ke chainId + verifyingContract — policy tidak bisa di-replay di chain lain.
21
+ */
22
+ declare function buildSessionPolicyV2Domain(chainId: number, verifyingContract: string): {
23
+ name: string;
24
+ version: string;
25
+ chainId: number;
26
+ verifyingContract: string;
27
+ };
28
+ /**
29
+ * Create and sign a Channel A Session Policy (V2).
30
+ *
31
+ * Receiver sign CONSTRAINTS — bukan transaksi spesifik.
32
+ * Receiver tidak perlu tahu siapa payer-nya saat membuat ini.
33
+ *
34
+ * Security model:
35
+ * - Receiver sign constraints (rule, maxAmount, asset, expiry)
36
+ * - Payer sign context transaksinya sendiri
37
+ * - Chain enforce keduanya — tidak ada self-approval
38
+ *
39
+ * Perbedaan dari V1:
40
+ * - Bind ke ruleSetHash on-chain → payer tidak bisa swap rule
41
+ * - Bind ke allowedAsset+maxAmount → payer tidak bisa exceed
42
+ * - Bind ke chainId+verifyingContract (EIP-712) → anti cross-chain replay
43
+ * - Signed via EIP-712 → human-readable di wallet UI
44
+ *
45
+ * @throws Jika maxAmount <= 0, expiresAt sudah lewat, atau address invalid
46
+ */
47
+ declare function createSessionPolicyV2(params: {
48
+ receiver: string;
49
+ ruleSetHash: string;
50
+ ruleAuthority: string;
51
+ allowedAsset: string;
52
+ maxAmount: bigint;
53
+ expiresAt: number;
54
+ payId: string;
55
+ chainId: number;
56
+ verifyingContract: string;
57
+ signer: ethers.Signer;
58
+ }): Promise<SessionPolicyV2>;
59
+
60
+ /**
61
+ * Decode and verify a V1 session policy.
62
+ * @deprecated Use decodeSessionPolicyV2 for new implementations.
63
+ */
64
+ declare function decodeSessionPolicy(sessionPolicy: PayIDSessionPolicyPayloadV1, now: number): RuleConfig;
65
+ /**
66
+ * Verify and decode a Channel A SessionPolicyV2.
67
+ *
68
+ * Checks (in order):
69
+ * 1. version === "payid.session.policy.v2"
70
+ * 2. blockTimestamp < expiresAt (belum expired)
71
+ * 3. EIP-712 signature valid dan recovered === receiver
72
+ *
73
+ * @param policy - SessionPolicyV2 dari QR / URL
74
+ * @param blockTimestamp - Timestamp dari block, bukan Date.now()
75
+ * @returns policy yang terverifikasi (same object)
76
+ * @throws INVALID_SESSION_POLICY_V2_VERSION | SESSION_POLICY_V2_EXPIRED | INVALID_SESSION_POLICY_V2_SIGNATURE
77
+ */
78
+ declare function decodeSessionPolicyV2(policy: SessionPolicyV2, blockTimestamp: number): SessionPolicyV2;
79
+ /**
80
+ * Encode SessionPolicyV2 ke QR / URL string.
81
+ * Format: "payid-v2:<base64url(JSON)>"
82
+ */
83
+ declare function encodeSessionPolicyV2QR(policy: SessionPolicyV2): string;
84
+ /**
85
+ * Decode QR / URL string ke SessionPolicyV2.
86
+ * @throws QR_FORMAT_UNKNOWN | QR_CORRUPT | SESSION_POLICY_V2_INVALID
87
+ */
88
+ declare function decodeSessionPolicyV2QR(qrString: string): SessionPolicyV2;
89
+
90
+ declare const index_PayIDSessionPolicyPayloadV1: typeof PayIDSessionPolicyPayloadV1;
91
+ declare const index_SESSION_POLICY_V2_TYPES: typeof SESSION_POLICY_V2_TYPES;
92
+ declare const index_SessionPolicyV2: typeof SessionPolicyV2;
93
+ declare const index_buildSessionPolicyV2Domain: typeof buildSessionPolicyV2Domain;
94
+ declare const index_createSessionPolicyPayload: typeof createSessionPolicyPayload;
95
+ declare const index_createSessionPolicyV2: typeof createSessionPolicyV2;
96
+ declare const index_decodeSessionPolicy: typeof decodeSessionPolicy;
97
+ declare const index_decodeSessionPolicyV2: typeof decodeSessionPolicyV2;
98
+ declare const index_decodeSessionPolicyV2QR: typeof decodeSessionPolicyV2QR;
99
+ declare const index_encodeSessionPolicyV2QR: typeof encodeSessionPolicyV2QR;
100
+ declare namespace index {
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 };
102
+ }
103
+
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 };