payid 1.0.4 → 1.1.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.
- package/dist/{chunk-AUW7WDAB.js → chunk-BC77BLFK.js} +20 -2
- package/dist/{chunk-HKHRYRD6.js → chunk-GQJAHRA7.js} +4 -91
- package/dist/{chunk-ESTGPUEQ.js → chunk-J5C4O242.js} +4 -2
- package/dist/{chunk-XMUHMJRD.js → chunk-R674DZJS.js} +1 -1
- package/dist/chunk-X43JAJPI.js +89 -0
- package/dist/{chunk-EZ3BGZ7G.js → chunk-XLQGSYE6.js} +5 -3
- package/dist/core/client/index.d.ts +3 -2
- package/dist/core/client/index.js +4 -3
- package/dist/core/server/index.d.ts +3 -2
- package/dist/core/server/index.js +3 -2
- package/dist/decision-proof/index.d.ts +23 -0
- package/dist/decision-proof/index.js +9 -0
- package/dist/{index-DSxDlF9J.d.ts → index-DpGIg0Hu.d.ts} +2 -1
- package/dist/{index-CsynGAGv.d.ts → index-IjgtzYO2.d.ts} +2 -1
- package/dist/index.d.ts +9 -6
- package/dist/index.js +13 -9
- package/dist/sessionPolicy/index.js +2 -2
- package/dist/types-CSZ5F9J7.d.ts +23 -0
- package/dist/types-cnCPtnaV.d.ts +29 -0
- package/package.json +7 -1
- package/dist/types-i4eTkhWa.d.ts +0 -50
|
@@ -146,8 +146,26 @@ function decodeSessionPolicyV2(policy, blockTimestamp) {
|
|
|
146
146
|
}
|
|
147
147
|
return policy;
|
|
148
148
|
}
|
|
149
|
+
function base64urlEncode(str) {
|
|
150
|
+
const encoder = new TextEncoder();
|
|
151
|
+
const uint8Array = encoder.encode(str);
|
|
152
|
+
let binary = "";
|
|
153
|
+
uint8Array.forEach((byte) => binary += String.fromCharCode(byte));
|
|
154
|
+
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
155
|
+
}
|
|
156
|
+
function base64urlDecode(str) {
|
|
157
|
+
str = str.replace(/-/g, "+").replace(/_/g, "/");
|
|
158
|
+
while (str.length % 4) str += "=";
|
|
159
|
+
const binary = atob(str);
|
|
160
|
+
const uint8Array = new Uint8Array(binary.length);
|
|
161
|
+
for (let i = 0; i < binary.length; i++) {
|
|
162
|
+
uint8Array[i] = binary.charCodeAt(i);
|
|
163
|
+
}
|
|
164
|
+
const decoder = new TextDecoder();
|
|
165
|
+
return decoder.decode(uint8Array);
|
|
166
|
+
}
|
|
149
167
|
function encodeSessionPolicyV2QR(policy) {
|
|
150
|
-
const encoded =
|
|
168
|
+
const encoded = base64urlEncode(JSON.stringify(policy));
|
|
151
169
|
return `payid-v2:${encoded}`;
|
|
152
170
|
}
|
|
153
171
|
function decodeSessionPolicyV2QR(qrString) {
|
|
@@ -159,7 +177,7 @@ function decodeSessionPolicyV2QR(qrString) {
|
|
|
159
177
|
}
|
|
160
178
|
let policy;
|
|
161
179
|
try {
|
|
162
|
-
const json =
|
|
180
|
+
const json = base64urlDecode(qrString.slice(PREFIX.length));
|
|
163
181
|
policy = JSON.parse(json);
|
|
164
182
|
} catch {
|
|
165
183
|
throw new Error("QR_CORRUPT: tidak bisa di-decode");
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
hashContext,
|
|
3
|
-
hashRuleSet
|
|
4
|
-
} from "./chunk-X7NYQ47Y.js";
|
|
5
|
-
import {
|
|
6
|
-
randomHex
|
|
7
|
-
} from "./chunk-KDC67LIN.js";
|
|
8
|
-
|
|
9
1
|
// src/attestation/verify.ts
|
|
10
2
|
import { ethers, keccak256, toUtf8Bytes, toBeArray } from "ethers";
|
|
11
3
|
function verifyAttestation(payload, proof, trustedIssuers) {
|
|
@@ -610,84 +602,6 @@ async function evaluate(context, ruleConfig, options, wasmBinary) {
|
|
|
610
602
|
return baseResult;
|
|
611
603
|
}
|
|
612
604
|
|
|
613
|
-
// src/decision-proof/generate.ts
|
|
614
|
-
import { ethers as ethers2, ZeroAddress } from "ethers";
|
|
615
|
-
var hash = (v) => ethers2.keccak256(ethers2.toUtf8Bytes(v));
|
|
616
|
-
async function generateDecisionProof(params) {
|
|
617
|
-
if (!ethers2.isAddress(params.payer) || params.payer === ethers2.ZeroAddress) {
|
|
618
|
-
throw new Error("GENERATE_PROOF: payer address tidak valid atau zero");
|
|
619
|
-
}
|
|
620
|
-
if (!ethers2.isAddress(params.receiver) || params.receiver === ethers2.ZeroAddress) {
|
|
621
|
-
throw new Error("GENERATE_PROOF: receiver address tidak valid atau zero");
|
|
622
|
-
}
|
|
623
|
-
if (!ethers2.isAddress(params.verifyingContract) || params.verifyingContract === ethers2.ZeroAddress) {
|
|
624
|
-
throw new Error("GENERATE_PROOF: verifyingContract tidak valid atau zero");
|
|
625
|
-
}
|
|
626
|
-
if (params.amount <= 0n) {
|
|
627
|
-
throw new Error("GENERATE_PROOF: amount harus > 0");
|
|
628
|
-
}
|
|
629
|
-
const now = params.blockTimestamp ?? Math.floor(Date.now() / 1e3);
|
|
630
|
-
const issuedAt = now - 30;
|
|
631
|
-
const expiresAt = now + (params.ttlSeconds ?? 300);
|
|
632
|
-
let chainId = params.chainId;
|
|
633
|
-
if (!chainId && params.signer.provider) {
|
|
634
|
-
const network = await params.signer.provider.getNetwork();
|
|
635
|
-
chainId = Number(network.chainId);
|
|
636
|
-
}
|
|
637
|
-
if (!chainId || chainId <= 0 || !Number.isInteger(chainId)) {
|
|
638
|
-
throw new Error(`GENERATE_PROOF: chainId tidak valid: ${chainId}`);
|
|
639
|
-
}
|
|
640
|
-
const requiresAttestation = Array.isArray(params.ruleConfig?.requires) && params.ruleConfig.requires.length > 0;
|
|
641
|
-
const attestationUIDsHash = params.attestationUIDs ? ethers2.keccak256(ethers2.AbiCoder.defaultAbiCoder().encode(["bytes32[]"], [params.attestationUIDs])) : ethers2.ZeroHash;
|
|
642
|
-
const payload = {
|
|
643
|
-
version: hash("2"),
|
|
644
|
-
payId: hash(params.payId),
|
|
645
|
-
payer: params.payer,
|
|
646
|
-
receiver: params.receiver,
|
|
647
|
-
asset: params.asset,
|
|
648
|
-
amount: params.amount,
|
|
649
|
-
contextHash: hashContext(params.context),
|
|
650
|
-
ruleSetHash: params.ruleSetHashOverride ?? hashRuleSet(params.ruleConfig),
|
|
651
|
-
ruleAuthority: params.ruleAuthority ?? ZeroAddress,
|
|
652
|
-
issuedAt: BigInt(issuedAt),
|
|
653
|
-
expiresAt: BigInt(expiresAt),
|
|
654
|
-
nonce: randomHex(32),
|
|
655
|
-
requiresAttestation,
|
|
656
|
-
attestationUIDsHash
|
|
657
|
-
};
|
|
658
|
-
const domain = {
|
|
659
|
-
name: "PAY.ID Decision",
|
|
660
|
-
version: "2",
|
|
661
|
-
chainId,
|
|
662
|
-
verifyingContract: params.verifyingContract
|
|
663
|
-
};
|
|
664
|
-
const types = {
|
|
665
|
-
Decision: [
|
|
666
|
-
{ name: "version", type: "bytes32" },
|
|
667
|
-
{ name: "payId", type: "bytes32" },
|
|
668
|
-
{ name: "payer", type: "address" },
|
|
669
|
-
{ name: "receiver", type: "address" },
|
|
670
|
-
{ name: "asset", type: "address" },
|
|
671
|
-
{ name: "amount", type: "uint256" },
|
|
672
|
-
{ name: "contextHash", type: "bytes32" },
|
|
673
|
-
{ name: "ruleSetHash", type: "bytes32" },
|
|
674
|
-
{ name: "ruleAuthority", type: "address" },
|
|
675
|
-
{ name: "issuedAt", type: "uint64" },
|
|
676
|
-
{ name: "expiresAt", type: "uint64" },
|
|
677
|
-
{ name: "nonce", type: "bytes32" },
|
|
678
|
-
{ name: "requiresAttestation", type: "bool" },
|
|
679
|
-
{ name: "attestationUIDsHash", type: "bytes32" }
|
|
680
|
-
]
|
|
681
|
-
};
|
|
682
|
-
const signature = await params.signer.signTypedData(domain, types, payload);
|
|
683
|
-
const recovered = ethers2.verifyTypedData(domain, types, payload, signature);
|
|
684
|
-
const signerAddress = await params.signer.getAddress();
|
|
685
|
-
if (recovered.toLowerCase() !== signerAddress.toLowerCase()) {
|
|
686
|
-
throw new Error("SIGNATURE_MISMATCH");
|
|
687
|
-
}
|
|
688
|
-
return { payload, signature };
|
|
689
|
-
}
|
|
690
|
-
|
|
691
605
|
// src/utils/subtle.ts
|
|
692
606
|
var subtleCrypto = globalThis.crypto.subtle;
|
|
693
607
|
|
|
@@ -717,7 +631,7 @@ function bufferToHex(buffer) {
|
|
|
717
631
|
// src/resolver/resolver.ts
|
|
718
632
|
var DEFAULT_ZG_INDEXER = "https://indexer-testnet.0g.ai";
|
|
719
633
|
async function resolveRule(source, options) {
|
|
720
|
-
const { uri, hash
|
|
634
|
+
const { uri, hash } = source;
|
|
721
635
|
if (uri.startsWith("inline://")) {
|
|
722
636
|
const encoded = uri.replace("inline://", "");
|
|
723
637
|
const json = JSON.parse(atob(encoded));
|
|
@@ -726,18 +640,18 @@ async function resolveRule(source, options) {
|
|
|
726
640
|
if (uri.startsWith("ipfs://")) {
|
|
727
641
|
const cid = uri.replace("ipfs://", "");
|
|
728
642
|
const url = `https://ipfs.io/ipfs/${cid}`;
|
|
729
|
-
const config = await fetchJsonWithHashCheck(url,
|
|
643
|
+
const config = await fetchJsonWithHashCheck(url, hash);
|
|
730
644
|
return { config, source };
|
|
731
645
|
}
|
|
732
646
|
if (uri.startsWith("http://") || uri.startsWith("https://")) {
|
|
733
|
-
const config = await fetchJsonWithHashCheck(uri,
|
|
647
|
+
const config = await fetchJsonWithHashCheck(uri, hash);
|
|
734
648
|
return { config, source };
|
|
735
649
|
}
|
|
736
650
|
if (uri.startsWith("0g://")) {
|
|
737
651
|
const rootHash = uri.replace("0g://", "");
|
|
738
652
|
const indexerUrl = options?.zgIndexerUrl ?? globalThis.PAYID_ZGS_INDEXER_URL ?? DEFAULT_ZG_INDEXER;
|
|
739
653
|
const url = `${indexerUrl}/blob/${rootHash}`;
|
|
740
|
-
const config = await fetchJsonWithHashCheck(url,
|
|
654
|
+
const config = await fetchJsonWithHashCheck(url, hash);
|
|
741
655
|
return { config, source };
|
|
742
656
|
}
|
|
743
657
|
throw new Error("UNSUPPORTED_RULE_URI");
|
|
@@ -747,6 +661,5 @@ export {
|
|
|
747
661
|
loadWasm,
|
|
748
662
|
verifyAttestation,
|
|
749
663
|
evaluate,
|
|
750
|
-
generateDecisionProof,
|
|
751
664
|
resolveRule
|
|
752
665
|
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import {
|
|
2
|
+
hashContext,
|
|
3
|
+
hashRuleSet
|
|
4
|
+
} from "./chunk-X7NYQ47Y.js";
|
|
5
|
+
import {
|
|
6
|
+
randomHex
|
|
7
|
+
} from "./chunk-KDC67LIN.js";
|
|
8
|
+
|
|
9
|
+
// src/decision-proof/generate.ts
|
|
10
|
+
import { ethers, ZeroAddress } from "ethers";
|
|
11
|
+
var hash = (v) => ethers.keccak256(ethers.toUtf8Bytes(v));
|
|
12
|
+
async function generateDecisionProof(params) {
|
|
13
|
+
if (!ethers.isAddress(params.payer) || params.payer === ethers.ZeroAddress) {
|
|
14
|
+
throw new Error("GENERATE_PROOF: payer address tidak valid atau zero");
|
|
15
|
+
}
|
|
16
|
+
if (!ethers.isAddress(params.receiver) || params.receiver === ethers.ZeroAddress) {
|
|
17
|
+
throw new Error("GENERATE_PROOF: receiver address tidak valid atau zero");
|
|
18
|
+
}
|
|
19
|
+
if (!ethers.isAddress(params.verifyingContract) || params.verifyingContract === ethers.ZeroAddress) {
|
|
20
|
+
throw new Error("GENERATE_PROOF: verifyingContract tidak valid atau zero");
|
|
21
|
+
}
|
|
22
|
+
if (params.amount <= 0n) {
|
|
23
|
+
throw new Error("GENERATE_PROOF: amount harus > 0");
|
|
24
|
+
}
|
|
25
|
+
const now = params.blockTimestamp ?? Math.floor(Date.now() / 1e3);
|
|
26
|
+
const issuedAt = now - 30;
|
|
27
|
+
const expiresAt = now + (params.ttlSeconds ?? 300);
|
|
28
|
+
let chainId = params.chainId;
|
|
29
|
+
if (!chainId && params.signer.provider) {
|
|
30
|
+
const network = await params.signer.provider.getNetwork();
|
|
31
|
+
chainId = Number(network.chainId);
|
|
32
|
+
}
|
|
33
|
+
if (!chainId || chainId <= 0 || !Number.isInteger(chainId)) {
|
|
34
|
+
throw new Error(`GENERATE_PROOF: chainId tidak valid: ${chainId}`);
|
|
35
|
+
}
|
|
36
|
+
const requiresAttestation = Array.isArray(params.ruleConfig?.requires) && params.ruleConfig.requires.length > 0;
|
|
37
|
+
const attestationUIDsHash = params.attestationUIDs ? ethers.keccak256(ethers.AbiCoder.defaultAbiCoder().encode(["bytes32[]"], [params.attestationUIDs])) : ethers.ZeroHash;
|
|
38
|
+
const payload = {
|
|
39
|
+
version: hash("2"),
|
|
40
|
+
payId: hash(params.payId),
|
|
41
|
+
payer: params.payer,
|
|
42
|
+
receiver: params.receiver,
|
|
43
|
+
asset: params.asset,
|
|
44
|
+
amount: params.amount,
|
|
45
|
+
contextHash: hashContext(params.context),
|
|
46
|
+
ruleSetHash: params.ruleSetHashOverride ?? hashRuleSet(params.ruleConfig),
|
|
47
|
+
ruleAuthority: params.ruleAuthority ?? ZeroAddress,
|
|
48
|
+
issuedAt: BigInt(issuedAt),
|
|
49
|
+
expiresAt: BigInt(expiresAt),
|
|
50
|
+
nonce: randomHex(32),
|
|
51
|
+
requiresAttestation,
|
|
52
|
+
attestationUIDsHash
|
|
53
|
+
};
|
|
54
|
+
const domain = {
|
|
55
|
+
name: "PAY.ID Decision",
|
|
56
|
+
version: "2",
|
|
57
|
+
chainId,
|
|
58
|
+
verifyingContract: params.verifyingContract
|
|
59
|
+
};
|
|
60
|
+
const types = {
|
|
61
|
+
Decision: [
|
|
62
|
+
{ name: "version", type: "bytes32" },
|
|
63
|
+
{ name: "payId", type: "bytes32" },
|
|
64
|
+
{ name: "payer", type: "address" },
|
|
65
|
+
{ name: "receiver", type: "address" },
|
|
66
|
+
{ name: "asset", type: "address" },
|
|
67
|
+
{ name: "amount", type: "uint256" },
|
|
68
|
+
{ name: "contextHash", type: "bytes32" },
|
|
69
|
+
{ name: "ruleSetHash", type: "bytes32" },
|
|
70
|
+
{ name: "ruleAuthority", type: "address" },
|
|
71
|
+
{ name: "issuedAt", type: "uint64" },
|
|
72
|
+
{ name: "expiresAt", type: "uint64" },
|
|
73
|
+
{ name: "nonce", type: "bytes32" },
|
|
74
|
+
{ name: "requiresAttestation", type: "bool" },
|
|
75
|
+
{ name: "attestationUIDsHash", type: "bytes32" }
|
|
76
|
+
]
|
|
77
|
+
};
|
|
78
|
+
const signature = await params.signer.signTypedData(domain, types, payload);
|
|
79
|
+
const recovered = ethers.verifyTypedData(domain, types, payload, signature);
|
|
80
|
+
const signerAddress = await params.signer.getAddress();
|
|
81
|
+
if (recovered.toLowerCase() !== signerAddress.toLowerCase()) {
|
|
82
|
+
throw new Error("SIGNATURE_MISMATCH");
|
|
83
|
+
}
|
|
84
|
+
return { payload, signature };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export {
|
|
88
|
+
generateDecisionProof
|
|
89
|
+
};
|
|
@@ -4,13 +4,15 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
decodeSessionPolicy,
|
|
6
6
|
decodeSessionPolicyV2
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-BC77BLFK.js";
|
|
8
8
|
import {
|
|
9
9
|
evaluate,
|
|
10
|
-
generateDecisionProof,
|
|
11
10
|
loadWasm,
|
|
12
11
|
resolveRule
|
|
13
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-GQJAHRA7.js";
|
|
13
|
+
import {
|
|
14
|
+
generateDecisionProof
|
|
15
|
+
} from "./chunk-X43JAJPI.js";
|
|
14
16
|
import {
|
|
15
17
|
__export
|
|
16
18
|
} from "./chunk-MLKGABMK.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { P as PayIDClient, c as createPayID, c as createPayIDClient } from '../../index-
|
|
1
|
+
export { P as PayIDClient, c as createPayID, c as createPayIDClient } from '../../index-IjgtzYO2.js';
|
|
2
2
|
import '../../rule-a_5ed-93.js';
|
|
3
3
|
import '../../context.v1-C1m-tz0o.js';
|
|
4
|
-
import '../../types-
|
|
4
|
+
import '../../types-cnCPtnaV.js';
|
|
5
5
|
import 'ethers';
|
|
6
|
+
import '../../types-CSZ5F9J7.js';
|
|
6
7
|
import '../../types-D2o6XS7a.js';
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PayIDClient,
|
|
3
3
|
createPayIDClient
|
|
4
|
-
} from "../../chunk-
|
|
4
|
+
} from "../../chunk-XLQGSYE6.js";
|
|
5
5
|
import "../../chunk-GG34PNTF.js";
|
|
6
|
-
import "../../chunk-
|
|
6
|
+
import "../../chunk-BC77BLFK.js";
|
|
7
7
|
import "../../chunk-6VPSJFO4.js";
|
|
8
|
-
import "../../chunk-
|
|
8
|
+
import "../../chunk-GQJAHRA7.js";
|
|
9
|
+
import "../../chunk-X43JAJPI.js";
|
|
9
10
|
import "../../chunk-X7NYQ47Y.js";
|
|
10
11
|
import "../../chunk-KDC67LIN.js";
|
|
11
12
|
import "../../chunk-MLKGABMK.js";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export { P as PayIDServer, c as createPayIDServer } from '../../index-
|
|
1
|
+
export { P as PayIDServer, c as createPayIDServer } from '../../index-DpGIg0Hu.js';
|
|
2
2
|
import 'ethers';
|
|
3
3
|
import '../../rule-a_5ed-93.js';
|
|
4
4
|
import '../../context.v1-C1m-tz0o.js';
|
|
5
|
-
import '../../types-
|
|
5
|
+
import '../../types-cnCPtnaV.js';
|
|
6
|
+
import '../../types-CSZ5F9J7.js';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PayIDServer,
|
|
3
3
|
createPayIDServer
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
4
|
+
} from "../../chunk-J5C4O242.js";
|
|
5
|
+
import "../../chunk-GQJAHRA7.js";
|
|
6
|
+
import "../../chunk-X43JAJPI.js";
|
|
6
7
|
import "../../chunk-X7NYQ47Y.js";
|
|
7
8
|
import "../../chunk-KDC67LIN.js";
|
|
8
9
|
import "../../chunk-MLKGABMK.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { a as DecisionProof } from '../types-CSZ5F9J7.js';
|
|
2
|
+
export { D as DecisionPayload, b as DecisionValue } from '../types-CSZ5F9J7.js';
|
|
3
|
+
import { ethers } from 'ethers';
|
|
4
|
+
|
|
5
|
+
declare function generateDecisionProof(params: {
|
|
6
|
+
payId: string;
|
|
7
|
+
payer: string;
|
|
8
|
+
receiver: string;
|
|
9
|
+
asset: string;
|
|
10
|
+
amount: bigint;
|
|
11
|
+
context: any;
|
|
12
|
+
ruleConfig: any;
|
|
13
|
+
ruleSetHashOverride?: string;
|
|
14
|
+
signer: ethers.Signer;
|
|
15
|
+
ruleAuthority: string;
|
|
16
|
+
verifyingContract: string;
|
|
17
|
+
ttlSeconds?: number;
|
|
18
|
+
chainId?: number;
|
|
19
|
+
blockTimestamp?: number;
|
|
20
|
+
attestationUIDs?: string[];
|
|
21
|
+
}): Promise<DecisionProof>;
|
|
22
|
+
|
|
23
|
+
export { DecisionProof, generateDecisionProof };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
2
|
import { b as RuleConfig } from './rule-a_5ed-93.js';
|
|
3
3
|
import { R as RuleContext } from './context.v1-C1m-tz0o.js';
|
|
4
|
-
import { R as ResolverOptions,
|
|
4
|
+
import { R as ResolverOptions, d as RuleSource, b as RuleResult } from './types-cnCPtnaV.js';
|
|
5
|
+
import { a as DecisionProof } from './types-CSZ5F9J7.js';
|
|
5
6
|
|
|
6
7
|
interface UserOperation {
|
|
7
8
|
sender: string;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { b as RuleConfig } from './rule-a_5ed-93.js';
|
|
2
2
|
import { R as RuleContext } from './context.v1-C1m-tz0o.js';
|
|
3
|
-
import { R as ResolverOptions,
|
|
3
|
+
import { R as ResolverOptions, d as RuleSource, b as RuleResult } from './types-cnCPtnaV.js';
|
|
4
4
|
import { ethers } from 'ethers';
|
|
5
|
+
import { a as DecisionProof } from './types-CSZ5F9J7.js';
|
|
5
6
|
import { P as PayIDSessionPolicyPayloadV1, S as SessionPolicyV2 } from './types-D2o6XS7a.js';
|
|
6
7
|
|
|
7
8
|
declare class PayIDClient {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import { P as PayIDClient$1 } from './index-
|
|
2
|
-
export { i as client } from './index-
|
|
3
|
-
import { Z as ZGStorage, P as PayIDServer$1, U as UserOperation } from './index-
|
|
4
|
-
export { i as server, z as storage } from './index-
|
|
1
|
+
import { P as PayIDClient$1 } from './index-IjgtzYO2.js';
|
|
2
|
+
export { i as client } from './index-IjgtzYO2.js';
|
|
3
|
+
import { Z as ZGStorage, P as PayIDServer$1, U as UserOperation } from './index-DpGIg0Hu.js';
|
|
4
|
+
export { i as server, z as storage } from './index-DpGIg0Hu.js';
|
|
5
5
|
import { ethers } from 'ethers';
|
|
6
|
-
import { R as ResolverOptions,
|
|
7
|
-
export {
|
|
6
|
+
import { R as ResolverOptions, d as RuleSource, b as RuleResult } from './types-cnCPtnaV.js';
|
|
7
|
+
export { a as RuleDecisionDebug, c as RuleResultDebug, e as RuleTraceEntry } from './types-cnCPtnaV.js';
|
|
8
8
|
import { b as RuleConfig } from './rule-a_5ed-93.js';
|
|
9
9
|
export { A as AnyRule, M as MultiConditionRule, N as NestedRule, R as Rule, a as RuleCondition, S as SimpleRule, i as isMultiConditionRule, c as isNestedRule, d as isSimpleRule } from './rule-a_5ed-93.js';
|
|
10
10
|
import { R as RuleContext } from './context.v1-C1m-tz0o.js';
|
|
11
11
|
export { C as ContextV1, P as PayIdContext, T as TxContext } from './context.v1-C1m-tz0o.js';
|
|
12
|
+
import { a as DecisionProof } from './types-CSZ5F9J7.js';
|
|
13
|
+
export { D as DecisionPayload } from './types-CSZ5F9J7.js';
|
|
12
14
|
import { S as SessionPolicyV2 } from './types-D2o6XS7a.js';
|
|
15
|
+
export { generateDecisionProof } from './decision-proof/index.js';
|
|
13
16
|
import { A as Attestation } from './context.v2-DIzPotmW.js';
|
|
14
17
|
export { C as ContextV2, E as EnvContext, O as OracleContext, R as RiskContext, S as StateContext } from './context.v2-DIzPotmW.js';
|
|
15
18
|
export { i as sessionPolicy } from './index-G_1SiZJo.js';
|
package/dist/index.js
CHANGED
|
@@ -10,21 +10,24 @@ import {
|
|
|
10
10
|
} from "./chunk-FZNMDGVK.js";
|
|
11
11
|
import {
|
|
12
12
|
sessionPolicy_exports
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-R674DZJS.js";
|
|
14
14
|
import {
|
|
15
15
|
PayIDClient,
|
|
16
16
|
client_exports
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-XLQGSYE6.js";
|
|
18
18
|
import "./chunk-GG34PNTF.js";
|
|
19
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-BC77BLFK.js";
|
|
20
20
|
import "./chunk-6VPSJFO4.js";
|
|
21
21
|
import {
|
|
22
22
|
PayIDServer,
|
|
23
23
|
server_exports
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-J5C4O242.js";
|
|
25
25
|
import {
|
|
26
26
|
verifyAttestation
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-GQJAHRA7.js";
|
|
28
|
+
import {
|
|
29
|
+
generateDecisionProof
|
|
30
|
+
} from "./chunk-X43JAJPI.js";
|
|
28
31
|
import "./chunk-X7NYQ47Y.js";
|
|
29
32
|
import "./chunk-KDC67LIN.js";
|
|
30
33
|
import {
|
|
@@ -360,7 +363,6 @@ async function simulateRegistration(params) {
|
|
|
360
363
|
}
|
|
361
364
|
|
|
362
365
|
// src/cli/verifyProof.ts
|
|
363
|
-
import "crypto";
|
|
364
366
|
async function verifyProof(options) {
|
|
365
367
|
try {
|
|
366
368
|
const receipt = await fetchReceipt(options.txHash, options.rpcUrl);
|
|
@@ -646,13 +648,14 @@ var ZGStorage = class {
|
|
|
646
648
|
const provider = new ethers2.JsonRpcProvider(this.config.nodeUrl);
|
|
647
649
|
const wallet = new ethers2.Wallet(this.config.privateKey, provider);
|
|
648
650
|
const content = typeof data === "string" ? data : JSON.stringify(data);
|
|
649
|
-
const
|
|
651
|
+
const encoder = new TextEncoder();
|
|
652
|
+
const uint8Array = encoder.encode(content);
|
|
650
653
|
const file = {
|
|
651
654
|
name: "metadata.json",
|
|
652
|
-
size:
|
|
655
|
+
size: uint8Array.length,
|
|
653
656
|
type: "application/json",
|
|
654
657
|
lastModified: Date.now(),
|
|
655
|
-
arrayBuffer: async () =>
|
|
658
|
+
arrayBuffer: async () => uint8Array.buffer.slice(uint8Array.byteOffset, uint8Array.byteOffset + uint8Array.byteLength)
|
|
656
659
|
};
|
|
657
660
|
const blob = new Blob(file);
|
|
658
661
|
const [result, err] = await this.indexer.upload(
|
|
@@ -696,6 +699,7 @@ export {
|
|
|
696
699
|
draftCache,
|
|
697
700
|
eas_exports as eas,
|
|
698
701
|
formatUsdValue,
|
|
702
|
+
generateDecisionProof,
|
|
699
703
|
getCacheStats,
|
|
700
704
|
historyCache,
|
|
701
705
|
isMultiConditionRule,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-R674DZJS.js";
|
|
2
2
|
import {
|
|
3
3
|
SESSION_POLICY_V2_TYPES,
|
|
4
4
|
buildSessionPolicyV2Domain,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
decodeSessionPolicyV2,
|
|
9
9
|
decodeSessionPolicyV2QR,
|
|
10
10
|
encodeSessionPolicyV2QR
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-BC77BLFK.js";
|
|
12
12
|
import "../chunk-6VPSJFO4.js";
|
|
13
13
|
import "../chunk-KDC67LIN.js";
|
|
14
14
|
import "../chunk-MLKGABMK.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
type DecisionValue = 0 | 1;
|
|
2
|
+
interface DecisionPayload {
|
|
3
|
+
version: string;
|
|
4
|
+
payId: string;
|
|
5
|
+
payer: string;
|
|
6
|
+
receiver: string;
|
|
7
|
+
asset: string;
|
|
8
|
+
amount: bigint;
|
|
9
|
+
contextHash: string;
|
|
10
|
+
ruleSetHash: string;
|
|
11
|
+
ruleAuthority: string;
|
|
12
|
+
issuedAt: bigint;
|
|
13
|
+
expiresAt: bigint;
|
|
14
|
+
nonce: string;
|
|
15
|
+
requiresAttestation: boolean;
|
|
16
|
+
attestationUIDsHash: string;
|
|
17
|
+
}
|
|
18
|
+
interface DecisionProof {
|
|
19
|
+
payload: DecisionPayload;
|
|
20
|
+
signature: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type { DecisionPayload as D, DecisionProof as a, DecisionValue as b };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
interface RuleResult {
|
|
2
|
+
decision: "ALLOW" | "REJECT";
|
|
3
|
+
code: string;
|
|
4
|
+
reason?: string;
|
|
5
|
+
}
|
|
6
|
+
interface RuleTraceEntry {
|
|
7
|
+
ruleId: string;
|
|
8
|
+
field: string;
|
|
9
|
+
op: string;
|
|
10
|
+
expected: any;
|
|
11
|
+
actual: any;
|
|
12
|
+
result: "PASS" | "FAIL";
|
|
13
|
+
}
|
|
14
|
+
interface RuleDecisionDebug {
|
|
15
|
+
trace: RuleTraceEntry[];
|
|
16
|
+
}
|
|
17
|
+
interface RuleResultDebug extends RuleResult {
|
|
18
|
+
debug?: RuleDecisionDebug;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface RuleSource {
|
|
22
|
+
uri: string;
|
|
23
|
+
hash?: string;
|
|
24
|
+
}
|
|
25
|
+
interface ResolverOptions {
|
|
26
|
+
zgIndexerUrl?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type { ResolverOptions as R, RuleDecisionDebug as a, RuleResult as b, RuleResultDebug as c, RuleSource as d, RuleTraceEntry as e };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payid",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -47,6 +47,12 @@
|
|
|
47
47
|
"import": "./dist/core/server/index.js",
|
|
48
48
|
"require": "./dist/core/server/index.js",
|
|
49
49
|
"default": "./dist/core/server/index.js"
|
|
50
|
+
},
|
|
51
|
+
"./decision-proof": {
|
|
52
|
+
"types": "./dist/decision-proof/index.d.ts",
|
|
53
|
+
"import": "./dist/decision-proof/index.js",
|
|
54
|
+
"require": "./dist/decision-proof/index.js",
|
|
55
|
+
"default": "./dist/decision-proof/index.js"
|
|
50
56
|
}
|
|
51
57
|
},
|
|
52
58
|
"files": [
|
package/dist/types-i4eTkhWa.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
interface RuleResult {
|
|
2
|
-
decision: "ALLOW" | "REJECT";
|
|
3
|
-
code: string;
|
|
4
|
-
reason?: string;
|
|
5
|
-
}
|
|
6
|
-
interface RuleTraceEntry {
|
|
7
|
-
ruleId: string;
|
|
8
|
-
field: string;
|
|
9
|
-
op: string;
|
|
10
|
-
expected: any;
|
|
11
|
-
actual: any;
|
|
12
|
-
result: "PASS" | "FAIL";
|
|
13
|
-
}
|
|
14
|
-
interface RuleDecisionDebug {
|
|
15
|
-
trace: RuleTraceEntry[];
|
|
16
|
-
}
|
|
17
|
-
interface RuleResultDebug extends RuleResult {
|
|
18
|
-
debug?: RuleDecisionDebug;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
interface DecisionPayload {
|
|
22
|
-
version: string;
|
|
23
|
-
payId: string;
|
|
24
|
-
payer: string;
|
|
25
|
-
receiver: string;
|
|
26
|
-
asset: string;
|
|
27
|
-
amount: bigint;
|
|
28
|
-
contextHash: string;
|
|
29
|
-
ruleSetHash: string;
|
|
30
|
-
ruleAuthority: string;
|
|
31
|
-
issuedAt: bigint;
|
|
32
|
-
expiresAt: bigint;
|
|
33
|
-
nonce: string;
|
|
34
|
-
requiresAttestation: boolean;
|
|
35
|
-
attestationUIDsHash: string;
|
|
36
|
-
}
|
|
37
|
-
interface DecisionProof {
|
|
38
|
-
payload: DecisionPayload;
|
|
39
|
-
signature: string;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
interface RuleSource {
|
|
43
|
-
uri: string;
|
|
44
|
-
hash?: string;
|
|
45
|
-
}
|
|
46
|
-
interface ResolverOptions {
|
|
47
|
-
zgIndexerUrl?: string;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export type { DecisionPayload as D, ResolverOptions as R, DecisionProof as a, RuleDecisionDebug as b, RuleResult as c, RuleResultDebug as d, RuleSource as e, RuleTraceEntry as f };
|