@elizaos/plugin-tee 2.0.0-alpha.3 → 2.0.0-alpha.4

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 (45) hide show
  1. package/dist/index.js +9 -7
  2. package/dist/index.js.map +6 -6
  3. package/dist/node/actions/index.d.ts +2 -0
  4. package/dist/node/actions/index.d.ts.map +1 -0
  5. package/dist/node/actions/index.js +1 -0
  6. package/dist/node/actions/remoteAttestation.d.ts +3 -0
  7. package/dist/node/actions/remoteAttestation.d.ts.map +1 -0
  8. package/dist/node/actions/remoteAttestation.js +115 -0
  9. package/dist/node/index.d.ts +10 -0
  10. package/dist/node/index.d.ts.map +1 -0
  11. package/dist/node/index.js +34 -0
  12. package/dist/node/providers/base.d.ts +8 -0
  13. package/dist/node/providers/base.d.ts.map +1 -0
  14. package/dist/node/providers/base.js +4 -0
  15. package/dist/node/providers/deriveKey.d.ts +24 -0
  16. package/dist/node/providers/deriveKey.d.ts.map +1 -0
  17. package/dist/node/providers/deriveKey.js +143 -0
  18. package/dist/node/providers/index.d.ts +4 -0
  19. package/dist/node/providers/index.d.ts.map +1 -0
  20. package/dist/node/providers/index.js +3 -0
  21. package/dist/node/providers/remoteAttestation.d.ts +10 -0
  22. package/dist/node/providers/remoteAttestation.d.ts.map +1 -0
  23. package/dist/node/providers/remoteAttestation.js +73 -0
  24. package/dist/node/services/index.d.ts +2 -0
  25. package/dist/node/services/index.d.ts.map +1 -0
  26. package/dist/node/services/index.js +1 -0
  27. package/dist/node/services/tee.d.ts +24 -0
  28. package/dist/node/services/tee.d.ts.map +1 -0
  29. package/dist/node/services/tee.js +42 -0
  30. package/dist/node/types/index.d.ts +58 -0
  31. package/dist/node/types/index.d.ts.map +1 -0
  32. package/dist/node/types/index.js +35 -0
  33. package/dist/node/utils/index.d.ts +9 -0
  34. package/dist/node/utils/index.d.ts.map +1 -0
  35. package/dist/node/utils/index.js +61 -0
  36. package/dist/node/vendors/index.d.ts +5 -0
  37. package/dist/node/vendors/index.d.ts.map +1 -0
  38. package/dist/node/vendors/index.js +14 -0
  39. package/dist/node/vendors/phala.d.ts +10 -0
  40. package/dist/node/vendors/phala.d.ts.map +1 -0
  41. package/dist/node/vendors/phala.js +18 -0
  42. package/dist/node/vendors/types.d.ts +13 -0
  43. package/dist/node/vendors/types.d.ts.map +1 -0
  44. package/dist/node/vendors/types.js +3 -0
  45. package/package.json +2 -2
@@ -0,0 +1,35 @@
1
+ export var TeeMode;
2
+ (function (TeeMode) {
3
+ TeeMode["LOCAL"] = "LOCAL";
4
+ TeeMode["DOCKER"] = "DOCKER";
5
+ TeeMode["PRODUCTION"] = "PRODUCTION";
6
+ })(TeeMode || (TeeMode = {}));
7
+ export var TeeVendor;
8
+ (function (TeeVendor) {
9
+ TeeVendor["PHALA"] = "phala";
10
+ })(TeeVendor || (TeeVendor = {}));
11
+ export var TeeType;
12
+ (function (TeeType) {
13
+ TeeType["SGX_GRAMINE"] = "sgx_gramine";
14
+ TeeType["TDX_DSTACK"] = "tdx_dstack";
15
+ })(TeeType || (TeeType = {}));
16
+ export function parseTeeMode(mode) {
17
+ switch (mode.toUpperCase()) {
18
+ case "LOCAL":
19
+ return TeeMode.LOCAL;
20
+ case "DOCKER":
21
+ return TeeMode.DOCKER;
22
+ case "PRODUCTION":
23
+ return TeeMode.PRODUCTION;
24
+ default:
25
+ throw new Error(`Invalid TEE_MODE: ${mode}. Must be one of: LOCAL, DOCKER, PRODUCTION`);
26
+ }
27
+ }
28
+ export function parseTeeVendor(vendor) {
29
+ switch (vendor.toLowerCase()) {
30
+ case "phala":
31
+ return TeeVendor.PHALA;
32
+ default:
33
+ throw new Error(`Invalid TEE_VENDOR: ${vendor}. Must be one of: phala`);
34
+ }
35
+ }
@@ -0,0 +1,9 @@
1
+ export declare function hexToUint8Array(hex: string): Uint8Array;
2
+ export declare function uint8ArrayToHex(bytes: Uint8Array): string;
3
+ export declare function calculateSHA256(input: string): Buffer;
4
+ export declare function sha256Bytes(input: Uint8Array): Uint8Array;
5
+ export declare function getTeeEndpoint(mode: string): string | undefined;
6
+ export declare function uploadAttestationQuote(data: Uint8Array): Promise<{
7
+ checksum: string;
8
+ }>;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAEA,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAkBvD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAIzD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIrD;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAIzD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAW/D;AAED,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAiB5F"}
@@ -0,0 +1,61 @@
1
+ import { createHash } from "node:crypto";
2
+ export function hexToUint8Array(hex) {
3
+ const hexString = hex.trim().replace(/^0x/, "");
4
+ if (!hexString) {
5
+ throw new Error("Invalid hex string: empty after stripping prefix");
6
+ }
7
+ if (hexString.length % 2 !== 0) {
8
+ throw new Error("Invalid hex string: odd number of characters");
9
+ }
10
+ const array = new Uint8Array(hexString.length / 2);
11
+ for (let i = 0; i < hexString.length; i += 2) {
12
+ const byte = Number.parseInt(hexString.slice(i, i + 2), 16);
13
+ if (Number.isNaN(byte)) {
14
+ throw new Error(`Invalid hex string: invalid byte at position ${i}`);
15
+ }
16
+ array[i / 2] = byte;
17
+ }
18
+ return array;
19
+ }
20
+ export function uint8ArrayToHex(bytes) {
21
+ return Array.from(bytes)
22
+ .map((b) => b.toString(16).padStart(2, "0"))
23
+ .join("");
24
+ }
25
+ export function calculateSHA256(input) {
26
+ const hash = createHash("sha256");
27
+ hash.update(input);
28
+ return hash.digest();
29
+ }
30
+ export function sha256Bytes(input) {
31
+ const hash = createHash("sha256");
32
+ hash.update(input);
33
+ return new Uint8Array(hash.digest());
34
+ }
35
+ export function getTeeEndpoint(mode) {
36
+ switch (mode.toUpperCase()) {
37
+ case "LOCAL":
38
+ return "http://localhost:8090";
39
+ case "DOCKER":
40
+ return "http://host.docker.internal:8090";
41
+ case "PRODUCTION":
42
+ return undefined;
43
+ default:
44
+ throw new Error(`Invalid TEE_MODE: ${mode}. Must be one of: LOCAL, DOCKER, PRODUCTION`);
45
+ }
46
+ }
47
+ export async function uploadAttestationQuote(data) {
48
+ const blob = new Blob([data], {
49
+ type: "application/octet-stream",
50
+ });
51
+ const formData = new FormData();
52
+ formData.append("file", blob, "quote.bin");
53
+ const response = await fetch("https://proof.t16z.com/api/upload", {
54
+ method: "POST",
55
+ body: formData,
56
+ });
57
+ if (!response.ok) {
58
+ throw new Error(`Failed to upload attestation quote: ${response.statusText}`);
59
+ }
60
+ return response.json();
61
+ }
@@ -0,0 +1,5 @@
1
+ import { type TeeVendorInterface, type TeeVendorName } from "./types";
2
+ export declare function getVendor(type: TeeVendorName): TeeVendorInterface;
3
+ export { PhalaVendor } from "./phala";
4
+ export { type TeeVendorInterface, type TeeVendorName, TeeVendorNames } from "./types";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vendors/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,aAAa,EAAkB,MAAM,SAAS,CAAC;AAMtF,wBAAgB,SAAS,CAAC,IAAI,EAAE,aAAa,GAAG,kBAAkB,CAMjE;AAED,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,aAAa,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { PhalaVendor } from "./phala";
2
+ import { TeeVendorNames } from "./types";
3
+ const vendors = {
4
+ [TeeVendorNames.PHALA]: new PhalaVendor(),
5
+ };
6
+ export function getVendor(type) {
7
+ const vendor = vendors[type];
8
+ if (!vendor) {
9
+ throw new Error(`Unsupported TEE vendor: ${type}`);
10
+ }
11
+ return vendor;
12
+ }
13
+ export { PhalaVendor } from "./phala";
14
+ export { TeeVendorNames } from "./types";
@@ -0,0 +1,10 @@
1
+ import type { Action, Provider } from "@elizaos/core";
2
+ import { type TeeVendorInterface } from "./types";
3
+ export declare class PhalaVendor implements TeeVendorInterface {
4
+ readonly type: "phala";
5
+ getActions(): Action[];
6
+ getProviders(): Provider[];
7
+ getName(): string;
8
+ getDescription(): string;
9
+ }
10
+ //# sourceMappingURL=phala.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phala.d.ts","sourceRoot":"","sources":["../../../src/vendors/phala.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGtD,OAAO,EAAE,KAAK,kBAAkB,EAAkB,MAAM,SAAS,CAAC;AAElE,qBAAa,WAAY,YAAW,kBAAkB;IACpD,QAAQ,CAAC,IAAI,UAAwB;IAErC,UAAU,IAAI,MAAM,EAAE;IAItB,YAAY,IAAI,QAAQ,EAAE;IAI1B,OAAO,IAAI,MAAM;IAIjB,cAAc,IAAI,MAAM;CAGzB"}
@@ -0,0 +1,18 @@
1
+ import { remoteAttestationAction } from "../actions/remoteAttestation";
2
+ import { phalaDeriveKeyProvider, phalaRemoteAttestationProvider } from "../providers";
3
+ import { TeeVendorNames } from "./types";
4
+ export class PhalaVendor {
5
+ type = TeeVendorNames.PHALA;
6
+ getActions() {
7
+ return [remoteAttestationAction];
8
+ }
9
+ getProviders() {
10
+ return [phalaDeriveKeyProvider, phalaRemoteAttestationProvider];
11
+ }
12
+ getName() {
13
+ return "phala-tee-plugin";
14
+ }
15
+ getDescription() {
16
+ return "Phala Network TEE for secure agent execution";
17
+ }
18
+ }
@@ -0,0 +1,13 @@
1
+ import type { Action, Provider } from "@elizaos/core";
2
+ export declare const TeeVendorNames: {
3
+ readonly PHALA: "phala";
4
+ };
5
+ export type TeeVendorName = (typeof TeeVendorNames)[keyof typeof TeeVendorNames];
6
+ export interface TeeVendorInterface {
7
+ readonly type: TeeVendorName;
8
+ getActions(): Action[];
9
+ getProviders(): Provider[];
10
+ getName(): string;
11
+ getDescription(): string;
12
+ }
13
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/vendors/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEtD,eAAO,MAAM,cAAc;;CAEjB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;AAEjF,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,UAAU,IAAI,MAAM,EAAE,CAAC;IACvB,YAAY,IAAI,QAAQ,EAAE,CAAC;IAC3B,OAAO,IAAI,MAAM,CAAC;IAClB,cAAc,IAAI,MAAM,CAAC;CAC1B"}
@@ -0,0 +1,3 @@
1
+ export const TeeVendorNames = {
2
+ PHALA: "phala",
3
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elizaos/plugin-tee",
3
- "version": "2.0.0-alpha.3",
3
+ "version": "2.0.0-alpha.4",
4
4
  "type": "module",
5
5
  "main": "dist/node/index.js",
6
6
  "module": "dist/node/index.js",
@@ -35,7 +35,7 @@
35
35
  "dependencies": {
36
36
  "@elizaos/core": "2.0.0-alpha.3",
37
37
  "@phala/dstack-sdk": "0.1.11",
38
- "@solana/web3.js": "1.98.2",
38
+ "@solana/web3.js": "1.98.4",
39
39
  "viem": "2.29.4"
40
40
  },
41
41
  "devDependencies": {