@gvnrdao/dh-lit-actions 0.0.14 → 0.0.17
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/out/authorization-dummy-b.hash +1 -0
- package/out/authorization-dummy-b.js +44 -0
- package/out/authorization-dummy.hash +1 -0
- package/out/authorization-dummy.js +64 -0
- package/out/pkp-validator-datil.hash +1 -0
- package/out/pkp-validator-datil.js +232 -0
- package/out/pkp-validator.hash +1 -0
- package/out/pkp-validator.js +410 -0
- package/out/ucd-mint-validator.hash +1 -0
- package/out/ucd-mint-validator.js +2154 -0
- package/package.json +3 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
6262c9467961c661d212b8c60806e499ed5e7d0fe8456e2455e536d40eb4c672
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// LIT Actions runtime provides: Lit, ethers, fetch
|
|
2
|
+
var _LIT_ACTION_ = (() => {
|
|
3
|
+
// src/authorization-dummy-b.ts
|
|
4
|
+
var authorizationGoB = async () => {
|
|
5
|
+
try {
|
|
6
|
+
const message = globalThis.messageToSign || "diamond-hands-test-signature-b";
|
|
7
|
+
if (!globalThis.publicKey) {
|
|
8
|
+
Lit.Actions.setResponse({
|
|
9
|
+
response: JSON.stringify({
|
|
10
|
+
success: false,
|
|
11
|
+
error: "PKP public key not available"
|
|
12
|
+
})
|
|
13
|
+
});
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const signature = await Lit.Actions.signEcdsa({
|
|
17
|
+
toSign: ethers.utils.arrayify(
|
|
18
|
+
ethers.utils.keccak256(ethers.utils.toUtf8Bytes(message))
|
|
19
|
+
),
|
|
20
|
+
publicKey: globalThis.publicKey,
|
|
21
|
+
sigName: "dummySig"
|
|
22
|
+
});
|
|
23
|
+
Lit.Actions.setResponse({
|
|
24
|
+
response: JSON.stringify({
|
|
25
|
+
success: true,
|
|
26
|
+
signature,
|
|
27
|
+
message,
|
|
28
|
+
pkpPublicKey: globalThis.publicKey,
|
|
29
|
+
timestamp: Date.now(),
|
|
30
|
+
action: "dummy-authorization-sign-b"
|
|
31
|
+
})
|
|
32
|
+
});
|
|
33
|
+
} catch (error) {
|
|
34
|
+
Lit.Actions.setResponse({
|
|
35
|
+
response: JSON.stringify({
|
|
36
|
+
success: false,
|
|
37
|
+
error: error.message || error.toString(),
|
|
38
|
+
timestamp: Date.now()
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
authorizationGoB();
|
|
44
|
+
})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
c732ef30e50a5013a6c1cbac6dc011d3638875237d21097e3aff722b323d174b
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// LIT Actions runtime provides: Lit, ethers, fetch
|
|
2
|
+
var _LIT_ACTION_ = (() => {
|
|
3
|
+
// src/authorization-dummy.ts
|
|
4
|
+
var authorizationGo = async () => {
|
|
5
|
+
try {
|
|
6
|
+
if (!globalThis.publicKey) {
|
|
7
|
+
Lit.Actions.setResponse({
|
|
8
|
+
response: JSON.stringify({
|
|
9
|
+
success: false,
|
|
10
|
+
error: "PKP public key not available"
|
|
11
|
+
})
|
|
12
|
+
});
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const rawToSign = globalThis.toSign;
|
|
16
|
+
const messageToSign = globalThis.messageToSign || "diamond-hands-test-signature";
|
|
17
|
+
let toSignData;
|
|
18
|
+
let signatureType;
|
|
19
|
+
if (rawToSign) {
|
|
20
|
+
if (typeof rawToSign === "string") {
|
|
21
|
+
toSignData = ethers.utils.arrayify(rawToSign);
|
|
22
|
+
} else if (rawToSign instanceof Uint8Array) {
|
|
23
|
+
toSignData = rawToSign;
|
|
24
|
+
} else if (Array.isArray(rawToSign)) {
|
|
25
|
+
toSignData = new Uint8Array(rawToSign);
|
|
26
|
+
} else {
|
|
27
|
+
throw new Error("Invalid toSign format");
|
|
28
|
+
}
|
|
29
|
+
signatureType = "bitcoin-raw-bytes";
|
|
30
|
+
} else {
|
|
31
|
+
toSignData = ethers.utils.arrayify(
|
|
32
|
+
ethers.utils.keccak256(ethers.utils.toUtf8Bytes(messageToSign))
|
|
33
|
+
);
|
|
34
|
+
signatureType = "ethereum-message-hash";
|
|
35
|
+
}
|
|
36
|
+
const signature = await Lit.Actions.signEcdsa({
|
|
37
|
+
toSign: toSignData,
|
|
38
|
+
publicKey: globalThis.publicKey,
|
|
39
|
+
sigName: "dummySig"
|
|
40
|
+
});
|
|
41
|
+
Lit.Actions.setResponse({
|
|
42
|
+
response: JSON.stringify({
|
|
43
|
+
success: true,
|
|
44
|
+
signature,
|
|
45
|
+
signatureType,
|
|
46
|
+
message: messageToSign,
|
|
47
|
+
rawDataSigned: rawToSign ? true : false,
|
|
48
|
+
pkpPublicKey: globalThis.publicKey,
|
|
49
|
+
timestamp: Date.now(),
|
|
50
|
+
action: "dummy-authorization-sign"
|
|
51
|
+
})
|
|
52
|
+
});
|
|
53
|
+
} catch (error) {
|
|
54
|
+
Lit.Actions.setResponse({
|
|
55
|
+
response: JSON.stringify({
|
|
56
|
+
success: false,
|
|
57
|
+
error: error.message || error.toString(),
|
|
58
|
+
timestamp: Date.now()
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
authorizationGo();
|
|
64
|
+
})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
a40f3406fd0adffcf65421a9cec2c8963f3ad3e7bcf35d76bf5a2f412a45502d
|
|
@@ -0,0 +1,232 @@
|
|
|
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
|
+
})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ac5d1dbc1ae8b678f435ac568320887e69e662d93d5f92e11f69e3a322f2e1ef
|