@keypo/typescript-sdk-server 1.0.0
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 +1 -0
- package/dist/decryptServer.d.ts +7 -0
- package/dist/decryptServer.d.ts.map +1 -0
- package/dist/decryptServer.js +50 -0
- package/dist/decryptServer.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +95 -0
- package/dist/index.js.map +1 -0
- package/dist/proxyExecuteServer.d.ts +9 -0
- package/dist/proxyExecuteServer.d.ts.map +1 -0
- package/dist/proxyExecuteServer.js +45 -0
- package/dist/proxyExecuteServer.js.map +1 -0
- package/dist/utils/authenticateLitSessionServer.d.ts +14 -0
- package/dist/utils/authenticateLitSessionServer.d.ts.map +1 -0
- package/dist/utils/authenticateLitSessionServer.js +268 -0
- package/dist/utils/authenticateLitSessionServer.js.map +1 -0
- package/dist/utils/createEVMBalanceCondition.d.ts +3 -0
- package/dist/utils/createEVMBalanceCondition.d.ts.map +1 -0
- package/dist/utils/createEVMBalanceCondition.js +20 -0
- package/dist/utils/createEVMBalanceCondition.js.map +1 -0
- package/dist/utils/createEVMContractCondition.d.ts +3 -0
- package/dist/utils/createEVMContractCondition.d.ts.map +1 -0
- package/dist/utils/createEVMContractCondition.js +45 -0
- package/dist/utils/createEVMContractCondition.js.map +1 -0
- package/dist/utils/getPermissionedFileMetadata.d.ts +2 -0
- package/dist/utils/getPermissionedFileMetadata.d.ts.map +1 -0
- package/dist/utils/getPermissionedFileMetadata.js +35 -0
- package/dist/utils/getPermissionedFileMetadata.js.map +1 -0
- package/package.json +67 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# keypo-sdk-server
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
import { type DecryptConfig, type DataMetadata } from "@keypo/typescript-sdk";
|
|
3
|
+
export declare function decryptServer(dataIdentifier: string, wallet: ethers.Wallet, config: DecryptConfig, debug?: boolean): Promise<{
|
|
4
|
+
decryptedData: Uint8Array;
|
|
5
|
+
metadata: DataMetadata;
|
|
6
|
+
}>;
|
|
7
|
+
//# sourceMappingURL=decryptServer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decryptServer.d.ts","sourceRoot":"","sources":["../src/decryptServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAA2B,MAAM,uBAAuB,CAAC;AAGvG,wBAAsB,aAAa,CAC/B,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,CAAC,MAAM,EACrB,MAAM,EAAE,aAAa,EACrB,KAAK,CAAC,EAAE,OAAO,GACd,OAAO,CAAC;IAAE,aAAa,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,YAAY,CAAA;CAAE,CAAC,CA4DlE"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decryptServer = decryptServer;
|
|
4
|
+
const authenticateLitSessionServer_1 = require("./utils/authenticateLitSessionServer");
|
|
5
|
+
async function decryptServer(dataIdentifier, wallet, config, debug) {
|
|
6
|
+
if (debug) {
|
|
7
|
+
console.log("[DEBUG] decryptServer() called with:");
|
|
8
|
+
console.log(" dataIdentifier:", dataIdentifier);
|
|
9
|
+
console.log(" wallet.address:", await wallet.getAddress());
|
|
10
|
+
console.log(" config:", config);
|
|
11
|
+
}
|
|
12
|
+
// Authenticate lit session with ethers wallet using server-side approach
|
|
13
|
+
if (debug) {
|
|
14
|
+
console.log("[DEBUG] Calling authenticateLitSessionServer...");
|
|
15
|
+
}
|
|
16
|
+
const { sessionSigs, dataMetadata } = await (0, authenticateLitSessionServer_1.authenticateLitSessionServer)(wallet, config.chain, config.expiration, config.registryContractAddress, dataIdentifier, config.apiUrl, debug);
|
|
17
|
+
if (debug) {
|
|
18
|
+
console.log("[DEBUG] authenticateLitSessionServer result:", {
|
|
19
|
+
sessionSigs,
|
|
20
|
+
dataMetadata,
|
|
21
|
+
});
|
|
22
|
+
console.log("dataMetadata", dataMetadata);
|
|
23
|
+
}
|
|
24
|
+
// Call the API endpoint to handle decryption
|
|
25
|
+
const response = await fetch(`${config.apiUrl}/decryption`, {
|
|
26
|
+
method: "POST",
|
|
27
|
+
headers: {
|
|
28
|
+
'Content-Type': 'application/json',
|
|
29
|
+
},
|
|
30
|
+
body: JSON.stringify({
|
|
31
|
+
dataIdentifier,
|
|
32
|
+
sessionSigs,
|
|
33
|
+
dataMetadata: JSON.stringify(dataMetadata),
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
if (!response.ok) {
|
|
37
|
+
throw new Error(`Decryption failed: ${response.statusText}`);
|
|
38
|
+
}
|
|
39
|
+
const result = await response.json();
|
|
40
|
+
if (debug) {
|
|
41
|
+
console.log("[DEBUG] API response:", result);
|
|
42
|
+
}
|
|
43
|
+
// Convert the decrypted data from a plain object to a Uint8Array
|
|
44
|
+
const decryptedDataArray = new Uint8Array(Object.values(result.decryptedData));
|
|
45
|
+
return {
|
|
46
|
+
decryptedData: decryptedDataArray,
|
|
47
|
+
metadata: result.metadata,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=decryptServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decryptServer.js","sourceRoot":"","sources":["../src/decryptServer.ts"],"names":[],"mappings":";;AAIA,sCAiEC;AAnED,uFAAoF;AAE7E,KAAK,UAAU,aAAa,CAC/B,cAAsB,EACtB,MAAqB,EACrB,MAAqB,EACrB,KAAe;IAEf,IAAI,KAAK,EAAE,CAAC;QACR,OAAO,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;QACpD,OAAO,CAAC,GAAG,CAAC,mBAAmB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OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC;IACjD,CAAC;IAED,iEAAiE;IACjE,MAAM,kBAAkB,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC;IAE/E,OAAO;QACH,aAAa,EAAE,kBAAkB;QACjC,QAAQ,EAAE,MAAM,CAAC,QAAQ;KAC5B,CAAC;AACN,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export * from './decryptServer';
|
|
2
|
+
export * from './proxyExecuteServer';
|
|
3
|
+
export { encrypt, encryptForProxy, deleteData, list, getDataInfo, postProcess, preProcess, genAuthSig, genSession, shareData, search, createEvmConditions, createEvmBalanceConditions, init, generateAccount } from '@keypo/typescript-sdk';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA+BE,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AAGrC,OAAO,EACL,OAAO,EACP,eAAe,EACf,UAAU,EACV,IAAI,EACJ,WAAW,EACX,WAAW,EACX,UAAU,EACV,UAAU,EACV,UAAU,EACV,SAAS,EACT,MAAM,EACN,mBAAmB,EACnB,0BAA0B,EAC1B,IAAI,EACJ,eAAe,EAChB,MAAM,uBAAuB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
36
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.generateAccount = exports.init = exports.createEvmBalanceConditions = exports.createEvmConditions = exports.search = exports.shareData = exports.genSession = exports.genAuthSig = exports.preProcess = exports.postProcess = exports.getDataInfo = exports.list = exports.deleteData = exports.encryptForProxy = exports.encrypt = void 0;
|
|
40
|
+
// Node.js entry point with polyfills
|
|
41
|
+
if (typeof globalThis !== 'undefined') {
|
|
42
|
+
// Polyfill crypto
|
|
43
|
+
if (!globalThis.crypto) {
|
|
44
|
+
(async () => {
|
|
45
|
+
try {
|
|
46
|
+
const cryptoModule = await Promise.resolve().then(() => __importStar(require('node:crypto')));
|
|
47
|
+
globalThis.crypto = cryptoModule.webcrypto;
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
console.warn('Web Crypto API not available, crypto operations may not work in this environment');
|
|
51
|
+
}
|
|
52
|
+
})();
|
|
53
|
+
}
|
|
54
|
+
// Polyfill fetch
|
|
55
|
+
if (!globalThis.fetch) {
|
|
56
|
+
(async () => {
|
|
57
|
+
try {
|
|
58
|
+
const fetchModule = await Promise.resolve().then(() => __importStar(require('node-fetch')));
|
|
59
|
+
globalThis.fetch = fetchModule.default;
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
console.warn('Fetch not available, HTTP requests may not work in this environment');
|
|
63
|
+
}
|
|
64
|
+
})();
|
|
65
|
+
}
|
|
66
|
+
// Polyfill browser globals
|
|
67
|
+
if (!globalThis.window)
|
|
68
|
+
globalThis.window = globalThis;
|
|
69
|
+
if (!globalThis.document)
|
|
70
|
+
globalThis.document = {};
|
|
71
|
+
if (!globalThis.navigator)
|
|
72
|
+
globalThis.navigator = {};
|
|
73
|
+
if (!globalThis.location)
|
|
74
|
+
globalThis.location = {};
|
|
75
|
+
}
|
|
76
|
+
__exportStar(require("./decryptServer"), exports);
|
|
77
|
+
__exportStar(require("./proxyExecuteServer"), exports);
|
|
78
|
+
// Export everything from @keypo/typescript-sdk except decryptServer and proxyExecuteServer
|
|
79
|
+
var typescript_sdk_1 = require("@keypo/typescript-sdk");
|
|
80
|
+
Object.defineProperty(exports, "encrypt", { enumerable: true, get: function () { return typescript_sdk_1.encrypt; } });
|
|
81
|
+
Object.defineProperty(exports, "encryptForProxy", { enumerable: true, get: function () { return typescript_sdk_1.encryptForProxy; } });
|
|
82
|
+
Object.defineProperty(exports, "deleteData", { enumerable: true, get: function () { return typescript_sdk_1.deleteData; } });
|
|
83
|
+
Object.defineProperty(exports, "list", { enumerable: true, get: function () { return typescript_sdk_1.list; } });
|
|
84
|
+
Object.defineProperty(exports, "getDataInfo", { enumerable: true, get: function () { return typescript_sdk_1.getDataInfo; } });
|
|
85
|
+
Object.defineProperty(exports, "postProcess", { enumerable: true, get: function () { return typescript_sdk_1.postProcess; } });
|
|
86
|
+
Object.defineProperty(exports, "preProcess", { enumerable: true, get: function () { return typescript_sdk_1.preProcess; } });
|
|
87
|
+
Object.defineProperty(exports, "genAuthSig", { enumerable: true, get: function () { return typescript_sdk_1.genAuthSig; } });
|
|
88
|
+
Object.defineProperty(exports, "genSession", { enumerable: true, get: function () { return typescript_sdk_1.genSession; } });
|
|
89
|
+
Object.defineProperty(exports, "shareData", { enumerable: true, get: function () { return typescript_sdk_1.shareData; } });
|
|
90
|
+
Object.defineProperty(exports, "search", { enumerable: true, get: function () { return typescript_sdk_1.search; } });
|
|
91
|
+
Object.defineProperty(exports, "createEvmConditions", { enumerable: true, get: function () { return typescript_sdk_1.createEvmConditions; } });
|
|
92
|
+
Object.defineProperty(exports, "createEvmBalanceConditions", { enumerable: true, get: function () { return typescript_sdk_1.createEvmBalanceConditions; } });
|
|
93
|
+
Object.defineProperty(exports, "init", { enumerable: true, get: function () { return typescript_sdk_1.init; } });
|
|
94
|
+
Object.defineProperty(exports, "generateAccount", { enumerable: true, get: function () { return typescript_sdk_1.generateAccount; } });
|
|
95
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAqC;AACrC,IAAI,OAAO,UAAU,KAAK,WAAW,EAAE,CAAC;IACpC,kBAAkB;IAClB,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;QACvB,CAAC,KAAK,IAAI,EAAE;YACV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,OAAA;AACV,4GAAA,UAAU,OAAA;AACV,2GAAA,SAAS,OAAA;AACT,wGAAA,MAAM,OAAA;AACN,qHAAA,mBAAmB,OAAA;AACnB,4HAAA,0BAA0B,OAAA;AAC1B,sGAAA,IAAI,OAAA;AACJ,iHAAA,eAAe,OAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
import { type ProxyExecuteConfig } from "@keypo/typescript-sdk";
|
|
3
|
+
export declare function proxyExecuteServer(dataIdentifier: string, wallet: ethers.Wallet, request: {
|
|
4
|
+
method: string;
|
|
5
|
+
url: string;
|
|
6
|
+
headers?: Record<string, string>;
|
|
7
|
+
body?: any;
|
|
8
|
+
}, config: ProxyExecuteConfig, debug?: boolean): Promise<any>;
|
|
9
|
+
//# sourceMappingURL=proxyExecuteServer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxyExecuteServer.d.ts","sourceRoot":"","sources":["../src/proxyExecuteServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,wBAAsB,kBAAkB,CACpC,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,CAAC,MAAM,EACrB,OAAO,EAAE;IACP,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,GAAG,CAAA;CACX,EACD,MAAM,EAAE,kBAAkB,EAC1B,KAAK,CAAC,EAAE,OAAO,GACd,OAAO,CAAC,GAAG,CAAC,CAiDhB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.proxyExecuteServer = proxyExecuteServer;
|
|
4
|
+
const authenticateLitSessionServer_1 = require("./utils/authenticateLitSessionServer");
|
|
5
|
+
async function proxyExecuteServer(dataIdentifier, wallet, request, config, debug) {
|
|
6
|
+
if (debug) {
|
|
7
|
+
console.log("dataIdentifier", dataIdentifier);
|
|
8
|
+
console.log("wallet", wallet);
|
|
9
|
+
console.log("request", request);
|
|
10
|
+
console.log("config", config);
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
// authenticate lit session using server-side approach
|
|
14
|
+
const { sessionSigs, authSig, litNodeClient, dataMetadata } = await (0, authenticateLitSessionServer_1.authenticateLitSessionServer)(wallet, config.chain, config.expiration, config.permissionsRegistryContractAddress, dataIdentifier, config.apiUrl, debug);
|
|
15
|
+
if (debug) {
|
|
16
|
+
console.log("sessionSigs", sessionSigs);
|
|
17
|
+
console.log("authSig", authSig);
|
|
18
|
+
console.log("litNodeClient", litNodeClient);
|
|
19
|
+
console.log("dataMetadata", dataMetadata);
|
|
20
|
+
console.log("request", request);
|
|
21
|
+
}
|
|
22
|
+
// prepare the request, which should include sessionSigs, authsig, evmConditions, dataMetadata, and the request body
|
|
23
|
+
const preparedRequest = {
|
|
24
|
+
sessionSigs,
|
|
25
|
+
authSig,
|
|
26
|
+
dataMetadata: JSON.stringify(dataMetadata),
|
|
27
|
+
request: JSON.stringify(request),
|
|
28
|
+
};
|
|
29
|
+
// make the request to the proxy
|
|
30
|
+
const response = await fetch(`${config.apiUrl}/proxy`, {
|
|
31
|
+
method: "POST",
|
|
32
|
+
headers: {
|
|
33
|
+
"Content-Type": "application/json",
|
|
34
|
+
},
|
|
35
|
+
body: JSON.stringify(preparedRequest),
|
|
36
|
+
});
|
|
37
|
+
const data = await response.json();
|
|
38
|
+
return data.Response;
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
console.error("Error in proxyExecuteServer:", error);
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMapping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AI,CAAC,SAAS,CAAC,YAAY,CAAC;YAC1C,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;SACjC,CAAC;QAEF,gCAAgC;QAChC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,MAAM,CAAC,MAAM,QAAQ,EAAE;YACrD,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC;SACtC,CAAC,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAuB,CAAC;QACxD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAC;QACrD,MAAM,KAAK,CAAC;IACd,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
import { LitNodeClient } from "@lit-protocol/lit-node-client";
|
|
3
|
+
import { type AccessControlConditions, type EvmContractConditions } from "@lit-protocol/types";
|
|
4
|
+
export declare const genAuthSigServer: (wallet: ethers.Wallet, client: LitNodeClient, uri: string, resources: any[], expiration?: string, debug?: boolean) => Promise<any>;
|
|
5
|
+
export declare const genSessionServer: (wallet: ethers.Wallet, client: LitNodeClient, resources: any[], expiration: string, chain: string, authSig?: any, debug?: boolean) => Promise<any>;
|
|
6
|
+
export declare const authenticateLitSessionServer: (wallet: ethers.Wallet, chain: string, expiration: string, permissionsRegistryContractAddress: string, dataIdentifier: string, apiUrl: string, debug?: boolean) => Promise<{
|
|
7
|
+
sessionSigs: any;
|
|
8
|
+
authSig: any;
|
|
9
|
+
litNodeClient: LitNodeClient;
|
|
10
|
+
dataToEncryptHash: string;
|
|
11
|
+
evmConditions: (AccessControlConditions | EvmContractConditions)[];
|
|
12
|
+
dataMetadata: any;
|
|
13
|
+
}>;
|
|
14
|
+
//# sourceMappingURL=authenticateLitSessionServer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticateLitSessionServer.d.ts","sourceRoot":"","sources":["../../src/utils/authenticateLitSessionServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAQhC,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAE3B,MAAM,qBAAqB,CAAC;AAe7B,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,MAAM,CAAC,MAAM,EACrB,QAAQ,aAAa,EACrB,KAAK,MAAM,EACX,WAAW,GAAG,EAAE,EAChB,aAAY,MAAyB,EACrC,QAAQ,OAAO,KACd,OAAO,CAAC,GAAG,CAsCb,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,MAAM,CAAC,MAAM,EACrB,QAAQ,aAAa,EACrB,WAAW,GAAG,EAAE,EAChB,YAAY,MAAM,EAClB,OAAO,MAAM,EACb,UAAU,GAAG,EACb,QAAQ,OAAO,KACd,OAAO,CAAC,GAAG,CAyEb,CAAC;AAEF,eAAO,MAAM,4BAA4B,GACvC,QAAQ,MAAM,CAAC,MAAM,EACrB,OAAO,MAAM,EACb,YAAY,MAAM,EAClB,oCAAoC,MAAM,EAC1C,gBAAgB,MAAM,EACtB,QAAQ,MAAM,EACd,QAAQ,OAAO,KACd,OAAO,CAAC;IACT,WAAW,EAAE,GAAG,CAAC;IACjB,OAAO,EAAE,GAAG,CAAC;IACb,aAAa,EAAE,aAAa,CAAC;IAC7B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,CAAC,uBAAuB,GAAG,qBAAqB,CAAC,EAAE,CAAC;IACnE,YAAY,EAAE,GAAG,CAAC;CACnB,CA6JA,CAAC"}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.authenticateLitSessionServer = exports.genSessionServer = exports.genAuthSigServer = void 0;
|
|
4
|
+
const auth_helpers_1 = require("@lit-protocol/auth-helpers");
|
|
5
|
+
const constants_1 = require("@lit-protocol/constants");
|
|
6
|
+
const lit_node_client_1 = require("@lit-protocol/lit-node-client");
|
|
7
|
+
const typescript_sdk_1 = require("@keypo/typescript-sdk");
|
|
8
|
+
const getPermissionedFileMetadata_1 = require("./getPermissionedFileMetadata");
|
|
9
|
+
const ONE_DAY_FROM_NOW = new Date(Date.now() + 1000 * 60 * 60 * 24).toISOString();
|
|
10
|
+
const genAuthSigServer = async (wallet, client, uri, resources, expiration = ONE_DAY_FROM_NOW, debug) => {
|
|
11
|
+
if (debug) {
|
|
12
|
+
console.log("[DEBUG] genAuthSigServer called with:", {
|
|
13
|
+
wallet,
|
|
14
|
+
client,
|
|
15
|
+
uri,
|
|
16
|
+
resources,
|
|
17
|
+
expiration,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
const blockHash = await client.getLatestBlockhash();
|
|
21
|
+
if (debug) {
|
|
22
|
+
console.log("[DEBUG] genAuthSigServer: blockHash:", blockHash);
|
|
23
|
+
}
|
|
24
|
+
const address = wallet.address;
|
|
25
|
+
if (debug) {
|
|
26
|
+
console.log("[DEBUG] genAuthSigServer: address:", address);
|
|
27
|
+
}
|
|
28
|
+
const message = await (0, auth_helpers_1.createSiweMessageWithRecaps)({
|
|
29
|
+
walletAddress: address,
|
|
30
|
+
nonce: blockHash,
|
|
31
|
+
litNodeClient: client,
|
|
32
|
+
resources,
|
|
33
|
+
expiration: expiration,
|
|
34
|
+
uri,
|
|
35
|
+
});
|
|
36
|
+
if (debug) {
|
|
37
|
+
console.log("[DEBUG] genAuthSigServer: constructed message:", message);
|
|
38
|
+
}
|
|
39
|
+
const authSig = await (0, auth_helpers_1.generateAuthSig)({
|
|
40
|
+
signer: wallet,
|
|
41
|
+
toSign: message,
|
|
42
|
+
});
|
|
43
|
+
if (debug) {
|
|
44
|
+
console.log("[DEBUG] genAuthSigServer: generated authSig:", authSig);
|
|
45
|
+
}
|
|
46
|
+
return authSig;
|
|
47
|
+
};
|
|
48
|
+
exports.genAuthSigServer = genAuthSigServer;
|
|
49
|
+
const genSessionServer = async (wallet, client, resources, expiration, chain, authSig, debug) => {
|
|
50
|
+
if (debug) {
|
|
51
|
+
console.log("[DEBUG] genSessionServer called with:", {
|
|
52
|
+
wallet,
|
|
53
|
+
client,
|
|
54
|
+
resources,
|
|
55
|
+
expiration,
|
|
56
|
+
chain,
|
|
57
|
+
authSig,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
// Get the latest blockhash for the authNeededCallback
|
|
61
|
+
const latestBlockhash = await client.getLatestBlockhash();
|
|
62
|
+
if (debug) {
|
|
63
|
+
console.log("[DEBUG] genSessionServer: latestBlockhash:", latestBlockhash);
|
|
64
|
+
}
|
|
65
|
+
// Define the authNeededCallback function following the Lit Protocol server-side pattern
|
|
66
|
+
const authNeededCallback = async (params) => {
|
|
67
|
+
if (debug) {
|
|
68
|
+
console.log("[DEBUG] authNeededCallback called with params:", params);
|
|
69
|
+
}
|
|
70
|
+
if (!params.uri) {
|
|
71
|
+
throw new Error("uri is required");
|
|
72
|
+
}
|
|
73
|
+
if (!params.expiration) {
|
|
74
|
+
throw new Error("expiration is required");
|
|
75
|
+
}
|
|
76
|
+
if (!params.resourceAbilityRequests) {
|
|
77
|
+
throw new Error("resourceAbilityRequests is required");
|
|
78
|
+
}
|
|
79
|
+
if (authSig) {
|
|
80
|
+
if (debug) {
|
|
81
|
+
console.log("[DEBUG] Returning provided authSig");
|
|
82
|
+
}
|
|
83
|
+
return authSig;
|
|
84
|
+
}
|
|
85
|
+
// Create the SIWE message following the Lit Protocol pattern
|
|
86
|
+
const toSign = await (0, auth_helpers_1.createSiweMessageWithRecaps)({
|
|
87
|
+
uri: params.uri,
|
|
88
|
+
expiration: params.expiration,
|
|
89
|
+
resources: params.resourceAbilityRequests,
|
|
90
|
+
walletAddress: wallet.address,
|
|
91
|
+
nonce: latestBlockhash,
|
|
92
|
+
litNodeClient: client,
|
|
93
|
+
});
|
|
94
|
+
if (debug) {
|
|
95
|
+
console.log("[DEBUG] authNeededCallback: constructed message:", toSign);
|
|
96
|
+
}
|
|
97
|
+
// Generate the authSig following the Lit Protocol pattern
|
|
98
|
+
const generatedAuthSig = await (0, auth_helpers_1.generateAuthSig)({
|
|
99
|
+
signer: wallet,
|
|
100
|
+
toSign,
|
|
101
|
+
});
|
|
102
|
+
if (debug) {
|
|
103
|
+
console.log("[DEBUG] authNeededCallback: generated authSig:", generatedAuthSig);
|
|
104
|
+
}
|
|
105
|
+
return generatedAuthSig;
|
|
106
|
+
};
|
|
107
|
+
return client.getSessionSigs({
|
|
108
|
+
chain: chain,
|
|
109
|
+
resourceAbilityRequests: resources,
|
|
110
|
+
authNeededCallback,
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
exports.genSessionServer = genSessionServer;
|
|
114
|
+
const authenticateLitSessionServer = async (wallet, chain, expiration, permissionsRegistryContractAddress, dataIdentifier, apiUrl, debug) => {
|
|
115
|
+
let walletAddress;
|
|
116
|
+
try {
|
|
117
|
+
walletAddress = await wallet.getAddress();
|
|
118
|
+
if (debug) {
|
|
119
|
+
console.log("[DEBUG] authenticateLitSessionServer called with:", {
|
|
120
|
+
walletAddress,
|
|
121
|
+
chain,
|
|
122
|
+
expiration,
|
|
123
|
+
permissionsRegistryContractAddress,
|
|
124
|
+
dataIdentifier,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch (err) {
|
|
129
|
+
console.error("[DEBUG] Error getting wallet address:", err);
|
|
130
|
+
throw err;
|
|
131
|
+
}
|
|
132
|
+
// Use ethers wallet directly as signer
|
|
133
|
+
const signer = wallet;
|
|
134
|
+
let dataMetadata;
|
|
135
|
+
try {
|
|
136
|
+
if (debug)
|
|
137
|
+
console.log("[DEBUG] Fetching permissioned file metadata...");
|
|
138
|
+
dataMetadata = await (0, getPermissionedFileMetadata_1.getPermissionedFileMetadata)(dataIdentifier, apiUrl, debug);
|
|
139
|
+
if (debug)
|
|
140
|
+
console.log("[DEBUG] dataMetadata (raw):", dataMetadata);
|
|
141
|
+
if (!dataMetadata) {
|
|
142
|
+
throw new Error("No data metadata found for the provided smart contract address");
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
catch (err) {
|
|
146
|
+
console.error("[DEBUG] Error fetching permissioned file metadata:", err);
|
|
147
|
+
throw err;
|
|
148
|
+
}
|
|
149
|
+
let dataMetadataObject;
|
|
150
|
+
try {
|
|
151
|
+
dataMetadataObject = JSON.parse(dataMetadata);
|
|
152
|
+
if (debug)
|
|
153
|
+
console.log("[DEBUG] dataMetadataObject (parsed):", dataMetadataObject);
|
|
154
|
+
}
|
|
155
|
+
catch (err) {
|
|
156
|
+
console.error("[DEBUG] Error parsing dataMetadata:", err);
|
|
157
|
+
throw err;
|
|
158
|
+
}
|
|
159
|
+
let litNodeClient;
|
|
160
|
+
try {
|
|
161
|
+
if (debug)
|
|
162
|
+
console.log("[DEBUG] Creating LitNodeClient...");
|
|
163
|
+
litNodeClient = new lit_node_client_1.LitNodeClient({
|
|
164
|
+
litNetwork: constants_1.LIT_NETWORK.DatilDev,
|
|
165
|
+
debug: false,
|
|
166
|
+
});
|
|
167
|
+
if (debug)
|
|
168
|
+
console.log("[DEBUG] Connecting LitNodeClient...");
|
|
169
|
+
await litNodeClient.connect();
|
|
170
|
+
if (debug)
|
|
171
|
+
console.log("[DEBUG] LitNodeClient connected.");
|
|
172
|
+
}
|
|
173
|
+
catch (err) {
|
|
174
|
+
console.error("[DEBUG] Error creating/connecting LitNodeClient:", err);
|
|
175
|
+
throw err;
|
|
176
|
+
}
|
|
177
|
+
// if dataMetadataObject.proxyMetadata exists, use createEvmBalanceConditions instead of createEvmConditions
|
|
178
|
+
let conditions = [];
|
|
179
|
+
try {
|
|
180
|
+
if (dataMetadataObject.proxyMetadata) {
|
|
181
|
+
if (debug)
|
|
182
|
+
console.log("[DEBUG] Using createEvmBalanceConditions...");
|
|
183
|
+
conditions = (0, typescript_sdk_1.createEvmBalanceConditions)(chain, dataMetadataObject.proxyMetadata.proxyAddress);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
if (debug)
|
|
187
|
+
console.log("[DEBUG] Using createEvmConditions...");
|
|
188
|
+
conditions = (0, typescript_sdk_1.createEvmConditions)(chain, permissionsRegistryContractAddress, dataIdentifier);
|
|
189
|
+
}
|
|
190
|
+
if (debug)
|
|
191
|
+
console.log("[DEBUG] conditions:", conditions);
|
|
192
|
+
}
|
|
193
|
+
catch (err) {
|
|
194
|
+
console.error("[DEBUG] Error creating conditions:", err);
|
|
195
|
+
throw err;
|
|
196
|
+
}
|
|
197
|
+
let accsResourceString;
|
|
198
|
+
try {
|
|
199
|
+
if (debug)
|
|
200
|
+
console.log("[DEBUG] Generating resource strings...");
|
|
201
|
+
accsResourceString = await auth_helpers_1.LitAccessControlConditionResource.generateResourceString(conditions, dataMetadataObject.encryptedData.dataToEncryptHash);
|
|
202
|
+
if (debug)
|
|
203
|
+
console.log("[DEBUG] accsResourceString:", accsResourceString);
|
|
204
|
+
}
|
|
205
|
+
catch (err) {
|
|
206
|
+
console.error("[DEBUG] Error generating resource string:", err);
|
|
207
|
+
throw err;
|
|
208
|
+
}
|
|
209
|
+
let resources;
|
|
210
|
+
try {
|
|
211
|
+
resources = [
|
|
212
|
+
{
|
|
213
|
+
resource: new auth_helpers_1.LitActionResource("*"),
|
|
214
|
+
ability: constants_1.LIT_ABILITY.LitActionExecution,
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
resource: new auth_helpers_1.LitAccessControlConditionResource(accsResourceString),
|
|
218
|
+
ability: constants_1.LIT_ABILITY.AccessControlConditionDecryption,
|
|
219
|
+
},
|
|
220
|
+
];
|
|
221
|
+
if (debug)
|
|
222
|
+
console.log("[DEBUG] resources:", resources);
|
|
223
|
+
}
|
|
224
|
+
catch (err) {
|
|
225
|
+
console.error("[DEBUG] Error creating resources array:", err);
|
|
226
|
+
throw err;
|
|
227
|
+
}
|
|
228
|
+
let sessionSigs;
|
|
229
|
+
try {
|
|
230
|
+
if (debug)
|
|
231
|
+
console.log("[DEBUG] Calling genSessionServer...");
|
|
232
|
+
sessionSigs = await (0, exports.genSessionServer)(wallet, litNodeClient, resources, expiration, chain, undefined, debug);
|
|
233
|
+
if (debug)
|
|
234
|
+
console.log("[DEBUG] sessionSigs:", sessionSigs);
|
|
235
|
+
}
|
|
236
|
+
catch (err) {
|
|
237
|
+
console.error("[DEBUG] Error in genSessionServer:", err);
|
|
238
|
+
throw err;
|
|
239
|
+
}
|
|
240
|
+
let authSig;
|
|
241
|
+
try {
|
|
242
|
+
if (debug)
|
|
243
|
+
console.log("[DEBUG] Calling genAuthSigServer...");
|
|
244
|
+
// Only get another authSig if proxyMetadata exists
|
|
245
|
+
if (dataMetadataObject.proxyMetadata) {
|
|
246
|
+
authSig = await (0, exports.genAuthSigServer)(wallet, litNodeClient, "https://www.keypo.io", resources, undefined, debug);
|
|
247
|
+
if (debug)
|
|
248
|
+
console.log("[DEBUG] authSig:", authSig);
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
authSig = null;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
catch (err) {
|
|
255
|
+
console.error("[DEBUG] Error in genAuthSigServer:", err);
|
|
256
|
+
throw err;
|
|
257
|
+
}
|
|
258
|
+
return {
|
|
259
|
+
sessionSigs,
|
|
260
|
+
authSig,
|
|
261
|
+
dataToEncryptHash: dataMetadataObject.encryptedData.dataToEncryptHash,
|
|
262
|
+
evmConditions: conditions,
|
|
263
|
+
litNodeClient: litNodeClient,
|
|
264
|
+
dataMetadata: dataMetadataObject,
|
|
265
|
+
};
|
|
266
|
+
};
|
|
267
|
+
exports.authenticateLitSessionServer = authenticateLitSessionServer;
|
|
268
|
+
//# sourceMappingURL=authenticateLitSessionServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticateLitSessionServer.js","sourceRoot":"","sources":["../../src/utils/authenticateLitSessionServer.ts"],"names":[],"mappings":";;;AACA,6DAKoC;AACpC,uDAAmE;AACnE,mEAA8D;AAM9D,0DAAwF;AACxF,+EAA4E;AAS5E,MAAM,gBAAgB,GAAG,IAAI,IAAI,CAC/B,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CACjC,CAAC,WAAW,EAAE,CAAC;AAET,MAAM,gBAAgB,GAAG,KAAK,EACnC,MAAqB,EACrB,MAAqB,EACrB,GAAW,EACX,SAAgB,EAChB,aAAqB,gBAAgB,EACrC,KAAe,EACD,EAAE;IAChB,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CAAC,GAAG,CAAC,uCAAuC,EAAE;YACnD,MAAM;YACN,MAAM;YACN,GAAG;YACH,SAAS;YACT,UAAU;SACX,CAAC,CAAC;IACL,CAAC;IACD,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,kBAAkB,EAAE,CAAC;IACpD,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CAAC,GAAG,CAAC,sCAAsC,EAAE,SAAS,CAAC,CAAC;IACjE,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAC/B,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CAAC,GAAG,CAAC,oCAAoC,EAAE,OAAO,CAAC,CAAC;IAC7D,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,IAAA,0CAA2B,EAAC;QAChD,aAAa,EAAE,OAAO;QACtB,KAAK,EAAE,SAAS;QAChB,aAAa,EAAE,MAAM;QACrB,SAAS;QACT,UAAU,EAAE,UAAU;QACtB,GAAG;KACJ,CAAC,CAAC;IACH,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,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AAC;QAC5G,IAAI,KAAK;YAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,WAAW,CAAC,CAAC;IAC9D,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,GAAG,CAAC,CAAC;QACzD,MAAM,GAAG,CAAC;IACZ,CAAC;IAED,IAAI,OAAO,CAAC;IACZ,IAAI,CAAC;QACH,IAAI,KAAK;YAAE,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;QAC9D,mDAAmD;QACnD,IAAI,kBAAkB,CAAC,aAAa,EAAE,CAAC;YACrC,OAAO,GAAG,MAAM,IAAA,wBAAgB,EAC9B,MAAM,EACN,aAAa,EACb,sBAAsB,EACtB,SAAS,EACT,SAAS,EACT,KAAK,CACN,CAAC;YACF,IAAI,KAAK;gBAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;QACtD,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,IAAI,CAAC;QACjB,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,GAAG,CAAC,CAAC;QACzD,MAAM,GAAG,CAAC;IACZ,CAAC;IAED,OAAO;QACL,WAAW;QACX,OAAO;QACP,iBAAiB,EAAE,kBAAkB,CAAC,aAAa,CAAC,iBAAiB;QACrE,aAAa,EAAE,UAAU;QACzB,aAAa,EAAE,aAAa;QAC5B,YAAY,EAAE,kBAAkB;KACjC,CAAC;AACJ,CAAC,CAAC;AA5KW,QAAA,4BAA4B,gCA4KvC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createEVMBalanceCondition.d.ts","sourceRoot":"","sources":["../../src/utils/createEVMBalanceCondition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAEnE,eAAO,MAAM,0BAA0B,GACrC,OAAO,MAAM,EACb,iBAAiB,MAAM,KAclB,uBACN,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createEvmBalanceConditions = void 0;
|
|
4
|
+
const createEvmBalanceConditions = (chain, litActionIpfsId) => {
|
|
5
|
+
return [
|
|
6
|
+
{
|
|
7
|
+
contractAddress: "",
|
|
8
|
+
standardContractType: "",
|
|
9
|
+
chain,
|
|
10
|
+
method: "",
|
|
11
|
+
parameters: [":currentActionIpfsId"],
|
|
12
|
+
returnValueTest: {
|
|
13
|
+
comparator: "=",
|
|
14
|
+
value: litActionIpfsId,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
];
|
|
18
|
+
};
|
|
19
|
+
exports.createEvmBalanceConditions = createEvmBalanceConditions;
|
|
20
|
+
//# sourceMappingURL=createEVMBalanceCondition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createEVMBalanceCondition.js","sourceRoot":"","sources":["../../src/utils/createEVMBalanceCondition.ts"],"names":[],"mappings":";;;AAEO,MAAM,0BAA0B,GAAG,CACxC,KAAa,EACb,eAAuB,EACvB,EAAE;IACF,OAAO;QACL;YACE,eAAe,EAAE,EAAE;YACnB,oBAAoB,EAAE,EAAE;YACxB,KAAK;YACL,MAAM,EAAE,EAAE;YACV,UAAU,EAAE,CAAC,sBAAsB,CAAC;YACpC,eAAe,EAAE;gBACf,UAAU,EAAE,GAAG;gBACf,KAAK,EAAE,eAAe;aACvB;SACF;KACyB,CAAC;AAC/B,CAAC,CAAC;AAjBW,QAAA,0BAA0B,8BAiBrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createEVMContractCondition.d.ts","sourceRoot":"","sources":["../../src/utils/createEVMContractCondition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAEjE,eAAO,MAAM,mBAAmB,GAC9B,OAAO,MAAM,EACb,iBAAiB,MAAM,EACvB,gBAAgB,MAAM,0BAyCvB,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createEvmConditions = void 0;
|
|
4
|
+
const createEvmConditions = (chain, contractAddress, fileIdentifier) => {
|
|
5
|
+
const conditions = [
|
|
6
|
+
{
|
|
7
|
+
contractAddress,
|
|
8
|
+
functionName: "checkPermission",
|
|
9
|
+
functionParams: [`${fileIdentifier}`, ":userAddress"],
|
|
10
|
+
functionAbi: {
|
|
11
|
+
type: "function",
|
|
12
|
+
stateMutability: "view",
|
|
13
|
+
outputs: [
|
|
14
|
+
{
|
|
15
|
+
type: "bool",
|
|
16
|
+
name: "",
|
|
17
|
+
internalType: "bool",
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
name: "checkPermission",
|
|
21
|
+
inputs: [
|
|
22
|
+
{
|
|
23
|
+
type: "string",
|
|
24
|
+
name: "fileIdentifier",
|
|
25
|
+
internalType: "string",
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
type: "address",
|
|
29
|
+
name: "requestAddress",
|
|
30
|
+
internalType: "address",
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
chain,
|
|
35
|
+
returnValueTest: {
|
|
36
|
+
key: "",
|
|
37
|
+
comparator: "=",
|
|
38
|
+
value: "true",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
return conditions;
|
|
43
|
+
};
|
|
44
|
+
exports.createEvmConditions = createEvmConditions;
|
|
45
|
+
//# sourceMappingURL=createEVMContractCondition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createEVMContractCondition.js","sourceRoot":"","sources":["../../src/utils/createEVMContractCondition.ts"],"names":[],"mappings":";;;AAEO,MAAM,mBAAmB,GAAG,CACjC,KAAa,EACb,eAAuB,EACvB,cAAsB,EACtB,EAAE;IACF,MAAM,UAAU,GAAG;QACjB;YACE,eAAe;YACf,YAAY,EAAE,iBAAiB;YAC/B,cAAc,EAAE,CAAC,GAAG,cAAc,EAAE,EAAE,cAAc,CAAC;YACrD,WAAW,EAAE;gBACX,IAAI,EAAE,UAAU;gBAChB,eAAe,EAAE,MAAM;gBACvB,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,EAAE;wBACR,YAAY,EAAE,MAAM;qBACrB;iBACF;gBACD,IAAI,EAAE,iBAAiB;gBACvB,MAAM,EAAE;oBACN;wBACE,IAAI,EAAE,QAAQ;wBACd,IAAI,EAAE,gBAAgB;wBACtB,YAAY,EAAE,QAAQ;qBACvB;oBACD;wBACE,IAAI,EAAE,SAAS;wBACf,IAAI,EAAE,gBAAgB;wBACtB,YAAY,EAAE,SAAS;qBACxB;iBACF;aACF;YACD,KAAK;YACL,eAAe,EAAE;gBACf,GAAG,EAAE,EAAE;gBACP,UAAU,EAAE,GAAG;gBACf,KAAK,EAAE,MAAM;aACd;SACF;KACuB,CAAC;IAE3B,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AA5CW,QAAA,mBAAmB,uBA4C9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPermissionedFileMetadata.d.ts","sourceRoot":"","sources":["../../src/utils/getPermissionedFileMetadata.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,2BAA2B,GACpC,gBAAgB,MAAM,EACtB,QAAQ,MAAM,EACd,QAAQ,OAAO,iBAkChB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPermissionedFileMetadata = void 0;
|
|
4
|
+
const getPermissionedFileMetadata = async (dataIdentifier, apiUrl, debug) => {
|
|
5
|
+
if (debug) {
|
|
6
|
+
console.log("[DEBUG] getPermissionedFileMetadata called with:", {
|
|
7
|
+
dataIdentifier,
|
|
8
|
+
apiUrl
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
try {
|
|
12
|
+
const url = `${apiUrl}/graph/fileMetadata?fileIdentifier=${dataIdentifier}`;
|
|
13
|
+
if (debug) {
|
|
14
|
+
console.log("[DEBUG] Calling API at:", url);
|
|
15
|
+
}
|
|
16
|
+
const response = await fetch(url);
|
|
17
|
+
if (!response.ok) {
|
|
18
|
+
throw new Error(`API request failed with status ${response.status}: ${await response.text()}`);
|
|
19
|
+
}
|
|
20
|
+
const data = await response.json();
|
|
21
|
+
if (debug) {
|
|
22
|
+
console.log("[DEBUG] Got metadata from API:", data);
|
|
23
|
+
}
|
|
24
|
+
if (!data.fileMetadata) {
|
|
25
|
+
throw new Error(`No file metadata found for identifier: ${dataIdentifier}`);
|
|
26
|
+
}
|
|
27
|
+
return data.fileMetadata.fileMetadata;
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
console.error("[ERROR] API request error:", error);
|
|
31
|
+
throw new Error(`Failed to fetch file metadata: ${error?.message || 'Unknown error'}`);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
exports.getPermissionedFileMetadata = getPermissionedFileMetadata;
|
|
35
|
+
//# sourceMappingURL=getPermissionedFileMetadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPermissionedFileMetadata.js","sourceRoot":"","sources":["../../src/utils/getPermissionedFileMetadata.ts"],"names":[],"mappings":";;;AAAO,MAAM,2BAA2B,GAAG,KAAK,EAC5C,cAAsB,EACtB,MAAc,EACd,KAAe,EACf,EAAE;IACF,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CAAC,GAAG,CAAC,kDAAkD,EAAE;YAC9D,cAAc;YACd,MAAM;SACP,CAAC,CAAC;IACL,CAAC;IAED,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,GAAG,MAAM,sCAAsC,cAAc,EAAE,CAAC;QAC5E,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,CAAC,GAAG,CAAC,yBAAyB,EAAE,GAAG,CAAC,CAAC;QAC9C,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;QAElC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,kCAAkC,QAAQ,CAAC,MAAM,KAAK,MAAM,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACjG,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAS,CAAC;QAC1C,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,CAAC,GAAG,CAAC,gCAAgC,EAAE,IAAI,CAAC,CAAC;QACtD,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,0CAA0C,cAAc,EAAE,CAAC,CAAC;QAC9E,CAAC;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC;IACxC,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;QACnD,MAAM,IAAI,KAAK,CAAC,kCAAkC,KAAK,EAAE,OAAO,IAAI,eAAe,EAAE,CAAC,CAAC;IACzF,CAAC;AACH,CAAC,CAAC;AArCS,QAAA,2BAA2B,+BAqCpC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@keypo/typescript-sdk-server",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Server-side SDK for Keypo with custom decrypt and proxy execute implementations",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"README.md"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"build:watch": "tsc --watch",
|
|
14
|
+
"clean": "rimraf dist",
|
|
15
|
+
"prebuild": "npm run clean",
|
|
16
|
+
"prepublishOnly": "npm run build",
|
|
17
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
18
|
+
"dev": "tsc --watch",
|
|
19
|
+
"lint": "eslint src --ext .ts",
|
|
20
|
+
"lint:fix": "eslint src --ext .ts --fix",
|
|
21
|
+
"type-check": "tsc --noEmit"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@keypo/typescript-sdk": "^1.0.28",
|
|
25
|
+
"@lit-protocol/auth-browser": "^7.2.0",
|
|
26
|
+
"@lit-protocol/auth-helpers": "^7.2.0",
|
|
27
|
+
"@lit-protocol/constants": "^7.2.0",
|
|
28
|
+
"@lit-protocol/encryption": "^7.2.0",
|
|
29
|
+
"@lit-protocol/lit-node-client": "^7.2.0",
|
|
30
|
+
"@lit-protocol/types": "^7.2.0"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"ethers": "^5.8.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "^20.19.7",
|
|
37
|
+
"@types/node-fetch": "^2.6.12",
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
39
|
+
"@typescript-eslint/parser": "^6.21.0",
|
|
40
|
+
"eslint": "^8.57.1",
|
|
41
|
+
"rimraf": "^5.0.10",
|
|
42
|
+
"typescript": "^5.8.3"
|
|
43
|
+
},
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git+https://github.com/decentralized-storage/keypo-sdk-server.git"
|
|
47
|
+
},
|
|
48
|
+
"keywords": [
|
|
49
|
+
"keypo",
|
|
50
|
+
"sdk",
|
|
51
|
+
"server",
|
|
52
|
+
"typescript",
|
|
53
|
+
"encryption",
|
|
54
|
+
"decryption",
|
|
55
|
+
"proxy",
|
|
56
|
+
"lit-protocol"
|
|
57
|
+
],
|
|
58
|
+
"author": "",
|
|
59
|
+
"license": "ISC",
|
|
60
|
+
"bugs": {
|
|
61
|
+
"url": "https://github.com/decentralized-storage/keypo-sdk-server/issues"
|
|
62
|
+
},
|
|
63
|
+
"homepage": "https://github.com/decentralized-storage/keypo-sdk-server#readme",
|
|
64
|
+
"engines": {
|
|
65
|
+
"node": ">=16.0.0"
|
|
66
|
+
}
|
|
67
|
+
}
|