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.
- package/dist/chunk-AUW7WDAB.js +198 -0
- package/dist/{chunk-SSO66YQI.js → chunk-E6VQETBC.js} +13 -0
- package/dist/{chunk-AYJYFAXJ.js → chunk-ESTGPUEQ.js} +24 -21
- package/dist/{chunk-ROBSNIIZ.js → chunk-EZ3BGZ7G.js} +25 -16
- package/dist/chunk-FZNMDGVK.js +24 -0
- package/dist/chunk-HKHRYRD6.js +752 -0
- package/dist/chunk-X7NYQ47Y.js +27 -0
- package/dist/chunk-XMUHMJRD.js +30 -0
- package/dist/context/index.d.ts +3 -2
- package/dist/context.v1-C1m-tz0o.d.ts +39 -0
- package/dist/context.v2-DIzPotmW.d.ts +37 -0
- package/dist/core/client/index.d.ts +5 -4
- package/dist/core/client/index.js +9 -5
- package/dist/core/server/index.d.ts +4 -3
- package/dist/core/server/index.js +7 -4
- package/dist/{index-2JCvey4-.d.ts → index-CDnE3SGM.d.ts} +18 -3
- package/dist/index-CsynGAGv.d.ts +53 -0
- package/dist/{index-Dj9IEios.d.ts → index-CubM9whW.d.ts} +4 -17
- package/dist/{index-C1DHMQA0.d.ts → index-DSxDlF9J.d.ts} +45 -68
- package/dist/{index-BEvnPzzt.d.ts → index-Dm2VdDEB.d.ts} +2 -1
- package/dist/index-G_1SiZJo.d.ts +104 -0
- package/dist/index.d.ts +407 -72
- package/dist/index.js +582 -77
- package/dist/issuer/index.d.ts +3 -2
- package/dist/issuer/index.js +4 -1
- package/dist/rule/index.d.ts +2 -2
- package/dist/rule/index.js +4 -3
- package/dist/rule-a_5ed-93.d.ts +39 -0
- package/dist/sessionPolicy/index.d.ts +3 -3
- package/dist/sessionPolicy/index.js +17 -6
- package/dist/types-D2o6XS7a.d.ts +66 -0
- package/dist/types-i4eTkhWa.d.ts +50 -0
- package/package.json +22 -9
- package/src/rule/engine/rule_engine.wasm +0 -0
- package/dist/chunk-IQNCMOIE.js +0 -47
- package/dist/chunk-MXKZJKXE.js +0 -33
- package/dist/chunk-PAJYP7JI.js +0 -308
- package/dist/chunk-QC24X74O.js +0 -41
- package/dist/index-BPJ_oOfy.d.ts +0 -81
- package/dist/index-BQQnMG2H.d.ts +0 -114
- package/dist/types-B8pJQdMQ.d.ts +0 -26
- package/dist/types-BmMf7udp.d.ts +0 -13
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import {
|
|
2
|
+
randomHex
|
|
3
|
+
} from "./chunk-KDC67LIN.js";
|
|
4
|
+
|
|
5
|
+
// src/sessionPolicy/create.ts
|
|
6
|
+
import { ethers } from "ethers";
|
|
7
|
+
async function createSessionPolicyPayload(_params) {
|
|
8
|
+
throw new Error(
|
|
9
|
+
"SESSION_POLICY_V1_DISABLED: V1 policies have no chainId binding and are vulnerable to cross-chain replay. Use createSessionPolicyV2() instead."
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
var SESSION_POLICY_V2_DOMAIN_NAME = "PAY.ID SessionPolicy";
|
|
13
|
+
var SESSION_POLICY_V2_DOMAIN_VERSION = "1";
|
|
14
|
+
var SESSION_POLICY_V2_TYPES = {
|
|
15
|
+
SessionPolicy: [
|
|
16
|
+
{ name: "receiver", type: "address" },
|
|
17
|
+
{ name: "ruleSetHash", type: "bytes32" },
|
|
18
|
+
{ name: "ruleAuthority", type: "address" },
|
|
19
|
+
{ name: "allowedAsset", type: "address" },
|
|
20
|
+
{ name: "maxAmount", type: "uint256" },
|
|
21
|
+
{ name: "expiresAt", type: "uint64" },
|
|
22
|
+
{ name: "policyNonce", type: "bytes32" },
|
|
23
|
+
{ name: "payId", type: "bytes32" }
|
|
24
|
+
]
|
|
25
|
+
};
|
|
26
|
+
function buildSessionPolicyV2Domain(chainId, verifyingContract) {
|
|
27
|
+
return {
|
|
28
|
+
name: SESSION_POLICY_V2_DOMAIN_NAME,
|
|
29
|
+
version: SESSION_POLICY_V2_DOMAIN_VERSION,
|
|
30
|
+
chainId,
|
|
31
|
+
verifyingContract
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
async function createSessionPolicyV2(params) {
|
|
35
|
+
const {
|
|
36
|
+
receiver,
|
|
37
|
+
ruleSetHash,
|
|
38
|
+
ruleAuthority,
|
|
39
|
+
allowedAsset,
|
|
40
|
+
maxAmount,
|
|
41
|
+
expiresAt,
|
|
42
|
+
payId,
|
|
43
|
+
chainId,
|
|
44
|
+
verifyingContract,
|
|
45
|
+
signer
|
|
46
|
+
} = params;
|
|
47
|
+
const MIN_TTL_SECONDS = 60;
|
|
48
|
+
const MAX_TTL_SECONDS = 30 * 24 * 3600;
|
|
49
|
+
if (!ethers.isAddress(receiver)) {
|
|
50
|
+
throw new Error(`SESSION_POLICY_V2: receiver address tidak valid: ${receiver}`);
|
|
51
|
+
}
|
|
52
|
+
if (maxAmount <= 0n) {
|
|
53
|
+
throw new Error("SESSION_POLICY_V2: maxAmount harus > 0");
|
|
54
|
+
}
|
|
55
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
56
|
+
if (expiresAt <= now + MIN_TTL_SECONDS) {
|
|
57
|
+
throw new Error(`SESSION_POLICY_V2: expiresAt terlalu dekat \u2014 minimum ${MIN_TTL_SECONDS}s dari sekarang`);
|
|
58
|
+
}
|
|
59
|
+
if (expiresAt > now + MAX_TTL_SECONDS) {
|
|
60
|
+
throw new Error(`SESSION_POLICY_V2: expiresAt terlalu jauh \u2014 maksimum ${MAX_TTL_SECONDS / 86400} hari`);
|
|
61
|
+
}
|
|
62
|
+
const policyNonce = randomHex(32);
|
|
63
|
+
const payIdBytes32 = ethers.keccak256(ethers.toUtf8Bytes(payId));
|
|
64
|
+
const domain = buildSessionPolicyV2Domain(chainId, verifyingContract);
|
|
65
|
+
const value = {
|
|
66
|
+
receiver,
|
|
67
|
+
ruleSetHash,
|
|
68
|
+
ruleAuthority,
|
|
69
|
+
allowedAsset,
|
|
70
|
+
maxAmount,
|
|
71
|
+
expiresAt,
|
|
72
|
+
policyNonce,
|
|
73
|
+
payId: payIdBytes32
|
|
74
|
+
};
|
|
75
|
+
const signature = await signer.signTypedData(
|
|
76
|
+
domain,
|
|
77
|
+
SESSION_POLICY_V2_TYPES,
|
|
78
|
+
value
|
|
79
|
+
);
|
|
80
|
+
const recovered = ethers.verifyTypedData(domain, SESSION_POLICY_V2_TYPES, value, signature);
|
|
81
|
+
if (recovered.toLowerCase() !== receiver.toLowerCase()) {
|
|
82
|
+
throw new Error("SESSION_POLICY_V2: self-verification gagal");
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
version: "payid.session.policy.v2",
|
|
86
|
+
receiver,
|
|
87
|
+
ruleSetHash,
|
|
88
|
+
ruleAuthority,
|
|
89
|
+
allowedAsset,
|
|
90
|
+
maxAmount: maxAmount.toString(),
|
|
91
|
+
expiresAt,
|
|
92
|
+
policyNonce,
|
|
93
|
+
payId,
|
|
94
|
+
chainId,
|
|
95
|
+
verifyingContract,
|
|
96
|
+
signature
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// src/sessionPolicy/decode.ts
|
|
101
|
+
import { ethers as ethers2 } from "ethers";
|
|
102
|
+
function decodeSessionPolicy(sessionPolicy, now) {
|
|
103
|
+
if (sessionPolicy.version !== "payid.session.policy.v1") {
|
|
104
|
+
throw new Error("INVALID_SESSION_POLICY_VERSION");
|
|
105
|
+
}
|
|
106
|
+
if (now > sessionPolicy.expiresAt) {
|
|
107
|
+
throw new Error("SESSION_POLICY_EXPIRED");
|
|
108
|
+
}
|
|
109
|
+
const payload = {
|
|
110
|
+
version: sessionPolicy.version,
|
|
111
|
+
receiver: sessionPolicy.receiver,
|
|
112
|
+
rule: sessionPolicy.rule,
|
|
113
|
+
issuedAt: sessionPolicy.issuedAt,
|
|
114
|
+
expiresAt: sessionPolicy.expiresAt,
|
|
115
|
+
nonce: sessionPolicy.nonce
|
|
116
|
+
};
|
|
117
|
+
const message = ethers2.keccak256(ethers2.toUtf8Bytes(JSON.stringify(payload)));
|
|
118
|
+
const recovered = ethers2.verifyMessage(message, sessionPolicy.signature);
|
|
119
|
+
if (recovered.toLowerCase() !== sessionPolicy.receiver.toLowerCase()) {
|
|
120
|
+
throw new Error("INVALID_SESSION_POLICY_SIGNATURE");
|
|
121
|
+
}
|
|
122
|
+
return sessionPolicy.rule;
|
|
123
|
+
}
|
|
124
|
+
function decodeSessionPolicyV2(policy, blockTimestamp) {
|
|
125
|
+
if (policy.version !== "payid.session.policy.v2") {
|
|
126
|
+
throw new Error("INVALID_SESSION_POLICY_V2_VERSION");
|
|
127
|
+
}
|
|
128
|
+
if (blockTimestamp >= policy.expiresAt) {
|
|
129
|
+
throw new Error("SESSION_POLICY_V2_EXPIRED");
|
|
130
|
+
}
|
|
131
|
+
const payIdBytes32 = ethers2.keccak256(ethers2.toUtf8Bytes(policy.payId));
|
|
132
|
+
const domain = buildSessionPolicyV2Domain(policy.chainId, policy.verifyingContract);
|
|
133
|
+
const value = {
|
|
134
|
+
receiver: policy.receiver,
|
|
135
|
+
ruleSetHash: policy.ruleSetHash,
|
|
136
|
+
ruleAuthority: policy.ruleAuthority,
|
|
137
|
+
allowedAsset: policy.allowedAsset,
|
|
138
|
+
maxAmount: BigInt(policy.maxAmount),
|
|
139
|
+
expiresAt: policy.expiresAt,
|
|
140
|
+
policyNonce: policy.policyNonce,
|
|
141
|
+
payId: payIdBytes32
|
|
142
|
+
};
|
|
143
|
+
const recovered = ethers2.verifyTypedData(domain, SESSION_POLICY_V2_TYPES, value, policy.signature);
|
|
144
|
+
if (recovered.toLowerCase() !== policy.receiver.toLowerCase()) {
|
|
145
|
+
throw new Error("INVALID_SESSION_POLICY_V2_SIGNATURE");
|
|
146
|
+
}
|
|
147
|
+
return policy;
|
|
148
|
+
}
|
|
149
|
+
function encodeSessionPolicyV2QR(policy) {
|
|
150
|
+
const encoded = Buffer.from(JSON.stringify(policy), "utf-8").toString("base64url");
|
|
151
|
+
return `payid-v2:${encoded}`;
|
|
152
|
+
}
|
|
153
|
+
function decodeSessionPolicyV2QR(qrString) {
|
|
154
|
+
const PREFIX = "payid-v2:";
|
|
155
|
+
if (!qrString.startsWith(PREFIX)) {
|
|
156
|
+
throw new Error(
|
|
157
|
+
`QR_FORMAT_UNKNOWN: harus diawali "${PREFIX}". Got: ${qrString.slice(0, 20)}...`
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
let policy;
|
|
161
|
+
try {
|
|
162
|
+
const json = Buffer.from(qrString.slice(PREFIX.length), "base64url").toString("utf-8");
|
|
163
|
+
policy = JSON.parse(json);
|
|
164
|
+
} catch {
|
|
165
|
+
throw new Error("QR_CORRUPT: tidak bisa di-decode");
|
|
166
|
+
}
|
|
167
|
+
const required = [
|
|
168
|
+
"version",
|
|
169
|
+
"receiver",
|
|
170
|
+
"ruleSetHash",
|
|
171
|
+
"ruleAuthority",
|
|
172
|
+
"allowedAsset",
|
|
173
|
+
"maxAmount",
|
|
174
|
+
"expiresAt",
|
|
175
|
+
"policyNonce",
|
|
176
|
+
"payId",
|
|
177
|
+
"chainId",
|
|
178
|
+
"verifyingContract",
|
|
179
|
+
"signature"
|
|
180
|
+
];
|
|
181
|
+
for (const f of required) {
|
|
182
|
+
if (policy[f] == null) {
|
|
183
|
+
throw new Error(`SESSION_POLICY_V2_INVALID: field "${f}" tidak ada`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return policy;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export {
|
|
190
|
+
createSessionPolicyPayload,
|
|
191
|
+
SESSION_POLICY_V2_TYPES,
|
|
192
|
+
buildSessionPolicyV2Domain,
|
|
193
|
+
createSessionPolicyV2,
|
|
194
|
+
decodeSessionPolicy,
|
|
195
|
+
decodeSessionPolicyV2,
|
|
196
|
+
encodeSessionPolicyV2QR,
|
|
197
|
+
decodeSessionPolicyV2QR
|
|
198
|
+
};
|
|
@@ -16,9 +16,22 @@ __export(issuer_exports, {
|
|
|
16
16
|
issueOracleContext: () => issueOracleContext,
|
|
17
17
|
issueRiskContext: () => issueRiskContext,
|
|
18
18
|
issueStateContext: () => issueStateContext,
|
|
19
|
+
issueTokenPriceContext: () => issueTokenPriceContext,
|
|
19
20
|
signAttestation: () => signAttestation
|
|
20
21
|
});
|
|
21
22
|
|
|
23
|
+
// src/issuer/issueTokenPriceContext.ts
|
|
24
|
+
async function issueTokenPriceContext(wallet, tokenPrice, tokenAmount, tokenDecimals) {
|
|
25
|
+
const amountUsd = tokenAmount * tokenPrice / 10n ** BigInt(tokenDecimals + 8);
|
|
26
|
+
const proof = await signAttestation(
|
|
27
|
+
wallet,
|
|
28
|
+
{ amountUsd: amountUsd.toString() },
|
|
29
|
+
120
|
|
30
|
+
);
|
|
31
|
+
return { amountUsd: amountUsd.toString(), proof };
|
|
32
|
+
}
|
|
33
|
+
|
|
22
34
|
export {
|
|
35
|
+
issueTokenPriceContext,
|
|
23
36
|
issuer_exports
|
|
24
37
|
};
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
evaluate,
|
|
3
3
|
generateDecisionProof,
|
|
4
4
|
resolveRule
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-HKHRYRD6.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
|
-
|
|
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
|
-
|
|
20
|
-
|
|
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
|
|
24
|
+
function buildPayNativeCallData(contractAddress, proof, attestationUIDs = []) {
|
|
25
25
|
const iface = new ethers.Interface(PAY_WITH_PAYID_ABI);
|
|
26
|
-
return iface.encodeFunctionData("
|
|
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
|
|
104
|
-
|
|
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
|
|
124
|
+
function createPayIDServer(params) {
|
|
120
125
|
return new PayIDServer(
|
|
121
126
|
params.signer,
|
|
122
127
|
params.trustedIssuers,
|
|
123
|
-
params.debugTrace
|
|
128
|
+
params.debugTrace,
|
|
124
129
|
params.wasm
|
|
125
130
|
);
|
|
126
131
|
}
|
|
127
132
|
|
|
128
133
|
export {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
buildUserOperation,
|
|
132
|
-
createPayID,
|
|
134
|
+
PayIDServer,
|
|
135
|
+
createPayIDServer,
|
|
133
136
|
server_exports
|
|
134
137
|
};
|
|
@@ -2,13 +2,15 @@ import {
|
|
|
2
2
|
combineRules
|
|
3
3
|
} from "./chunk-GG34PNTF.js";
|
|
4
4
|
import {
|
|
5
|
-
decodeSessionPolicy
|
|
6
|
-
|
|
5
|
+
decodeSessionPolicy,
|
|
6
|
+
decodeSessionPolicyV2
|
|
7
|
+
} from "./chunk-AUW7WDAB.js";
|
|
7
8
|
import {
|
|
8
9
|
evaluate,
|
|
9
10
|
generateDecisionProof,
|
|
11
|
+
loadWasm,
|
|
10
12
|
resolveRule
|
|
11
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-HKHRYRD6.js";
|
|
12
14
|
import {
|
|
13
15
|
__export
|
|
14
16
|
} from "./chunk-MLKGABMK.js";
|
|
@@ -16,34 +18,42 @@ import {
|
|
|
16
18
|
// src/core/client/index.ts
|
|
17
19
|
var client_exports = {};
|
|
18
20
|
__export(client_exports, {
|
|
19
|
-
|
|
21
|
+
PayIDClient: () => PayIDClient,
|
|
22
|
+
createPayID: () => createPayIDClient,
|
|
23
|
+
createPayIDClient: () => createPayIDClient
|
|
20
24
|
});
|
|
21
25
|
|
|
22
26
|
// src/core/client/client.ts
|
|
23
|
-
import { loadWasm } from "payid-rule-engine";
|
|
24
27
|
import "ethers";
|
|
25
28
|
function isRuleSource(rule) {
|
|
26
29
|
return typeof rule === "object" && rule !== null && "uri" in rule;
|
|
27
30
|
}
|
|
28
31
|
var PayIDClient = class {
|
|
29
|
-
constructor(debugTrace, wasm) {
|
|
32
|
+
constructor(debugTrace, wasm, resolverOptions) {
|
|
30
33
|
this.debugTrace = debugTrace;
|
|
31
34
|
this.wasm = wasm;
|
|
35
|
+
this.resolverOptions = resolverOptions;
|
|
32
36
|
this._ready = loadWasm(this.wasm).then(() => {
|
|
33
37
|
}).catch(() => {
|
|
34
38
|
});
|
|
35
39
|
}
|
|
40
|
+
debugTrace;
|
|
41
|
+
wasm;
|
|
42
|
+
resolverOptions;
|
|
36
43
|
_ready;
|
|
37
44
|
async ready() {
|
|
38
45
|
return this._ready;
|
|
39
46
|
}
|
|
40
47
|
async evaluate(context, rule) {
|
|
41
|
-
const config = isRuleSource(rule) ? (await resolveRule(rule)).config : rule;
|
|
48
|
+
const config = isRuleSource(rule) ? (await resolveRule(rule, this.resolverOptions)).config : rule;
|
|
42
49
|
return evaluate(context, config, { debug: this.debugTrace }, this.wasm);
|
|
43
50
|
}
|
|
44
51
|
async evaluateAndProve(params) {
|
|
45
|
-
const authorityConfig = isRuleSource(params.authorityRule) ? (await resolveRule(params.authorityRule)).config : params.authorityRule;
|
|
46
|
-
const evalConfig = params.evaluationRule ?? (params.
|
|
52
|
+
const authorityConfig = isRuleSource(params.authorityRule) ? (await resolveRule(params.authorityRule, this.resolverOptions)).config : params.authorityRule;
|
|
53
|
+
const evalConfig = params.evaluationRule ?? (params.sessionPolicyV2 ? (() => {
|
|
54
|
+
decodeSessionPolicyV2(params.sessionPolicyV2, params.blockTimestamp);
|
|
55
|
+
return authorityConfig;
|
|
56
|
+
})() : params.sessionPolicy ? combineRules(
|
|
47
57
|
authorityConfig,
|
|
48
58
|
decodeSessionPolicy(
|
|
49
59
|
params.sessionPolicy,
|
|
@@ -73,21 +83,20 @@ var PayIDClient = class {
|
|
|
73
83
|
ruleAuthority: params.ruleAuthority,
|
|
74
84
|
chainId: params.chainId ?? params.context?.tx?.chainId,
|
|
75
85
|
ttlSeconds: params.ttlSeconds,
|
|
76
|
-
blockTimestamp: params.blockTimestamp
|
|
86
|
+
blockTimestamp: params.blockTimestamp,
|
|
87
|
+
attestationUIDs: params.attestationUIDs
|
|
77
88
|
});
|
|
78
89
|
return { result, proof };
|
|
79
90
|
}
|
|
80
91
|
};
|
|
81
92
|
|
|
82
93
|
// src/core/client/index.ts
|
|
83
|
-
function
|
|
84
|
-
return new PayIDClient(
|
|
85
|
-
params.debugTrace ?? false,
|
|
86
|
-
params.wasm
|
|
87
|
-
);
|
|
94
|
+
function createPayIDClient(params) {
|
|
95
|
+
return new PayIDClient(params?.debugTrace, params?.wasm);
|
|
88
96
|
}
|
|
89
97
|
|
|
90
98
|
export {
|
|
91
|
-
|
|
99
|
+
PayIDClient,
|
|
100
|
+
createPayIDClient,
|
|
92
101
|
client_exports
|
|
93
102
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
combineRules
|
|
3
|
+
} from "./chunk-GG34PNTF.js";
|
|
4
|
+
import {
|
|
5
|
+
canonicalizeRuleSet
|
|
6
|
+
} from "./chunk-6VPSJFO4.js";
|
|
7
|
+
import {
|
|
8
|
+
hashRuleSet
|
|
9
|
+
} from "./chunk-X7NYQ47Y.js";
|
|
10
|
+
import {
|
|
11
|
+
__export
|
|
12
|
+
} from "./chunk-MLKGABMK.js";
|
|
13
|
+
|
|
14
|
+
// src/rule/index.ts
|
|
15
|
+
var rule_exports = {};
|
|
16
|
+
__export(rule_exports, {
|
|
17
|
+
canonicalizeRuleSet: () => canonicalizeRuleSet,
|
|
18
|
+
combineRules: () => combineRules,
|
|
19
|
+
hashRuleSet: () => hashRuleSet
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
rule_exports
|
|
24
|
+
};
|