payid 0.3.9 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +689 -18
- package/dist/index.js +780 -52
- package/package.json +3 -3
- package/dist/chunk-5ZEKI5Y2.js +0 -18
- package/dist/chunk-7U3P7XJE.js +0 -67
- package/dist/chunk-AOKLY2QN.js +0 -24
- package/dist/chunk-ATWJEWZH.js +0 -47
- package/dist/chunk-JJEWYFOV.js +0 -42
- package/dist/chunk-JRVCGSKK.js +0 -30
- package/dist/chunk-METOE7DV.js +0 -264
- package/dist/chunk-MXKZJKXE.js +0 -33
- package/dist/chunk-QYH3FNQ4.js +0 -19
- package/dist/chunk-R5U7XKVJ.js +0 -16
- package/dist/chunk-RCXMRX4F.js +0 -54
- package/dist/chunk-SIHQPH55.js +0 -139
- package/dist/chunk-UBGZH6HB.js +0 -90
- package/dist/context/index.d.ts +0 -3
- package/dist/context/index.js +0 -8
- package/dist/core/client/index.d.ts +0 -5
- package/dist/core/client/index.js +0 -12
- package/dist/core/server/index.d.ts +0 -4
- package/dist/core/server/index.js +0 -9
- package/dist/index-2JCvey4-.d.ts +0 -23
- package/dist/index-BEvnPzzt.d.ts +0 -160
- package/dist/index-C7vziL_Z.d.ts +0 -150
- package/dist/index-CiTDNVSZ.d.ts +0 -158
- package/dist/index-DuOeYzN2.d.ts +0 -118
- package/dist/index-on2SYkvq.d.ts +0 -114
- package/dist/issuer/index.d.ts +0 -3
- package/dist/issuer/index.js +0 -16
- package/dist/rule/index.d.ts +0 -2
- package/dist/rule/index.js +0 -15
- package/dist/sessionPolicy/index.d.ts +0 -4
- package/dist/sessionPolicy/index.js +0 -13
- package/dist/types-B8pJQdMQ.d.ts +0 -26
- package/dist/types-DKt-zH0P.d.ts +0 -15
package/dist/chunk-SIHQPH55.js
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
evaluate,
|
|
3
|
-
generateDecisionProof,
|
|
4
|
-
resolveRule
|
|
5
|
-
} from "./chunk-METOE7DV.js";
|
|
6
|
-
import {
|
|
7
|
-
__export
|
|
8
|
-
} from "./chunk-R5U7XKVJ.js";
|
|
9
|
-
|
|
10
|
-
// src/core/server/index.ts
|
|
11
|
-
var server_exports = {};
|
|
12
|
-
__export(server_exports, {
|
|
13
|
-
createPayID: () => createPayID
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
// src/erc4337/build.ts
|
|
17
|
-
import { ethers } from "ethers";
|
|
18
|
-
var PAY_WITH_PAYID_ABI = [
|
|
19
|
-
// ETH payment — attestationUIDs adalah EAS UIDs, pass [] jika tidak perlu
|
|
20
|
-
"function payETH((bytes32 version, bytes32 payId, address payer, address receiver, address asset, uint256 amount, bytes32 contextHash, bytes32 ruleSetHash, address ruleAuthority, uint64 issuedAt, uint64 expiresAt, bytes32 nonce, bool requiresAttestation) d, bytes sig, bytes32[] attestationUIDs) payable",
|
|
21
|
-
// ERC20 payment
|
|
22
|
-
"function payERC20((bytes32 version, bytes32 payId, address payer, address receiver, address asset, uint256 amount, bytes32 contextHash, bytes32 ruleSetHash, address ruleAuthority, uint64 issuedAt, uint64 expiresAt, bytes32 nonce, bool requiresAttestation) d, bytes sig, bytes32[] attestationUIDs)"
|
|
23
|
-
];
|
|
24
|
-
function buildPayETHCallData(contractAddress, proof, attestationUIDs = []) {
|
|
25
|
-
const iface = new ethers.Interface(PAY_WITH_PAYID_ABI);
|
|
26
|
-
return iface.encodeFunctionData("payETH", [
|
|
27
|
-
proof.payload,
|
|
28
|
-
proof.signature,
|
|
29
|
-
attestationUIDs
|
|
30
|
-
]);
|
|
31
|
-
}
|
|
32
|
-
function buildPayERC20CallData(contractAddress, proof, attestationUIDs = []) {
|
|
33
|
-
const iface = new ethers.Interface(PAY_WITH_PAYID_ABI);
|
|
34
|
-
return iface.encodeFunctionData("payERC20", [
|
|
35
|
-
proof.payload,
|
|
36
|
-
proof.signature,
|
|
37
|
-
attestationUIDs
|
|
38
|
-
]);
|
|
39
|
-
}
|
|
40
|
-
function buildPayCallData(contractAddress, proof, attestationUIDs = []) {
|
|
41
|
-
return buildPayERC20CallData(contractAddress, proof, attestationUIDs);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// src/erc4337/userop.ts
|
|
45
|
-
function buildUserOperation(params) {
|
|
46
|
-
return {
|
|
47
|
-
sender: params.sender,
|
|
48
|
-
nonce: params.nonce,
|
|
49
|
-
initCode: params.initCode ?? "0x",
|
|
50
|
-
callData: params.callData,
|
|
51
|
-
callGasLimit: params.gas.callGasLimit,
|
|
52
|
-
verificationGasLimit: params.gas.verificationGasLimit,
|
|
53
|
-
preVerificationGas: params.gas.preVerificationGas,
|
|
54
|
-
maxFeePerGas: params.gas.maxFeePerGas,
|
|
55
|
-
maxPriorityFeePerGas: params.gas.maxPriorityFeePerGas,
|
|
56
|
-
paymasterAndData: params.paymasterAndData ?? "0x",
|
|
57
|
-
signature: "0x"
|
|
58
|
-
// signed later by smart account
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// src/core/server/server.ts
|
|
63
|
-
function isRuleSource(rule) {
|
|
64
|
-
return typeof rule === "object" && rule !== null && "uri" in rule;
|
|
65
|
-
}
|
|
66
|
-
var PayIDServer = class {
|
|
67
|
-
constructor(wasm, signer, trustedIssuers, debugTrace) {
|
|
68
|
-
this.wasm = wasm;
|
|
69
|
-
this.signer = signer;
|
|
70
|
-
this.trustedIssuers = trustedIssuers;
|
|
71
|
-
this.debugTrace = debugTrace;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Evaluate + generate proof dengan signer dari constructor
|
|
75
|
-
*/
|
|
76
|
-
async evaluateAndProve(params) {
|
|
77
|
-
const authorityConfig = isRuleSource(params.authorityRule) ? (await resolveRule(params.authorityRule)).config : params.authorityRule;
|
|
78
|
-
const evalConfig = params.evaluationRule ?? authorityConfig;
|
|
79
|
-
const result = await evaluate(
|
|
80
|
-
this.wasm,
|
|
81
|
-
params.context,
|
|
82
|
-
evalConfig,
|
|
83
|
-
{
|
|
84
|
-
debug: this.debugTrace,
|
|
85
|
-
trustedIssuers: this.trustedIssuers
|
|
86
|
-
}
|
|
87
|
-
);
|
|
88
|
-
if (result.decision !== "ALLOW") {
|
|
89
|
-
return { result, proof: null };
|
|
90
|
-
}
|
|
91
|
-
const proof = await generateDecisionProof({
|
|
92
|
-
payId: params.payId,
|
|
93
|
-
payer: params.payer,
|
|
94
|
-
receiver: params.receiver,
|
|
95
|
-
asset: params.asset,
|
|
96
|
-
amount: params.amount,
|
|
97
|
-
context: params.context,
|
|
98
|
-
ruleConfig: authorityConfig,
|
|
99
|
-
signer: this.signer,
|
|
100
|
-
verifyingContract: params.verifyingContract,
|
|
101
|
-
ruleAuthority: params.ruleAuthority,
|
|
102
|
-
chainId: params.context?.tx?.chainId,
|
|
103
|
-
ttlSeconds: params.ttlSeconds
|
|
104
|
-
});
|
|
105
|
-
return { result, proof };
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Build ERC-4337 UserOperation dari Decision Proof
|
|
109
|
-
* Untuk bundler/relayer — server only
|
|
110
|
-
*/
|
|
111
|
-
buildUserOperation(params) {
|
|
112
|
-
const callData = buildPayCallData(params.targetContract, params.proof);
|
|
113
|
-
return buildUserOperation({
|
|
114
|
-
sender: params.smartAccount,
|
|
115
|
-
nonce: params.nonce,
|
|
116
|
-
callData,
|
|
117
|
-
gas: params.gas,
|
|
118
|
-
paymasterAndData: params.paymasterAndData
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
// src/core/server/index.ts
|
|
124
|
-
function createPayID(params) {
|
|
125
|
-
return new PayIDServer(
|
|
126
|
-
params.wasm,
|
|
127
|
-
params.signer,
|
|
128
|
-
params.trustedIssuers,
|
|
129
|
-
params.debugTrace ?? false
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export {
|
|
134
|
-
buildPayETHCallData,
|
|
135
|
-
buildPayERC20CallData,
|
|
136
|
-
buildUserOperation,
|
|
137
|
-
createPayID,
|
|
138
|
-
server_exports
|
|
139
|
-
};
|
package/dist/chunk-UBGZH6HB.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
combineRules
|
|
3
|
-
} from "./chunk-QYH3FNQ4.js";
|
|
4
|
-
import {
|
|
5
|
-
decodeSessionPolicy
|
|
6
|
-
} from "./chunk-MXKZJKXE.js";
|
|
7
|
-
import {
|
|
8
|
-
evaluate,
|
|
9
|
-
generateDecisionProof,
|
|
10
|
-
resolveRule
|
|
11
|
-
} from "./chunk-METOE7DV.js";
|
|
12
|
-
import {
|
|
13
|
-
__export
|
|
14
|
-
} from "./chunk-R5U7XKVJ.js";
|
|
15
|
-
|
|
16
|
-
// src/core/client/index.ts
|
|
17
|
-
var client_exports = {};
|
|
18
|
-
__export(client_exports, {
|
|
19
|
-
createPayID: () => createPayID
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
// src/core/client/client.ts
|
|
23
|
-
import "ethers";
|
|
24
|
-
function isRuleSource(rule) {
|
|
25
|
-
return typeof rule === "object" && rule !== null && "uri" in rule;
|
|
26
|
-
}
|
|
27
|
-
var PayIDClient = class {
|
|
28
|
-
constructor(wasm, debugTrace) {
|
|
29
|
-
this.wasm = wasm;
|
|
30
|
-
this.debugTrace = debugTrace;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Pure rule evaluation — client-safe, no signing, no server
|
|
34
|
-
*/
|
|
35
|
-
async evaluate(context, rule) {
|
|
36
|
-
const config = isRuleSource(rule) ? (await resolveRule(rule)).config : rule;
|
|
37
|
-
return evaluate(this.wasm, context, config, { debug: this.debugTrace });
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Evaluate + generate EIP-712 Decision Proof.
|
|
41
|
-
* Payer sign sendiri menggunakan wallet mereka — tidak butuh server.
|
|
42
|
-
*/
|
|
43
|
-
async evaluateAndProve(params) {
|
|
44
|
-
const authorityConfig = isRuleSource(params.authorityRule) ? (await resolveRule(params.authorityRule)).config : params.authorityRule;
|
|
45
|
-
const evalConfig = params.evaluationRule ?? (params.sessionPolicy ? combineRules(
|
|
46
|
-
authorityConfig,
|
|
47
|
-
decodeSessionPolicy(
|
|
48
|
-
params.sessionPolicy,
|
|
49
|
-
Math.floor(Date.now() / 1e3)
|
|
50
|
-
).rules
|
|
51
|
-
) : authorityConfig);
|
|
52
|
-
const result = await evaluate(
|
|
53
|
-
this.wasm,
|
|
54
|
-
params.context,
|
|
55
|
-
evalConfig,
|
|
56
|
-
{ debug: this.debugTrace }
|
|
57
|
-
);
|
|
58
|
-
if (result.decision !== "ALLOW") {
|
|
59
|
-
return { result, proof: null };
|
|
60
|
-
}
|
|
61
|
-
const proof = await generateDecisionProof({
|
|
62
|
-
payId: params.payId,
|
|
63
|
-
payer: params.payer,
|
|
64
|
-
receiver: params.receiver,
|
|
65
|
-
asset: params.asset,
|
|
66
|
-
amount: params.amount,
|
|
67
|
-
context: params.context,
|
|
68
|
-
ruleConfig: authorityConfig,
|
|
69
|
-
signer: params.signer,
|
|
70
|
-
verifyingContract: params.verifyingContract,
|
|
71
|
-
ruleAuthority: params.ruleAuthority,
|
|
72
|
-
chainId: params.context?.tx?.chainId,
|
|
73
|
-
ttlSeconds: params.ttlSeconds
|
|
74
|
-
});
|
|
75
|
-
return { result, proof };
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
// src/core/client/index.ts
|
|
80
|
-
function createPayID(params) {
|
|
81
|
-
return new PayIDClient(
|
|
82
|
-
params.wasm,
|
|
83
|
-
params.debugTrace ?? false
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export {
|
|
88
|
-
createPayID,
|
|
89
|
-
client_exports
|
|
90
|
-
};
|
package/dist/context/index.d.ts
DELETED
package/dist/context/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createPayID
|
|
3
|
-
} from "../../chunk-UBGZH6HB.js";
|
|
4
|
-
import "../../chunk-QYH3FNQ4.js";
|
|
5
|
-
import "../../chunk-MXKZJKXE.js";
|
|
6
|
-
import "../../chunk-JJEWYFOV.js";
|
|
7
|
-
import "../../chunk-METOE7DV.js";
|
|
8
|
-
import "../../chunk-5ZEKI5Y2.js";
|
|
9
|
-
import "../../chunk-R5U7XKVJ.js";
|
|
10
|
-
export {
|
|
11
|
-
createPayID
|
|
12
|
-
};
|
package/dist/index-2JCvey4-.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { EnvContext, OracleContext, RiskContext, StateContext, Attestation } from 'payid-types';
|
|
2
|
-
import { Wallet } from 'ethers';
|
|
3
|
-
|
|
4
|
-
declare function issueEnvContext(wallet: Wallet): Promise<EnvContext>;
|
|
5
|
-
|
|
6
|
-
declare function issueOracleContext(wallet: Wallet, data: Record<string, string | number>): Promise<OracleContext>;
|
|
7
|
-
|
|
8
|
-
declare function issueRiskContext(wallet: Wallet, score: number, category: string, modelHash: string): Promise<RiskContext>;
|
|
9
|
-
|
|
10
|
-
declare function issueStateContext(wallet: Wallet, spentToday: string, period: string): Promise<StateContext>;
|
|
11
|
-
|
|
12
|
-
declare function signAttestation(issuerWallet: Wallet, payload: object, ttlSeconds?: number): Promise<Attestation>;
|
|
13
|
-
|
|
14
|
-
declare const index_issueEnvContext: typeof issueEnvContext;
|
|
15
|
-
declare const index_issueOracleContext: typeof issueOracleContext;
|
|
16
|
-
declare const index_issueRiskContext: typeof issueRiskContext;
|
|
17
|
-
declare const index_issueStateContext: typeof issueStateContext;
|
|
18
|
-
declare const index_signAttestation: typeof signAttestation;
|
|
19
|
-
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 };
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export { issueEnvContext as a, issueOracleContext as b, issueRiskContext as c, issueStateContext as d, index as i, signAttestation as s };
|
package/dist/index-BEvnPzzt.d.ts
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { Wallet } from 'ethers';
|
|
2
|
-
import { ContextV1, ContextV2 } from 'payid-types';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Build an attested Context V2 object from a base execution context
|
|
6
|
-
* and a set of optional attestation issuers.
|
|
7
|
-
*
|
|
8
|
-
* ## Purpose
|
|
9
|
-
*
|
|
10
|
-
* This function assembles **Context V2**, which extends a raw
|
|
11
|
-
* execution context (Context V1) with **cryptographically attested
|
|
12
|
-
* facts** such as:
|
|
13
|
-
* - Environment data (time, runtime conditions)
|
|
14
|
-
* - Stateful data (daily spend, quotas)
|
|
15
|
-
* - Oracle data (country, FX rate, KYC attributes)
|
|
16
|
-
* - Risk signals (ML score, risk category)
|
|
17
|
-
*
|
|
18
|
-
* The resulting context is suitable for:
|
|
19
|
-
* - Deterministic rule evaluation
|
|
20
|
-
* - Context V2 verification via `preprocessContextV2`
|
|
21
|
-
* - Off-chain decision proof generation
|
|
22
|
-
* - On-chain attestation verification
|
|
23
|
-
*
|
|
24
|
-
* ## Trust model
|
|
25
|
-
*
|
|
26
|
-
* - Each context domain (`env`, `state`, `oracle`, `risk`) MUST be
|
|
27
|
-
* issued and signed by a trusted issuer.
|
|
28
|
-
* - The rule engine does NOT trust raw values; it only trusts
|
|
29
|
-
* verified attestations.
|
|
30
|
-
* - Which domains are required is determined by `ruleConfig.requires`.
|
|
31
|
-
*
|
|
32
|
-
* ## Responsibility
|
|
33
|
-
*
|
|
34
|
-
* This function:
|
|
35
|
-
* - Calls the appropriate issuer functions to generate attestations
|
|
36
|
-
* - Aggregates all issued contexts into a single Context V2 object
|
|
37
|
-
* - Does NOT evaluate rules
|
|
38
|
-
* - Does NOT perform attestation verification
|
|
39
|
-
*
|
|
40
|
-
* ## Environment
|
|
41
|
-
*
|
|
42
|
-
* This function may be called from:
|
|
43
|
-
* - Backend services
|
|
44
|
-
* - Relayers / bundlers
|
|
45
|
-
* - Edge runtimes
|
|
46
|
-
*
|
|
47
|
-
* It SHOULD NOT be called directly from untrusted clients unless
|
|
48
|
-
* issuer keys are properly secured.
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* ### Minimal Context V2 (env + state only)
|
|
52
|
-
*
|
|
53
|
-
* ```ts
|
|
54
|
-
* const contextV2 = await buildContextV2({
|
|
55
|
-
* baseContext: {
|
|
56
|
-
* tx,
|
|
57
|
-
* payId
|
|
58
|
-
* },
|
|
59
|
-
* env: {
|
|
60
|
-
* issuer: envIssuer
|
|
61
|
-
* },
|
|
62
|
-
* state: {
|
|
63
|
-
* issuer: stateIssuer,
|
|
64
|
-
* spentToday: "2500000",
|
|
65
|
-
* period: "DAY"
|
|
66
|
-
* }
|
|
67
|
-
* });
|
|
68
|
-
* ```
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* ### Full Context V2 (env + state + oracle + risk)
|
|
72
|
-
*
|
|
73
|
-
* ```ts
|
|
74
|
-
* const contextV2 = await buildContextV2({
|
|
75
|
-
* baseContext: {
|
|
76
|
-
* tx,
|
|
77
|
-
* payId
|
|
78
|
-
* },
|
|
79
|
-
* env: {
|
|
80
|
-
* issuer: envIssuer
|
|
81
|
-
* },
|
|
82
|
-
* state: {
|
|
83
|
-
* issuer: stateIssuer,
|
|
84
|
-
* spentToday: "2500000",
|
|
85
|
-
* period: "DAY"
|
|
86
|
-
* },
|
|
87
|
-
* oracle: {
|
|
88
|
-
* issuer: oracleIssuer,
|
|
89
|
-
* data: {
|
|
90
|
-
* country: "ID",
|
|
91
|
-
* fxRate: 15600
|
|
92
|
-
* }
|
|
93
|
-
* },
|
|
94
|
-
* risk: {
|
|
95
|
-
* issuer: riskIssuer,
|
|
96
|
-
* score: 72,
|
|
97
|
-
* category: "MEDIUM",
|
|
98
|
-
* modelHash: "0xmodelhash123"
|
|
99
|
-
* }
|
|
100
|
-
* });
|
|
101
|
-
* ```
|
|
102
|
-
*
|
|
103
|
-
* @param params
|
|
104
|
-
* Context assembly parameters.
|
|
105
|
-
*
|
|
106
|
-
* @param params.baseContext
|
|
107
|
-
* Base execution context (Context V1), containing transaction
|
|
108
|
-
* and PayID-related fields.
|
|
109
|
-
*
|
|
110
|
-
* @param params.env
|
|
111
|
-
* Optional environment attestation.
|
|
112
|
-
* Typically used for time-based or runtime constraints.
|
|
113
|
-
*
|
|
114
|
-
* @param params.state
|
|
115
|
-
* Optional state attestation.
|
|
116
|
-
* Used for cumulative values such as daily spend or quota tracking.
|
|
117
|
-
*
|
|
118
|
-
* @param params.oracle
|
|
119
|
-
* Optional oracle attestation.
|
|
120
|
-
* Used for external facts such as country, FX rate, or KYC signals.
|
|
121
|
-
*
|
|
122
|
-
* @param params.risk
|
|
123
|
-
* Optional risk attestation.
|
|
124
|
-
* Used for ML-based risk scoring and categorization.
|
|
125
|
-
*
|
|
126
|
-
* @returns
|
|
127
|
-
* A fully assembled Context V2 object containing the base context
|
|
128
|
-
* and all requested attested sub-contexts.
|
|
129
|
-
*
|
|
130
|
-
* @throws
|
|
131
|
-
* May throw if attestation issuance fails for any domain.
|
|
132
|
-
*/
|
|
133
|
-
declare function buildContextV2(params: {
|
|
134
|
-
baseContext: ContextV1;
|
|
135
|
-
env?: {
|
|
136
|
-
issuer: Wallet;
|
|
137
|
-
};
|
|
138
|
-
state?: {
|
|
139
|
-
issuer: Wallet;
|
|
140
|
-
spentToday: string;
|
|
141
|
-
period: string;
|
|
142
|
-
};
|
|
143
|
-
oracle?: {
|
|
144
|
-
issuer: Wallet;
|
|
145
|
-
data: Record<string, string | number>;
|
|
146
|
-
};
|
|
147
|
-
risk?: {
|
|
148
|
-
issuer: Wallet;
|
|
149
|
-
score: number;
|
|
150
|
-
category: string;
|
|
151
|
-
modelHash: string;
|
|
152
|
-
};
|
|
153
|
-
}): Promise<ContextV2>;
|
|
154
|
-
|
|
155
|
-
declare const index_buildContextV2: typeof buildContextV2;
|
|
156
|
-
declare namespace index {
|
|
157
|
-
export { index_buildContextV2 as buildContextV2 };
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export { buildContextV2 as b, index as i };
|
package/dist/index-C7vziL_Z.d.ts
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { RuleConfig } from 'payid-types';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Combine an authoritative rule set with additional ephemeral rules
|
|
5
|
-
* for off-chain evaluation.
|
|
6
|
-
*
|
|
7
|
-
* This helper merges:
|
|
8
|
-
* - A **default (authoritative) rule set** owned by the receiver
|
|
9
|
-
* - One or more **ephemeral rule constraints** (e.g. session / QR rules)
|
|
10
|
-
*
|
|
11
|
-
* The resulting rule set is intended **ONLY for off-chain evaluation**
|
|
12
|
-
* and MUST NOT be used as an authoritative rule on-chain.
|
|
13
|
-
*
|
|
14
|
-
* ## Security model
|
|
15
|
-
*
|
|
16
|
-
* - The default rule set defines sovereignty and ownership.
|
|
17
|
-
* - Ephemeral rules can only further restrict behavior
|
|
18
|
-
* (logical AND composition).
|
|
19
|
-
* - Ephemeral rules MUST NOT bypass or weaken default rules.
|
|
20
|
-
*
|
|
21
|
-
* ## Canonicalization
|
|
22
|
-
*
|
|
23
|
-
* - The combined rule set is canonicalized to ensure deterministic
|
|
24
|
-
* hashing and evaluation behavior.
|
|
25
|
-
*
|
|
26
|
-
* ## Invariants
|
|
27
|
-
*
|
|
28
|
-
* - The resulting rule set always uses logical AND semantics.
|
|
29
|
-
* - Rule order is normalized via canonicalization.
|
|
30
|
-
*
|
|
31
|
-
* @param defaultRuleSet
|
|
32
|
-
* The authoritative rule configuration (on-chain registered).
|
|
33
|
-
*
|
|
34
|
-
* @param sessionRule
|
|
35
|
-
* A list of additional rule conditions derived from an ephemeral
|
|
36
|
-
* policy (session, QR, intent, etc.).
|
|
37
|
-
*
|
|
38
|
-
* @returns
|
|
39
|
-
* A canonicalized rule configuration suitable for off-chain
|
|
40
|
-
* evaluation.
|
|
41
|
-
*/
|
|
42
|
-
declare function combineRules(defaultRuleSet: RuleConfig, sessionRule: any[]): {
|
|
43
|
-
version: string;
|
|
44
|
-
logic: "AND" | "OR";
|
|
45
|
-
rules: {
|
|
46
|
-
id: any;
|
|
47
|
-
if: any;
|
|
48
|
-
}[];
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Canonicalize a rule set into a deterministic, order-independent form.
|
|
53
|
-
*
|
|
54
|
-
* Canonicalization ensures that semantically identical rule sets
|
|
55
|
-
* always produce the same structural representation, regardless of:
|
|
56
|
-
* - Rule insertion order
|
|
57
|
-
* - Object key order
|
|
58
|
-
* - Nested object layout
|
|
59
|
-
*
|
|
60
|
-
* This function is CRITICAL for:
|
|
61
|
-
* - Rule hashing (`ruleSetHash`)
|
|
62
|
-
* - Policy signing (QR / session / intent)
|
|
63
|
-
* - Consistent off-chain evaluation
|
|
64
|
-
*
|
|
65
|
-
* ## Canonicalization rules
|
|
66
|
-
*
|
|
67
|
-
* - Rules are normalized individually.
|
|
68
|
-
* - Rule entries are sorted lexicographically by `id`.
|
|
69
|
-
* - All nested objects are recursively sorted by key.
|
|
70
|
-
* - Arrays preserve their original order unless explicitly sorted.
|
|
71
|
-
*
|
|
72
|
-
* ## Security model
|
|
73
|
-
*
|
|
74
|
-
* - Canonicalization MUST be applied BEFORE hashing or signing.
|
|
75
|
-
* - Canonicalization MUST NOT be applied during verification
|
|
76
|
-
* (the verified payload must match exactly what was signed).
|
|
77
|
-
*
|
|
78
|
-
* ## Invariants
|
|
79
|
-
*
|
|
80
|
-
* - Canonicalization does NOT change rule semantics.
|
|
81
|
-
* - Canonicalization does NOT weaken rule constraints.
|
|
82
|
-
* - Canonicalization is a pure, deterministic operation.
|
|
83
|
-
*
|
|
84
|
-
* @param ruleSet
|
|
85
|
-
* A rule configuration object containing:
|
|
86
|
-
* - `version`: rule schema version
|
|
87
|
-
* - `logic`: logical operator ("AND" | "OR")
|
|
88
|
-
* - `rules`: list of rule definitions
|
|
89
|
-
*
|
|
90
|
-
* @returns
|
|
91
|
-
* A canonicalized rule configuration suitable for hashing,
|
|
92
|
-
* signing, and deterministic evaluation.
|
|
93
|
-
*/
|
|
94
|
-
declare function canonicalizeRuleSet(ruleSet: {
|
|
95
|
-
version: string;
|
|
96
|
-
logic: "AND" | "OR";
|
|
97
|
-
rules: any[];
|
|
98
|
-
}): {
|
|
99
|
-
version: string;
|
|
100
|
-
logic: "AND" | "OR";
|
|
101
|
-
rules: {
|
|
102
|
-
id: any;
|
|
103
|
-
if: any;
|
|
104
|
-
}[];
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Compute a deterministic hash of a canonicalized rule set.
|
|
109
|
-
*
|
|
110
|
-
* This function produces the `ruleSetHash` used to:
|
|
111
|
-
* - Reference authoritative rules in on-chain registries
|
|
112
|
-
* - Bind decision proofs to a specific rule configuration
|
|
113
|
-
* - Ensure integrity between off-chain evaluation and on-chain verification
|
|
114
|
-
*
|
|
115
|
-
* ## Canonicalization requirement
|
|
116
|
-
*
|
|
117
|
-
* - The input rule set MUST already be canonicalized using
|
|
118
|
-
* `canonicalizeRuleSet`.
|
|
119
|
-
* - Hashing a non-canonical rule set may result in inconsistent
|
|
120
|
-
* hashes for semantically identical rules.
|
|
121
|
-
*
|
|
122
|
-
* ## Security model
|
|
123
|
-
*
|
|
124
|
-
* - The hash represents the exact structure of the rule set at the
|
|
125
|
-
* time of hashing.
|
|
126
|
-
* - Any mutation (key order, rule order, value change) will produce
|
|
127
|
-
* a different hash.
|
|
128
|
-
*
|
|
129
|
-
* ## Invariants
|
|
130
|
-
*
|
|
131
|
-
* - This function does NOT perform canonicalization.
|
|
132
|
-
* - This function is pure and deterministic.
|
|
133
|
-
* - The same canonical rule set will always yield the same hash.
|
|
134
|
-
*
|
|
135
|
-
* @param ruleSet
|
|
136
|
-
* A canonicalized rule configuration object.
|
|
137
|
-
*
|
|
138
|
-
* @returns
|
|
139
|
-
* A `bytes32` hex string (keccak256) uniquely identifying the rule set.
|
|
140
|
-
*/
|
|
141
|
-
declare function hashRuleSet(ruleSet: any): string;
|
|
142
|
-
|
|
143
|
-
declare const index_canonicalizeRuleSet: typeof canonicalizeRuleSet;
|
|
144
|
-
declare const index_combineRules: typeof combineRules;
|
|
145
|
-
declare const index_hashRuleSet: typeof hashRuleSet;
|
|
146
|
-
declare namespace index {
|
|
147
|
-
export { index_canonicalizeRuleSet as canonicalizeRuleSet, index_combineRules as combineRules, index_hashRuleSet as hashRuleSet };
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export { canonicalizeRuleSet as a, combineRules as c, hashRuleSet as h, index as i };
|