payid 0.5.3 → 0.5.6

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.
@@ -0,0 +1,181 @@
1
+ import {
2
+ buildPayERC20CallData,
3
+ buildPayETHCallData,
4
+ buildUserOperation
5
+ } from "./chunk-5WO2F5HT.js";
6
+ import {
7
+ evaluate,
8
+ generateDecisionProof,
9
+ resolveRule
10
+ } from "./chunk-LHLJP2TB.js";
11
+ import {
12
+ __export
13
+ } from "./chunk-R5U7XKVJ.js";
14
+
15
+ // src/core/payid.ts
16
+ function isRuleSource(rule) {
17
+ return typeof rule === "object" && rule !== null && "uri" in rule;
18
+ }
19
+ var PayID = class {
20
+ constructor(wasm, debugTrace, trustedIssuers) {
21
+ this.wasm = wasm;
22
+ this.debugTrace = debugTrace;
23
+ this.trustedIssuers = trustedIssuers;
24
+ }
25
+ async evaluate(context, rule) {
26
+ const config = isRuleSource(rule) ? (await resolveRule(rule)).config : rule;
27
+ return evaluate(context, config, {
28
+ debug: this.debugTrace,
29
+ trustedIssuers: this.trustedIssuers
30
+ }, this.wasm);
31
+ }
32
+ async evaluateAndProve(params) {
33
+ const authorityConfig = isRuleSource(params.authorityRule) ? (await resolveRule(params.authorityRule)).config : params.authorityRule;
34
+ const evalConfig = params.evaluationRule ?? authorityConfig;
35
+ const result = await evaluate(
36
+ params.context,
37
+ evalConfig,
38
+ {
39
+ debug: this.debugTrace,
40
+ trustedIssuers: this.trustedIssuers
41
+ },
42
+ this.wasm
43
+ );
44
+ if (result.decision !== "ALLOW") {
45
+ return { result, proof: null };
46
+ }
47
+ const proof = await generateDecisionProof({
48
+ payId: params.payId,
49
+ payer: params.payer,
50
+ receiver: params.receiver,
51
+ asset: params.asset,
52
+ amount: params.amount,
53
+ context: params.context,
54
+ ruleConfig: authorityConfig,
55
+ signer: params.signer,
56
+ verifyingContract: params.verifyingContract,
57
+ ruleAuthority: params.ruleAuthority,
58
+ chainId: params.chainId ?? params.context?.tx?.chainId,
59
+ ttlSeconds: params.ttlSeconds,
60
+ blockTimestamp: params.blockTimestamp
61
+ });
62
+ return { result, proof };
63
+ }
64
+ buildUserOperation(params) {
65
+ const attestationUIDs = params.attestationUIDs ?? [];
66
+ const isETH = params.paymentType === "eth";
67
+ const callData = isETH ? buildPayETHCallData(params.targetContract, params.proof, attestationUIDs) : buildPayERC20CallData(params.targetContract, params.proof, attestationUIDs);
68
+ return buildUserOperation({
69
+ sender: params.smartAccount,
70
+ nonce: params.nonce,
71
+ callData,
72
+ gas: params.gas,
73
+ paymasterAndData: params.paymasterAndData
74
+ });
75
+ }
76
+ };
77
+
78
+ // src/factory.ts
79
+ function createPayID(params) {
80
+ return new PayID(
81
+ params.wasm,
82
+ params.debugTrace ?? false,
83
+ params.trustedIssuers
84
+ );
85
+ }
86
+
87
+ // src/eas.ts
88
+ var eas_exports = {};
89
+ __export(eas_exports, {
90
+ EASClient: () => EASClient,
91
+ EAS_ADDRESSES: () => EAS_ADDRESSES
92
+ });
93
+ import { ethers } from "ethers";
94
+ var EAS_ABI = [
95
+ "function getAttestation(bytes32 uid) external view returns (tuple(bytes32 uid, bytes32 schema, uint64 time, uint64 expirationTime, uint64 revocationTime, bytes32 refUID, address attester, address recipient, bool revocable, bytes data))",
96
+ "function isAttestationValid(bytes32 uid) external view returns (bool)",
97
+ "event Attested(address indexed recipient, address indexed attester, bytes32 uid, bytes32 indexed schema)"
98
+ ];
99
+ var EASClient = class {
100
+ contract;
101
+ constructor(options) {
102
+ this.contract = new ethers.Contract(
103
+ options.easAddress,
104
+ EAS_ABI,
105
+ options.provider
106
+ );
107
+ }
108
+ async getAttestation(uid) {
109
+ const raw = await this.contract.getFunction("getAttestation")(uid);
110
+ return {
111
+ uid: raw.uid,
112
+ schema: raw.schema,
113
+ time: raw.time,
114
+ expirationTime: raw.expirationTime,
115
+ revocationTime: raw.revocationTime,
116
+ attester: raw.attester,
117
+ recipient: raw.recipient,
118
+ revocable: raw.revocable,
119
+ data: raw.data
120
+ };
121
+ }
122
+ async isValid(uid) {
123
+ const result = await this.contract.getFunction("isAttestationValid")(uid);
124
+ return result;
125
+ }
126
+ async getAttestationUIDs(params) {
127
+ const attestedFilter = this.contract.filters["Attested"];
128
+ if (!attestedFilter) {
129
+ throw new Error("EAS: Attested event not found in ABI");
130
+ }
131
+ const filter = attestedFilter(
132
+ params.recipient,
133
+ params.attester ?? null,
134
+ null,
135
+ params.schemaUID
136
+ );
137
+ const events = await this.contract.queryFilter(
138
+ filter,
139
+ params.fromBlock ?? 0
140
+ );
141
+ const uids = events.map(
142
+ (e) => e.args["uid"]
143
+ );
144
+ const validUids = [];
145
+ for (const uid of uids) {
146
+ const valid = await this.isValid(uid);
147
+ if (valid) validUids.push(uid);
148
+ }
149
+ return validUids;
150
+ }
151
+ /**
152
+ * One-liner: dapat valid UIDs siap di-pass ke payETH/payERC20
153
+ *
154
+ * @example
155
+ * const eas = new EASClient({ easAddress: EAS_ADDRESSES[11155111], provider })
156
+ * const uids = await eas.getValidUIDs({ recipient: payerAddress, schemaUID: KYC_SCHEMA_UID })
157
+ * await payWithPayID.payERC20(decision, sig, uids)
158
+ */
159
+ async getValidUIDs(params) {
160
+ return this.getAttestationUIDs(params);
161
+ }
162
+ };
163
+ var EAS_ADDRESSES = {
164
+ 1: "0xA1207F3BBa224E2c9c3c6D5aF63D0eb1582Ce587",
165
+ // Ethereum Mainnet
166
+ 8453: "0x4200000000000000000000000000000000000021",
167
+ // Base
168
+ 10: "0x4200000000000000000000000000000000000020",
169
+ // Optimism
170
+ 42161: "0xbD75f629A22Dc1ceD33dDA0b68c546A1c035c458",
171
+ // Arbitrum One
172
+ 11155111: "0xC2679fBD37d54388Ce493F1DB75320D236e1815e",
173
+ // Sepolia
174
+ 4202: "0xC2679fBD37d54388Ce493F1DB75320D236e1815e"
175
+ // Lisk Sepolia
176
+ };
177
+
178
+ export {
179
+ createPayID,
180
+ eas_exports
181
+ };
package/dist/index.d.ts CHANGED
@@ -1,206 +1,11 @@
1
- import { RuleContext, RuleConfig, RuleResult } from 'payid-types';
2
- import { R as RuleSource } from './types-B8pJQdMQ.js';
3
- import { U as UserOperation } from './index-C1DHMQA0.js';
4
- export { i as server } from './index-C1DHMQA0.js';
5
- import { ethers } from 'ethers';
1
+ export { PayIDClient, PayIDServer, createPayID, eas } from './src/index.js';
6
2
  export { i as sessionPolicy } from './index-BQQnMG2H.js';
7
3
  export { i as rule } from './index-Dj9IEios.js';
8
4
  export { i as issuer } from './index-2JCvey4-.js';
9
5
  export { i as context } from './index-BEvnPzzt.js';
10
6
  export { i as client } from './index-BPJ_oOfy.js';
7
+ export { i as server } from './index-C1DHMQA0.js';
8
+ import 'payid-types';
9
+ import './types-B8pJQdMQ.js';
10
+ import 'ethers';
11
11
  import './types-BmMf7udp.js';
12
-
13
- interface PayIDClient {
14
- /**
15
- * Pure rule evaluation — client-safe, no signing
16
- */
17
- evaluate(context: RuleContext, rule: RuleConfig | RuleSource): Promise<RuleResult>;
18
- /**
19
- * Evaluate + generate EIP-712 Decision Proof
20
- * Client sign sendiri pakai wallet mereka
21
- */
22
- evaluateAndProve(params: {
23
- context: RuleContext;
24
- authorityRule: RuleConfig | RuleSource;
25
- evaluationRule?: RuleConfig;
26
- payId: string;
27
- payer: string;
28
- receiver: string;
29
- asset: string;
30
- amount: bigint;
31
- signer: ethers.Signer;
32
- verifyingContract: string;
33
- ruleAuthority: string;
34
- ttlSeconds?: number;
35
- }): Promise<{
36
- result: RuleResult;
37
- proof: any | null;
38
- }>;
39
- }
40
- interface PayIDServer {
41
- /**
42
- * Evaluate + generate proof dengan trusted issuers
43
- * Signer sudah di-inject saat construct PayIDServer
44
- */
45
- evaluateAndProve(params: {
46
- context: RuleContext;
47
- authorityRule: RuleConfig | RuleSource;
48
- evaluationRule?: RuleConfig;
49
- payId: string;
50
- payer: string;
51
- receiver: string;
52
- asset: string;
53
- amount: bigint;
54
- verifyingContract: string;
55
- ruleAuthority: string;
56
- ttlSeconds?: number;
57
- chainId: number;
58
- blockTimestamp: number;
59
- }): Promise<{
60
- result: RuleResult;
61
- proof: any | null;
62
- }>;
63
- /**
64
- * Build ERC-4337 UserOperation dari Decision Proof
65
- * Server/bundler only
66
- */
67
- buildUserOperation(params: {
68
- proof: any;
69
- smartAccount: string;
70
- nonce: string;
71
- gas: any;
72
- targetContract: string;
73
- paymasterAndData?: string;
74
- attestationUIDs?: string[];
75
- }): UserOperation;
76
- }
77
-
78
- /**
79
- * Create a PayID policy engine instance backed by a WASM rule evaluator.
80
- *
81
- * ## Responsibility
82
- *
83
- * - Holds the WASM binary used for rule execution
84
- * - Defines the trust boundary for context attestation verification
85
- * - Acts as the primary entry point for PayID rule evaluation
86
- *
87
- * ## Trust model
88
- *
89
- * - If `trustedIssuers` is provided, Context V2 attestation
90
- * verification is ENFORCED.
91
- * - If `trustedIssuers` is omitted, the engine runs in
92
- * legacy (Context V1) mode without cryptographic verification.
93
- *
94
- * ## Environment
95
- *
96
- * This class is safe to instantiate in:
97
- * - Browsers
98
- * - Mobile apps
99
- * - Edge runtimes
100
- * - Backend services
101
- *
102
- * @param wasm
103
- * Compiled PayID WASM rule engine binary.
104
- *
105
- * @param debugTrace
106
- * Optional flag to enable decision trace generation for debugging.
107
- *
108
- * @param trustedIssuers
109
- * Optional set of trusted attestation issuer addresses.
110
- *
111
- * When provided, Context V2 attestation verification is ENFORCED:
112
- * - Only attestations issued by addresses in this set are accepted.
113
- * - Missing, expired, or invalid attestations cause evaluation to fail.
114
- *
115
- * When omitted, the engine runs in legacy (Context V1) mode
116
- * without cryptographic verification.
117
- *
118
- * ⚠️ Important:
119
- * - Do NOT pass an empty Set.
120
- * An empty set means "no issuer is trusted" and will
121
- * cause all attestations to be rejected.
122
- *
123
- * @example
124
- * ```ts
125
- * const trustedIssuers = new Set([
126
- * TIME_ISSUER,
127
- * STATE_ISSUER,
128
- * ORACLE_ISSUER,
129
- * RISK_ISSUER
130
- * ]);
131
- *
132
- * const payid = new PayID(wasmBinary, debugTrace, trustedIssuers);
133
- * ```
134
- */
135
- declare function createPayID(params: {
136
- wasm?: Uint8Array;
137
- debugTrace?: boolean;
138
- trustedIssuers?: Set<string>;
139
- }): PayIDClient & PayIDServer;
140
-
141
- /**
142
- * @module eas
143
- * @description EAS (Ethereum Attestation Service) helper untuk client-side.
144
- * Fully serverless — fetch attestation UIDs langsung dari chain.
145
- *
146
- * EAS addresses:
147
- * Mainnet : 0xA1207F3BBa224E2c9c3c6D5aF63D0eb1582Ce587
148
- * Base : 0x4200000000000000000000000000000000000021
149
- * Optimism : 0x4200000000000000000000000000000000000020
150
- * Arbitrum : 0xbD75f629A22Dc1ceD33dDA0b68c546A1c035c458
151
- * Sepolia : 0xC2679fBD37d54388Ce493F1DB75320D236e1815e
152
- */
153
-
154
- interface EASAttestation {
155
- uid: string;
156
- schema: string;
157
- time: bigint;
158
- expirationTime: bigint;
159
- revocationTime: bigint;
160
- attester: string;
161
- recipient: string;
162
- revocable: boolean;
163
- data: string;
164
- }
165
- interface EASClientOptions {
166
- easAddress: string;
167
- provider: ethers.Provider;
168
- }
169
- declare class EASClient {
170
- private readonly contract;
171
- constructor(options: EASClientOptions);
172
- getAttestation(uid: string): Promise<EASAttestation>;
173
- isValid(uid: string): Promise<boolean>;
174
- getAttestationUIDs(params: {
175
- recipient: string;
176
- schemaUID: string;
177
- attester?: string;
178
- fromBlock?: number;
179
- }): Promise<string[]>;
180
- /**
181
- * One-liner: dapat valid UIDs siap di-pass ke payETH/payERC20
182
- *
183
- * @example
184
- * const eas = new EASClient({ easAddress: EAS_ADDRESSES[11155111], provider })
185
- * const uids = await eas.getValidUIDs({ recipient: payerAddress, schemaUID: KYC_SCHEMA_UID })
186
- * await payWithPayID.payERC20(decision, sig, uids)
187
- */
188
- getValidUIDs(params: {
189
- recipient: string;
190
- schemaUID: string;
191
- attester?: string;
192
- fromBlock?: number;
193
- }): Promise<string[]>;
194
- }
195
- declare const EAS_ADDRESSES: Record<number, string>;
196
-
197
- type eas_EASAttestation = EASAttestation;
198
- type eas_EASClient = EASClient;
199
- declare const eas_EASClient: typeof EASClient;
200
- type eas_EASClientOptions = EASClientOptions;
201
- declare const eas_EAS_ADDRESSES: typeof EAS_ADDRESSES;
202
- declare namespace eas {
203
- export { type eas_EASAttestation as EASAttestation, eas_EASClient as EASClient, type eas_EASClientOptions as EASClientOptions, eas_EAS_ADDRESSES as EAS_ADDRESSES };
204
- }
205
-
206
- export { type PayIDClient, type PayIDServer, createPayID, eas };
package/dist/index.js CHANGED
@@ -1,3 +1,7 @@
1
+ import {
2
+ createPayID,
3
+ eas_exports
4
+ } from "./chunk-B2KKQDFN.js";
1
5
  import {
2
6
  context_exports
3
7
  } from "./chunk-RICUEGTH.js";
@@ -18,183 +22,11 @@ import "./chunk-GG34PNTF.js";
18
22
  import "./chunk-MXKZJKXE.js";
19
23
  import "./chunk-6VPSJFO4.js";
20
24
  import {
21
- buildPayERC20CallData,
22
- buildPayETHCallData,
23
- buildUserOperation,
24
25
  server_exports
25
26
  } from "./chunk-5WO2F5HT.js";
26
- import {
27
- evaluate,
28
- generateDecisionProof,
29
- resolveRule
30
- } from "./chunk-LHLJP2TB.js";
27
+ import "./chunk-LHLJP2TB.js";
31
28
  import "./chunk-5ZEKI5Y2.js";
32
- import {
33
- __export
34
- } from "./chunk-R5U7XKVJ.js";
35
-
36
- // src/core/payid.ts
37
- function isRuleSource(rule) {
38
- return typeof rule === "object" && rule !== null && "uri" in rule;
39
- }
40
- var PayID = class {
41
- constructor(wasm, debugTrace, trustedIssuers) {
42
- this.wasm = wasm;
43
- this.debugTrace = debugTrace;
44
- this.trustedIssuers = trustedIssuers;
45
- }
46
- async evaluate(context, rule) {
47
- const config = isRuleSource(rule) ? (await resolveRule(rule)).config : rule;
48
- return evaluate(context, config, {
49
- debug: this.debugTrace,
50
- trustedIssuers: this.trustedIssuers
51
- }, this.wasm);
52
- }
53
- async evaluateAndProve(params) {
54
- const authorityConfig = isRuleSource(params.authorityRule) ? (await resolveRule(params.authorityRule)).config : params.authorityRule;
55
- const evalConfig = params.evaluationRule ?? authorityConfig;
56
- const result = await evaluate(
57
- params.context,
58
- evalConfig,
59
- {
60
- debug: this.debugTrace,
61
- trustedIssuers: this.trustedIssuers
62
- },
63
- this.wasm
64
- );
65
- if (result.decision !== "ALLOW") {
66
- return { result, proof: null };
67
- }
68
- const proof = await generateDecisionProof({
69
- payId: params.payId,
70
- payer: params.payer,
71
- receiver: params.receiver,
72
- asset: params.asset,
73
- amount: params.amount,
74
- context: params.context,
75
- ruleConfig: authorityConfig,
76
- signer: params.signer,
77
- verifyingContract: params.verifyingContract,
78
- ruleAuthority: params.ruleAuthority,
79
- chainId: params.chainId ?? params.context?.tx?.chainId,
80
- ttlSeconds: params.ttlSeconds,
81
- blockTimestamp: params.blockTimestamp
82
- });
83
- return { result, proof };
84
- }
85
- buildUserOperation(params) {
86
- const attestationUIDs = params.attestationUIDs ?? [];
87
- const isETH = params.paymentType === "eth";
88
- const callData = isETH ? buildPayETHCallData(params.targetContract, params.proof, attestationUIDs) : buildPayERC20CallData(params.targetContract, params.proof, attestationUIDs);
89
- return buildUserOperation({
90
- sender: params.smartAccount,
91
- nonce: params.nonce,
92
- callData,
93
- gas: params.gas,
94
- paymasterAndData: params.paymasterAndData
95
- });
96
- }
97
- };
98
-
99
- // src/factory.ts
100
- function createPayID(params) {
101
- return new PayID(
102
- params.wasm,
103
- params.debugTrace ?? false,
104
- params.trustedIssuers
105
- );
106
- }
107
-
108
- // src/eas.ts
109
- var eas_exports = {};
110
- __export(eas_exports, {
111
- EASClient: () => EASClient,
112
- EAS_ADDRESSES: () => EAS_ADDRESSES
113
- });
114
- import { ethers } from "ethers";
115
- var EAS_ABI = [
116
- "function getAttestation(bytes32 uid) external view returns (tuple(bytes32 uid, bytes32 schema, uint64 time, uint64 expirationTime, uint64 revocationTime, bytes32 refUID, address attester, address recipient, bool revocable, bytes data))",
117
- "function isAttestationValid(bytes32 uid) external view returns (bool)",
118
- "event Attested(address indexed recipient, address indexed attester, bytes32 uid, bytes32 indexed schema)"
119
- ];
120
- var EASClient = class {
121
- contract;
122
- constructor(options) {
123
- this.contract = new ethers.Contract(
124
- options.easAddress,
125
- EAS_ABI,
126
- options.provider
127
- );
128
- }
129
- async getAttestation(uid) {
130
- const raw = await this.contract.getFunction("getAttestation")(uid);
131
- return {
132
- uid: raw.uid,
133
- schema: raw.schema,
134
- time: raw.time,
135
- expirationTime: raw.expirationTime,
136
- revocationTime: raw.revocationTime,
137
- attester: raw.attester,
138
- recipient: raw.recipient,
139
- revocable: raw.revocable,
140
- data: raw.data
141
- };
142
- }
143
- async isValid(uid) {
144
- const result = await this.contract.getFunction("isAttestationValid")(uid);
145
- return result;
146
- }
147
- async getAttestationUIDs(params) {
148
- const attestedFilter = this.contract.filters["Attested"];
149
- if (!attestedFilter) {
150
- throw new Error("EAS: Attested event not found in ABI");
151
- }
152
- const filter = attestedFilter(
153
- params.recipient,
154
- params.attester ?? null,
155
- null,
156
- params.schemaUID
157
- );
158
- const events = await this.contract.queryFilter(
159
- filter,
160
- params.fromBlock ?? 0
161
- );
162
- const uids = events.map(
163
- (e) => e.args["uid"]
164
- );
165
- const validUids = [];
166
- for (const uid of uids) {
167
- const valid = await this.isValid(uid);
168
- if (valid) validUids.push(uid);
169
- }
170
- return validUids;
171
- }
172
- /**
173
- * One-liner: dapat valid UIDs siap di-pass ke payETH/payERC20
174
- *
175
- * @example
176
- * const eas = new EASClient({ easAddress: EAS_ADDRESSES[11155111], provider })
177
- * const uids = await eas.getValidUIDs({ recipient: payerAddress, schemaUID: KYC_SCHEMA_UID })
178
- * await payWithPayID.payERC20(decision, sig, uids)
179
- */
180
- async getValidUIDs(params) {
181
- return this.getAttestationUIDs(params);
182
- }
183
- };
184
- var EAS_ADDRESSES = {
185
- 1: "0xA1207F3BBa224E2c9c3c6D5aF63D0eb1582Ce587",
186
- // Ethereum Mainnet
187
- 8453: "0x4200000000000000000000000000000000000021",
188
- // Base
189
- 10: "0x4200000000000000000000000000000000000020",
190
- // Optimism
191
- 42161: "0xbD75f629A22Dc1ceD33dDA0b68c546A1c035c458",
192
- // Arbitrum One
193
- 11155111: "0xC2679fBD37d54388Ce493F1DB75320D236e1815e",
194
- // Sepolia
195
- 4202: "0xC2679fBD37d54388Ce493F1DB75320D236e1815e"
196
- // Lisk Sepolia
197
- };
29
+ import "./chunk-R5U7XKVJ.js";
198
30
  export {
199
31
  client_exports as client,
200
32
  context_exports as context,
@@ -0,0 +1,3 @@
1
+ export { b as buildContextV2 } from '../../index-BEvnPzzt.js';
2
+ import 'ethers';
3
+ import 'payid-types';
@@ -0,0 +1,8 @@
1
+ import {
2
+ buildContextV2
3
+ } from "../../chunk-RICUEGTH.js";
4
+ import "../../chunk-YKCMGGYB.js";
5
+ import "../../chunk-R5U7XKVJ.js";
6
+ export {
7
+ buildContextV2
8
+ };
@@ -0,0 +1,5 @@
1
+ export { c as createPayID } from '../../../index-BPJ_oOfy.js';
2
+ import 'payid-types';
3
+ import 'ethers';
4
+ import '../../../types-B8pJQdMQ.js';
5
+ import '../../../types-BmMf7udp.js';
@@ -0,0 +1,12 @@
1
+ import {
2
+ createPayID
3
+ } from "../../../chunk-KUWSOJU7.js";
4
+ import "../../../chunk-GG34PNTF.js";
5
+ import "../../../chunk-MXKZJKXE.js";
6
+ import "../../../chunk-6VPSJFO4.js";
7
+ import "../../../chunk-LHLJP2TB.js";
8
+ import "../../../chunk-5ZEKI5Y2.js";
9
+ import "../../../chunk-R5U7XKVJ.js";
10
+ export {
11
+ createPayID
12
+ };
@@ -0,0 +1,4 @@
1
+ export { c as createPayID } from '../../../index-C1DHMQA0.js';
2
+ import 'ethers';
3
+ import 'payid-types';
4
+ import '../../../types-B8pJQdMQ.js';
@@ -0,0 +1,9 @@
1
+ import {
2
+ createPayID
3
+ } from "../../../chunk-5WO2F5HT.js";
4
+ import "../../../chunk-LHLJP2TB.js";
5
+ import "../../../chunk-5ZEKI5Y2.js";
6
+ import "../../../chunk-R5U7XKVJ.js";
7
+ export {
8
+ createPayID
9
+ };
@@ -0,0 +1,206 @@
1
+ export { i as sessionPolicy } from '../index-BQQnMG2H.js';
2
+ export { i as rule } from '../index-Dj9IEios.js';
3
+ export { i as issuer } from '../index-2JCvey4-.js';
4
+ export { i as context } from '../index-BEvnPzzt.js';
5
+ export { i as client } from '../index-BPJ_oOfy.js';
6
+ import { U as UserOperation } from '../index-C1DHMQA0.js';
7
+ export { i as server } from '../index-C1DHMQA0.js';
8
+ import { RuleContext, RuleConfig, RuleResult } from 'payid-types';
9
+ import { R as RuleSource } from '../types-B8pJQdMQ.js';
10
+ import { ethers } from 'ethers';
11
+ import '../types-BmMf7udp.js';
12
+
13
+ interface PayIDClient {
14
+ /**
15
+ * Pure rule evaluation — client-safe, no signing
16
+ */
17
+ evaluate(context: RuleContext, rule: RuleConfig | RuleSource): Promise<RuleResult>;
18
+ /**
19
+ * Evaluate + generate EIP-712 Decision Proof
20
+ * Client sign sendiri pakai wallet mereka
21
+ */
22
+ evaluateAndProve(params: {
23
+ context: RuleContext;
24
+ authorityRule: RuleConfig | RuleSource;
25
+ evaluationRule?: RuleConfig;
26
+ payId: string;
27
+ payer: string;
28
+ receiver: string;
29
+ asset: string;
30
+ amount: bigint;
31
+ signer: ethers.Signer;
32
+ verifyingContract: string;
33
+ ruleAuthority: string;
34
+ ttlSeconds?: number;
35
+ }): Promise<{
36
+ result: RuleResult;
37
+ proof: any | null;
38
+ }>;
39
+ }
40
+ interface PayIDServer {
41
+ /**
42
+ * Evaluate + generate proof dengan trusted issuers
43
+ * Signer sudah di-inject saat construct PayIDServer
44
+ */
45
+ evaluateAndProve(params: {
46
+ context: RuleContext;
47
+ authorityRule: RuleConfig | RuleSource;
48
+ evaluationRule?: RuleConfig;
49
+ payId: string;
50
+ payer: string;
51
+ receiver: string;
52
+ asset: string;
53
+ amount: bigint;
54
+ verifyingContract: string;
55
+ ruleAuthority: string;
56
+ ttlSeconds?: number;
57
+ chainId: number;
58
+ blockTimestamp: number;
59
+ }): Promise<{
60
+ result: RuleResult;
61
+ proof: any | null;
62
+ }>;
63
+ /**
64
+ * Build ERC-4337 UserOperation dari Decision Proof
65
+ * Server/bundler only
66
+ */
67
+ buildUserOperation(params: {
68
+ proof: any;
69
+ smartAccount: string;
70
+ nonce: string;
71
+ gas: any;
72
+ targetContract: string;
73
+ paymasterAndData?: string;
74
+ attestationUIDs?: string[];
75
+ }): UserOperation;
76
+ }
77
+
78
+ /**
79
+ * Create a PayID policy engine instance backed by a WASM rule evaluator.
80
+ *
81
+ * ## Responsibility
82
+ *
83
+ * - Holds the WASM binary used for rule execution
84
+ * - Defines the trust boundary for context attestation verification
85
+ * - Acts as the primary entry point for PayID rule evaluation
86
+ *
87
+ * ## Trust model
88
+ *
89
+ * - If `trustedIssuers` is provided, Context V2 attestation
90
+ * verification is ENFORCED.
91
+ * - If `trustedIssuers` is omitted, the engine runs in
92
+ * legacy (Context V1) mode without cryptographic verification.
93
+ *
94
+ * ## Environment
95
+ *
96
+ * This class is safe to instantiate in:
97
+ * - Browsers
98
+ * - Mobile apps
99
+ * - Edge runtimes
100
+ * - Backend services
101
+ *
102
+ * @param wasm
103
+ * Compiled PayID WASM rule engine binary.
104
+ *
105
+ * @param debugTrace
106
+ * Optional flag to enable decision trace generation for debugging.
107
+ *
108
+ * @param trustedIssuers
109
+ * Optional set of trusted attestation issuer addresses.
110
+ *
111
+ * When provided, Context V2 attestation verification is ENFORCED:
112
+ * - Only attestations issued by addresses in this set are accepted.
113
+ * - Missing, expired, or invalid attestations cause evaluation to fail.
114
+ *
115
+ * When omitted, the engine runs in legacy (Context V1) mode
116
+ * without cryptographic verification.
117
+ *
118
+ * ⚠️ Important:
119
+ * - Do NOT pass an empty Set.
120
+ * An empty set means "no issuer is trusted" and will
121
+ * cause all attestations to be rejected.
122
+ *
123
+ * @example
124
+ * ```ts
125
+ * const trustedIssuers = new Set([
126
+ * TIME_ISSUER,
127
+ * STATE_ISSUER,
128
+ * ORACLE_ISSUER,
129
+ * RISK_ISSUER
130
+ * ]);
131
+ *
132
+ * const payid = new PayID(wasmBinary, debugTrace, trustedIssuers);
133
+ * ```
134
+ */
135
+ declare function createPayID(params: {
136
+ wasm?: Uint8Array;
137
+ debugTrace?: boolean;
138
+ trustedIssuers?: Set<string>;
139
+ }): PayIDClient & PayIDServer;
140
+
141
+ /**
142
+ * @module eas
143
+ * @description EAS (Ethereum Attestation Service) helper untuk client-side.
144
+ * Fully serverless — fetch attestation UIDs langsung dari chain.
145
+ *
146
+ * EAS addresses:
147
+ * Mainnet : 0xA1207F3BBa224E2c9c3c6D5aF63D0eb1582Ce587
148
+ * Base : 0x4200000000000000000000000000000000000021
149
+ * Optimism : 0x4200000000000000000000000000000000000020
150
+ * Arbitrum : 0xbD75f629A22Dc1ceD33dDA0b68c546A1c035c458
151
+ * Sepolia : 0xC2679fBD37d54388Ce493F1DB75320D236e1815e
152
+ */
153
+
154
+ interface EASAttestation {
155
+ uid: string;
156
+ schema: string;
157
+ time: bigint;
158
+ expirationTime: bigint;
159
+ revocationTime: bigint;
160
+ attester: string;
161
+ recipient: string;
162
+ revocable: boolean;
163
+ data: string;
164
+ }
165
+ interface EASClientOptions {
166
+ easAddress: string;
167
+ provider: ethers.Provider;
168
+ }
169
+ declare class EASClient {
170
+ private readonly contract;
171
+ constructor(options: EASClientOptions);
172
+ getAttestation(uid: string): Promise<EASAttestation>;
173
+ isValid(uid: string): Promise<boolean>;
174
+ getAttestationUIDs(params: {
175
+ recipient: string;
176
+ schemaUID: string;
177
+ attester?: string;
178
+ fromBlock?: number;
179
+ }): Promise<string[]>;
180
+ /**
181
+ * One-liner: dapat valid UIDs siap di-pass ke payETH/payERC20
182
+ *
183
+ * @example
184
+ * const eas = new EASClient({ easAddress: EAS_ADDRESSES[11155111], provider })
185
+ * const uids = await eas.getValidUIDs({ recipient: payerAddress, schemaUID: KYC_SCHEMA_UID })
186
+ * await payWithPayID.payERC20(decision, sig, uids)
187
+ */
188
+ getValidUIDs(params: {
189
+ recipient: string;
190
+ schemaUID: string;
191
+ attester?: string;
192
+ fromBlock?: number;
193
+ }): Promise<string[]>;
194
+ }
195
+ declare const EAS_ADDRESSES: Record<number, string>;
196
+
197
+ type eas_EASAttestation = EASAttestation;
198
+ type eas_EASClient = EASClient;
199
+ declare const eas_EASClient: typeof EASClient;
200
+ type eas_EASClientOptions = EASClientOptions;
201
+ declare const eas_EAS_ADDRESSES: typeof EAS_ADDRESSES;
202
+ declare namespace eas {
203
+ export { type eas_EASAttestation as EASAttestation, eas_EASClient as EASClient, type eas_EASClientOptions as EASClientOptions, eas_EAS_ADDRESSES as EAS_ADDRESSES };
204
+ }
205
+
206
+ export { type PayIDClient, type PayIDServer, createPayID, eas };
@@ -0,0 +1,39 @@
1
+ import {
2
+ createPayID,
3
+ eas_exports
4
+ } from "../chunk-B2KKQDFN.js";
5
+ import {
6
+ context_exports
7
+ } from "../chunk-RICUEGTH.js";
8
+ import {
9
+ issuer_exports
10
+ } from "../chunk-J3SM3HWZ.js";
11
+ import "../chunk-YKCMGGYB.js";
12
+ import {
13
+ rule_exports
14
+ } from "../chunk-U7PPUJJH.js";
15
+ import {
16
+ sessionPolicy_exports
17
+ } from "../chunk-Y75PSD7U.js";
18
+ import {
19
+ client_exports
20
+ } from "../chunk-KUWSOJU7.js";
21
+ import "../chunk-GG34PNTF.js";
22
+ import "../chunk-MXKZJKXE.js";
23
+ import "../chunk-6VPSJFO4.js";
24
+ import {
25
+ server_exports
26
+ } from "../chunk-5WO2F5HT.js";
27
+ import "../chunk-LHLJP2TB.js";
28
+ import "../chunk-5ZEKI5Y2.js";
29
+ import "../chunk-R5U7XKVJ.js";
30
+ export {
31
+ client_exports as client,
32
+ context_exports as context,
33
+ createPayID,
34
+ eas_exports as eas,
35
+ issuer_exports as issuer,
36
+ rule_exports as rule,
37
+ server_exports as server,
38
+ sessionPolicy_exports as sessionPolicy
39
+ };
@@ -1,3 +1,3 @@
1
- export { a as issueEnvContext, b as issueOracleContext, c as issueRiskContext, d as issueStateContext, s as signAttestation } from '../index-2JCvey4-.js';
1
+ export { a as issueEnvContext, b as issueOracleContext, c as issueRiskContext, d as issueStateContext, s as signAttestation } from '../../index-2JCvey4-.js';
2
2
  import 'payid-types';
3
3
  import 'ethers';
@@ -1,12 +1,12 @@
1
- import "../chunk-J3SM3HWZ.js";
1
+ import "../../chunk-J3SM3HWZ.js";
2
2
  import {
3
3
  issueEnvContext,
4
4
  issueOracleContext,
5
5
  issueRiskContext,
6
6
  issueStateContext,
7
7
  signAttestation
8
- } from "../chunk-YKCMGGYB.js";
9
- import "../chunk-R5U7XKVJ.js";
8
+ } from "../../chunk-YKCMGGYB.js";
9
+ import "../../chunk-R5U7XKVJ.js";
10
10
  export {
11
11
  issueEnvContext,
12
12
  issueOracleContext,
@@ -1,2 +1,2 @@
1
- export { a as canonicalizeRuleSet, c as combineRules, h as hashRuleSet } from '../index-Dj9IEios.js';
1
+ export { a as canonicalizeRuleSet, c as combineRules, h as hashRuleSet } from '../../index-Dj9IEios.js';
2
2
  import 'payid-types';
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  hashRuleSet
3
- } from "../chunk-U7PPUJJH.js";
3
+ } from "../../chunk-U7PPUJJH.js";
4
4
  import {
5
5
  combineRules
6
- } from "../chunk-GG34PNTF.js";
6
+ } from "../../chunk-GG34PNTF.js";
7
7
  import {
8
8
  canonicalizeRuleSet
9
- } from "../chunk-6VPSJFO4.js";
10
- import "../chunk-R5U7XKVJ.js";
9
+ } from "../../chunk-6VPSJFO4.js";
10
+ import "../../chunk-R5U7XKVJ.js";
11
11
  export {
12
12
  canonicalizeRuleSet,
13
13
  combineRules,
@@ -0,0 +1,4 @@
1
+ export { c as createSessionPolicyPayload, d as decodeSessionPolicy } from '../../index-BQQnMG2H.js';
2
+ export { P as PayIDSessionPolicyPayloadV1 } from '../../types-BmMf7udp.js';
3
+ import 'ethers';
4
+ import 'payid-types';
@@ -0,0 +1,13 @@
1
+ import {
2
+ createSessionPolicyPayload
3
+ } from "../../chunk-Y75PSD7U.js";
4
+ import {
5
+ decodeSessionPolicy
6
+ } from "../../chunk-MXKZJKXE.js";
7
+ import "../../chunk-6VPSJFO4.js";
8
+ import "../../chunk-5ZEKI5Y2.js";
9
+ import "../../chunk-R5U7XKVJ.js";
10
+ export {
11
+ createSessionPolicyPayload,
12
+ decodeSessionPolicy
13
+ };
package/package.json CHANGED
@@ -1,59 +1,58 @@
1
1
  {
2
2
  "name": "payid",
3
- "version": "0.5.3",
3
+ "version": "0.5.6",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
- "types": "./dist/types.d.ts",
7
+ "types": "./dist/index.d.ts",
8
8
  "exports": {
9
9
  ".": {
10
- "import": "./dist/index.js",
11
- "types": "./dist/index.d.ts"
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
12
  },
13
13
  "./sessionPolicy": {
14
- "import": "./dist/sessionPolicy/index.js",
15
- "types": "./dist/sessionPolicy/index.d.ts"
14
+ "types": "./dist/sessionPolicy/index.d.ts",
15
+ "import": "./dist/sessionPolicy/index.js"
16
16
  },
17
17
  "./rule": {
18
- "import": "./dist/rule/index.js",
19
- "types": "./dist/rule/index.d.ts"
18
+ "types": "./dist/rule/index.d.ts",
19
+ "import": "./dist/rule/index.js"
20
20
  },
21
21
  "./issuer": {
22
- "import": "./dist/issuer/index.js",
23
- "types": "./dist/issuer/index.d.ts"
22
+ "types": "./dist/issuer/index.d.ts",
23
+ "import": "./dist/issuer/index.js"
24
24
  },
25
25
  "./context": {
26
- "import": "./dist/context/index.js",
27
- "types": "./dist/context/index.d.ts"
26
+ "types": "./dist/context/index.d.ts",
27
+ "import": "./dist/context/index.js"
28
28
  },
29
29
  "./client": {
30
- "import": "./dist/core/client/index.js",
31
- "types": "./dist/core/client/index.d.ts"
30
+ "types": "./dist/core/client/index.d.ts",
31
+ "import": "./dist/core/client/index.js"
32
32
  },
33
33
  "./server": {
34
- "import": "./dist/core/server/index.js",
35
- "types": "./dist/core/server/index.d.ts"
34
+ "types": "./dist/core/server/index.d.ts",
35
+ "import": "./dist/core/server/index.js"
36
36
  }
37
37
  },
38
- "dependencies": {
39
- "ethers": "^6.16.0",
40
- "payid-rule-engine": "^0.3.1",
41
- "payid-types": "^0.2.0"
42
- },
43
38
  "files": [
44
39
  "dist"
45
40
  ],
41
+ "dependencies": {
42
+ "ethers": "^6.16.0",
43
+ "payid-rule-engine": "^0.3.3",
44
+ "payid-types": "^0.2.2"
45
+ },
46
+ "peerDependencies": {
47
+ "typescript": "^5.9.3"
48
+ },
46
49
  "scripts": {
47
- "build": "tsup src/index.ts --format esm --dts --clean",
48
- "build2": "tsup src/index.ts src/sessionPolicy/index.ts src/rule/index.ts src/issuer/index.ts src/context/index.ts src/core/client/index.ts src/core/server/index.ts --format esm --dts --clean"
50
+ "build": "tsup"
49
51
  },
50
52
  "devDependencies": {
51
53
  "@types/bun": "latest",
52
54
  "tsup": "^8.5.1"
53
55
  },
54
- "peerDependencies": {
55
- "typescript": "^5.9.3"
56
- },
57
56
  "description": "pay-policy",
58
57
  "repository": {
59
58
  "type": "git",
@@ -1,3 +0,0 @@
1
- export { b as buildContextV2 } from '../index-BEvnPzzt.js';
2
- import 'ethers';
3
- import 'payid-types';
@@ -1,8 +0,0 @@
1
- import {
2
- buildContextV2
3
- } from "../chunk-RICUEGTH.js";
4
- import "../chunk-YKCMGGYB.js";
5
- import "../chunk-R5U7XKVJ.js";
6
- export {
7
- buildContextV2
8
- };
@@ -1,5 +0,0 @@
1
- export { c as createPayID } from '../../index-BPJ_oOfy.js';
2
- import 'payid-types';
3
- import 'ethers';
4
- import '../../types-B8pJQdMQ.js';
5
- import '../../types-BmMf7udp.js';
@@ -1,12 +0,0 @@
1
- import {
2
- createPayID
3
- } from "../../chunk-KUWSOJU7.js";
4
- import "../../chunk-GG34PNTF.js";
5
- import "../../chunk-MXKZJKXE.js";
6
- import "../../chunk-6VPSJFO4.js";
7
- import "../../chunk-LHLJP2TB.js";
8
- import "../../chunk-5ZEKI5Y2.js";
9
- import "../../chunk-R5U7XKVJ.js";
10
- export {
11
- createPayID
12
- };
@@ -1,4 +0,0 @@
1
- export { c as createPayID } from '../../index-C1DHMQA0.js';
2
- import 'ethers';
3
- import 'payid-types';
4
- import '../../types-B8pJQdMQ.js';
@@ -1,9 +0,0 @@
1
- import {
2
- createPayID
3
- } from "../../chunk-5WO2F5HT.js";
4
- import "../../chunk-LHLJP2TB.js";
5
- import "../../chunk-5ZEKI5Y2.js";
6
- import "../../chunk-R5U7XKVJ.js";
7
- export {
8
- createPayID
9
- };
@@ -1,4 +0,0 @@
1
- export { c as createSessionPolicyPayload, d as decodeSessionPolicy } from '../index-BQQnMG2H.js';
2
- export { P as PayIDSessionPolicyPayloadV1 } from '../types-BmMf7udp.js';
3
- import 'ethers';
4
- import 'payid-types';
@@ -1,13 +0,0 @@
1
- import {
2
- createSessionPolicyPayload
3
- } from "../chunk-Y75PSD7U.js";
4
- import {
5
- decodeSessionPolicy
6
- } from "../chunk-MXKZJKXE.js";
7
- import "../chunk-6VPSJFO4.js";
8
- import "../chunk-5ZEKI5Y2.js";
9
- import "../chunk-R5U7XKVJ.js";
10
- export {
11
- createSessionPolicyPayload,
12
- decodeSessionPolicy
13
- };