payid 0.4.9 → 0.5.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/{chunk-K2FSXHVA.js → chunk-4RDYA3QD.js} +1 -1
- package/dist/{chunk-AOKLY2QN.js → chunk-J3SM3HWZ.js} +1 -1
- package/dist/{chunk-RCXMRX4F.js → chunk-RICUEGTH.js} +1 -1
- package/dist/{chunk-ILV7Z3IN.js → chunk-U7PPUJJH.js} +12 -1
- package/dist/{chunk-TIK4HPDU.js → chunk-UBYKCXWR.js} +5 -2
- package/dist/{chunk-E262BLMV.js → chunk-YGCGT2JP.js} +1 -1
- package/dist/{chunk-7U3P7XJE.js → chunk-YKCMGGYB.js} +2 -2
- package/dist/context/index.js +2 -2
- package/dist/core/client/index.js +2 -2
- package/dist/core/server/index.js +2 -2
- package/dist/{index-DerQdZmf.d.ts → index-Dj9IEios.d.ts} +8 -30
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -7
- package/dist/issuer/index.js +2 -2
- package/dist/rule/index.d.ts +1 -1
- package/dist/rule/index.js +1 -1
- package/package.json +1 -1
|
@@ -18,9 +18,20 @@ __export(rule_exports, {
|
|
|
18
18
|
|
|
19
19
|
// src/rule/hash.ts
|
|
20
20
|
import { keccak256, toUtf8Bytes } from "ethers";
|
|
21
|
+
function stableStringify(obj) {
|
|
22
|
+
if (Array.isArray(obj)) {
|
|
23
|
+
return `[${obj.map(stableStringify).join(",")}]`;
|
|
24
|
+
}
|
|
25
|
+
if (obj && typeof obj === "object") {
|
|
26
|
+
return `{${Object.keys(obj).sort().map(
|
|
27
|
+
(k) => `"${k}":${stableStringify(obj[k])}`
|
|
28
|
+
).join(",")}}`;
|
|
29
|
+
}
|
|
30
|
+
return JSON.stringify(obj);
|
|
31
|
+
}
|
|
21
32
|
function hashRuleSet(ruleSet) {
|
|
22
33
|
return keccak256(
|
|
23
|
-
toUtf8Bytes(
|
|
34
|
+
toUtf8Bytes(stableStringify(ruleSet))
|
|
24
35
|
);
|
|
25
36
|
}
|
|
26
37
|
|
|
@@ -239,11 +239,14 @@ function stableStringify(obj) {
|
|
|
239
239
|
}
|
|
240
240
|
return JSON.stringify(obj);
|
|
241
241
|
}
|
|
242
|
+
function toUtf8Bytes(str) {
|
|
243
|
+
return new TextEncoder().encode(str);
|
|
244
|
+
}
|
|
242
245
|
function hashContext(context) {
|
|
243
|
-
return keccak256(
|
|
246
|
+
return keccak256(toUtf8Bytes(stableStringify(context)));
|
|
244
247
|
}
|
|
245
248
|
function hashRuleSet(ruleConfig) {
|
|
246
|
-
return keccak256(
|
|
249
|
+
return keccak256(toUtf8Bytes(stableStringify(ruleConfig)));
|
|
247
250
|
}
|
|
248
251
|
|
|
249
252
|
// src/decision-proof/generate.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/issuer/signAttestation.ts
|
|
2
|
-
import { keccak256, toUtf8Bytes } from "ethers";
|
|
2
|
+
import { keccak256, toUtf8Bytes, getBytes } from "ethers";
|
|
3
3
|
async function signAttestation(issuerWallet, payload, ttlSeconds = 60) {
|
|
4
4
|
const issuedAt = Math.floor(Date.now() / 1e3);
|
|
5
5
|
const expiresAt = issuedAt + ttlSeconds;
|
|
@@ -7,7 +7,7 @@ async function signAttestation(issuerWallet, payload, ttlSeconds = 60) {
|
|
|
7
7
|
toUtf8Bytes(JSON.stringify(payload))
|
|
8
8
|
);
|
|
9
9
|
const signature = await issuerWallet.signMessage(
|
|
10
|
-
|
|
10
|
+
getBytes(hash)
|
|
11
11
|
);
|
|
12
12
|
return {
|
|
13
13
|
issuer: issuerWallet.address,
|
package/dist/context/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createPayID
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-YGCGT2JP.js";
|
|
4
4
|
import "../../chunk-GG34PNTF.js";
|
|
5
5
|
import "../../chunk-MXKZJKXE.js";
|
|
6
6
|
import "../../chunk-6VPSJFO4.js";
|
|
7
|
-
import "../../chunk-
|
|
7
|
+
import "../../chunk-UBYKCXWR.js";
|
|
8
8
|
import "../../chunk-5ZEKI5Y2.js";
|
|
9
9
|
import "../../chunk-R5U7XKVJ.js";
|
|
10
10
|
export {
|
|
@@ -67,36 +67,14 @@ declare function canonicalizeRuleSet(ruleSet: {
|
|
|
67
67
|
/**
|
|
68
68
|
* Compute a deterministic hash of a canonicalized rule set.
|
|
69
69
|
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* -
|
|
73
|
-
* -
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* `canonicalizeRuleSet`.
|
|
79
|
-
* - Hashing a non-canonical rule set may result in inconsistent
|
|
80
|
-
* hashes for semantically identical rules.
|
|
81
|
-
*
|
|
82
|
-
* ## Security model
|
|
83
|
-
*
|
|
84
|
-
* - The hash represents the exact structure of the rule set at the
|
|
85
|
-
* time of hashing.
|
|
86
|
-
* - Any mutation (key order, rule order, value change) will produce
|
|
87
|
-
* a different hash.
|
|
88
|
-
*
|
|
89
|
-
* ## Invariants
|
|
90
|
-
*
|
|
91
|
-
* - This function does NOT perform canonicalization.
|
|
92
|
-
* - This function is pure and deterministic.
|
|
93
|
-
* - The same canonical rule set will always yield the same hash.
|
|
94
|
-
*
|
|
95
|
-
* @param ruleSet
|
|
96
|
-
* A canonicalized rule configuration object.
|
|
97
|
-
*
|
|
98
|
-
* @returns
|
|
99
|
-
* A `bytes32` hex string (keccak256) uniquely identifying the rule set.
|
|
70
|
+
* PENTING: Fungsi ini HARUS menggunakan stableStringify (bukan JSON.stringify)
|
|
71
|
+
* agar menghasilkan hash yang sama dengan:
|
|
72
|
+
* - register-combined-rule.ts (canonicalize + keccak256)
|
|
73
|
+
* - decision-proof/hash.ts (hashRuleSet)
|
|
74
|
+
* - CombinedRuleStorage.sol (ruleSetHash tersimpan on-chain)
|
|
75
|
+
*
|
|
76
|
+
* Menggunakan JSON.stringify biasa akan menghasilkan key order berbeda
|
|
77
|
+
* → hash berbeda → getRuleByHash revert dengan RULE_NOT_ACTIVE.
|
|
100
78
|
*/
|
|
101
79
|
declare function hashRuleSet(ruleSet: any): string;
|
|
102
80
|
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { U as UserOperation } from './index-C1DHMQA0.js';
|
|
|
4
4
|
export { i as server } from './index-C1DHMQA0.js';
|
|
5
5
|
import { ethers } from 'ethers';
|
|
6
6
|
export { i as sessionPolicy } from './index-BQQnMG2H.js';
|
|
7
|
-
export { i as rule } from './index-
|
|
7
|
+
export { i as rule } from './index-Dj9IEios.js';
|
|
8
8
|
export { i as issuer } from './index-2JCvey4-.js';
|
|
9
9
|
export { i as context } from './index-BEvnPzzt.js';
|
|
10
10
|
export { i as client } from './index-BUTI_SDh.js';
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
context_exports
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-RICUEGTH.js";
|
|
4
4
|
import {
|
|
5
5
|
issuer_exports
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-J3SM3HWZ.js";
|
|
7
|
+
import "./chunk-YKCMGGYB.js";
|
|
8
8
|
import {
|
|
9
9
|
rule_exports
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-U7PPUJJH.js";
|
|
11
11
|
import {
|
|
12
12
|
sessionPolicy_exports
|
|
13
13
|
} from "./chunk-Y75PSD7U.js";
|
|
14
14
|
import {
|
|
15
15
|
client_exports
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-YGCGT2JP.js";
|
|
17
17
|
import "./chunk-GG34PNTF.js";
|
|
18
18
|
import "./chunk-MXKZJKXE.js";
|
|
19
19
|
import "./chunk-6VPSJFO4.js";
|
|
@@ -22,12 +22,12 @@ import {
|
|
|
22
22
|
buildPayETHCallData,
|
|
23
23
|
buildUserOperation,
|
|
24
24
|
server_exports
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-4RDYA3QD.js";
|
|
26
26
|
import {
|
|
27
27
|
evaluate,
|
|
28
28
|
generateDecisionProof,
|
|
29
29
|
resolveRule
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-UBYKCXWR.js";
|
|
31
31
|
import "./chunk-5ZEKI5Y2.js";
|
|
32
32
|
import {
|
|
33
33
|
__export
|
package/dist/issuer/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import "../chunk-
|
|
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-
|
|
8
|
+
} from "../chunk-YKCMGGYB.js";
|
|
9
9
|
import "../chunk-R5U7XKVJ.js";
|
|
10
10
|
export {
|
|
11
11
|
issueEnvContext,
|
package/dist/rule/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { a as canonicalizeRuleSet, c as combineRules, h as hashRuleSet } from '../index-
|
|
1
|
+
export { a as canonicalizeRuleSet, c as combineRules, h as hashRuleSet } from '../index-Dj9IEios.js';
|
|
2
2
|
import 'payid-types';
|
package/dist/rule/index.js
CHANGED