@gvnrdao/dh-lit-actions 0.0.33 → 0.0.34

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.
Files changed (71) hide show
  1. package/package.json +12 -18
  2. package/pkg-dist/constants/chunks/lit-actions-registry.d.ts.map +1 -1
  3. package/pkg-dist/constants/chunks/{lit-actions-registry.cjs → lit-actions-registry.js} +111 -34
  4. package/pkg-dist/constants/chunks/lit-actions-registry.js.map +1 -0
  5. package/pkg-dist/constants/chunks/{package-registry.cjs → package-registry.js} +1 -1
  6. package/pkg-dist/constants/chunks/package-registry.js.map +1 -0
  7. package/pkg-dist/constants/{index.cjs → index.js} +2 -2
  8. package/pkg-dist/constants/index.js.map +1 -0
  9. package/pkg-dist/{index.cjs → index.js} +4 -4
  10. package/pkg-dist/index.js.map +1 -0
  11. package/pkg-dist/interfaces/chunks/diamond-hands-lit-actions.i.d.ts +4 -0
  12. package/pkg-dist/interfaces/chunks/diamond-hands-lit-actions.i.d.ts.map +1 -1
  13. package/pkg-dist/interfaces/chunks/diamond-hands-lit-actions.i.js.map +1 -0
  14. package/pkg-dist/interfaces/chunks/lit-action-config.i.js.map +1 -0
  15. package/pkg-dist/interfaces/chunks/lit-action-name.i.js.map +1 -0
  16. package/pkg-dist/interfaces/chunks/lit-action-registry.i.js.map +1 -0
  17. package/pkg-dist/interfaces/chunks/pkp-info.i.js.map +1 -0
  18. package/pkg-dist/interfaces/{index.cjs → index.js} +4 -4
  19. package/pkg-dist/interfaces/index.js.map +1 -0
  20. package/pkg-dist/package.json +1 -0
  21. package/pkg-dist/utils/chunks/cid-utils.js.map +1 -0
  22. package/pkg-dist/utils/chunks/{connection-helpers.cjs → connection-helpers.js} +4 -4
  23. package/pkg-dist/utils/chunks/connection-helpers.js.map +1 -0
  24. package/pkg-dist/utils/chunks/debug-logger.js.map +1 -0
  25. package/pkg-dist/utils/chunks/error-classification.js.map +1 -0
  26. package/pkg-dist/utils/chunks/{lit-action-helpers.cjs → lit-action-helpers.js} +1 -1
  27. package/pkg-dist/utils/chunks/lit-action-helpers.js.map +1 -0
  28. package/pkg-dist/utils/chunks/{pkp-setup.cjs → pkp-setup.js} +1 -1
  29. package/pkg-dist/utils/chunks/pkp-setup.js.map +1 -0
  30. package/pkg-dist/utils/chunks/{session-signature-cache.cjs → session-signature-cache.js} +1 -1
  31. package/pkg-dist/utils/chunks/session-signature-cache.js.map +1 -0
  32. package/pkg-dist/utils/{index.cjs → index.js} +7 -7
  33. package/pkg-dist/utils/index.js.map +1 -0
  34. package/out/authorization-dummy-b.hash +0 -1
  35. package/out/authorization-dummy-b.js +0 -44
  36. package/out/authorization-dummy.hash +0 -1
  37. package/out/authorization-dummy.js +0 -64
  38. package/out/btc-deposit-validator.hash +0 -1
  39. package/out/btc-deposit-validator.js +0 -1488
  40. package/out/pkp-validator-datil.hash +0 -1
  41. package/out/pkp-validator-datil.js +0 -232
  42. package/out/pkp-validator.hash +0 -1
  43. package/out/pkp-validator.js +0 -410
  44. package/out/ucd-mint-validator.hash +0 -1
  45. package/out/ucd-mint-validator.js +0 -2203
  46. package/pkg-dist/constants/chunks/lit-actions-registry.cjs.map +0 -1
  47. package/pkg-dist/constants/chunks/package-registry.cjs.map +0 -1
  48. package/pkg-dist/constants/index.cjs.map +0 -1
  49. package/pkg-dist/index.cjs.map +0 -1
  50. package/pkg-dist/interfaces/chunks/diamond-hands-lit-actions.i.cjs.map +0 -1
  51. package/pkg-dist/interfaces/chunks/lit-action-config.i.cjs.map +0 -1
  52. package/pkg-dist/interfaces/chunks/lit-action-name.i.cjs.map +0 -1
  53. package/pkg-dist/interfaces/chunks/lit-action-registry.i.cjs.map +0 -1
  54. package/pkg-dist/interfaces/chunks/pkp-info.i.cjs.map +0 -1
  55. package/pkg-dist/interfaces/index.cjs.map +0 -1
  56. package/pkg-dist/utils/chunks/cid-utils.cjs.map +0 -1
  57. package/pkg-dist/utils/chunks/connection-helpers.cjs.map +0 -1
  58. package/pkg-dist/utils/chunks/debug-logger.cjs.map +0 -1
  59. package/pkg-dist/utils/chunks/error-classification.cjs.map +0 -1
  60. package/pkg-dist/utils/chunks/lit-action-helpers.cjs.map +0 -1
  61. package/pkg-dist/utils/chunks/pkp-setup.cjs.map +0 -1
  62. package/pkg-dist/utils/chunks/session-signature-cache.cjs.map +0 -1
  63. package/pkg-dist/utils/index.cjs.map +0 -1
  64. /package/pkg-dist/interfaces/chunks/{diamond-hands-lit-actions.i.cjs → diamond-hands-lit-actions.i.js} +0 -0
  65. /package/pkg-dist/interfaces/chunks/{lit-action-config.i.cjs → lit-action-config.i.js} +0 -0
  66. /package/pkg-dist/interfaces/chunks/{lit-action-name.i.cjs → lit-action-name.i.js} +0 -0
  67. /package/pkg-dist/interfaces/chunks/{lit-action-registry.i.cjs → lit-action-registry.i.js} +0 -0
  68. /package/pkg-dist/interfaces/chunks/{pkp-info.i.cjs → pkp-info.i.js} +0 -0
  69. /package/pkg-dist/utils/chunks/{cid-utils.cjs → cid-utils.js} +0 -0
  70. /package/pkg-dist/utils/chunks/{debug-logger.cjs → debug-logger.js} +0 -0
  71. /package/pkg-dist/utils/chunks/{error-classification.cjs → error-classification.js} +0 -0
@@ -1 +0,0 @@
1
- a40f3406fd0adffcf65421a9cec2c8963f3ad3e7bcf35d76bf5a2f412a45502d
@@ -1,232 +0,0 @@
1
- // LIT Actions runtime provides: Lit, ethers, fetch
2
- var _LIT_ACTION_ = (() => {
3
- // src/pkp-validator-datil.ts
4
- var go = async () => {
5
- const targetPkpTokenId = globalThis.targetPkpTokenId;
6
- const expectedCid = globalThis.expectedCid;
7
- const network = globalThis.network;
8
- try {
9
- if (!targetPkpTokenId) {
10
- throw new Error("targetPkpTokenId is required in parameters");
11
- }
12
- if (!expectedCid) {
13
- throw new Error("expectedCid is required in parameters");
14
- }
15
- console.log("\n\u{1F512} PKP SECURITY VALIDATION");
16
- console.log(
17
- " Using EXACT same logic as validatePKPSecurity test function"
18
- );
19
- console.log(" Making direct smart contract calls to verify security");
20
- console.log(` Target PKP: ${targetPkpTokenId}`);
21
- console.log(` Expected CID: ${expectedCid}`);
22
- console.log(` Network: ${network}`);
23
- const LIT_DATIL_TEST_CONTRACTS = {
24
- PKPNFT: "0x6a0f439f064B7167A8Ea6B22AcC07ae5360ee0d1",
25
- PKPPermissions: "0x60C1ddC8b9e38F730F0e7B70A2F84C1A98A69167"
26
- };
27
- const LIT_DATIL_CONTRACTS = {
28
- PKPNFT: "0x487A9D096BB4B7Ac1520Cb12370e31e677B175EA",
29
- PKPPermissions: "0x213Db6E1446928E19588269bEF7dFc9187c4829A"
30
- };
31
- const LIT_CONTRACTS = network === "datil-test" ? LIT_DATIL_TEST_CONTRACTS : LIT_DATIL_CONTRACTS;
32
- console.log("\n\u{1F50D} Step 1: PKP Existence Check...");
33
- const existsCalldata = ethers.utils.concat([
34
- ethers.utils.id("exists(uint256)").substring(0, 10),
35
- // function selector
36
- ethers.utils.defaultAbiCoder.encode(["uint256"], [targetPkpTokenId])
37
- ]);
38
- const existsCall = {
39
- to: LIT_CONTRACTS.PKPNFT,
40
- data: ethers.utils.hexlify(existsCalldata)
41
- };
42
- const existsRpcPayload = {
43
- method: "eth_call",
44
- params: [existsCall, "latest"],
45
- id: 1,
46
- jsonrpc: "2.0"
47
- };
48
- const existsResponse = await fetch(
49
- "https://yellowstone-rpc.litprotocol.com",
50
- {
51
- method: "POST",
52
- headers: { "Content-Type": "application/json" },
53
- body: JSON.stringify(existsRpcPayload)
54
- }
55
- );
56
- const existsResult = await existsResponse.json();
57
- if (existsResult.error) {
58
- throw new Error(
59
- `RPC Error checking exists: ${existsResult.error.message}`
60
- );
61
- }
62
- const exists = ethers.utils.defaultAbiCoder.decode(
63
- ["bool"],
64
- existsResult.result
65
- )[0];
66
- console.log(` PKP exists: ${exists}`);
67
- console.log("\n\u{1F50D} Step 2: PKP Immutability Check...");
68
- const ownerOfCalldata = ethers.utils.concat([
69
- ethers.utils.id("ownerOf(uint256)").substring(0, 10),
70
- // function selector
71
- ethers.utils.defaultAbiCoder.encode(["uint256"], [targetPkpTokenId])
72
- ]);
73
- const ownerOfCall = {
74
- to: LIT_CONTRACTS.PKPNFT,
75
- data: ethers.utils.hexlify(ownerOfCalldata)
76
- };
77
- const ownerOfRpcPayload = {
78
- method: "eth_call",
79
- params: [ownerOfCall, "latest"],
80
- id: 2,
81
- jsonrpc: "2.0"
82
- };
83
- let owner = "0x0000000000000000000000000000000000000000";
84
- let isImmutable = false;
85
- if (exists) {
86
- const ownerOfResponse = await fetch(
87
- "https://yellowstone-rpc.litprotocol.com",
88
- {
89
- method: "POST",
90
- headers: { "Content-Type": "application/json" },
91
- body: JSON.stringify(ownerOfRpcPayload)
92
- }
93
- );
94
- const ownerOfResult = await ownerOfResponse.json();
95
- if (ownerOfResult.error) {
96
- throw new Error(
97
- `RPC Error checking owner: ${ownerOfResult.error.message}`
98
- );
99
- }
100
- owner = ethers.utils.defaultAbiCoder.decode(
101
- ["address"],
102
- ownerOfResult.result
103
- )[0];
104
- const BURN_ADDRESS = "0x000000000000000000000000000000000000dEaD";
105
- isImmutable = owner.toLowerCase() === BURN_ADDRESS.toLowerCase();
106
- }
107
- console.log(` PKP owner: ${owner}`);
108
- console.log(` Is immutable (burned to dead address): ${isImmutable}`);
109
- console.log("\n\u{1F510} Step 3: Authorization Check...");
110
- const getPermittedActionsCalldata = ethers.utils.concat([
111
- ethers.utils.id("getPermittedActions(uint256)").substring(0, 10),
112
- // function selector
113
- ethers.utils.defaultAbiCoder.encode(["uint256"], [targetPkpTokenId])
114
- ]);
115
- const getPermittedActionsCall = {
116
- to: LIT_CONTRACTS.PKPPermissions,
117
- data: ethers.utils.hexlify(getPermittedActionsCalldata)
118
- };
119
- const getPermittedActionsRpcPayload = {
120
- method: "eth_call",
121
- params: [getPermittedActionsCall, "latest"],
122
- id: 3,
123
- jsonrpc: "2.0"
124
- };
125
- let actionsBytes = [];
126
- let hasOnlyOneAction = false;
127
- let matchesExpectedCID = false;
128
- let foundCid = null;
129
- if (exists) {
130
- const getPermittedActionsResponse = await fetch(
131
- "https://yellowstone-rpc.litprotocol.com",
132
- {
133
- method: "POST",
134
- headers: { "Content-Type": "application/json" },
135
- body: JSON.stringify(getPermittedActionsRpcPayload)
136
- }
137
- );
138
- const getPermittedActionsResult = await getPermittedActionsResponse.json();
139
- if (getPermittedActionsResult.error) {
140
- throw new Error(
141
- `RPC Error getting permitted actions: ${getPermittedActionsResult.error.message}`
142
- );
143
- }
144
- actionsBytes = ethers.utils.defaultAbiCoder.decode(
145
- ["bytes[]"],
146
- getPermittedActionsResult.result
147
- )[0];
148
- hasOnlyOneAction = actionsBytes.length === 1;
149
- foundCid = actionsBytes[0] || null;
150
- matchesExpectedCID = foundCid?.toLowerCase() === expectedCid.toLowerCase();
151
- }
152
- console.log(` Permitted actions count: ${actionsBytes.length}`);
153
- console.log(` Actions bytes:`, actionsBytes);
154
- console.log(` Has exactly one action: ${hasOnlyOneAction}`);
155
- console.log(` Matches expected CID: ${matchesExpectedCID}`);
156
- console.log(` Expected CID: ${expectedCid}`);
157
- console.log(` Found CID: ${foundCid || "NONE"}`);
158
- const allValid = exists && isImmutable && hasOnlyOneAction && matchesExpectedCID;
159
- const validationSummary = {
160
- pkpExists: `${exists} ${exists ? "\u2705" : "\u274C"}`,
161
- pkpImmutable: `${isImmutable} ${isImmutable ? "\u2705" : "\u274C"}`,
162
- singleAction: `${hasOnlyOneAction} ${hasOnlyOneAction ? "\u2705" : "\u274C"}`,
163
- correctCID: `${matchesExpectedCID} ${matchesExpectedCID ? "\u2705" : "\u274C"}`,
164
- overallSecurity: `${allValid} ${allValid ? "\u{1F512} SECURE" : "\u26A0\uFE0F INSECURE"}`
165
- };
166
- console.log("\n\u{1F512} COMPLETE SECURITY VALIDATION RESULT:");
167
- console.log(` PKP exists: ${validationSummary.pkpExists}`);
168
- console.log(` PKP immutable: ${validationSummary.pkpImmutable}`);
169
- console.log(` Single action: ${validationSummary.singleAction}`);
170
- console.log(` Correct CID: ${validationSummary.correctCID}`);
171
- console.log(` OVERALL SECURITY: ${validationSummary.overallSecurity}`);
172
- if (!allValid) {
173
- throw new Error(
174
- "PKP security validation failed - not all conditions met"
175
- );
176
- }
177
- console.log("\n\u{1F389} PKP IS FULLY SECURE!");
178
- console.log(" \u2705 Exists on-chain");
179
- console.log(" \u2705 Immutable (cannot be modified)");
180
- console.log(" \u2705 Only authorized for expected LIT Action");
181
- console.log(" \u{1F512} READY FOR PRODUCTION USE");
182
- console.log("Step 3: Signing certification of PKP-CID relationship...");
183
- const pkpIdBigInt = BigInt(`0x${targetPkpTokenId}`);
184
- const pkpIdDecimal = `0x${pkpIdBigInt.toString(10)}`;
185
- const cidHex = expectedCid.toLowerCase();
186
- const certificationMessage = `PKP::${pkpIdDecimal}::CID::${cidHex}::SECURE`;
187
- console.log(` Certification message: ${certificationMessage}`);
188
- const messageHash = ethers.utils.arrayify(
189
- ethers.utils.hashMessage(certificationMessage)
190
- );
191
- console.log(` Message hash (with Ethereum prefix): ${ethers.utils.hexlify(messageHash)}`);
192
- const signature = await Lit.Actions.signEcdsa({
193
- toSign: messageHash,
194
- publicKey: globalThis.publicKey,
195
- sigName: "pkpValidation"
196
- });
197
- console.log("\u2705 PKP-CID relationship certification signature generated");
198
- Lit.Actions.setResponse({
199
- response: JSON.stringify({
200
- success: true,
201
- validated: {
202
- pkpTokenId: targetPkpTokenId,
203
- exists,
204
- immutable: isImmutable,
205
- singleAction: hasOnlyOneAction,
206
- correctCid: matchesExpectedCID,
207
- expectedCid,
208
- foundCidHex: actionsBytes[0]
209
- },
210
- validatorPkp: globalThis.publicKey,
211
- signedMessage: certificationMessage,
212
- signature,
213
- timestamp: Date.now(),
214
- network
215
- })
216
- });
217
- } catch (error) {
218
- console.error("\u274C PKP Validation failed:", error.message);
219
- Lit.Actions.setResponse({
220
- response: JSON.stringify({
221
- success: false,
222
- error: error.message || error.toString(),
223
- targetPkpTokenId: globalThis.targetPkpTokenId || "unknown",
224
- validatorPkp: globalThis.publicKey || "unknown",
225
- timestamp: Date.now(),
226
- network
227
- })
228
- });
229
- }
230
- };
231
- go();
232
- })();
@@ -1 +0,0 @@
1
- ac5d1dbc1ae8b678f435ac568320887e69e662d93d5f92e11f69e3a322f2e1ef
@@ -1,410 +0,0 @@
1
- // LIT Actions runtime provides: Lit, ethers, fetch
2
- var _LIT_ACTION_ = (() => {
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
-
21
- // src/pkp-validator.ts
22
- var pkp_validator_exports = {};
23
- __export(pkp_validator_exports, {
24
- runPkpValidator: () => runPkpValidator
25
- });
26
- var runPkpValidator = async () => {
27
- const targetPkpTokenId = globalThis.targetPkpTokenId;
28
- const expectedCid = globalThis.expectedCid;
29
- const network = globalThis.network;
30
- const RPC_ENDPOINTS = {
31
- "datil-test": "https://datil-test-rpc.litprotocol.com",
32
- datil: "https://yellowstone-rpc.litprotocol.com"
33
- };
34
- const CONTRACT_ADDRESSES = {
35
- "datil-test": {
36
- // https://github.com/LIT-Protocol/networks/blob/main/contracts/datil-test.json
37
- PKPNFT: "0x6a0f439f064B7167A8Ea6B22AcC07ae5360ee0d1",
38
- PKPPermissions: "0x60C1ddC8b9e38F730F0e7B70A2F84C1A98A69167"
39
- },
40
- datil: {
41
- // Updated contract addresses for datil mainnet - these may need verification
42
- // Chronicle Yellowstone rollup deployment addresses
43
- PKPNFT: "0x8F75a53F65e31DD0D2e40d0827becAaE2299D111",
44
- PKPPermissions: "0x969471556e2B9DC984f4C9c24667B8B0Efb5B7F8"
45
- }
46
- };
47
- const withTimeout = async (promise, timeoutMs, operation) => {
48
- return Promise.race([
49
- promise,
50
- new Promise(
51
- (_, reject) => setTimeout(() => reject(new Error(`Timeout after ${timeoutMs}ms during ${operation}`)), timeoutMs)
52
- )
53
- ]);
54
- };
55
- const makeRpcCall = async (payload, endpoint, operation, maxRetries = 3) => {
56
- let lastError;
57
- for (let attempt = 1; attempt <= maxRetries; attempt++) {
58
- try {
59
- console.log(`\u{1F310} [Attempt ${attempt}/${maxRetries}] Making RPC call for ${operation}`);
60
- console.log(` Endpoint: ${endpoint}`);
61
- console.log(` Payload ID: ${payload.id}`);
62
- console.log(` Method: ${payload.method}`);
63
- const startTime = Date.now();
64
- const response = await withTimeout(
65
- fetch(endpoint, {
66
- method: "POST",
67
- headers: { "Content-Type": "application/json" },
68
- body: JSON.stringify(payload)
69
- }),
70
- 3e4,
71
- // 30 second timeout
72
- operation
73
- );
74
- const duration = Date.now() - startTime;
75
- console.log(`\u23F1\uFE0F RPC call completed in ${duration}ms`);
76
- if (!response.ok) {
77
- throw new Error(`HTTP ${response.status}: ${response.statusText}`);
78
- }
79
- const result = await response.json();
80
- if (result.error) {
81
- console.log(`\u274C RPC Error:`, result.error);
82
- throw new Error(`RPC Error: ${result.error.message} (Code: ${result.error.code})`);
83
- }
84
- console.log(`\u2705 RPC call successful for ${operation}`);
85
- console.log(` Result length: ${JSON.stringify(result).length} bytes`);
86
- return result;
87
- } catch (error) {
88
- lastError = error;
89
- console.log(`\u274C [Attempt ${attempt}/${maxRetries}] ${operation} failed: ${error.message}`);
90
- if (attempt < maxRetries) {
91
- const delay = Math.pow(2, attempt - 1) * 1e3;
92
- console.log(`\u23F3 Retrying in ${delay}ms...`);
93
- await new Promise((resolve) => setTimeout(resolve, delay));
94
- }
95
- }
96
- }
97
- throw lastError ?? new Error(`Unknown error during ${operation}`);
98
- };
99
- try {
100
- const targetPkpTokenId2 = globalThis.targetPkpTokenId;
101
- const expectedCid2 = globalThis.expectedCid;
102
- const network2 = globalThis.network || "datil";
103
- if (!Object.prototype.hasOwnProperty.call(RPC_ENDPOINTS, network2)) {
104
- throw new Error(`Unsupported network: ${network2}`);
105
- }
106
- if (!targetPkpTokenId2) {
107
- throw new Error("targetPkpTokenId is required in parameters");
108
- }
109
- if (!expectedCid2) {
110
- throw new Error("expectedCid is required in parameters");
111
- }
112
- console.log("\n\u{1F512} PKP SECURITY VALIDATION - ENHANCED DEBUG MODE");
113
- console.log("==========================================================");
114
- console.log(" Using EXACT same logic as validatePKPSecurity test function");
115
- console.log(" Making direct smart contract calls to verify security");
116
- console.log(` Target PKP: ${targetPkpTokenId2}`);
117
- console.log(` Expected CID: ${expectedCid2}`);
118
- console.log(` Network: ${network2}`);
119
- console.log(` Execution timestamp: ${Date.now()}`);
120
- console.log("==========================================================");
121
- const rpcEndpoint = RPC_ENDPOINTS[network2];
122
- const LIT_CONTRACTS = CONTRACT_ADDRESSES[network2];
123
- console.log("\n\u{1F527} CONFIGURATION VERIFICATION:");
124
- console.log(` RPC Endpoint: ${rpcEndpoint}`);
125
- console.log(` PKPNFT Contract: ${LIT_CONTRACTS.PKPNFT}`);
126
- console.log(` PKPPermissions Contract: ${LIT_CONTRACTS.PKPPermissions}`);
127
- console.log(` Network resolved: ${network2}`);
128
- console.log("\n\u{1F310} TESTING RPC CONNECTIVITY...");
129
- try {
130
- const connectivityTest = {
131
- method: "eth_chainId",
132
- params: [],
133
- id: 0,
134
- jsonrpc: "2.0"
135
- };
136
- const chainIdResult = await makeRpcCall(connectivityTest, rpcEndpoint, "connectivity_test");
137
- const chainId = parseInt(chainIdResult.result, 16);
138
- console.log(`\u2705 RPC connectivity confirmed - Chain ID: ${chainId}`);
139
- } catch (error) {
140
- console.log(`\u274C RPC connectivity failed: ${error.message}`);
141
- throw new Error(`Cannot connect to RPC endpoint ${rpcEndpoint}: ${error.message}`);
142
- }
143
- console.log("\n\u{1F50D} STEP 1: PKP EXISTENCE CHECK");
144
- console.log("====================================");
145
- console.log(` Checking PKP existence for: ${targetPkpTokenId2}`);
146
- console.log(` Contract: ${LIT_CONTRACTS.PKPNFT}`);
147
- const existsCalldata = ethers.utils.concat([
148
- ethers.utils.id("exists(uint256)").substring(0, 10),
149
- // function selector
150
- ethers.utils.defaultAbiCoder.encode(["uint256"], [targetPkpTokenId2])
151
- ]);
152
- console.log(` Function selector: ${ethers.utils.id("exists(uint256)").substring(0, 10)}`);
153
- console.log(` Calldata: ${ethers.utils.hexlify(existsCalldata)}`);
154
- const existsCall = {
155
- to: LIT_CONTRACTS.PKPNFT,
156
- data: ethers.utils.hexlify(existsCalldata)
157
- };
158
- const existsRpcPayload = {
159
- method: "eth_call",
160
- params: [existsCall, "latest"],
161
- id: 1,
162
- jsonrpc: "2.0"
163
- };
164
- const existsResult = await makeRpcCall(existsRpcPayload, rpcEndpoint, "PKP_existence_check");
165
- const exists = ethers.utils.defaultAbiCoder.decode(
166
- ["bool"],
167
- existsResult.result
168
- )[0];
169
- console.log(` Raw result: ${existsResult.result}`);
170
- console.log(` Decoded result: ${exists}`);
171
- console.log(`\u2705 PKP EXISTS CHECK RESULT: ${exists}`);
172
- if (!exists) {
173
- console.log(`\u274C CRITICAL: PKP ${targetPkpTokenId2} does not exist on-chain!`);
174
- console.log(` This PKP was never minted or the token ID is incorrect`);
175
- console.log(` Cannot proceed with security validation`);
176
- }
177
- console.log("\n\u{1F50D} STEP 2: PKP IMMUTABILITY CHECK");
178
- console.log("=====================================");
179
- console.log(` Checking owner status for PKP: ${targetPkpTokenId2}`);
180
- const ownerOfCalldata = ethers.utils.concat([
181
- ethers.utils.id("ownerOf(uint256)").substring(0, 10),
182
- // function selector
183
- ethers.utils.defaultAbiCoder.encode(["uint256"], [targetPkpTokenId2])
184
- ]);
185
- console.log(` Function selector: ${ethers.utils.id("ownerOf(uint256)").substring(0, 10)}`);
186
- console.log(` Calldata: ${ethers.utils.hexlify(ownerOfCalldata)}`);
187
- const ownerOfCall = {
188
- to: LIT_CONTRACTS.PKPNFT,
189
- data: ethers.utils.hexlify(ownerOfCalldata)
190
- };
191
- const ownerOfRpcPayload = {
192
- method: "eth_call",
193
- params: [ownerOfCall, "latest"],
194
- id: 2,
195
- jsonrpc: "2.0"
196
- };
197
- let owner = "0x0000000000000000000000000000000000000000";
198
- let isImmutable = false;
199
- if (exists) {
200
- const ownerOfResult = await makeRpcCall(ownerOfRpcPayload, rpcEndpoint, "PKP_owner_check");
201
- owner = ethers.utils.defaultAbiCoder.decode(
202
- ["address"],
203
- ownerOfResult.result
204
- )[0];
205
- const BURN_ADDRESS = "0x000000000000000000000000000000000000dEaD";
206
- isImmutable = owner.toLowerCase() === BURN_ADDRESS.toLowerCase();
207
- console.log(` Raw owner result: ${ownerOfResult.result}`);
208
- console.log(` Decoded owner: ${owner}`);
209
- console.log(` Expected burn address: ${BURN_ADDRESS}`);
210
- console.log(` Owner matches burn address: ${isImmutable}`);
211
- } else {
212
- console.log(` Skipping owner check - PKP does not exist`);
213
- }
214
- console.log(`\u2705 PKP IMMUTABILITY CHECK RESULT: ${isImmutable}`);
215
- console.log("\n\u{1F510} STEP 3: AUTHORIZATION CHECK");
216
- console.log("==================================");
217
- console.log(` Checking permitted actions for PKP: ${targetPkpTokenId2}`);
218
- console.log(` Contract: ${LIT_CONTRACTS.PKPPermissions}`);
219
- const getPermittedActionsCalldata = ethers.utils.concat([
220
- ethers.utils.id("getPermittedActions(uint256)").substring(0, 10),
221
- // function selector
222
- ethers.utils.defaultAbiCoder.encode(["uint256"], [targetPkpTokenId2])
223
- ]);
224
- console.log(` Function selector: ${ethers.utils.id("getPermittedActions(uint256)").substring(0, 10)}`);
225
- console.log(` Calldata: ${ethers.utils.hexlify(getPermittedActionsCalldata)}`);
226
- const getPermittedActionsCall = {
227
- to: LIT_CONTRACTS.PKPPermissions,
228
- data: ethers.utils.hexlify(getPermittedActionsCalldata)
229
- };
230
- const getPermittedActionsRpcPayload = {
231
- method: "eth_call",
232
- params: [getPermittedActionsCall, "latest"],
233
- id: 3,
234
- jsonrpc: "2.0"
235
- };
236
- let actionsBytes = [];
237
- let hasOnlyOneAction = false;
238
- let matchesExpectedCID = false;
239
- let foundCid = null;
240
- if (exists) {
241
- const getPermittedActionsResult = await makeRpcCall(
242
- getPermittedActionsRpcPayload,
243
- rpcEndpoint,
244
- "PKP_permitted_actions_check"
245
- );
246
- console.log(` Raw permissions result: ${getPermittedActionsResult.result}`);
247
- actionsBytes = ethers.utils.defaultAbiCoder.decode(
248
- ["bytes[]"],
249
- getPermittedActionsResult.result
250
- )[0];
251
- console.log(` Decoded actions count: ${actionsBytes.length}`);
252
- console.log(` Actions bytes array:`, actionsBytes);
253
- hasOnlyOneAction = actionsBytes.length === 1;
254
- foundCid = actionsBytes[0] || null;
255
- matchesExpectedCID = foundCid?.toLowerCase() === expectedCid2.toLowerCase();
256
- console.log(` First action bytes: ${foundCid}`);
257
- console.log(` Expected CID (input): ${expectedCid2}`);
258
- console.log(` CID comparison (case-insensitive):`);
259
- console.log(` Found: ${foundCid?.toLowerCase()}`);
260
- console.log(` Expected: ${expectedCid2.toLowerCase()}`);
261
- console.log(` Match: ${matchesExpectedCID}`);
262
- } else {
263
- console.log(` Skipping authorization check - PKP does not exist`);
264
- }
265
- console.log("\n\u{1F4CA} AUTHORIZATION CHECK SUMMARY:");
266
- console.log(` Permitted actions count: ${actionsBytes.length}`);
267
- console.log(` Has exactly one action: ${hasOnlyOneAction}`);
268
- console.log(` Matches expected CID: ${matchesExpectedCID}`);
269
- console.log(` Expected CID: ${expectedCid2}`);
270
- console.log(` Found CID: ${foundCid || "NONE"}`);
271
- if (actionsBytes.length > 1) {
272
- console.log(` \u26A0\uFE0F WARNING: PKP has ${actionsBytes.length} authorized actions (expected 1)`);
273
- console.log(` Additional actions:`);
274
- actionsBytes.slice(1).forEach((action, index) => {
275
- console.log(` [${index + 2}]: ${action}`);
276
- });
277
- }
278
- if (actionsBytes.length === 0) {
279
- console.log(` \u274C CRITICAL: PKP has no authorized actions!`);
280
- }
281
- const allValid = exists && isImmutable && hasOnlyOneAction && matchesExpectedCID;
282
- const validationSummary = {
283
- pkpExists: `${exists} ${exists ? "\u2705" : "\u274C"}`,
284
- pkpImmutable: `${isImmutable} ${isImmutable ? "\u2705" : "\u274C"}`,
285
- singleAction: `${hasOnlyOneAction} ${hasOnlyOneAction ? "\u2705" : "\u274C"}`,
286
- correctCID: `${matchesExpectedCID} ${matchesExpectedCID ? "\u2705" : "\u274C"}`,
287
- overallSecurity: `${allValid} ${allValid ? "\u{1F512} SECURE" : "\u26A0\uFE0F INSECURE"}`
288
- };
289
- console.log("\n\u{1F512} COMPLETE SECURITY VALIDATION RESULT:");
290
- console.log("==========================================");
291
- console.log(` PKP exists: ${validationSummary.pkpExists}`);
292
- console.log(` PKP immutable: ${validationSummary.pkpImmutable}`);
293
- console.log(` Single action: ${validationSummary.singleAction}`);
294
- console.log(` Correct CID: ${validationSummary.correctCID}`);
295
- console.log(` OVERALL SECURITY: ${validationSummary.overallSecurity}`);
296
- console.log("==========================================");
297
- if (!allValid) {
298
- const failureReasons = [];
299
- if (!exists) failureReasons.push("PKP does not exist on-chain");
300
- if (!isImmutable) failureReasons.push("PKP is not immutable (not burned)");
301
- if (!hasOnlyOneAction) failureReasons.push(`PKP has ${actionsBytes.length} actions instead of 1`);
302
- if (!matchesExpectedCID) failureReasons.push("PKP CID does not match expected value");
303
- const errorMessage = `PKP security validation failed:
304
- ${failureReasons.map((r) => ` - ${r}`).join("\n")}`;
305
- console.log(`
306
- \u274C VALIDATION FAILURES:`);
307
- failureReasons.forEach((reason) => console.log(` - ${reason}`));
308
- throw new Error(errorMessage);
309
- }
310
- console.log("\n\u{1F389} PKP IS FULLY SECURE!");
311
- console.log(" \u2705 Exists on-chain");
312
- console.log(" \u2705 Immutable (cannot be modified)");
313
- console.log(" \u2705 Only authorized for expected LIT Action");
314
- console.log(" \u{1F512} READY FOR PRODUCTION USE");
315
- console.log("\n\u{1F50F} STEP 4: GENERATING VALIDATION PROOF");
316
- console.log("=========================================");
317
- console.log("All security validations passed - generating verifiable proof...");
318
- console.log("");
319
- console.log("ARCHITECTURAL NOTE:");
320
- console.log("This validator PKP is BURNED (immutable) and cannot sign within");
321
- console.log("a LIT Action called via session signatures from another wallet.");
322
- console.log("The validation proof is the on-chain state verification itself.");
323
- console.log("");
324
- console.log("The fact that THIS LIT Action (authorized for this PKP) executed");
325
- console.log("successfully and verified all security conditions IS the certification.");
326
- console.log("");
327
- const pkpIdBigInt = BigInt(`0x${targetPkpTokenId2}`);
328
- const pkpIdDecimal = `0x${pkpIdBigInt.toString(10)}`;
329
- const cidHex = expectedCid2.toLowerCase();
330
- const proofMessage = `PKP::${pkpIdDecimal}::CID::${cidHex}::SECURE`;
331
- const proofHash = ethers.utils.keccak256(ethers.utils.toUtf8Bytes(proofMessage));
332
- console.log(` Proof message: ${proofMessage}`);
333
- console.log(` Proof hash: ${proofHash}`);
334
- console.log(` Validator PKP: ${globalThis.publicKey}`);
335
- console.log(` Validator LIT Action CID: ${expectedCid2}`);
336
- console.log("");
337
- console.log("\u2705 Validation proof generated successfully");
338
- console.log("");
339
- console.log("VERIFICATION INSTRUCTIONS:");
340
- console.log("Anyone can independently verify this validation by:");
341
- console.log("1. Querying PKP NFT contract for existence and immutability");
342
- console.log("2. Querying PKP Permissions contract for authorized actions");
343
- console.log("3. Confirming PKP is only authorized for the expected LIT Action CID");
344
- console.log("4. This validation result proves the PKP passed all security checks");
345
- Lit.Actions.setResponse({
346
- response: JSON.stringify({
347
- success: true,
348
- validated: {
349
- pkpTokenId: targetPkpTokenId2,
350
- exists,
351
- immutable: isImmutable,
352
- singleAction: hasOnlyOneAction,
353
- correctCid: matchesExpectedCID,
354
- expectedCid: expectedCid2,
355
- foundCidHex: actionsBytes[0]
356
- },
357
- validatorPkp: globalThis.publicKey,
358
- validatorActionCid: expectedCid2,
359
- proofMessage,
360
- proofHash,
361
- timestamp: Date.now(),
362
- network: network2,
363
- verificationNote: "This validation was performed by the authorized LIT Action for this validator PKP. The validation itself is the proof of security."
364
- })
365
- });
366
- } catch (error) {
367
- console.error("\n\u{1F4A5} CRITICAL ERROR - PKP VALIDATION FAILED");
368
- console.error("===========================================");
369
- console.error(`Error type: ${error.constructor.name}`);
370
- console.error(`Error message: ${error.message}`);
371
- console.error(`Error stack: ${error.stack}`);
372
- console.error(`Network: ${network}`);
373
- console.error(`Target PKP: ${globalThis.targetPkpTokenId || "unknown"}`);
374
- console.error(`Expected CID: ${globalThis.expectedCid || "unknown"}`);
375
- console.error(`Validator PKP: ${globalThis.publicKey || "unknown"}`);
376
- console.error(`Timestamp: ${(/* @__PURE__ */ new Date()).toISOString()}`);
377
- console.error("===========================================");
378
- let errorCategory = "UNKNOWN_ERROR";
379
- if (error.message.includes("Timeout")) {
380
- errorCategory = "TIMEOUT_ERROR";
381
- } else if (error.message.includes("RPC") || error.message.includes("HTTP")) {
382
- errorCategory = "NETWORK_ERROR";
383
- } else if (error.message.includes("PKP security validation failed")) {
384
- errorCategory = "VALIDATION_ERROR";
385
- } else if (error.message.includes("signEcdsa") || error.message.includes("signature")) {
386
- errorCategory = "SIGNATURE_ERROR";
387
- }
388
- Lit.Actions.setResponse({
389
- response: JSON.stringify({
390
- success: false,
391
- error: error.message || error.toString(),
392
- errorCategory,
393
- errorStack: error.stack || "No stack trace available",
394
- targetPkpTokenId: globalThis.targetPkpTokenId || "unknown",
395
- expectedCid: globalThis.expectedCid || "unknown",
396
- validatorPkp: globalThis.publicKey || "unknown",
397
- network,
398
- timestamp: Date.now(),
399
- debug: {
400
- rpcEndpoint: RPC_ENDPOINTS[network],
401
- contracts: CONTRACT_ADDRESSES[network] || CONTRACT_ADDRESSES["datil-test"],
402
- globalThisKeys: Object.keys(globalThis)
403
- }
404
- })
405
- });
406
- }
407
- };
408
- runPkpValidator();
409
- return __toCommonJS(pkp_validator_exports);
410
- })();
@@ -1 +0,0 @@
1
- 5d5511b61e20ac05dd50403a43cdb747a457d3d64765e674bb0e81a25ed1f016