@opendatalabs/vana-sdk 2.2.1 → 2.2.3

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 (37) hide show
  1. package/dist/config/features.cjs +1 -24
  2. package/dist/config/features.cjs.map +1 -1
  3. package/dist/config/features.d.ts +13 -44
  4. package/dist/config/features.js +1 -24
  5. package/dist/config/features.js.map +1 -1
  6. package/dist/controllers/permissions.cjs +19 -14
  7. package/dist/controllers/permissions.cjs.map +1 -1
  8. package/dist/controllers/permissions.js +19 -14
  9. package/dist/controllers/permissions.js.map +1 -1
  10. package/dist/crypto/ecies/index.cjs.map +1 -1
  11. package/dist/crypto/ecies/index.d.ts +10 -2
  12. package/dist/crypto/ecies/index.js.map +1 -1
  13. package/dist/index.browser.d.ts +2 -0
  14. package/dist/index.browser.js +10 -0
  15. package/dist/index.browser.js.map +1 -1
  16. package/dist/index.node.cjs +12 -0
  17. package/dist/index.node.cjs.map +1 -1
  18. package/dist/index.node.d.ts +3 -0
  19. package/dist/index.node.js +12 -0
  20. package/dist/index.node.js.map +1 -1
  21. package/dist/platform/browser.cjs +40 -119
  22. package/dist/platform/browser.cjs.map +1 -1
  23. package/dist/platform/browser.d.ts +7 -7
  24. package/dist/platform/browser.js +40 -119
  25. package/dist/platform/browser.js.map +1 -1
  26. package/dist/platform/node.cjs +51 -129
  27. package/dist/platform/node.cjs.map +1 -1
  28. package/dist/platform/node.d.ts +5 -5
  29. package/dist/platform/node.js +51 -129
  30. package/dist/platform/node.js.map +1 -1
  31. package/dist/types/permissions.cjs.map +1 -1
  32. package/dist/types/permissions.d.ts +2 -0
  33. package/package.json +1 -2
  34. package/dist/types/eccrypto-js.d.cjs +0 -2
  35. package/dist/types/eccrypto-js.d.cjs.map +0 -1
  36. package/dist/types/eccrypto-js.d.js +0 -1
  37. package/dist/types/eccrypto-js.d.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/platform/node.ts"],"sourcesContent":["/**\n * Provides Node.js-specific implementations of platform abstraction interfaces.\n *\n * @remarks\n * This module implements all platform-specific operations for Node.js environments,\n * including cryptography, PGP operations, HTTP requests, and caching. It dynamically\n * imports dependencies to avoid Turbopack TDZ issues and supports both standard\n * eccrypto and custom ECIES implementations based on feature flags.\n *\n * WARNING: Dependencies that access globals during init MUST be dynamically imported\n * to support Turbopack. See: https://github.com/vercel/next.js/issues/82632\n *\n * @example\n * ```typescript\n * // Use the Node.js platform adapter\n * import { nodePlatformAdapter } from '@vana-sdk/platform/node';\n *\n * // Encrypt data with public key\n * const encrypted = await nodePlatformAdapter.crypto.encryptWithPublicKey(\n * 'sensitive data',\n * '0x04...' // Public key hex\n * );\n *\n * // Generate PGP key pair\n * const { publicKey, privateKey } = await nodePlatformAdapter.pgp.generateKeyPair({\n * name: 'Data Owner',\n * email: 'owner@example.com'\n * });\n * ```\n *\n * @category Platform\n * @module platform/node\n */\n\nimport type {\n VanaPlatformAdapter,\n VanaCryptoAdapter,\n VanaPGPAdapter,\n VanaHttpAdapter,\n VanaCacheAdapter,\n} from \"./interface\";\nimport { getPGPKeyGenParams } from \"./shared/pgp-utils\";\nimport { wrapCryptoError } from \"./shared/error-utils\";\nimport { streamToUint8Array } from \"./shared/stream-utils\";\nimport { lazyImport } from \"../utils/lazy-import\";\nimport { features } from \"../config/features\";\nimport { WalletKeyEncryptionService } from \"../crypto/services/WalletKeyEncryptionService\";\nimport {\n processWalletPrivateKey,\n parseEncryptedDataBuffer,\n processWalletPublicKey,\n} from \"../utils/crypto-utils\";\n\n// Lazy-loaded dependencies to avoid Turbopack TDZ issues\nconst getOpenPGP = lazyImport(() => import(\"openpgp\"));\nconst getEccryptoJS = lazyImport(() => import(\"eccrypto-js\"));\n\n// Import both ECIES implementations statically\nimport { NodeECIESUint8Provider } from \"../crypto/ecies/node\";\nimport { ECIESError } from \"../crypto/ecies/interface\";\nimport type { ECIESEncrypted } from \"../crypto/ecies\";\nimport { randomBytes } from \"crypto\";\nimport secp256k1Import from \"secp256k1\";\n\n// Type definition for secp256k1 module\ninterface Secp256k1Module {\n privateKeyVerify(privateKey: Buffer): boolean;\n publicKeyCreate(privateKey: Buffer, compressed: boolean): Buffer;\n publicKeyVerify(publicKey: Buffer): boolean;\n publicKeyConvert(publicKey: Buffer, compressed: boolean): Buffer;\n ecdh(\n publicKey: Buffer,\n privateKey: Buffer,\n options: {\n hashfn: (x: Uint8Array, y: Uint8Array, output?: Uint8Array) => Uint8Array;\n },\n output: Buffer,\n ): Buffer;\n}\n\n/**\n * Implements cryptographic operations for Node.js environments.\n *\n * @remarks\n * Provides ECIES encryption/decryption, key generation, and password-based\n * encryption using either eccrypto-js or a custom ECIES implementation.\n * The implementation choice is controlled by the `useCustomECIES` feature flag.\n *\n * @internal\n */\nclass NodeCryptoAdapter implements VanaCryptoAdapter {\n // Initialize both providers - only one will be used based on feature flag\n private customEciesProvider = new NodeECIESUint8Provider();\n private customWalletService = new WalletKeyEncryptionService({\n eciesProvider: this.customEciesProvider,\n });\n\n /**\n * Encrypts data using ECIES with a public key.\n *\n * @param data - The plaintext string to encrypt.\n * Typically user data or sensitive information.\n * @param publicKeyHex - The recipient's public key in hex format.\n * Obtain from key generation or user profile.\n * @returns Encrypted data as a hex string containing IV, ephemeral key, ciphertext, and MAC\n *\n * @throws {Error} If encryption fails or public key is invalid\n */\n async encryptWithPublicKey(\n data: string,\n publicKeyHex: string,\n ): Promise<string> {\n try {\n if (features.useCustomECIES) {\n // Use custom ECIES implementation\n const publicKey = Buffer.from(publicKeyHex, \"hex\");\n const message = Buffer.from(data, \"utf8\");\n\n const encrypted = await this.customEciesProvider.encrypt(\n publicKey,\n message,\n );\n\n // Concatenate all components and return as hex string for API consistency\n const result = Buffer.concat([\n encrypted.iv,\n encrypted.ephemPublicKey,\n encrypted.ciphertext,\n encrypted.mac,\n ]);\n\n return result.toString(\"hex\");\n } else {\n // Use eccrypto-js (default)\n const eccryptojs = await getEccryptoJS();\n const publicKeyBytes = Buffer.from(publicKeyHex, \"hex\");\n\n // Normalize to uncompressed format using the ECIES provider\n // This handles both compressed (33 bytes) and uncompressed (65 bytes) keys\n const uncompressed = this.customEciesProvider.normalizeToUncompressed(\n new Uint8Array(publicKeyBytes),\n );\n const publicKey = Buffer.from(uncompressed);\n\n const message = Buffer.from(data, \"utf8\");\n\n const encrypted = await eccryptojs.encrypt(publicKey, message);\n\n // Concatenate all components and return as hex string for API consistency\n const result = Buffer.concat([\n encrypted.iv,\n encrypted.ephemPublicKey,\n encrypted.ciphertext,\n encrypted.mac,\n ]);\n\n return result.toString(\"hex\");\n }\n } catch (error) {\n if (features.useCustomECIES && error instanceof ECIESError) {\n throw error;\n }\n throw new Error(\n `Encryption failed: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n\n /**\n * Decrypts ECIES-encrypted data using a private key.\n *\n * @param encryptedData - Hex string containing encrypted data.\n * Must include IV, ephemeral public key, ciphertext, and MAC.\n * @param privateKeyHex - The private key in hex format.\n * Must correspond to the public key used for encryption.\n * @returns The decrypted plaintext string\n *\n * @throws {Error} If decryption fails or MAC verification fails\n * @throws {ECIESError} If using custom ECIES and specific error occurs\n */\n async decryptWithPrivateKey(\n encryptedData: string,\n privateKeyHex: string,\n ): Promise<string> {\n try {\n if (features.useCustomECIES) {\n // Use custom ECIES implementation\n const privateKeyBuffer = processWalletPrivateKey(privateKeyHex);\n const encryptedBuffer = Buffer.from(encryptedData, \"hex\");\n const { iv, ephemPublicKey, ciphertext, mac } =\n parseEncryptedDataBuffer(encryptedBuffer);\n\n // Reconstruct the encrypted data structure\n const encryptedObj: ECIESEncrypted = {\n iv,\n ephemPublicKey,\n ciphertext,\n mac,\n };\n\n const decrypted = await this.customEciesProvider.decrypt(\n privateKeyBuffer,\n encryptedObj,\n );\n return new TextDecoder().decode(decrypted);\n } else {\n // Use eccrypto-js (default)\n const eccryptojs = await getEccryptoJS();\n const privateKey = Buffer.from(privateKeyHex, \"hex\");\n const encryptedBuffer = Buffer.from(encryptedData, \"hex\");\n\n // Parse the encrypted data\n const { iv, ephemPublicKey, ciphertext, mac } =\n parseEncryptedDataBuffer(encryptedBuffer);\n\n const decrypted = await eccryptojs.decrypt(privateKey, {\n iv: Buffer.from(iv),\n ephemPublicKey: Buffer.from(ephemPublicKey),\n ciphertext: Buffer.from(ciphertext),\n mac: Buffer.from(mac),\n });\n\n return decrypted.toString(\"utf8\");\n }\n } catch (error) {\n if (features.useCustomECIES && error instanceof ECIESError) {\n throw error;\n }\n throw new Error(\n `Decryption failed: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n\n /**\n * Generates a new secp256k1 key pair for ECIES operations.\n *\n * @returns Object containing hex-encoded public and private keys\n * @returns returns.publicKey - Compressed public key in hex format\n * @returns returns.privateKey - Private key in hex format\n *\n * @throws {Error} If key generation fails\n */\n async generateKeyPair(): Promise<{ publicKey: string; privateKey: string }> {\n try {\n if (features.useCustomECIES) {\n // Use custom implementation with secp256k1\n const secp256k1 = secp256k1Import as unknown as Secp256k1Module;\n\n // Generate private key\n let privateKey: Buffer;\n do {\n privateKey = randomBytes(32);\n } while (!secp256k1.privateKeyVerify(privateKey));\n\n // Get compressed public key\n const publicKey = Buffer.from(\n secp256k1.publicKeyCreate(privateKey, true),\n );\n\n return {\n privateKey: privateKey.toString(\"hex\"),\n publicKey: publicKey.toString(\"hex\"),\n };\n } else {\n // Use eccrypto-js (default)\n const eccryptojs = await getEccryptoJS();\n const privateKey = eccryptojs.generatePrivate();\n const publicKey = eccryptojs.getPublic(privateKey);\n\n return {\n privateKey: privateKey.toString(\"hex\"),\n publicKey: publicKey.toString(\"hex\"),\n };\n }\n } catch (error) {\n throw wrapCryptoError(\"key generation\", error);\n }\n }\n\n /**\n * Encrypts data using a wallet's public key.\n *\n * @param data - The plaintext string to encrypt.\n * Typically permission data or DLP metadata.\n * @param publicKey - The wallet's public key (with or without 0x prefix).\n * Obtain from wallet connection or user profile.\n * @returns Encrypted data as a hex string\n *\n * @throws {Error} If encryption fails or key processing fails\n */\n async encryptWithWalletPublicKey(\n data: string,\n publicKey: string,\n ): Promise<string> {\n try {\n if (features.useCustomECIES) {\n // Use custom ECIES implementation via WalletKeyEncryptionService\n return await this.customWalletService.encryptWithWalletPublicKey(\n data,\n publicKey,\n );\n } else {\n // Use eccrypto-js directly for wallet encryption\n const eccryptojs = await getEccryptoJS();\n const publicKeyBytes = processWalletPublicKey(publicKey);\n\n // Normalize to uncompressed format using the ECIES provider\n // This handles both compressed (33 bytes) and uncompressed (65 bytes) keys\n const uncompressed =\n this.customEciesProvider.normalizeToUncompressed(publicKeyBytes);\n const publicKeyBuffer = Buffer.from(uncompressed);\n\n const message = Buffer.from(data, \"utf8\");\n\n const encrypted = await eccryptojs.encrypt(publicKeyBuffer, message);\n\n // Concatenate all components and return as hex string\n const result = Buffer.concat([\n encrypted.iv,\n encrypted.ephemPublicKey,\n encrypted.ciphertext,\n encrypted.mac,\n ]);\n\n return result.toString(\"hex\");\n }\n } catch (error) {\n throw wrapCryptoError(\"encrypt with wallet public key\", error);\n }\n }\n\n /**\n * Decrypts data using a wallet's private key.\n *\n * @param encryptedData - Hex string containing encrypted data.\n * Must be encrypted with corresponding wallet public key.\n * @param privateKey - The wallet's private key.\n * Obtain from wallet connection (handle with care).\n * @returns The decrypted plaintext string\n *\n * @throws {Error} If decryption fails or key is invalid\n */\n async decryptWithWalletPrivateKey(\n encryptedData: string,\n privateKey: string,\n ): Promise<string> {\n try {\n if (features.useCustomECIES) {\n // Use custom ECIES implementation via WalletKeyEncryptionService\n return await this.customWalletService.decryptWithWalletPrivateKey(\n encryptedData,\n privateKey,\n );\n } else {\n // Use eccrypto-js directly for wallet decryption\n const eccryptojs = await getEccryptoJS();\n const privateKeyBuffer = Buffer.from(\n processWalletPrivateKey(privateKey),\n );\n const encryptedBuffer = Buffer.from(encryptedData, \"hex\");\n\n // Parse the encrypted data\n const { iv, ephemPublicKey, ciphertext, mac } =\n parseEncryptedDataBuffer(encryptedBuffer);\n\n const decrypted = await eccryptojs.decrypt(privateKeyBuffer, {\n iv: Buffer.from(iv),\n ephemPublicKey: Buffer.from(ephemPublicKey),\n ciphertext: Buffer.from(ciphertext),\n mac: Buffer.from(mac),\n });\n\n return decrypted.toString(\"utf8\");\n }\n } catch (error) {\n throw wrapCryptoError(\"decrypt with wallet private key\", error);\n }\n }\n\n /**\n * Encrypts binary data using password-based encryption.\n *\n * @param data - Binary data to encrypt.\n * Typically file contents or serialized objects.\n * @param password - Password for encryption.\n * Often derived from wallet signatures.\n * @returns Encrypted data as Uint8Array\n *\n * @remarks\n * Uses OpenPGP for password-based encryption. Note that this is not\n * deterministic due to OpenPGP's random salt generation.\n *\n * @throws {Error} If encryption fails\n */\n async encryptWithPassword(\n data: Uint8Array,\n password: string,\n ): Promise<Uint8Array> {\n try {\n const openpgp = await getOpenPGP();\n const message = await openpgp.createMessage({\n binary: data,\n });\n\n // Use password-based encryption with wallet signature as password\n // Note: For deterministic encryption, we would need to control the salt\n // This implementation is secure but not deterministic due to OpenPGP's design\n const encrypted = await openpgp.encrypt({\n message,\n passwords: [password],\n format: \"binary\",\n });\n\n // In Node.js, the encrypted result is already a Uint8Array\n if (encrypted instanceof Uint8Array) {\n return encrypted;\n }\n\n // If it's a stream (should not happen with format: \"binary\"), read it\n if (\n encrypted &&\n typeof encrypted === \"object\" &&\n \"getReader\" in encrypted\n ) {\n return await streamToUint8Array(\n encrypted as ReadableStream<Uint8Array>,\n );\n }\n\n throw new Error(\"Unexpected encrypted data format\");\n } catch (error) {\n throw wrapCryptoError(\"encrypt with password\", error);\n }\n }\n\n /**\n * Decrypts password-encrypted binary data.\n *\n * @param encryptedData - Password-encrypted data as Uint8Array.\n * Must be encrypted with the same password.\n * @param password - Password for decryption.\n * Must match the encryption password.\n * @returns Decrypted data as Uint8Array\n *\n * @throws {Error} If decryption fails or password is incorrect\n */\n async decryptWithPassword(\n encryptedData: Uint8Array,\n password: string,\n ): Promise<Uint8Array> {\n try {\n const openpgp = await getOpenPGP();\n const message = await openpgp.readMessage({\n binaryMessage: encryptedData,\n });\n\n // Use password-based decryption with wallet signature as password\n const { data: decrypted } = await openpgp.decrypt({\n message,\n passwords: [password],\n format: \"binary\",\n });\n\n // Convert decrypted data back to Uint8Array\n return new Uint8Array(decrypted as ArrayBuffer);\n } catch (error) {\n throw wrapCryptoError(\"decrypt with password\", error);\n }\n }\n}\n\n/**\n * Implements PGP operations for Node.js environments.\n *\n * @remarks\n * Provides PGP encryption, decryption, and key generation using the OpenPGP.js\n * library with Node.js-specific optimizations like zlib compression.\n *\n * @internal\n */\nclass NodePGPAdapter implements VanaPGPAdapter {\n /**\n * Encrypts data using PGP public key encryption.\n *\n * @param data - The plaintext string to encrypt.\n * Typically messages or structured data.\n * @param publicKeyArmored - ASCII-armored PGP public key.\n * Obtain from PGP key generation or key servers.\n * @returns ASCII-armored encrypted message\n *\n * @throws {Error} If encryption fails or public key is invalid\n */\n async encrypt(data: string, publicKeyArmored: string): Promise<string> {\n try {\n const openpgp = await getOpenPGP();\n const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });\n\n const encrypted = await openpgp.encrypt({\n message: await openpgp.createMessage({ text: data }),\n encryptionKeys: publicKey,\n config: {\n preferredCompressionAlgorithm: openpgp.enums.compression.zlib,\n },\n });\n\n return encrypted as string;\n } catch (error) {\n throw wrapCryptoError(\"PGP encryption\", error);\n }\n }\n\n /**\n * Decrypts PGP-encrypted data using a private key.\n *\n * @param encryptedData - ASCII-armored encrypted message.\n * Must be encrypted with corresponding public key.\n * @param privateKeyArmored - ASCII-armored PGP private key.\n * Must correspond to the public key used for encryption.\n * @returns The decrypted plaintext string\n *\n * @throws {Error} If decryption fails or private key is invalid\n */\n async decrypt(\n encryptedData: string,\n privateKeyArmored: string,\n ): Promise<string> {\n try {\n const openpgp = await getOpenPGP();\n const privateKey = await openpgp.readPrivateKey({\n armoredKey: privateKeyArmored,\n });\n const message = await openpgp.readMessage({\n armoredMessage: encryptedData,\n });\n\n const { data: decrypted } = await openpgp.decrypt({\n message,\n decryptionKeys: privateKey,\n });\n\n return decrypted as string;\n } catch (error) {\n throw wrapCryptoError(\"PGP decryption\", error);\n }\n }\n\n /**\n * Generates a new PGP key pair.\n *\n * @param options - Key generation options\n * @param options.name - Name for the key identity.\n * Defaults to 'Vana User'.\n * @param options.email - Email for the key identity.\n * Defaults to 'user@vana.com'.\n * @param options.passphrase - Passphrase to protect the private key.\n * If not provided, key is unprotected.\n * @returns ASCII-armored public and private keys\n *\n * @throws {Error} If key generation fails\n */\n async generateKeyPair(options?: {\n name?: string;\n email?: string;\n passphrase?: string;\n }): Promise<{ publicKey: string; privateKey: string }> {\n try {\n const openpgp = await getOpenPGP();\n // Use shared utility to get standardized parameters\n const keyGenParams = getPGPKeyGenParams(options);\n\n const { privateKey, publicKey } = await openpgp.generateKey(keyGenParams);\n\n return { publicKey, privateKey };\n } catch (error) {\n throw wrapCryptoError(\"PGP key generation\", error);\n }\n }\n}\n\n/**\n * Implements HTTP operations for Node.js environments.\n *\n * @remarks\n * Provides fetch functionality using the global fetch if available,\n * suitable for Node.js 18+ or environments with fetch polyfills.\n *\n * @internal\n */\nclass NodeHttpAdapter implements VanaHttpAdapter {\n /**\n * Performs an HTTP request using fetch.\n *\n * @param url - The URL to fetch.\n * Must be a valid HTTP/HTTPS URL.\n * @param options - Standard fetch options.\n * See MDN fetch documentation for details.\n * @returns Standard fetch Response object\n *\n * @throws {Error} If fetch is not available in the environment\n */\n async fetch(url: string, options?: RequestInit): Promise<Response> {\n if (typeof globalThis.fetch !== \"undefined\") {\n return globalThis.fetch(url, options);\n }\n\n throw new Error(\"No fetch implementation available in Node.js environment\");\n }\n}\n\n/**\n * Implements in-memory caching for Node.js environments.\n *\n * @remarks\n * Provides a simple TTL-based cache using a Map. Cached values expire\n * after 2 hours by default. This cache is not persistent and will be\n * cleared when the process exits.\n *\n * @internal\n */\nclass NodeCacheAdapter implements VanaCacheAdapter {\n private cache = new Map<string, { value: string; expires: number }>();\n private readonly defaultTtl = 2 * 60 * 60 * 1000; // 2 hours in milliseconds\n\n /**\n * Retrieves a cached value by key.\n *\n * @param key - The cache key to look up.\n * Typically derived from operation parameters.\n * @returns The cached value or null if not found/expired\n */\n get(key: string): string | null {\n const entry = this.cache.get(key);\n if (!entry) {\n return null;\n }\n\n // Check if expired\n if (Date.now() > entry.expires) {\n this.cache.delete(key);\n return null;\n }\n\n return entry.value;\n }\n\n /**\n * Stores a value in the cache with TTL.\n *\n * @param key - The cache key.\n * Should be unique per operation.\n * @param value - The value to cache.\n * Typically serialized data or signatures.\n */\n set(key: string, value: string): void {\n this.cache.set(key, {\n value,\n expires: Date.now() + this.defaultTtl,\n });\n }\n\n /**\n * Removes a specific key from the cache.\n *\n * @param key - The cache key to remove.\n * Use when cached data becomes invalid.\n */\n delete(key: string): void {\n this.cache.delete(key);\n }\n\n /**\n * Clears all cached values.\n *\n * @remarks\n * Use with caution as this removes all cached signatures\n * and other performance optimizations.\n */\n clear(): void {\n this.cache.clear();\n }\n}\n\n/**\n * Provides complete platform abstraction for Node.js environments.\n *\n * @remarks\n * This adapter aggregates all Node.js-specific implementations of platform\n * operations. It automatically selects appropriate cryptographic implementations\n * based on feature flags and provides consistent APIs across all operations.\n *\n * @example\n * ```typescript\n * // Create a custom Node.js adapter instance\n * const adapter = new NodePlatformAdapter();\n *\n * // Use for encryption\n * const encrypted = await adapter.crypto.encryptWithPublicKey(\n * 'secret data',\n * publicKeyHex\n * );\n *\n * // Use for caching\n * adapter.cache.set('signature_key', signatureValue);\n * ```\n *\n * @category Platform\n */\nexport class NodePlatformAdapter implements VanaPlatformAdapter {\n crypto: VanaCryptoAdapter;\n pgp: VanaPGPAdapter;\n http: VanaHttpAdapter;\n cache: VanaCacheAdapter;\n platform: \"node\" = \"node\" as const;\n\n constructor() {\n this.crypto = new NodeCryptoAdapter();\n this.pgp = new NodePGPAdapter();\n this.http = new NodeHttpAdapter();\n this.cache = new NodeCacheAdapter();\n }\n}\n\n/**\n * Pre-configured Node.js platform adapter instance.\n *\n * @remarks\n * This singleton instance is the default adapter used by the SDK when\n * running in Node.js environments. It's automatically selected based on\n * platform detection.\n *\n * @example\n * ```typescript\n * import { nodePlatformAdapter } from '@vana-sdk/platform/node';\n *\n * // Use directly for platform operations\n * const keys = await nodePlatformAdapter.crypto.generateKeyPair();\n * ```\n *\n * @category Platform\n */\nexport const nodePlatformAdapter: VanaPlatformAdapter =\n new NodePlatformAdapter();\n"],"mappings":"AAyCA,SAAS,0BAA0B;AACnC,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AACnC,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AACzB,SAAS,kCAAkC;AAC3C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,MAAM,aAAa,WAAW,MAAM,OAAO,SAAS,CAAC;AACrD,MAAM,gBAAgB,WAAW,MAAM,OAAO,aAAa,CAAC;AAG5D,SAAS,8BAA8B;AACvC,SAAS,kBAAkB;AAE3B,SAAS,mBAAmB;AAC5B,OAAO,qBAAqB;AA4B5B,MAAM,kBAA+C;AAAA;AAAA,EAE3C,sBAAsB,IAAI,uBAAuB;AAAA,EACjD,sBAAsB,IAAI,2BAA2B;AAAA,IAC3D,eAAe,KAAK;AAAA,EACtB,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaD,MAAM,qBACJ,MACA,cACiB;AACjB,QAAI;AACF,UAAI,SAAS,gBAAgB;AAE3B,cAAM,YAAY,OAAO,KAAK,cAAc,KAAK;AACjD,cAAM,UAAU,OAAO,KAAK,MAAM,MAAM;AAExC,cAAM,YAAY,MAAM,KAAK,oBAAoB;AAAA,UAC/C;AAAA,UACA;AAAA,QACF;AAGA,cAAM,SAAS,OAAO,OAAO;AAAA,UAC3B,UAAU;AAAA,UACV,UAAU;AAAA,UACV,UAAU;AAAA,UACV,UAAU;AAAA,QACZ,CAAC;AAED,eAAO,OAAO,SAAS,KAAK;AAAA,MAC9B,OAAO;A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AA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,QAAc;AACZ,SAAK,MAAM,MAAM;AAAA,EACnB;AACF;AA2BO,MAAM,oBAAmD;AAAA,EAC9D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAmB;AAAA,EAEnB,cAAc;AACZ,SAAK,SAAS,IAAI,kBAAkB;AACpC,SAAK,MAAM,IAAI,eAAe;AAC9B,SAAK,OAAO,IAAI,gBAAgB;AAChC,SAAK,QAAQ,IAAI,iBAAiB;AAAA,EACpC;AACF;AAoBO,MAAM,sBACX,IAAI,oBAAoB;","names":[]}
1
+ {"version":3,"sources":["../../src/platform/node.ts"],"sourcesContent":["/**\n * Provides Node.js-specific implementations of platform abstraction interfaces.\n *\n * @remarks\n * This module implements all platform-specific operations for Node.js environments,\n * including cryptography, PGP operations, HTTP requests, and caching. It dynamically\n * imports dependencies to avoid Turbopack TDZ issues and uses a custom ECIES\n * implementation with native secp256k1 for optimal performance.\n *\n * WARNING: Dependencies that access globals during init MUST be dynamically imported\n * to support Turbopack. See: https://github.com/vercel/next.js/issues/82632\n *\n * @example\n * ```typescript\n * // Use the Node.js platform adapter\n * import { nodePlatformAdapter} from '@vana-sdk/platform/node';\n *\n * // Encrypt data with public key\n * const encrypted = await nodePlatformAdapter.crypto.encryptWithPublicKey(\n * 'sensitive data',\n * '0x04...' // Public key hex\n * );\n *\n * // Generate PGP key pair\n * const { publicKey, privateKey } = await nodePlatformAdapter.pgp.generateKeyPair({\n * name: 'Data Owner',\n * email: 'owner@example.com'\n * });\n * ```\n *\n * @category Platform\n * @module platform/node\n */\n\nimport type {\n VanaPlatformAdapter,\n VanaCryptoAdapter,\n VanaPGPAdapter,\n VanaHttpAdapter,\n VanaCacheAdapter,\n} from \"./interface\";\nimport { getPGPKeyGenParams } from \"./shared/pgp-utils\";\nimport { wrapCryptoError } from \"./shared/error-utils\";\nimport { streamToUint8Array } from \"./shared/stream-utils\";\nimport { lazyImport } from \"../utils/lazy-import\";\nimport { WalletKeyEncryptionService } from \"../crypto/services/WalletKeyEncryptionService\";\nimport {\n processWalletPrivateKey,\n parseEncryptedDataBuffer,\n processWalletPublicKey,\n} from \"../utils/crypto-utils\";\n\n// Lazy-loaded dependencies to avoid Turbopack TDZ issues\nconst getOpenPGP = lazyImport(() => import(\"openpgp\"));\n\n// Import ECIES implementation\nimport { NodeECIESUint8Provider } from \"../crypto/ecies/node\";\nimport { ECIESError } from \"../crypto/ecies/interface\";\nimport type { ECIESEncrypted } from \"../crypto/ecies\";\nimport { randomBytes } from \"crypto\";\nimport secp256k1Import from \"secp256k1\";\n\n// Type definition for secp256k1 module\ninterface Secp256k1Module {\n privateKeyVerify(privateKey: Buffer): boolean;\n publicKeyCreate(privateKey: Buffer, compressed: boolean): Buffer;\n publicKeyVerify(publicKey: Buffer): boolean;\n publicKeyConvert(publicKey: Buffer, compressed: boolean): Buffer;\n ecdh(\n publicKey: Buffer,\n privateKey: Buffer,\n options: {\n hashfn: (x: Uint8Array, y: Uint8Array, output?: Uint8Array) => Uint8Array;\n },\n output: Buffer,\n ): Buffer;\n}\n\n/**\n * Implements cryptographic operations for Node.js environments.\n *\n * @remarks\n * Provides ECIES encryption/decryption, key generation, and password-based\n * encryption using a custom ECIES implementation with native secp256k1.\n *\n * @internal\n */\nclass NodeCryptoAdapter implements VanaCryptoAdapter {\n private eciesProvider = new NodeECIESUint8Provider();\n private walletService = new WalletKeyEncryptionService({\n eciesProvider: this.eciesProvider,\n });\n\n /**\n * Encrypts data using ECIES with a public key.\n *\n * @param data - The plaintext string to encrypt.\n * Typically user data or sensitive information.\n * @param publicKeyHex - The recipient's public key in hex format.\n * Obtain from key generation or user profile.\n * @returns Encrypted data as a hex string containing IV, ephemeral key, ciphertext, and MAC\n *\n * @throws {Error} If encryption fails or public key is invalid\n */\n async encryptWithPublicKey(\n data: string,\n publicKeyHex: string,\n ): Promise<string> {\n try {\n // Process public key to handle 0x prefix and convert to Buffer\n const publicKeyBytes = processWalletPublicKey(publicKeyHex);\n const publicKey = Buffer.from(publicKeyBytes);\n const message = Buffer.from(data, \"utf8\");\n\n const encrypted = await this.eciesProvider.encrypt(publicKey, message);\n\n // Concatenate all components and return as hex string for API consistency\n const result = Buffer.concat([\n encrypted.iv,\n encrypted.ephemPublicKey,\n encrypted.ciphertext,\n encrypted.mac,\n ]);\n\n return result.toString(\"hex\");\n } catch (error) {\n if (error instanceof ECIESError) {\n throw error;\n }\n throw new Error(\n `Encryption failed: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n\n /**\n * Decrypts ECIES-encrypted data using a private key.\n *\n * @param encryptedData - Hex string containing encrypted data.\n * Must include IV, ephemeral public key, ciphertext, and MAC.\n * @param privateKeyHex - The private key in hex format.\n * Must correspond to the public key used for encryption.\n * @returns The decrypted plaintext string\n *\n * @throws {Error} If decryption fails or MAC verification fails\n * @throws {ECIESError} If using custom ECIES and specific error occurs\n */\n async decryptWithPrivateKey(\n encryptedData: string,\n privateKeyHex: string,\n ): Promise<string> {\n try {\n const privateKeyBuffer = processWalletPrivateKey(privateKeyHex);\n // Handle 0x prefix in encrypted data (e.g., from viem's toHex)\n const encryptedHex = encryptedData.startsWith(\"0x\")\n ? encryptedData.slice(2)\n : encryptedData;\n const encryptedBuffer = Buffer.from(encryptedHex, \"hex\");\n const { iv, ephemPublicKey, ciphertext, mac } =\n parseEncryptedDataBuffer(encryptedBuffer);\n\n // Reconstruct the encrypted data structure\n const encryptedObj: ECIESEncrypted = {\n iv,\n ephemPublicKey,\n ciphertext,\n mac,\n };\n\n const decrypted = await this.eciesProvider.decrypt(\n privateKeyBuffer,\n encryptedObj,\n );\n return new TextDecoder().decode(decrypted);\n } catch (error) {\n if (error instanceof ECIESError) {\n throw error;\n }\n throw new Error(\n `Decryption failed: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n\n /**\n * Generates a new secp256k1 key pair for ECIES operations.\n *\n * @returns Object containing hex-encoded public and private keys\n * @returns returns.publicKey - Compressed public key in hex format\n * @returns returns.privateKey - Private key in hex format\n *\n * @throws {Error} If key generation fails\n */\n async generateKeyPair(): Promise<{ publicKey: string; privateKey: string }> {\n try {\n const secp256k1 = secp256k1Import as unknown as Secp256k1Module;\n\n // Generate private key\n let privateKey: Buffer;\n do {\n privateKey = randomBytes(32);\n } while (!secp256k1.privateKeyVerify(privateKey));\n\n // Get compressed public key\n const publicKey = Buffer.from(\n secp256k1.publicKeyCreate(privateKey, true),\n );\n\n return {\n privateKey: privateKey.toString(\"hex\"),\n publicKey: publicKey.toString(\"hex\"),\n };\n } catch (error) {\n throw wrapCryptoError(\"key generation\", error);\n }\n }\n\n /**\n * Encrypts data using a wallet's public key.\n *\n * @param data - The plaintext string to encrypt.\n * Typically permission data or DLP metadata.\n * @param publicKey - The wallet's public key (with or without 0x prefix).\n * Obtain from wallet connection or user profile.\n * @returns Encrypted data as a hex string\n *\n * @throws {Error} If encryption fails or key processing fails\n */\n async encryptWithWalletPublicKey(\n data: string,\n publicKey: string,\n ): Promise<string> {\n try {\n return await this.walletService.encryptWithWalletPublicKey(\n data,\n publicKey,\n );\n } catch (error) {\n throw wrapCryptoError(\"encrypt with wallet public key\", error);\n }\n }\n\n /**\n * Decrypts data using a wallet's private key.\n *\n * @param encryptedData - Hex string containing encrypted data.\n * Must be encrypted with corresponding wallet public key.\n * @param privateKey - The wallet's private key.\n * Obtain from wallet connection (handle with care).\n * @returns The decrypted plaintext string\n *\n * @throws {Error} If decryption fails or key is invalid\n */\n async decryptWithWalletPrivateKey(\n encryptedData: string,\n privateKey: string,\n ): Promise<string> {\n try {\n return await this.walletService.decryptWithWalletPrivateKey(\n encryptedData,\n privateKey,\n );\n } catch (error) {\n throw wrapCryptoError(\"decrypt with wallet private key\", error);\n }\n }\n\n /**\n * Encrypts binary data using password-based encryption.\n *\n * @param data - Binary data to encrypt.\n * Typically file contents or serialized objects.\n * @param password - Password for encryption.\n * Often derived from wallet signatures.\n * @returns Encrypted data as Uint8Array\n *\n * @remarks\n * Uses OpenPGP for password-based encryption. Note that this is not\n * deterministic due to OpenPGP's random salt generation.\n *\n * @throws {Error} If encryption fails\n */\n async encryptWithPassword(\n data: Uint8Array,\n password: string,\n ): Promise<Uint8Array> {\n try {\n const openpgp = await getOpenPGP();\n const message = await openpgp.createMessage({\n binary: data,\n });\n\n // Use password-based encryption with wallet signature as password\n // Note: For deterministic encryption, we would need to control the salt\n // This implementation is secure but not deterministic due to OpenPGP's design\n const encrypted = await openpgp.encrypt({\n message,\n passwords: [password],\n format: \"binary\",\n });\n\n // In Node.js, the encrypted result is already a Uint8Array\n if (encrypted instanceof Uint8Array) {\n return encrypted;\n }\n\n // If it's a stream (should not happen with format: \"binary\"), read it\n if (\n encrypted &&\n typeof encrypted === \"object\" &&\n \"getReader\" in encrypted\n ) {\n return await streamToUint8Array(\n encrypted as ReadableStream<Uint8Array>,\n );\n }\n\n throw new Error(\"Unexpected encrypted data format\");\n } catch (error) {\n throw wrapCryptoError(\"encrypt with password\", error);\n }\n }\n\n /**\n * Decrypts password-encrypted binary data.\n *\n * @param encryptedData - Password-encrypted data as Uint8Array.\n * Must be encrypted with the same password.\n * @param password - Password for decryption.\n * Must match the encryption password.\n * @returns Decrypted data as Uint8Array\n *\n * @throws {Error} If decryption fails or password is incorrect\n */\n async decryptWithPassword(\n encryptedData: Uint8Array,\n password: string,\n ): Promise<Uint8Array> {\n try {\n const openpgp = await getOpenPGP();\n const message = await openpgp.readMessage({\n binaryMessage: encryptedData,\n });\n\n // Use password-based decryption with wallet signature as password\n const { data: decrypted } = await openpgp.decrypt({\n message,\n passwords: [password],\n format: \"binary\",\n });\n\n // Convert decrypted data back to Uint8Array\n return new Uint8Array(decrypted as ArrayBuffer);\n } catch (error) {\n throw wrapCryptoError(\"decrypt with password\", error);\n }\n }\n}\n\n/**\n * Implements PGP operations for Node.js environments.\n *\n * @remarks\n * Provides PGP encryption, decryption, and key generation using the OpenPGP.js\n * library with Node.js-specific optimizations like zlib compression.\n *\n * @internal\n */\nclass NodePGPAdapter implements VanaPGPAdapter {\n /**\n * Encrypts data using PGP public key encryption.\n *\n * @param data - The plaintext string to encrypt.\n * Typically messages or structured data.\n * @param publicKeyArmored - ASCII-armored PGP public key.\n * Obtain from PGP key generation or key servers.\n * @returns ASCII-armored encrypted message\n *\n * @throws {Error} If encryption fails or public key is invalid\n */\n async encrypt(data: string, publicKeyArmored: string): Promise<string> {\n try {\n const openpgp = await getOpenPGP();\n const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });\n\n const encrypted = await openpgp.encrypt({\n message: await openpgp.createMessage({ text: data }),\n encryptionKeys: publicKey,\n config: {\n preferredCompressionAlgorithm: openpgp.enums.compression.zlib,\n },\n });\n\n return encrypted as string;\n } catch (error) {\n throw wrapCryptoError(\"PGP encryption\", error);\n }\n }\n\n /**\n * Decrypts PGP-encrypted data using a private key.\n *\n * @param encryptedData - ASCII-armored encrypted message.\n * Must be encrypted with corresponding public key.\n * @param privateKeyArmored - ASCII-armored PGP private key.\n * Must correspond to the public key used for encryption.\n * @returns The decrypted plaintext string\n *\n * @throws {Error} If decryption fails or private key is invalid\n */\n async decrypt(\n encryptedData: string,\n privateKeyArmored: string,\n ): Promise<string> {\n try {\n const openpgp = await getOpenPGP();\n const privateKey = await openpgp.readPrivateKey({\n armoredKey: privateKeyArmored,\n });\n const message = await openpgp.readMessage({\n armoredMessage: encryptedData,\n });\n\n const { data: decrypted } = await openpgp.decrypt({\n message,\n decryptionKeys: privateKey,\n });\n\n return decrypted as string;\n } catch (error) {\n throw wrapCryptoError(\"PGP decryption\", error);\n }\n }\n\n /**\n * Generates a new PGP key pair.\n *\n * @param options - Key generation options\n * @param options.name - Name for the key identity.\n * Defaults to 'Vana User'.\n * @param options.email - Email for the key identity.\n * Defaults to 'user@vana.com'.\n * @param options.passphrase - Passphrase to protect the private key.\n * If not provided, key is unprotected.\n * @returns ASCII-armored public and private keys\n *\n * @throws {Error} If key generation fails\n */\n async generateKeyPair(options?: {\n name?: string;\n email?: string;\n passphrase?: string;\n }): Promise<{ publicKey: string; privateKey: string }> {\n try {\n const openpgp = await getOpenPGP();\n // Use shared utility to get standardized parameters\n const keyGenParams = getPGPKeyGenParams(options);\n\n const { privateKey, publicKey } = await openpgp.generateKey(keyGenParams);\n\n return { publicKey, privateKey };\n } catch (error) {\n throw wrapCryptoError(\"PGP key generation\", error);\n }\n }\n}\n\n/**\n * Implements HTTP operations for Node.js environments.\n *\n * @remarks\n * Provides fetch functionality using the global fetch if available,\n * suitable for Node.js 18+ or environments with fetch polyfills.\n *\n * @internal\n */\nclass NodeHttpAdapter implements VanaHttpAdapter {\n /**\n * Performs an HTTP request using fetch.\n *\n * @param url - The URL to fetch.\n * Must be a valid HTTP/HTTPS URL.\n * @param options - Standard fetch options.\n * See MDN fetch documentation for details.\n * @returns Standard fetch Response object\n *\n * @throws {Error} If fetch is not available in the environment\n */\n async fetch(url: string, options?: RequestInit): Promise<Response> {\n if (typeof globalThis.fetch !== \"undefined\") {\n return globalThis.fetch(url, options);\n }\n\n throw new Error(\"No fetch implementation available in Node.js environment\");\n }\n}\n\n/**\n * Implements in-memory caching for Node.js environments.\n *\n * @remarks\n * Provides a simple TTL-based cache using a Map. Cached values expire\n * after 2 hours by default. This cache is not persistent and will be\n * cleared when the process exits.\n *\n * @internal\n */\nclass NodeCacheAdapter implements VanaCacheAdapter {\n private cache = new Map<string, { value: string; expires: number }>();\n private readonly defaultTtl = 2 * 60 * 60 * 1000; // 2 hours in milliseconds\n\n /**\n * Retrieves a cached value by key.\n *\n * @param key - The cache key to look up.\n * Typically derived from operation parameters.\n * @returns The cached value or null if not found/expired\n */\n get(key: string): string | null {\n const entry = this.cache.get(key);\n if (!entry) {\n return null;\n }\n\n // Check if expired\n if (Date.now() > entry.expires) {\n this.cache.delete(key);\n return null;\n }\n\n return entry.value;\n }\n\n /**\n * Stores a value in the cache with TTL.\n *\n * @param key - The cache key.\n * Should be unique per operation.\n * @param value - The value to cache.\n * Typically serialized data or signatures.\n */\n set(key: string, value: string): void {\n this.cache.set(key, {\n value,\n expires: Date.now() + this.defaultTtl,\n });\n }\n\n /**\n * Removes a specific key from the cache.\n *\n * @param key - The cache key to remove.\n * Use when cached data becomes invalid.\n */\n delete(key: string): void {\n this.cache.delete(key);\n }\n\n /**\n * Clears all cached values.\n *\n * @remarks\n * Use with caution as this removes all cached signatures\n * and other performance optimizations.\n */\n clear(): void {\n this.cache.clear();\n }\n}\n\n/**\n * Provides complete platform abstraction for Node.js environments.\n *\n * @remarks\n * This adapter aggregates all Node.js-specific implementations of platform\n * operations using a custom ECIES implementation with native secp256k1 for\n * optimal performance and provides consistent APIs across all operations.\n *\n * @example\n * ```typescript\n * // Create a custom Node.js adapter instance\n * const adapter = new NodePlatformAdapter();\n *\n * // Use for encryption\n * const encrypted = await adapter.crypto.encryptWithPublicKey(\n * 'secret data',\n * publicKeyHex\n * );\n *\n * // Use for caching\n * adapter.cache.set('signature_key', signatureValue);\n * ```\n *\n * @category Platform\n */\nexport class NodePlatformAdapter implements VanaPlatformAdapter {\n crypto: VanaCryptoAdapter;\n pgp: VanaPGPAdapter;\n http: VanaHttpAdapter;\n cache: VanaCacheAdapter;\n platform: \"node\" = \"node\" as const;\n\n constructor() {\n this.crypto = new NodeCryptoAdapter();\n this.pgp = new NodePGPAdapter();\n this.http = new NodeHttpAdapter();\n this.cache = new NodeCacheAdapter();\n }\n}\n\n/**\n * Pre-configured Node.js platform adapter instance.\n *\n * @remarks\n * This singleton instance is the default adapter used by the SDK when\n * running in Node.js environments. It's automatically selected based on\n * platform detection.\n *\n * @example\n * ```typescript\n * import { nodePlatformAdapter } from '@vana-sdk/platform/node';\n *\n * // Use directly for platform operations\n * const keys = await nodePlatformAdapter.crypto.generateKeyPair();\n * ```\n *\n * @category Platform\n */\nexport const nodePlatformAdapter: VanaPlatformAdapter =\n new NodePlatformAdapter();\n"],"mappings":"AAyCA,SAAS,0BAA0B;AACnC,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AACnC,SAAS,kBAAkB;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AACF;AA2BO,MAAM,oBAAmD;AAAA,EAC9D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAmB;AAAA,EAEnB,cAAc;AACZ,SAAK,SAAS,IAAI,kBAAkB;AACpC,SAAK,MAAM,IAAI,eAAe;AAC9B,SAAK,OAAO,IAAI,gBAAgB;AAChC,SAAK,QAAQ,IAAI,iBAAiB;AAAA,EACpC;AACF;AAoBO,MAAM,sBACX,IAAI,oBAAoB;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/permissions.ts"],"sourcesContent":["import type { Address, Hash } from \"viem\";\n\n/**\n * Base interface for types that need to be compatible with Record<string, unknown>\n *\n * @category Permissions\n */\nexport interface RecordCompatible {\n [key: string]: unknown;\n}\n\n/**\n * Contains on-chain permission data for efficient retrieval.\n *\n * @remarks\n * Provides fast access to permission metadata from subgraph without\n * IPFS calls. For detailed parameters, resolve `grantUrl` separately.\n *\n * @category Permissions\n * @example\n * ```typescript\n * const grants = await vana.permissions.getUserPermissionGrantsOnChain();\n *\n * // Resolve details when needed\n * const details = await retrieveGrantFile(grants[0].grantUrl);\n * console.log(`Operation: ${details.operation}`);\n * ```\n */\nexport interface OnChainPermissionGrant {\n /** Unique identifier for the permission */\n id: bigint;\n /** The grant URL containing detailed permission parameters (IPFS link) */\n grantUrl: string;\n /** Cryptographic signature that authorized this permission */\n grantSignature: string;\n /** Nonce used when granting the permission */\n nonce: bigint;\n /** Block number when permission started */\n startBlock: bigint;\n /** Block number when permission was granted */\n addedAtBlock: bigint;\n /** Timestamp when permission was added */\n addedAtTimestamp: bigint;\n /** Transaction hash of the grant transaction */\n transactionHash: string;\n /** Address that granted the permission */\n grantor: Address;\n /** Grantee information */\n grantee: {\n /** Grantee ID */\n id: string;\n /** Grantee address */\n address: string;\n };\n /** Whether the permission is still active (not revoked) */\n active: boolean;\n}\n\n/**\n * Options for retrieving user permissions\n *\n * @category Permissions\n */\nexport interface GetUserPermissionsOptions {\n /** Maximum number of permissions to retrieve */\n limit?: number;\n /** Whether to fetch all permissions (ignores limit) */\n fetchAll?: boolean;\n /** Custom subgraph URL to use for querying */\n subgraphUrl?: string;\n}\n\n/**\n * Defines parameters for granting file access permissions.\n *\n * @remarks\n * Specifies application, operation, files, and parameters for\n * permission grants via `vana.permissions.grant()`.\n *\n * @category Permissions\n * @example\n * ```typescript\n * const params: GrantPermissionParams = {\n * grantee: '0x1234...',\n * operation: 'llm_inference',\n * files: [1, 2, 3],\n * parameters: { model: 'gpt-4', maxTokens: 1000 }\n * };\n * const result = await vana.permissions.grant(params);\n * ```\n */\nexport interface GrantPermissionParams {\n /** The on-chain identity of the application */\n grantee: Address;\n /** The class of computation, e.g., \"llm_inference\" */\n operation: string;\n /**\n * Array of file IDs to grant permission for.\n * Obtain file IDs from `vana.data.getUserFiles()` or from upload results via `vana.data.upload().fileId`.\n */\n files: number[];\n /** The full, off-chain parameters (e.g., LLM prompt) */\n parameters: Record<string, unknown>;\n /** Optional JSONPath filters to apply to files, keyed by file ID */\n filters?: Record<string, string>;\n /** Optional pre-stored grant URL to avoid duplicate IPFS storage */\n grantUrl?: string;\n /** Optional nonce for the permission */\n nonce?: bigint;\n /** Optional expiration time for the permission */\n expiresAt?: number;\n}\n\n/**\n * Parameters for revoking a previously granted data access permission.\n *\n * Used with `PermissionsController.revoke()` to remove an application's access\n * to user data. Once revoked, the application can no longer use the permission\n * to access the specified files.\n *\n * @category Permissions\n * @example\n * ```typescript\n * const revokeParams: RevokePermissionParams = {\n * permissionId: 123n // Permission ID to revoke\n * };\n *\n * await vana.permissions.revoke(revokeParams);\n * ```\n */\nexport interface RevokePermissionParams {\n /** The permission ID to revoke */\n permissionId: bigint;\n}\n\n/**\n * Parameters for checking if a specific permission exists and is valid.\n *\n * Used to verify whether an application has active permission to access\n * specific user files for a particular operation before attempting to use the data.\n *\n * @category Permissions\n * @example\n * ```typescript\n * const checkParams: CheckPermissionParams = {\n * application: '0x1234...', // App address\n * operation: 'llm_inference',\n * files: [1, 2, 3], // File IDs to check\n * parameters: { model: 'gpt-4' }, // Operation parameters\n * user: '0xabcd...' // Optional specific user\n * };\n *\n * const hasPermission = await vana.permissions.check(checkParams);\n * ```\n */\nexport interface CheckPermissionParams {\n /** The application address */\n application: Address;\n /** The operation type */\n operation: string;\n /** The file IDs */\n files: number[];\n /** The grant parameters */\n parameters: Record<string, unknown>;\n /** The user address */\n user?: Address;\n}\n\n/**\n * Permission check result\n *\n * @category Permissions\n */\nexport interface PermissionCheckResult {\n /** Whether the permission exists and is valid */\n exists: boolean;\n /** The permission details if it exists */\n permission?: GrantedPermission;\n /** Reason why permission is invalid (if applicable) */\n reason?: string;\n}\n\n/**\n * EIP-712 domain definition for PermissionGrant signatures\n *\n * @category Permissions\n */\nexport interface PermissionGrantDomain {\n /** Domain name */\n name: string;\n /** Domain version */\n version: string;\n /** Chain ID */\n chainId: number;\n /** Verifying contract address */\n verifyingContract: Address;\n}\n\n/**\n * EIP-712 Permission message structure (current contract format)\n *\n * @category Permissions\n */\nexport interface PermissionGrantMessage {\n /** Application address */\n application: Address;\n /** File IDs */\n files: number[];\n /** Operation type */\n operation: string;\n /** Grant URL */\n grant: string;\n /** Parameters as JSON string */\n parameters: string;\n /** Nonce */\n nonce: bigint;\n}\n\n/**\n * EIP-712 PermissionInput message structure (new simplified format)\n *\n * @category Permissions\n */\nexport interface PermissionInputMessage extends RecordCompatible {\n /** Nonce */\n nonce: bigint;\n /** Grantee ID */\n granteeId: bigint;\n /** Grant URL */\n grant: string;\n /** File IDs */\n fileIds: bigint[];\n}\n\n/**\n * Contract PermissionInput structure\n *\n * @category Permissions\n */\nexport interface PermissionInput {\n /** Nonce */\n nonce: bigint;\n /** Grantee ID */\n granteeId: bigint;\n /** Grant URL */\n grant: string;\n /** File IDs to grant permission for */\n fileIds: bigint[];\n}\n\n/**\n * Contract RevokePermissionInput structure\n *\n * @category Permissions\n */\nexport interface RevokePermissionInput extends RecordCompatible {\n /** Nonce */\n nonce: bigint;\n /** Permission ID to revoke */\n permissionId: bigint;\n}\n\n/**\n * Contract Permission Info structure returned from the contract\n *\n * @category Permissions\n */\nexport interface PermissionInfo {\n /** Permission ID */\n id: bigint;\n /** Address that granted the permission */\n grantor: Address;\n /** Nonce used when creating */\n nonce: bigint;\n /** Grantee ID */\n granteeId: bigint;\n /** Grant URL */\n grant: string;\n /** Signature bytes (removed in newer contract versions) */\n signature?: `0x${string}`;\n /** Start block */\n startBlock: bigint;\n /** End block */\n endBlock: bigint;\n /** File IDs associated with this permission */\n fileIds: readonly bigint[];\n}\n\n/**\n * EIP-712 Permission message structure (simplified future format)\n *\n * @category Permissions\n */\nexport interface SimplifiedPermissionMessage {\n /** Application address */\n application: Address;\n /** Grant URL */\n grant: string;\n /** Nonce */\n nonce: bigint;\n}\n\n/**\n * Grant file structure containing permission details.\n *\n * Grant files contain the complete specification of what an application is permitted\n * to do with user data, including operation parameters and file access rights.\n *\n * @category Permissions\n * @example\n * ```typescript\n * const grantFile: GrantFile = {\n * grantee: '0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6',\n * operation: 'llm_inference',\n * parameters: {\n * prompt: 'Analyze this data: {{data}}',\n * model: 'gpt-4',\n * maxTokens: 2000,\n * temperature: 0.7\n * },\n * expires: 1736467579\n * };\n * ```\n */\nexport interface GrantFile {\n /** EVM address of the application authorized to use this grant */\n grantee: Address;\n /** Operation the grantee is authorized to perform */\n operation: string;\n /** Operation-specific parameters */\n parameters: Record<string, unknown>;\n /** Optional Unix timestamp when grant expires (seconds since epoch per POSIX.1-2008) */\n expires?: number;\n}\n\n/**\n * EIP-712 typed data structure for Permission\n *\n * @category Permissions\n */\nexport interface PermissionGrantTypedData extends GenericTypedData {\n /** EIP-712 types */\n types: {\n Permission: Array<{\n name: string;\n type: string;\n }>;\n };\n /** Primary type */\n primaryType: \"Permission\";\n /** Message to sign */\n message: PermissionInputMessage;\n}\n\n/**\n * Generic EIP-712 typed data structure\n *\n * @category Permissions\n */\nexport interface GenericTypedData extends RecordCompatible {\n /** EIP-712 domain */\n domain: PermissionGrantDomain;\n /** EIP-712 types */\n types: Record<string, Array<{ name: string; type: string }>>;\n /** Primary type */\n primaryType: string;\n /** Message to sign */\n message: Record<string, unknown>;\n}\n\n/**\n * Represents EIP-712 typed data for permission revocation.\n *\n * @remarks\n * Used when revoking previously granted permissions through gasless transactions.\n * The message contains a nonce and the permission ID to revoke.\n *\n * @category Permissions\n */\nexport interface RevokePermissionTypedData extends GenericTypedData {\n /** EIP-712 type definitions for the RevokePermission structure */\n types: {\n RevokePermission: Array<{\n name: string;\n type: string;\n }>;\n };\n /** The primary type identifier for revocation operations */\n primaryType: \"RevokePermission\";\n /** The structured message containing revocation parameters */\n message: RevokePermissionInput;\n}\n\n/**\n * Defines all valid primary types for EIP-712 typed data in the Vana SDK.\n *\n * @remarks\n * These literal types ensure compile-time safety when handling typed data operations.\n * Each corresponds to a specific blockchain operation type.\n *\n * @category Permissions\n */\nexport type TypedDataPrimaryType =\n | \"Permission\"\n | \"RevokePermission\"\n | \"TrustServer\"\n | \"UntrustServer\"\n | \"AddServer\"\n | \"RegisterGrantee\"\n | \"ServerFilesAndPermission\";\n\n/**\n * Represents the union of all specific typed data interfaces.\n *\n * @remarks\n * Enables type-safe handling of any typed data structure in the SDK.\n * Used internally by relayer handlers and signature verification.\n *\n * @category Permissions\n */\nexport type SpecificTypedData =\n | PermissionGrantTypedData\n | RevokePermissionTypedData\n | TrustServerTypedData\n | UntrustServerTypedData\n | AddAndTrustServerTypedData\n | RegisterGranteeTypedData\n | ServerFilesAndPermissionTypedData;\n\n/**\n * Permission operation types\n *\n * @category Permissions\n */\nexport type PermissionOperation =\n | \"llm_inference\"\n | \"data_analysis\"\n | \"model_training\"\n | \"data_sharing\"\n | \"compute_task\"\n | string;\n\n/**\n * Permission status\n *\n * @category Permissions\n */\nexport type PermissionStatus = \"active\" | \"revoked\" | \"expired\" | \"pending\";\n\n/**\n * Parameters for querying permissions\n *\n * @category Permissions\n */\nexport interface QueryPermissionsParams {\n /** Filter by grantor address */\n grantor?: Address;\n /** Filter by grantee address */\n grantee?: Address;\n /** Filter by operation type */\n operation?: PermissionOperation;\n /** Filter by file IDs */\n files?: number[];\n /** Filter by status */\n status?: PermissionStatus;\n /** Starting block number */\n fromBlock?: bigint;\n /** Ending block number */\n toBlock?: bigint;\n /** Maximum number of results */\n limit?: number;\n /** Offset for pagination */\n offset?: number;\n}\n\n/**\n * Granted permission details\n *\n * @category Permissions\n */\nexport interface GrantedPermission {\n /** Unique identifier for the permission */\n id: bigint;\n /** Array of file IDs that the permission applies to */\n files: number[];\n /** The type of operation being granted permission for */\n operation: string;\n /** Grant file reference (IPFS hash or URL) */\n grant: string;\n /** Address of the application granted permission */\n grantee: Address;\n /** Address of the user who granted permission */\n grantor: Address;\n /** Custom parameters for the operation */\n parameters: Record<string, unknown>;\n /** Whether the permission is still active */\n active: boolean;\n /** Data status for the permission */\n dataStatus?: string;\n /** Nonce used for the permission */\n nonce?: number;\n /** Timestamp when permission was granted */\n grantedAt?: number;\n /** Optional expiration timestamp */\n expiresAt?: number;\n /** Transaction hash of the grant transaction */\n transactionHash?: string;\n /** Block number when permission was granted */\n blockNumber?: bigint;\n}\n\n/**\n * Permission query result\n *\n * @category Permissions\n */\nexport interface PermissionQueryResult {\n /** Array of permissions matching the query */\n permissions: GrantedPermission[];\n /** Total number of permissions (for pagination) */\n total: number;\n /** Whether there are more results available */\n hasMore: boolean;\n}\n\n/**\n * Permission analytics data\n *\n * @category Permissions\n */\nexport interface PermissionAnalytics {\n /** Total number of permissions granted */\n totalPermissions: number;\n /** Number of active permissions */\n activePermissions: number;\n /** Number of revoked permissions */\n revokedPermissions: number;\n /** Number of expired permissions */\n expiredPermissions: number;\n /** Most common operation types */\n topOperations: Array<{\n operation: PermissionOperation;\n count: number;\n }>;\n /** Most active applications */\n topApplications: Array<{\n application: Address;\n count: number;\n }>;\n}\n\n/**\n * Server information\n *\n * @category Permissions\n */\nexport interface Server {\n /** Server ID (numeric) */\n id: number;\n /** Server owner address */\n owner: Address;\n /** Server URL */\n url: string;\n /** Server address */\n serverAddress: Address;\n /** Server public key */\n publicKey: string;\n}\n\n/**\n * Contract ServerInfo structure returned from the contract\n *\n * @category Permissions\n */\nexport interface ServerInfo {\n /** Server ID */\n id: bigint;\n /** Server owner address */\n owner: Address;\n /** Server address */\n serverAddress: Address;\n /** Server public key */\n publicKey: string;\n /** Server URL */\n url: string;\n}\n\n/**\n * Parameters for adding and trusting a server\n *\n * @category Permissions\n */\nexport interface AddAndTrustServerParams {\n /** Server address */\n serverAddress: Address;\n /** Server URL */\n serverUrl: string;\n /** Server public key */\n publicKey: string;\n}\n\n/**\n * Parameters for trusting a server (legacy)\n *\n * @category Permissions\n * @deprecated Use AddAndTrustServerParams instead\n */\nexport interface TrustServerParams {\n /** Server ID (numeric) */\n serverId: number;\n}\n\n/**\n * Parameters for untrusting a server\n *\n * @category Permissions\n */\nexport interface UntrustServerParams {\n /** Server ID (numeric) */\n serverId: number;\n}\n\n/**\n * Input for adding and trusting a server with signature (gasless)\n *\n * @category Permissions\n */\nexport interface AddAndTrustServerInput extends RecordCompatible {\n /** User nonce */\n nonce: bigint;\n /** Server address */\n serverAddress: Address;\n /** Server URL */\n serverUrl: string;\n /** Server public key */\n publicKey: string;\n}\n\n/**\n * Input for trusting a server with signature (gasless)\n *\n * @category Permissions\n * @deprecated Use AddAndTrustServerInput instead\n */\nexport interface TrustServerInput extends RecordCompatible {\n /** User nonce */\n nonce: bigint;\n /** Server ID (numeric) */\n serverId: number;\n}\n\n/**\n * Input for untrusting a server with signature (gasless)\n *\n * @category Permissions\n */\nexport interface UntrustServerInput extends RecordCompatible {\n /** User nonce */\n nonce: bigint;\n /** Server ID (numeric) */\n serverId: number;\n}\n\n/**\n * EIP-712 typed data for AddAndTrustServer\n *\n * @category Permissions\n */\nexport interface AddAndTrustServerTypedData extends GenericTypedData {\n /** EIP-712 types */\n types: {\n AddServer: Array<{\n name: string;\n type: string;\n }>;\n };\n /** Primary type */\n primaryType: \"AddServer\";\n /** Message to sign */\n message: AddAndTrustServerInput;\n}\n\n/**\n * EIP-712 typed data for TrustServer\n *\n * @category Permissions\n * @deprecated Use AddAndTrustServerTypedData instead\n */\nexport interface TrustServerTypedData extends GenericTypedData {\n /** EIP-712 types */\n types: {\n TrustServer: Array<{\n name: string;\n type: string;\n }>;\n };\n /** Primary type */\n primaryType: \"TrustServer\";\n /** Message to sign */\n message: TrustServerInput;\n}\n\n/**\n * EIP-712 typed data for UntrustServer\n *\n * @category Permissions\n */\nexport interface UntrustServerTypedData extends GenericTypedData {\n /** EIP-712 types */\n types: {\n UntrustServer: Array<{\n name: string;\n type: string;\n }>;\n };\n /** Primary type */\n primaryType: \"UntrustServer\";\n /** Message to sign */\n message: UntrustServerInput;\n}\n\n/**\n * Permission event data\n *\n * @category Permissions\n */\nexport interface PermissionEvent {\n /** Event type */\n type: \"granted\" | \"revoked\" | \"expired\";\n /** Permission details */\n permission: GrantedPermission;\n /** Block number where event occurred */\n blockNumber: bigint;\n /** Transaction hash */\n transactionHash: Hash;\n /** Event timestamp */\n timestamp: number;\n}\n\n/**\n * Enhanced trusted server information with trust status\n *\n * @category Permissions\n */\nexport interface TrustedServerInfo {\n /** Server ID */\n id: bigint;\n /** Server owner address */\n owner: Address;\n /** Server address */\n serverAddress: Address;\n /** Server public key */\n publicKey: string;\n /** Server URL */\n url: string;\n /** Start block when trust relationship began */\n startBlock: bigint;\n /** End block when trust relationship ended (0 if still active) */\n endBlock: bigint;\n}\n\n/**\n * Paginated result for trusted server queries\n *\n * @category Permissions\n */\nexport interface PaginatedTrustedServers {\n /** Array of server IDs (numeric) */\n servers: number[];\n /** Total number of trusted servers */\n total: number;\n /** Offset used for this query */\n offset: number;\n /** Limit used for this query */\n limit: number;\n /** Whether there are more servers beyond this page */\n hasMore: boolean;\n}\n\n/**\n * Options for querying trusted servers\n *\n * @category Permissions\n */\nexport interface TrustedServerQueryOptions {\n /** User address to query (defaults to current user) */\n userAddress?: Address;\n /** Maximum number of servers to return */\n limit?: number;\n /** Offset for pagination */\n offset?: number;\n /** Whether to include full server info or just IDs */\n includeServerInfo?: boolean;\n}\n\n/**\n * Result of batch server info requests\n *\n * @category Permissions\n */\nexport interface BatchServerInfoResult {\n /** Successfully retrieved server info */\n servers: Map<number, Server>;\n /** Server IDs that failed to retrieve */\n failed: number[];\n}\n\n/**\n * Server trust status information\n *\n * @category Permissions\n */\nexport interface ServerTrustStatus {\n /** Server ID being checked (numeric) */\n serverId: number;\n /** Whether the server is trusted by the user */\n isTrusted: boolean;\n /** Index in user's trusted server list (if trusted) */\n trustIndex?: number;\n}\n\n/**\n * Grantee information\n *\n * @category Permissions\n */\nexport interface Grantee {\n /** Grantee ID (numeric) */\n id: number;\n /** Grantee owner address */\n owner: Address;\n /** Grantee address */\n address: Address;\n /** Grantee public key */\n publicKey: string;\n /** Permission IDs associated with this grantee */\n permissionIds: number[];\n}\n\n/**\n * Contract GranteeInfo structure returned from the contract\n *\n * @category Permissions\n */\nexport interface GranteeInfo {\n /** Grantee owner address */\n owner: Address;\n /** Grantee address */\n granteeAddress: Address;\n /** Grantee public key */\n publicKey: string;\n /** Permission IDs associated with this grantee */\n permissionIds: readonly bigint[];\n}\n\n/**\n * Parameters for registering a grantee\n *\n * @category Permissions\n */\nexport interface RegisterGranteeParams {\n /** Grantee owner address */\n owner: Address;\n /** Grantee address */\n granteeAddress: Address;\n /** Grantee public key */\n publicKey: string;\n}\n\n/**\n * Input for registering a grantee with signature (gasless)\n *\n * @category Permissions\n */\nexport interface RegisterGranteeInput extends RecordCompatible {\n /** User nonce */\n nonce: bigint;\n /** Grantee owner address */\n owner: Address;\n /** Grantee address */\n granteeAddress: Address;\n /** Grantee public key */\n publicKey: string;\n}\n\n/**\n * EIP-712 typed data for RegisterGrantee\n *\n * @category Permissions\n */\nexport interface RegisterGranteeTypedData extends GenericTypedData {\n /** EIP-712 types */\n types: {\n RegisterGrantee: Array<{\n name: string;\n type: string;\n }>;\n };\n /** Primary type */\n primaryType: \"RegisterGrantee\";\n /** Message to sign */\n message: RegisterGranteeInput;\n}\n\n/**\n * Options for querying grantees\n *\n * @category Permissions\n */\nexport interface GranteeQueryOptions {\n /** Maximum number of grantees to return */\n limit?: number;\n /** Offset for pagination */\n offset?: number;\n /** Whether to include permission info or just basic info */\n includePermissions?: boolean;\n}\n\n/**\n * Paginated result for grantee queries\n *\n * @category Permissions\n */\nexport interface PaginatedGrantees {\n /** Array of grantees */\n grantees: Grantee[];\n /** Total number of grantees */\n total: number;\n /** Offset used for this query */\n offset: number;\n /** Limit used for this query */\n limit: number;\n /** Whether there are more grantees beyond this page */\n hasMore: boolean;\n}\n\n/**\n * Contract Permission structure as used in ServerFilesAndPermissionInput\n *\n * @category Permissions\n */\nexport interface Permission {\n /** Account address for the permission */\n account: Address;\n /** Permission key */\n key: string;\n}\n\n/**\n * Contract ServerFilesAndPermissionInput structure\n *\n * @category Permissions\n */\nexport interface ServerFilesAndPermissionInput {\n /** User nonce */\n nonce: bigint;\n /** Grantee ID */\n granteeId: bigint;\n /** Grant URL */\n grant: string;\n /** File URLs */\n fileUrls: string[];\n /** Server address */\n serverAddress: Address;\n /** Server URL */\n serverUrl: string;\n /** Server public key */\n serverPublicKey: string;\n /** File permissions array - permissions for each file */\n filePermissions: Permission[][];\n}\n\n/**\n * Parameters for server files and permissions operations\n *\n * @category Permissions\n */\nexport interface ServerFilesAndPermissionParams {\n /** Grantee ID */\n granteeId: bigint;\n /** Grant URL or grant data */\n grant: string;\n /** File URLs */\n fileUrls: string[];\n /** Schema IDs for each file - use 0 for files without schema validation */\n schemaIds: number[];\n /** Server address */\n serverAddress: Address;\n /** Server URL */\n serverUrl: string;\n /** Server public key */\n serverPublicKey: string;\n /** File permissions array - permissions for each file */\n filePermissions: Permission[][];\n}\n\n/**\n * EIP-712 typed data for server files and permissions messages\n *\n * @category Permissions\n */\nexport interface ServerFilesAndPermissionTypedData extends GenericTypedData {\n /** Message data structure */\n message: {\n /** User nonce */\n nonce: bigint;\n /** Grantee ID */\n granteeId: bigint;\n /** Grant URL */\n grant: string;\n /** File URLs */\n fileUrls: string[];\n /** Schema IDs for each file - use 0 for files without schema validation */\n schemaIds: bigint[];\n /** Server address */\n serverAddress: Address;\n /** Server URL */\n serverUrl: string;\n /** Server public key */\n serverPublicKey: string;\n /** File permissions array - permissions for each file */\n filePermissions: Permission[][];\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../src/types/permissions.ts"],"sourcesContent":["import type { Address, Hash } from \"viem\";\n\n/**\n * Base interface for types that need to be compatible with Record<string, unknown>\n *\n * @category Permissions\n */\nexport interface RecordCompatible {\n [key: string]: unknown;\n}\n\n/**\n * Contains on-chain permission data for efficient retrieval.\n *\n * @remarks\n * Provides fast access to permission metadata from subgraph without\n * IPFS calls. For detailed parameters, resolve `grantUrl` separately.\n *\n * @category Permissions\n * @example\n * ```typescript\n * const grants = await vana.permissions.getUserPermissionGrantsOnChain();\n *\n * // Resolve details when needed\n * const details = await retrieveGrantFile(grants[0].grantUrl);\n * console.log(`Operation: ${details.operation}`);\n * ```\n */\nexport interface OnChainPermissionGrant {\n /** Unique identifier for the permission */\n id: bigint;\n /** The grant URL containing detailed permission parameters (IPFS link) */\n grantUrl: string;\n /** Cryptographic signature that authorized this permission */\n grantSignature: string;\n /** Nonce used when granting the permission */\n nonce: bigint;\n /** Block number when permission started */\n startBlock: bigint;\n /** Block number when permission ends (0 or MAX_UINT256 means no expiry) */\n endBlock: bigint;\n /** Block number when permission was granted */\n addedAtBlock: bigint;\n /** Timestamp when permission was added */\n addedAtTimestamp: bigint;\n /** Transaction hash of the grant transaction */\n transactionHash: string;\n /** Address that granted the permission */\n grantor: Address;\n /** Grantee information */\n grantee: {\n /** Grantee ID */\n id: string;\n /** Grantee address */\n address: string;\n };\n /** Whether the permission is still active (not revoked) */\n active: boolean;\n}\n\n/**\n * Options for retrieving user permissions\n *\n * @category Permissions\n */\nexport interface GetUserPermissionsOptions {\n /** Maximum number of permissions to retrieve */\n limit?: number;\n /** Whether to fetch all permissions (ignores limit) */\n fetchAll?: boolean;\n /** Custom subgraph URL to use for querying */\n subgraphUrl?: string;\n}\n\n/**\n * Defines parameters for granting file access permissions.\n *\n * @remarks\n * Specifies application, operation, files, and parameters for\n * permission grants via `vana.permissions.grant()`.\n *\n * @category Permissions\n * @example\n * ```typescript\n * const params: GrantPermissionParams = {\n * grantee: '0x1234...',\n * operation: 'llm_inference',\n * files: [1, 2, 3],\n * parameters: { model: 'gpt-4', maxTokens: 1000 }\n * };\n * const result = await vana.permissions.grant(params);\n * ```\n */\nexport interface GrantPermissionParams {\n /** The on-chain identity of the application */\n grantee: Address;\n /** The class of computation, e.g., \"llm_inference\" */\n operation: string;\n /**\n * Array of file IDs to grant permission for.\n * Obtain file IDs from `vana.data.getUserFiles()` or from upload results via `vana.data.upload().fileId`.\n */\n files: number[];\n /** The full, off-chain parameters (e.g., LLM prompt) */\n parameters: Record<string, unknown>;\n /** Optional JSONPath filters to apply to files, keyed by file ID */\n filters?: Record<string, string>;\n /** Optional pre-stored grant URL to avoid duplicate IPFS storage */\n grantUrl?: string;\n /** Optional nonce for the permission */\n nonce?: bigint;\n /** Optional expiration time for the permission */\n expiresAt?: number;\n}\n\n/**\n * Parameters for revoking a previously granted data access permission.\n *\n * Used with `PermissionsController.revoke()` to remove an application's access\n * to user data. Once revoked, the application can no longer use the permission\n * to access the specified files.\n *\n * @category Permissions\n * @example\n * ```typescript\n * const revokeParams: RevokePermissionParams = {\n * permissionId: 123n // Permission ID to revoke\n * };\n *\n * await vana.permissions.revoke(revokeParams);\n * ```\n */\nexport interface RevokePermissionParams {\n /** The permission ID to revoke */\n permissionId: bigint;\n}\n\n/**\n * Parameters for checking if a specific permission exists and is valid.\n *\n * Used to verify whether an application has active permission to access\n * specific user files for a particular operation before attempting to use the data.\n *\n * @category Permissions\n * @example\n * ```typescript\n * const checkParams: CheckPermissionParams = {\n * application: '0x1234...', // App address\n * operation: 'llm_inference',\n * files: [1, 2, 3], // File IDs to check\n * parameters: { model: 'gpt-4' }, // Operation parameters\n * user: '0xabcd...' // Optional specific user\n * };\n *\n * const hasPermission = await vana.permissions.check(checkParams);\n * ```\n */\nexport interface CheckPermissionParams {\n /** The application address */\n application: Address;\n /** The operation type */\n operation: string;\n /** The file IDs */\n files: number[];\n /** The grant parameters */\n parameters: Record<string, unknown>;\n /** The user address */\n user?: Address;\n}\n\n/**\n * Permission check result\n *\n * @category Permissions\n */\nexport interface PermissionCheckResult {\n /** Whether the permission exists and is valid */\n exists: boolean;\n /** The permission details if it exists */\n permission?: GrantedPermission;\n /** Reason why permission is invalid (if applicable) */\n reason?: string;\n}\n\n/**\n * EIP-712 domain definition for PermissionGrant signatures\n *\n * @category Permissions\n */\nexport interface PermissionGrantDomain {\n /** Domain name */\n name: string;\n /** Domain version */\n version: string;\n /** Chain ID */\n chainId: number;\n /** Verifying contract address */\n verifyingContract: Address;\n}\n\n/**\n * EIP-712 Permission message structure (current contract format)\n *\n * @category Permissions\n */\nexport interface PermissionGrantMessage {\n /** Application address */\n application: Address;\n /** File IDs */\n files: number[];\n /** Operation type */\n operation: string;\n /** Grant URL */\n grant: string;\n /** Parameters as JSON string */\n parameters: string;\n /** Nonce */\n nonce: bigint;\n}\n\n/**\n * EIP-712 PermissionInput message structure (new simplified format)\n *\n * @category Permissions\n */\nexport interface PermissionInputMessage extends RecordCompatible {\n /** Nonce */\n nonce: bigint;\n /** Grantee ID */\n granteeId: bigint;\n /** Grant URL */\n grant: string;\n /** File IDs */\n fileIds: bigint[];\n}\n\n/**\n * Contract PermissionInput structure\n *\n * @category Permissions\n */\nexport interface PermissionInput {\n /** Nonce */\n nonce: bigint;\n /** Grantee ID */\n granteeId: bigint;\n /** Grant URL */\n grant: string;\n /** File IDs to grant permission for */\n fileIds: bigint[];\n}\n\n/**\n * Contract RevokePermissionInput structure\n *\n * @category Permissions\n */\nexport interface RevokePermissionInput extends RecordCompatible {\n /** Nonce */\n nonce: bigint;\n /** Permission ID to revoke */\n permissionId: bigint;\n}\n\n/**\n * Contract Permission Info structure returned from the contract\n *\n * @category Permissions\n */\nexport interface PermissionInfo {\n /** Permission ID */\n id: bigint;\n /** Address that granted the permission */\n grantor: Address;\n /** Nonce used when creating */\n nonce: bigint;\n /** Grantee ID */\n granteeId: bigint;\n /** Grant URL */\n grant: string;\n /** Signature bytes (removed in newer contract versions) */\n signature?: `0x${string}`;\n /** Start block */\n startBlock: bigint;\n /** End block */\n endBlock: bigint;\n /** File IDs associated with this permission */\n fileIds: readonly bigint[];\n}\n\n/**\n * EIP-712 Permission message structure (simplified future format)\n *\n * @category Permissions\n */\nexport interface SimplifiedPermissionMessage {\n /** Application address */\n application: Address;\n /** Grant URL */\n grant: string;\n /** Nonce */\n nonce: bigint;\n}\n\n/**\n * Grant file structure containing permission details.\n *\n * Grant files contain the complete specification of what an application is permitted\n * to do with user data, including operation parameters and file access rights.\n *\n * @category Permissions\n * @example\n * ```typescript\n * const grantFile: GrantFile = {\n * grantee: '0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6',\n * operation: 'llm_inference',\n * parameters: {\n * prompt: 'Analyze this data: {{data}}',\n * model: 'gpt-4',\n * maxTokens: 2000,\n * temperature: 0.7\n * },\n * expires: 1736467579\n * };\n * ```\n */\nexport interface GrantFile {\n /** EVM address of the application authorized to use this grant */\n grantee: Address;\n /** Operation the grantee is authorized to perform */\n operation: string;\n /** Operation-specific parameters */\n parameters: Record<string, unknown>;\n /** Optional Unix timestamp when grant expires (seconds since epoch per POSIX.1-2008) */\n expires?: number;\n}\n\n/**\n * EIP-712 typed data structure for Permission\n *\n * @category Permissions\n */\nexport interface PermissionGrantTypedData extends GenericTypedData {\n /** EIP-712 types */\n types: {\n Permission: Array<{\n name: string;\n type: string;\n }>;\n };\n /** Primary type */\n primaryType: \"Permission\";\n /** Message to sign */\n message: PermissionInputMessage;\n}\n\n/**\n * Generic EIP-712 typed data structure\n *\n * @category Permissions\n */\nexport interface GenericTypedData extends RecordCompatible {\n /** EIP-712 domain */\n domain: PermissionGrantDomain;\n /** EIP-712 types */\n types: Record<string, Array<{ name: string; type: string }>>;\n /** Primary type */\n primaryType: string;\n /** Message to sign */\n message: Record<string, unknown>;\n}\n\n/**\n * Represents EIP-712 typed data for permission revocation.\n *\n * @remarks\n * Used when revoking previously granted permissions through gasless transactions.\n * The message contains a nonce and the permission ID to revoke.\n *\n * @category Permissions\n */\nexport interface RevokePermissionTypedData extends GenericTypedData {\n /** EIP-712 type definitions for the RevokePermission structure */\n types: {\n RevokePermission: Array<{\n name: string;\n type: string;\n }>;\n };\n /** The primary type identifier for revocation operations */\n primaryType: \"RevokePermission\";\n /** The structured message containing revocation parameters */\n message: RevokePermissionInput;\n}\n\n/**\n * Defines all valid primary types for EIP-712 typed data in the Vana SDK.\n *\n * @remarks\n * These literal types ensure compile-time safety when handling typed data operations.\n * Each corresponds to a specific blockchain operation type.\n *\n * @category Permissions\n */\nexport type TypedDataPrimaryType =\n | \"Permission\"\n | \"RevokePermission\"\n | \"TrustServer\"\n | \"UntrustServer\"\n | \"AddServer\"\n | \"RegisterGrantee\"\n | \"ServerFilesAndPermission\";\n\n/**\n * Represents the union of all specific typed data interfaces.\n *\n * @remarks\n * Enables type-safe handling of any typed data structure in the SDK.\n * Used internally by relayer handlers and signature verification.\n *\n * @category Permissions\n */\nexport type SpecificTypedData =\n | PermissionGrantTypedData\n | RevokePermissionTypedData\n | TrustServerTypedData\n | UntrustServerTypedData\n | AddAndTrustServerTypedData\n | RegisterGranteeTypedData\n | ServerFilesAndPermissionTypedData;\n\n/**\n * Permission operation types\n *\n * @category Permissions\n */\nexport type PermissionOperation =\n | \"llm_inference\"\n | \"data_analysis\"\n | \"model_training\"\n | \"data_sharing\"\n | \"compute_task\"\n | string;\n\n/**\n * Permission status\n *\n * @category Permissions\n */\nexport type PermissionStatus = \"active\" | \"revoked\" | \"expired\" | \"pending\";\n\n/**\n * Parameters for querying permissions\n *\n * @category Permissions\n */\nexport interface QueryPermissionsParams {\n /** Filter by grantor address */\n grantor?: Address;\n /** Filter by grantee address */\n grantee?: Address;\n /** Filter by operation type */\n operation?: PermissionOperation;\n /** Filter by file IDs */\n files?: number[];\n /** Filter by status */\n status?: PermissionStatus;\n /** Starting block number */\n fromBlock?: bigint;\n /** Ending block number */\n toBlock?: bigint;\n /** Maximum number of results */\n limit?: number;\n /** Offset for pagination */\n offset?: number;\n}\n\n/**\n * Granted permission details\n *\n * @category Permissions\n */\nexport interface GrantedPermission {\n /** Unique identifier for the permission */\n id: bigint;\n /** Array of file IDs that the permission applies to */\n files: number[];\n /** The type of operation being granted permission for */\n operation: string;\n /** Grant file reference (IPFS hash or URL) */\n grant: string;\n /** Address of the application granted permission */\n grantee: Address;\n /** Address of the user who granted permission */\n grantor: Address;\n /** Custom parameters for the operation */\n parameters: Record<string, unknown>;\n /** Whether the permission is still active */\n active: boolean;\n /** Data status for the permission */\n dataStatus?: string;\n /** Nonce used for the permission */\n nonce?: number;\n /** Timestamp when permission was granted */\n grantedAt?: number;\n /** Optional expiration timestamp */\n expiresAt?: number;\n /** Transaction hash of the grant transaction */\n transactionHash?: string;\n /** Block number when permission was granted */\n blockNumber?: bigint;\n}\n\n/**\n * Permission query result\n *\n * @category Permissions\n */\nexport interface PermissionQueryResult {\n /** Array of permissions matching the query */\n permissions: GrantedPermission[];\n /** Total number of permissions (for pagination) */\n total: number;\n /** Whether there are more results available */\n hasMore: boolean;\n}\n\n/**\n * Permission analytics data\n *\n * @category Permissions\n */\nexport interface PermissionAnalytics {\n /** Total number of permissions granted */\n totalPermissions: number;\n /** Number of active permissions */\n activePermissions: number;\n /** Number of revoked permissions */\n revokedPermissions: number;\n /** Number of expired permissions */\n expiredPermissions: number;\n /** Most common operation types */\n topOperations: Array<{\n operation: PermissionOperation;\n count: number;\n }>;\n /** Most active applications */\n topApplications: Array<{\n application: Address;\n count: number;\n }>;\n}\n\n/**\n * Server information\n *\n * @category Permissions\n */\nexport interface Server {\n /** Server ID (numeric) */\n id: number;\n /** Server owner address */\n owner: Address;\n /** Server URL */\n url: string;\n /** Server address */\n serverAddress: Address;\n /** Server public key */\n publicKey: string;\n}\n\n/**\n * Contract ServerInfo structure returned from the contract\n *\n * @category Permissions\n */\nexport interface ServerInfo {\n /** Server ID */\n id: bigint;\n /** Server owner address */\n owner: Address;\n /** Server address */\n serverAddress: Address;\n /** Server public key */\n publicKey: string;\n /** Server URL */\n url: string;\n}\n\n/**\n * Parameters for adding and trusting a server\n *\n * @category Permissions\n */\nexport interface AddAndTrustServerParams {\n /** Server address */\n serverAddress: Address;\n /** Server URL */\n serverUrl: string;\n /** Server public key */\n publicKey: string;\n}\n\n/**\n * Parameters for trusting a server (legacy)\n *\n * @category Permissions\n * @deprecated Use AddAndTrustServerParams instead\n */\nexport interface TrustServerParams {\n /** Server ID (numeric) */\n serverId: number;\n}\n\n/**\n * Parameters for untrusting a server\n *\n * @category Permissions\n */\nexport interface UntrustServerParams {\n /** Server ID (numeric) */\n serverId: number;\n}\n\n/**\n * Input for adding and trusting a server with signature (gasless)\n *\n * @category Permissions\n */\nexport interface AddAndTrustServerInput extends RecordCompatible {\n /** User nonce */\n nonce: bigint;\n /** Server address */\n serverAddress: Address;\n /** Server URL */\n serverUrl: string;\n /** Server public key */\n publicKey: string;\n}\n\n/**\n * Input for trusting a server with signature (gasless)\n *\n * @category Permissions\n * @deprecated Use AddAndTrustServerInput instead\n */\nexport interface TrustServerInput extends RecordCompatible {\n /** User nonce */\n nonce: bigint;\n /** Server ID (numeric) */\n serverId: number;\n}\n\n/**\n * Input for untrusting a server with signature (gasless)\n *\n * @category Permissions\n */\nexport interface UntrustServerInput extends RecordCompatible {\n /** User nonce */\n nonce: bigint;\n /** Server ID (numeric) */\n serverId: number;\n}\n\n/**\n * EIP-712 typed data for AddAndTrustServer\n *\n * @category Permissions\n */\nexport interface AddAndTrustServerTypedData extends GenericTypedData {\n /** EIP-712 types */\n types: {\n AddServer: Array<{\n name: string;\n type: string;\n }>;\n };\n /** Primary type */\n primaryType: \"AddServer\";\n /** Message to sign */\n message: AddAndTrustServerInput;\n}\n\n/**\n * EIP-712 typed data for TrustServer\n *\n * @category Permissions\n * @deprecated Use AddAndTrustServerTypedData instead\n */\nexport interface TrustServerTypedData extends GenericTypedData {\n /** EIP-712 types */\n types: {\n TrustServer: Array<{\n name: string;\n type: string;\n }>;\n };\n /** Primary type */\n primaryType: \"TrustServer\";\n /** Message to sign */\n message: TrustServerInput;\n}\n\n/**\n * EIP-712 typed data for UntrustServer\n *\n * @category Permissions\n */\nexport interface UntrustServerTypedData extends GenericTypedData {\n /** EIP-712 types */\n types: {\n UntrustServer: Array<{\n name: string;\n type: string;\n }>;\n };\n /** Primary type */\n primaryType: \"UntrustServer\";\n /** Message to sign */\n message: UntrustServerInput;\n}\n\n/**\n * Permission event data\n *\n * @category Permissions\n */\nexport interface PermissionEvent {\n /** Event type */\n type: \"granted\" | \"revoked\" | \"expired\";\n /** Permission details */\n permission: GrantedPermission;\n /** Block number where event occurred */\n blockNumber: bigint;\n /** Transaction hash */\n transactionHash: Hash;\n /** Event timestamp */\n timestamp: number;\n}\n\n/**\n * Enhanced trusted server information with trust status\n *\n * @category Permissions\n */\nexport interface TrustedServerInfo {\n /** Server ID */\n id: bigint;\n /** Server owner address */\n owner: Address;\n /** Server address */\n serverAddress: Address;\n /** Server public key */\n publicKey: string;\n /** Server URL */\n url: string;\n /** Start block when trust relationship began */\n startBlock: bigint;\n /** End block when trust relationship ended (0 if still active) */\n endBlock: bigint;\n}\n\n/**\n * Paginated result for trusted server queries\n *\n * @category Permissions\n */\nexport interface PaginatedTrustedServers {\n /** Array of server IDs (numeric) */\n servers: number[];\n /** Total number of trusted servers */\n total: number;\n /** Offset used for this query */\n offset: number;\n /** Limit used for this query */\n limit: number;\n /** Whether there are more servers beyond this page */\n hasMore: boolean;\n}\n\n/**\n * Options for querying trusted servers\n *\n * @category Permissions\n */\nexport interface TrustedServerQueryOptions {\n /** User address to query (defaults to current user) */\n userAddress?: Address;\n /** Maximum number of servers to return */\n limit?: number;\n /** Offset for pagination */\n offset?: number;\n /** Whether to include full server info or just IDs */\n includeServerInfo?: boolean;\n}\n\n/**\n * Result of batch server info requests\n *\n * @category Permissions\n */\nexport interface BatchServerInfoResult {\n /** Successfully retrieved server info */\n servers: Map<number, Server>;\n /** Server IDs that failed to retrieve */\n failed: number[];\n}\n\n/**\n * Server trust status information\n *\n * @category Permissions\n */\nexport interface ServerTrustStatus {\n /** Server ID being checked (numeric) */\n serverId: number;\n /** Whether the server is trusted by the user */\n isTrusted: boolean;\n /** Index in user's trusted server list (if trusted) */\n trustIndex?: number;\n}\n\n/**\n * Grantee information\n *\n * @category Permissions\n */\nexport interface Grantee {\n /** Grantee ID (numeric) */\n id: number;\n /** Grantee owner address */\n owner: Address;\n /** Grantee address */\n address: Address;\n /** Grantee public key */\n publicKey: string;\n /** Permission IDs associated with this grantee */\n permissionIds: number[];\n}\n\n/**\n * Contract GranteeInfo structure returned from the contract\n *\n * @category Permissions\n */\nexport interface GranteeInfo {\n /** Grantee owner address */\n owner: Address;\n /** Grantee address */\n granteeAddress: Address;\n /** Grantee public key */\n publicKey: string;\n /** Permission IDs associated with this grantee */\n permissionIds: readonly bigint[];\n}\n\n/**\n * Parameters for registering a grantee\n *\n * @category Permissions\n */\nexport interface RegisterGranteeParams {\n /** Grantee owner address */\n owner: Address;\n /** Grantee address */\n granteeAddress: Address;\n /** Grantee public key */\n publicKey: string;\n}\n\n/**\n * Input for registering a grantee with signature (gasless)\n *\n * @category Permissions\n */\nexport interface RegisterGranteeInput extends RecordCompatible {\n /** User nonce */\n nonce: bigint;\n /** Grantee owner address */\n owner: Address;\n /** Grantee address */\n granteeAddress: Address;\n /** Grantee public key */\n publicKey: string;\n}\n\n/**\n * EIP-712 typed data for RegisterGrantee\n *\n * @category Permissions\n */\nexport interface RegisterGranteeTypedData extends GenericTypedData {\n /** EIP-712 types */\n types: {\n RegisterGrantee: Array<{\n name: string;\n type: string;\n }>;\n };\n /** Primary type */\n primaryType: \"RegisterGrantee\";\n /** Message to sign */\n message: RegisterGranteeInput;\n}\n\n/**\n * Options for querying grantees\n *\n * @category Permissions\n */\nexport interface GranteeQueryOptions {\n /** Maximum number of grantees to return */\n limit?: number;\n /** Offset for pagination */\n offset?: number;\n /** Whether to include permission info or just basic info */\n includePermissions?: boolean;\n}\n\n/**\n * Paginated result for grantee queries\n *\n * @category Permissions\n */\nexport interface PaginatedGrantees {\n /** Array of grantees */\n grantees: Grantee[];\n /** Total number of grantees */\n total: number;\n /** Offset used for this query */\n offset: number;\n /** Limit used for this query */\n limit: number;\n /** Whether there are more grantees beyond this page */\n hasMore: boolean;\n}\n\n/**\n * Contract Permission structure as used in ServerFilesAndPermissionInput\n *\n * @category Permissions\n */\nexport interface Permission {\n /** Account address for the permission */\n account: Address;\n /** Permission key */\n key: string;\n}\n\n/**\n * Contract ServerFilesAndPermissionInput structure\n *\n * @category Permissions\n */\nexport interface ServerFilesAndPermissionInput {\n /** User nonce */\n nonce: bigint;\n /** Grantee ID */\n granteeId: bigint;\n /** Grant URL */\n grant: string;\n /** File URLs */\n fileUrls: string[];\n /** Server address */\n serverAddress: Address;\n /** Server URL */\n serverUrl: string;\n /** Server public key */\n serverPublicKey: string;\n /** File permissions array - permissions for each file */\n filePermissions: Permission[][];\n}\n\n/**\n * Parameters for server files and permissions operations\n *\n * @category Permissions\n */\nexport interface ServerFilesAndPermissionParams {\n /** Grantee ID */\n granteeId: bigint;\n /** Grant URL or grant data */\n grant: string;\n /** File URLs */\n fileUrls: string[];\n /** Schema IDs for each file - use 0 for files without schema validation */\n schemaIds: number[];\n /** Server address */\n serverAddress: Address;\n /** Server URL */\n serverUrl: string;\n /** Server public key */\n serverPublicKey: string;\n /** File permissions array - permissions for each file */\n filePermissions: Permission[][];\n}\n\n/**\n * EIP-712 typed data for server files and permissions messages\n *\n * @category Permissions\n */\nexport interface ServerFilesAndPermissionTypedData extends GenericTypedData {\n /** Message data structure */\n message: {\n /** User nonce */\n nonce: bigint;\n /** Grantee ID */\n granteeId: bigint;\n /** Grant URL */\n grant: string;\n /** File URLs */\n fileUrls: string[];\n /** Schema IDs for each file - use 0 for files without schema validation */\n schemaIds: bigint[];\n /** Server address */\n serverAddress: Address;\n /** Server URL */\n serverUrl: string;\n /** Server public key */\n serverPublicKey: string;\n /** File permissions array - permissions for each file */\n filePermissions: Permission[][];\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -35,6 +35,8 @@ export interface OnChainPermissionGrant {
35
35
  nonce: bigint;
36
36
  /** Block number when permission started */
37
37
  startBlock: bigint;
38
+ /** Block number when permission ends (0 or MAX_UINT256 means no expiry) */
39
+ endBlock: bigint;
38
40
  /** Block number when permission was granted */
39
41
  addedAtBlock: bigint;
40
42
  /** Timestamp when permission was added */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opendatalabs/vana-sdk",
3
- "version": "2.2.1",
3
+ "version": "2.2.3",
4
4
  "description": "A TypeScript library for interacting with Vana Network smart contracts.",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -120,7 +120,6 @@
120
120
  "abitype": "^1.0.9",
121
121
  "ajv": "^8.17.1",
122
122
  "ajv-formats": "^3.0.1",
123
- "eccrypto-js": "^5.4.0",
124
123
  "graphql": "^16.11.0",
125
124
  "openpgp": "^6.1.1",
126
125
  "uuid": "^13.0.0",
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=eccrypto-js.d.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=eccrypto-js.d.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}