@gvnrdao/dh-lit-ops 0.0.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/README.md +197 -0
- package/dist/constants/chunks/pkp-data.d.ts +28 -0
- package/dist/constants/chunks/pkp-data.d.ts.map +1 -0
- package/dist/constants/chunks/pkp-data.js +86 -0
- package/dist/constants/chunks/pkp-data.js.map +1 -0
- package/dist/constants/index.d.ts +8 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +25 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +63 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/chunks/authentication.d.ts +29 -0
- package/dist/interfaces/chunks/authentication.d.ts.map +1 -0
- package/dist/interfaces/chunks/authentication.js +7 -0
- package/dist/interfaces/chunks/authentication.js.map +1 -0
- package/dist/interfaces/chunks/config.d.ts +52 -0
- package/dist/interfaces/chunks/config.d.ts.map +1 -0
- package/dist/interfaces/chunks/config.js +7 -0
- package/dist/interfaces/chunks/config.js.map +1 -0
- package/dist/interfaces/chunks/lit-action-execution.d.ts +27 -0
- package/dist/interfaces/chunks/lit-action-execution.d.ts.map +1 -0
- package/dist/interfaces/chunks/lit-action-execution.js +7 -0
- package/dist/interfaces/chunks/lit-action-execution.js.map +1 -0
- package/dist/interfaces/chunks/pkp-operations.d.ts +143 -0
- package/dist/interfaces/chunks/pkp-operations.d.ts.map +1 -0
- package/dist/interfaces/chunks/pkp-operations.js +3 -0
- package/dist/interfaces/chunks/pkp-operations.js.map +1 -0
- package/dist/interfaces/index.d.ts +11 -0
- package/dist/interfaces/index.d.ts.map +1 -0
- package/dist/interfaces/index.js +31 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/modules/action-executor.module.d.ts +34 -0
- package/dist/modules/action-executor.module.d.ts.map +1 -0
- package/dist/modules/action-executor.module.js +231 -0
- package/dist/modules/action-executor.module.js.map +1 -0
- package/dist/modules/auth-manager.module.d.ts +24 -0
- package/dist/modules/auth-manager.module.d.ts.map +1 -0
- package/dist/modules/auth-manager.module.js +103 -0
- package/dist/modules/auth-manager.module.js.map +1 -0
- package/dist/modules/client-manager.module.d.ts +64 -0
- package/dist/modules/client-manager.module.d.ts.map +1 -0
- package/dist/modules/client-manager.module.js +213 -0
- package/dist/modules/client-manager.module.js.map +1 -0
- package/dist/modules/lit-ops.module.d.ts +261 -0
- package/dist/modules/lit-ops.module.d.ts.map +1 -0
- package/dist/modules/lit-ops.module.js +792 -0
- package/dist/modules/lit-ops.module.js.map +1 -0
- package/dist/modules/pkp-authorizer.module.d.ts +72 -0
- package/dist/modules/pkp-authorizer.module.d.ts.map +1 -0
- package/dist/modules/pkp-authorizer.module.js +126 -0
- package/dist/modules/pkp-authorizer.module.js.map +1 -0
- package/dist/modules/pkp-macros.module.d.ts +188 -0
- package/dist/modules/pkp-macros.module.d.ts.map +1 -0
- package/dist/modules/pkp-macros.module.js +656 -0
- package/dist/modules/pkp-macros.module.js.map +1 -0
- package/dist/modules/pkp-manager.module.d.ts +56 -0
- package/dist/modules/pkp-manager.module.d.ts.map +1 -0
- package/dist/modules/pkp-manager.module.js +304 -0
- package/dist/modules/pkp-manager.module.js.map +1 -0
- package/dist/modules/pkp-minter.module.d.ts +66 -0
- package/dist/modules/pkp-minter.module.d.ts.map +1 -0
- package/dist/modules/pkp-minter.module.js +185 -0
- package/dist/modules/pkp-minter.module.js.map +1 -0
- package/dist/modules/pkp-signer.module.d.ts +56 -0
- package/dist/modules/pkp-signer.module.d.ts.map +1 -0
- package/dist/modules/pkp-signer.module.js +148 -0
- package/dist/modules/pkp-signer.module.js.map +1 -0
- package/dist/modules/session-signature-manager.module.d.ts +32 -0
- package/dist/modules/session-signature-manager.module.d.ts.map +1 -0
- package/dist/modules/session-signature-manager.module.js +123 -0
- package/dist/modules/session-signature-manager.module.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { ethers as ethers5 } from "ethers";
|
|
2
|
+
/**
|
|
3
|
+
* PKP Operation Types
|
|
4
|
+
* Types related to PKP (Programmable Key Pair) operations and management
|
|
5
|
+
*/
|
|
6
|
+
export interface PKPData {
|
|
7
|
+
tokenId: string;
|
|
8
|
+
publicKey: string;
|
|
9
|
+
ethAddress: string;
|
|
10
|
+
authorizedCid: string;
|
|
11
|
+
authorizedCidHex: string;
|
|
12
|
+
authorizedCidStored: string;
|
|
13
|
+
permittedActionsCount: number;
|
|
14
|
+
createTransactionHash: string;
|
|
15
|
+
burnTransactionHash: string;
|
|
16
|
+
burnGasUsed: number;
|
|
17
|
+
blockNumber: number;
|
|
18
|
+
exists: boolean;
|
|
19
|
+
burned: boolean;
|
|
20
|
+
verified: boolean;
|
|
21
|
+
createdAt: string;
|
|
22
|
+
network: string;
|
|
23
|
+
workflow: string;
|
|
24
|
+
duration: number;
|
|
25
|
+
isImmutable: boolean;
|
|
26
|
+
isProductionReady: boolean;
|
|
27
|
+
creatorCanModify: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* PKP validation response from LIT Actions
|
|
31
|
+
*/
|
|
32
|
+
export interface PKPCreationRequest {
|
|
33
|
+
/** Signer for authentication (standalone mode) */
|
|
34
|
+
signer?: ethers5.Signer;
|
|
35
|
+
/** User identifier (service mode) */
|
|
36
|
+
userId?: string;
|
|
37
|
+
/** LIT Action CID to authorize */
|
|
38
|
+
litActionCid?: string;
|
|
39
|
+
/** Additional metadata */
|
|
40
|
+
metadata?: Record<string, any>;
|
|
41
|
+
}
|
|
42
|
+
export interface PKPCreationResult extends BaseResult {
|
|
43
|
+
pkpId?: string;
|
|
44
|
+
publicKey?: string;
|
|
45
|
+
ethAddress?: string;
|
|
46
|
+
transactionHash?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface PKPValidationRequest {
|
|
49
|
+
pkpId: string;
|
|
50
|
+
signer?: ethers5.Signer;
|
|
51
|
+
userId?: string;
|
|
52
|
+
}
|
|
53
|
+
export interface PKPValidationResult extends BaseResult {
|
|
54
|
+
isValid?: boolean;
|
|
55
|
+
pkpId: string;
|
|
56
|
+
}
|
|
57
|
+
export interface PKPBurnRequest {
|
|
58
|
+
pkpId: string;
|
|
59
|
+
signer?: ethers5.Signer;
|
|
60
|
+
userId?: string;
|
|
61
|
+
reason?: string;
|
|
62
|
+
}
|
|
63
|
+
export interface PKPBurnResult extends BaseResult {
|
|
64
|
+
pkpId: string;
|
|
65
|
+
burned?: boolean;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Base result interface for all PKP operations
|
|
69
|
+
*/
|
|
70
|
+
export interface BaseResult {
|
|
71
|
+
success: boolean;
|
|
72
|
+
error?: string;
|
|
73
|
+
timestamp: number;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Extended PKP Data for complete workflow results
|
|
77
|
+
* Extends the base PKPData with workflow-specific fields
|
|
78
|
+
*/
|
|
79
|
+
export interface ExtendedPKPData {
|
|
80
|
+
tokenId: string;
|
|
81
|
+
publicKey: string;
|
|
82
|
+
ethAddress: string;
|
|
83
|
+
mintTransactionHash: string;
|
|
84
|
+
verified: boolean;
|
|
85
|
+
owner: string;
|
|
86
|
+
authTransactionHash: string;
|
|
87
|
+
isPermitted: boolean;
|
|
88
|
+
permittedActions: string[];
|
|
89
|
+
burnTransactionHash?: string;
|
|
90
|
+
burned?: boolean;
|
|
91
|
+
workflow: string;
|
|
92
|
+
timestamp: number;
|
|
93
|
+
duration: number;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* PKP Security Validation Result
|
|
97
|
+
*/
|
|
98
|
+
export interface PKPSecurityValidationResult {
|
|
99
|
+
success: boolean;
|
|
100
|
+
signature?: string;
|
|
101
|
+
error?: string;
|
|
102
|
+
signatureValid: boolean;
|
|
103
|
+
pkpAddress?: string;
|
|
104
|
+
recoveredAddress?: string;
|
|
105
|
+
validationResult?: {
|
|
106
|
+
exists: boolean;
|
|
107
|
+
isImmutable: boolean;
|
|
108
|
+
hasOnlyOneAction: boolean;
|
|
109
|
+
matchesExpectedCID: boolean;
|
|
110
|
+
allValid: boolean;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Audit Step interface
|
|
115
|
+
*/
|
|
116
|
+
export interface AuditStep {
|
|
117
|
+
step: number;
|
|
118
|
+
description: string;
|
|
119
|
+
timestamp: number;
|
|
120
|
+
duration: number;
|
|
121
|
+
success: boolean;
|
|
122
|
+
data?: any;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Audit Trail interface
|
|
126
|
+
*/
|
|
127
|
+
export interface AuditTrail {
|
|
128
|
+
steps: AuditStep[];
|
|
129
|
+
totalDuration: number;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Complete PKP Creation and Validation Result
|
|
133
|
+
* Return type for LitOps.createAndValidatePkpToLitAction and LitOps.getNewDiamondHandsLoanPkp
|
|
134
|
+
* Extends BaseResult and composes other interfaces
|
|
135
|
+
*/
|
|
136
|
+
export interface PKPCreationAndValidationResult extends BaseResult {
|
|
137
|
+
duration: number;
|
|
138
|
+
targetCid: string;
|
|
139
|
+
pkpData: ExtendedPKPData;
|
|
140
|
+
validationResult: PKPSecurityValidationResult;
|
|
141
|
+
auditTrail: AuditTrail;
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=pkp-operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pkp-operations.d.ts","sourceRoot":"","sources":["../../../src/interfaces/chunks/pkp-operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,MAAM,QAAQ,CAAC;AAE3C;;;GAGG;AAGH,MAAM,WAAW,OAAO;IAEtB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IAGnB,aAAa,EAAE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IAC1B,gBAAgB,CAAC,EAAE;QACjB,MAAM,EAAE,OAAO,CAAC;QAChB,WAAW,EAAE,OAAO,CAAC;QACrB,gBAAgB,EAAE,OAAO,CAAC;QAC1B,kBAAkB,EAAE,OAAO,CAAC;QAC5B,QAAQ,EAAE,OAAO,CAAC;KACnB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AACH,MAAM,WAAW,8BAA+B,SAAQ,UAAU;IAChE,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,eAAe,CAAC;IACzB,gBAAgB,EAAE,2BAA2B,CAAC;IAC9C,UAAU,EAAE,UAAU,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pkp-operations.js","sourceRoot":"","sources":["../../../src/interfaces/chunks/pkp-operations.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LIT-OPS Package Interfaces
|
|
3
|
+
* All TypeScript interfaces and types used in the package
|
|
4
|
+
*
|
|
5
|
+
* Following the golden source pattern with organized chunks
|
|
6
|
+
*/
|
|
7
|
+
export * from "./chunks/config";
|
|
8
|
+
export * from "./chunks/pkp-operations";
|
|
9
|
+
export * from "./chunks/lit-action-execution";
|
|
10
|
+
export * from "./chunks/authentication";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,iBAAiB,CAAC;AAGhC,cAAc,yBAAyB,CAAC;AAGxC,cAAc,+BAA+B,CAAC;AAG9C,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* LIT-OPS Package Interfaces
|
|
4
|
+
* All TypeScript interfaces and types used in the package
|
|
5
|
+
*
|
|
6
|
+
* Following the golden source pattern with organized chunks
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
// Configuration Types
|
|
24
|
+
__exportStar(require("./chunks/config"), exports);
|
|
25
|
+
// PKP Operation Types
|
|
26
|
+
__exportStar(require("./chunks/pkp-operations"), exports);
|
|
27
|
+
// LIT Action Types
|
|
28
|
+
__exportStar(require("./chunks/lit-action-execution"), exports);
|
|
29
|
+
// Session & Authentication Types
|
|
30
|
+
__exportStar(require("./chunks/authentication"), exports);
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,sBAAsB;AACtB,kDAAgC;AAEhC,sBAAsB;AACtB,0DAAwC;AAExC,mBAAmB;AACnB,gEAA8C;AAE9C,iCAAiC;AACjC,0DAAwC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LIT Action Execution Manager
|
|
3
|
+
* Handles LIT Action execution from code or CID
|
|
4
|
+
*/
|
|
5
|
+
import { LitActionExecutionRequest, LitActionExecutionResult, LitOpsMode } from "../interfaces";
|
|
6
|
+
import { LitAuthManager } from "./auth-manager.module";
|
|
7
|
+
export declare class LitActionExecutor {
|
|
8
|
+
private mode;
|
|
9
|
+
private debug;
|
|
10
|
+
private authManager;
|
|
11
|
+
private serviceEndpoint?;
|
|
12
|
+
constructor(mode: LitOpsMode, debug?: boolean, authManager?: LitAuthManager, serviceEndpoint?: string);
|
|
13
|
+
/**
|
|
14
|
+
* Execute a LIT Action
|
|
15
|
+
*/
|
|
16
|
+
executeAction(request: LitActionExecutionRequest, litClient: any): Promise<LitActionExecutionResult>;
|
|
17
|
+
/**
|
|
18
|
+
* Execute LIT Action in standalone mode
|
|
19
|
+
*/
|
|
20
|
+
private executeActionStandalone;
|
|
21
|
+
/**
|
|
22
|
+
* Execute LIT Action via service
|
|
23
|
+
*/
|
|
24
|
+
private executeActionService;
|
|
25
|
+
/**
|
|
26
|
+
* Execute mock LIT Action for fallback
|
|
27
|
+
*/
|
|
28
|
+
private executeMockAction;
|
|
29
|
+
/**
|
|
30
|
+
* Fetch LIT Action code from IPFS
|
|
31
|
+
*/
|
|
32
|
+
private fetchLitActionFromIPFS;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=action-executor.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-executor.module.d.ts","sourceRoot":"","sources":["../../src/modules/action-executor.module.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,UAAU,EACX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,KAAK,CAAU;IACvB,OAAO,CAAC,WAAW,CAAiB;IACpC,OAAO,CAAC,eAAe,CAAC,CAAS;gBAG/B,IAAI,EAAE,UAAU,EAChB,KAAK,GAAE,OAAe,EACtB,WAAW,CAAC,EAAE,cAAc,EAC5B,eAAe,CAAC,EAAE,MAAM;IAQ1B;;OAEG;IACG,aAAa,CACjB,OAAO,EAAE,yBAAyB,EAClC,SAAS,EAAE,GAAG,GACb,OAAO,CAAC,wBAAwB,CAAC;IAkBpC;;OAEG;YACW,uBAAuB;IAuFrC;;OAEG;YACW,oBAAoB;IA2DlC;;OAEG;IACH,OAAO,CAAC,iBAAiB;IA+BzB;;OAEG;YACW,sBAAsB;CAyCrC"}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* LIT Action Execution Manager
|
|
4
|
+
* Handles LIT Action execution from code or CID
|
|
5
|
+
*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.LitActionExecutor = void 0;
|
|
11
|
+
const axios_1 = __importDefault(require("axios"));
|
|
12
|
+
const ethers_1 = require("ethers");
|
|
13
|
+
const auth_manager_module_1 = require("./auth-manager.module");
|
|
14
|
+
class LitActionExecutor {
|
|
15
|
+
constructor(mode, debug = false, authManager, serviceEndpoint) {
|
|
16
|
+
this.mode = mode;
|
|
17
|
+
this.debug = debug;
|
|
18
|
+
this.authManager = authManager || new auth_manager_module_1.LitAuthManager(debug);
|
|
19
|
+
this.serviceEndpoint = serviceEndpoint;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Execute a LIT Action
|
|
23
|
+
*/
|
|
24
|
+
async executeAction(request, litClient) {
|
|
25
|
+
if (this.debug) {
|
|
26
|
+
console.log("🚀 Executing LIT Action in", this.mode, "mode");
|
|
27
|
+
if (request.code) {
|
|
28
|
+
console.log(" Using inline code");
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
console.log(" CID:", request.cid);
|
|
32
|
+
}
|
|
33
|
+
console.log(" PKP:", request.pkpPublicKey);
|
|
34
|
+
}
|
|
35
|
+
if (this.mode === "standalone") {
|
|
36
|
+
return this.executeActionStandalone(request, litClient);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return this.executeActionService(request);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Execute LIT Action in standalone mode
|
|
44
|
+
*/
|
|
45
|
+
async executeActionStandalone(request, litClient) {
|
|
46
|
+
try {
|
|
47
|
+
// Get LIT Action code
|
|
48
|
+
let litActionCode;
|
|
49
|
+
if (request.code) {
|
|
50
|
+
litActionCode = request.code;
|
|
51
|
+
if (this.debug) {
|
|
52
|
+
console.log("✅ Using provided LIT Action code");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else if (request.cid) {
|
|
56
|
+
litActionCode = await this.fetchLitActionFromIPFS(request.cid);
|
|
57
|
+
if (this.debug) {
|
|
58
|
+
console.log("✅ Fetched LIT Action from CID:", request.cid);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
throw new Error("Either code or cid must be provided");
|
|
63
|
+
}
|
|
64
|
+
// Check if we have a signer for real execution
|
|
65
|
+
if (!request.signer) {
|
|
66
|
+
if (this.debug) {
|
|
67
|
+
console.log("❌ No signer provided - using mock execution");
|
|
68
|
+
}
|
|
69
|
+
return this.executeMockAction(request, litActionCode);
|
|
70
|
+
}
|
|
71
|
+
// Generate sessionSigs for real execution
|
|
72
|
+
const sessionSigsResult = await this.authManager.generateSessionSigs({
|
|
73
|
+
signer: request.signer,
|
|
74
|
+
expirationMinutes: 10,
|
|
75
|
+
}, litClient);
|
|
76
|
+
if (!sessionSigsResult.success) {
|
|
77
|
+
if (this.debug) {
|
|
78
|
+
console.log("❌ SessionSigs generation failed - using mock execution");
|
|
79
|
+
}
|
|
80
|
+
return this.executeMockAction(request, litActionCode);
|
|
81
|
+
}
|
|
82
|
+
// Execute real LIT Action
|
|
83
|
+
if (this.debug) {
|
|
84
|
+
console.log("🔥 Executing REAL LIT Action from CID!");
|
|
85
|
+
}
|
|
86
|
+
const result = await litClient.executeJs({
|
|
87
|
+
code: litActionCode,
|
|
88
|
+
sessionSigs: sessionSigsResult.sessionSigs,
|
|
89
|
+
jsParams: {
|
|
90
|
+
...request.params,
|
|
91
|
+
publicKey: request.pkpPublicKey,
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
if (this.debug) {
|
|
95
|
+
console.log("🎉 REAL LIT ACTION EXECUTED SUCCESSFULLY!");
|
|
96
|
+
console.log(" Response:", result.response);
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
success: true,
|
|
100
|
+
response: result.response,
|
|
101
|
+
logs: result.logs,
|
|
102
|
+
signatures: result.signatures,
|
|
103
|
+
timestamp: Date.now(),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
if (this.debug) {
|
|
108
|
+
console.error("❌ LIT Action execution failed:", error);
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
success: false,
|
|
112
|
+
error: error instanceof Error ? error.message : String(error),
|
|
113
|
+
timestamp: Date.now(),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Execute LIT Action via service
|
|
119
|
+
*/
|
|
120
|
+
async executeActionService(request) {
|
|
121
|
+
if (!this.serviceEndpoint) {
|
|
122
|
+
throw new Error("Service endpoint not configured for service mode");
|
|
123
|
+
}
|
|
124
|
+
try {
|
|
125
|
+
const response = await fetch(`${this.serviceEndpoint}/api/execute-lit-action`, {
|
|
126
|
+
method: 'POST',
|
|
127
|
+
headers: {
|
|
128
|
+
'Content-Type': 'application/json',
|
|
129
|
+
},
|
|
130
|
+
body: JSON.stringify({
|
|
131
|
+
cid: request.cid,
|
|
132
|
+
pkpPublicKey: request.pkpPublicKey,
|
|
133
|
+
params: request.params,
|
|
134
|
+
userId: request.userId,
|
|
135
|
+
}),
|
|
136
|
+
});
|
|
137
|
+
if (!response.ok) {
|
|
138
|
+
throw new Error(`Service request failed: ${response.status} ${response.statusText}`);
|
|
139
|
+
}
|
|
140
|
+
const result = await response.json();
|
|
141
|
+
if (this.debug) {
|
|
142
|
+
console.log("✅ LIT Action executed via service:", result);
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
success: result.success,
|
|
146
|
+
response: {
|
|
147
|
+
message: result.message || "LIT Action executed via service",
|
|
148
|
+
signature: result.signature,
|
|
149
|
+
},
|
|
150
|
+
signatures: result.signature ? { signature: result.signature } : undefined,
|
|
151
|
+
timestamp: Date.now(),
|
|
152
|
+
error: result.error,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
if (this.debug) {
|
|
157
|
+
console.error("❌ Service LIT Action execution failed:", error);
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
success: false,
|
|
161
|
+
error: error instanceof Error ? error.message : String(error),
|
|
162
|
+
timestamp: Date.now(),
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Execute mock LIT Action for fallback
|
|
168
|
+
*/
|
|
169
|
+
executeMockAction(request, litActionCode) {
|
|
170
|
+
const mockSignature = ethers_1.ethers.utils.keccak256(ethers_1.ethers.utils.toUtf8Bytes(JSON.stringify(request.params) || "mock"));
|
|
171
|
+
const mockResponse = {
|
|
172
|
+
success: true,
|
|
173
|
+
signature: mockSignature,
|
|
174
|
+
message: request.params.message || "mock-execution",
|
|
175
|
+
pkpPublicKey: request.pkpPublicKey,
|
|
176
|
+
timestamp: Date.now(),
|
|
177
|
+
action: "mock-lit-action-execution",
|
|
178
|
+
note: "Mock execution - provide signer for real LIT Protocol execution",
|
|
179
|
+
};
|
|
180
|
+
if (this.debug) {
|
|
181
|
+
console.log("🎭 Mock LIT Action execution completed");
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
success: true,
|
|
185
|
+
response: JSON.stringify(mockResponse),
|
|
186
|
+
logs: "Mock LIT Action execution completed",
|
|
187
|
+
signatures: {},
|
|
188
|
+
timestamp: Date.now(),
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Fetch LIT Action code from IPFS
|
|
193
|
+
*/
|
|
194
|
+
async fetchLitActionFromIPFS(cid) {
|
|
195
|
+
const gateways = [
|
|
196
|
+
`https://${cid}.ipfs.dweb.link/`,
|
|
197
|
+
`https://dweb.link/ipfs/${cid}`,
|
|
198
|
+
`https://ipfs.io/ipfs/${cid}`,
|
|
199
|
+
`https://gateway.pinata.cloud/ipfs/${cid}`,
|
|
200
|
+
`https://cloudflare-ipfs.com/ipfs/${cid}`,
|
|
201
|
+
];
|
|
202
|
+
for (const gateway of gateways) {
|
|
203
|
+
try {
|
|
204
|
+
if (this.debug) {
|
|
205
|
+
console.log(`📡 Fetching from ${gateway}...`);
|
|
206
|
+
}
|
|
207
|
+
const response = await axios_1.default.get(gateway, {
|
|
208
|
+
timeout: 10000,
|
|
209
|
+
headers: {
|
|
210
|
+
Accept: "text/plain, application/javascript, text/javascript",
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
if (response.data && typeof response.data === "string") {
|
|
214
|
+
if (this.debug) {
|
|
215
|
+
console.log(`✅ Fetched LIT Action from ${gateway}`);
|
|
216
|
+
}
|
|
217
|
+
return response.data;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
if (this.debug) {
|
|
222
|
+
console.log(`❌ Failed to fetch from ${gateway}:`, error instanceof Error ? error.message : error);
|
|
223
|
+
}
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
throw new Error(`Failed to fetch LIT Action from IPFS CID: ${cid}`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
exports.LitActionExecutor = LitActionExecutor;
|
|
231
|
+
//# sourceMappingURL=action-executor.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-executor.module.js","sourceRoot":"","sources":["../../src/modules/action-executor.module.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,kDAA0B;AAC1B,mCAA2C;AAM3C,+DAAuD;AAEvD,MAAa,iBAAiB;IAM5B,YACE,IAAgB,EAChB,QAAiB,KAAK,EACtB,WAA4B,EAC5B,eAAwB;QAExB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,WAAW,GAAG,WAAW,IAAI,IAAI,oCAAc,CAAC,KAAK,CAAC,CAAC;QAC5D,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,aAAa,CACjB,OAAkC,EAClC,SAAc;QAEd,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,GAAG,CAAC,4BAA4B,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAC7D,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;gBACjB,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;YACtC,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,GAA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,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,GAAG,CACT,0BAA0B,OAAO,GAAG,EACpC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAC/C,CAAC;gBACJ,CAAC;gBACD,SAAS;YACX,CAAC;QACH,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,6CAA6C,GAAG,EAAE,CAAC,CAAC;IACtE,CAAC;CACF;AAhRD,8CAgRC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LIT Protocol Authentication
|
|
3
|
+
* Handles sessionSigs generation for standalone mode
|
|
4
|
+
*/
|
|
5
|
+
import { ethers as ethers5 } from "ethers";
|
|
6
|
+
import { SessionSigsRequest, SessionSigsResult } from "../interfaces";
|
|
7
|
+
export declare class LitAuthManager {
|
|
8
|
+
private debug;
|
|
9
|
+
constructor(debug?: boolean);
|
|
10
|
+
/**
|
|
11
|
+
* Generate session signatures for LIT Action execution
|
|
12
|
+
* Based on samples/sdk patterns
|
|
13
|
+
*/
|
|
14
|
+
generateSessionSigs(request: SessionSigsRequest, litClient: any): Promise<SessionSigsResult>;
|
|
15
|
+
/**
|
|
16
|
+
* Validate if sessionSigs are still valid
|
|
17
|
+
*/
|
|
18
|
+
validateSessionSigs(sessionSigs: any, expiresAt?: number): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Generate simplified session sigs for testing
|
|
21
|
+
*/
|
|
22
|
+
generateTestSessionSigs(signer: ethers5.Signer, litClient: any): Promise<SessionSigsResult>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=auth-manager.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-manager.module.d.ts","sourceRoot":"","sources":["../../src/modules/auth-manager.module.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEtE,qBAAa,cAAc;IACzB,OAAO,CAAC,KAAK,CAAU;gBAEX,KAAK,GAAE,OAAe;IAIlC;;;OAGG;IACG,mBAAmB,CACvB,OAAO,EAAE,kBAAkB,EAC3B,SAAS,EAAE,GAAG,GACb,OAAO,CAAC,iBAAiB,CAAC;IA2E7B;;OAEG;IACH,mBAAmB,CAAC,WAAW,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO;IAalE;;OAEG;IACG,uBAAuB,CAC3B,MAAM,EAAE,OAAO,CAAC,MAAM,EACtB,SAAS,EAAE,GAAG,GACb,OAAO,CAAC,iBAAiB,CAAC;CAU9B"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* LIT Protocol Authentication
|
|
4
|
+
* Handles sessionSigs generation for standalone mode
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.LitAuthManager = void 0;
|
|
8
|
+
const auth_helpers_1 = require("@lit-protocol/auth-helpers");
|
|
9
|
+
class LitAuthManager {
|
|
10
|
+
constructor(debug = false) {
|
|
11
|
+
this.debug = debug;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Generate session signatures for LIT Action execution
|
|
15
|
+
* Based on samples/sdk patterns
|
|
16
|
+
*/
|
|
17
|
+
async generateSessionSigs(request, litClient) {
|
|
18
|
+
try {
|
|
19
|
+
const { signer, domain = "diamond-hands.local", expirationMinutes = 15, } = request;
|
|
20
|
+
if (this.debug) {
|
|
21
|
+
console.log("🔑 Generating sessionSigs for LIT Action execution...");
|
|
22
|
+
console.log(" Signer address:", await signer.getAddress());
|
|
23
|
+
console.log(" Domain:", domain);
|
|
24
|
+
console.log(" Expiration:", expirationMinutes, "minutes");
|
|
25
|
+
}
|
|
26
|
+
const sessionSigs = await litClient.getSessionSigs({
|
|
27
|
+
chain: "ethereum",
|
|
28
|
+
expiration: new Date(Date.now() + 1000 * 60 * expirationMinutes).toISOString(),
|
|
29
|
+
resourceAbilityRequests: [
|
|
30
|
+
{
|
|
31
|
+
resource: new auth_helpers_1.LitActionResource("*"),
|
|
32
|
+
ability: "lit-action-execution",
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
authNeededCallback: async (params) => {
|
|
36
|
+
if (this.debug) {
|
|
37
|
+
console.log("🔐 Creating SIWE message for authentication...");
|
|
38
|
+
}
|
|
39
|
+
const toSign = await (0, auth_helpers_1.createSiweMessage)({
|
|
40
|
+
uri: params.uri,
|
|
41
|
+
domain: domain,
|
|
42
|
+
expiration: params.expiration,
|
|
43
|
+
resources: params.resourceAbilityRequests,
|
|
44
|
+
walletAddress: await signer.getAddress(),
|
|
45
|
+
nonce: await litClient.getLatestBlockhash(),
|
|
46
|
+
statement: "Diamond Hands Protocol - LIT Action Execution Authorization",
|
|
47
|
+
litNodeClient: litClient,
|
|
48
|
+
});
|
|
49
|
+
if (this.debug) {
|
|
50
|
+
console.log("✍️ Signing authentication message...");
|
|
51
|
+
}
|
|
52
|
+
return await (0, auth_helpers_1.generateAuthSig)({
|
|
53
|
+
signer,
|
|
54
|
+
toSign,
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
if (this.debug) {
|
|
59
|
+
console.log("✅ SessionSigs generated successfully");
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
success: true,
|
|
63
|
+
sessionSigs,
|
|
64
|
+
expiresAt: Date.now() + expirationMinutes * 60 * 1000,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (this.debug) {
|
|
69
|
+
console.error("❌ SessionSigs generation failed:", error);
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
success: false,
|
|
73
|
+
error: error instanceof Error ? error.message : String(error),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Validate if sessionSigs are still valid
|
|
79
|
+
*/
|
|
80
|
+
validateSessionSigs(sessionSigs, expiresAt) {
|
|
81
|
+
if (!sessionSigs)
|
|
82
|
+
return false;
|
|
83
|
+
if (expiresAt && Date.now() > expiresAt) {
|
|
84
|
+
if (this.debug) {
|
|
85
|
+
console.log("⏰ SessionSigs expired");
|
|
86
|
+
}
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Generate simplified session sigs for testing
|
|
93
|
+
*/
|
|
94
|
+
async generateTestSessionSigs(signer, litClient) {
|
|
95
|
+
return this.generateSessionSigs({
|
|
96
|
+
signer,
|
|
97
|
+
domain: "diamond-hands-test.local",
|
|
98
|
+
expirationMinutes: 10,
|
|
99
|
+
}, litClient);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.LitAuthManager = LitAuthManager;
|
|
103
|
+
//# sourceMappingURL=auth-manager.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-manager.module.js","sourceRoot":"","sources":["../../src/modules/auth-manager.module.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6DAIoC;AAIpC,MAAa,cAAc;IAGzB,YAAY,QAAiB,KAAK;QAChC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,mBAAmB,CACvB,OAA2B,EAC3B,SAAc;QAEd,IAAI,CAAC;YACH,MAAM,EACJ,MAAM,EACN,MAAM,GAAG,qBAAqB,EAC9B,iBAAiB,GAAG,EAAE,GACvB,GAAG,OAAO,CAAC;YAEZ,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,GAAG,CAAC,uDAAuD,CAAC,CAAC;g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