@opendatalabs/vana-sdk 0.1.0-alpha.7e71046 → 0.1.0-alpha.7ee7635
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -4
- package/dist/browser.cjs +29 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.cts +2 -0
- package/dist/browser.d.ts +2 -1
- package/dist/browser.js +1 -305
- package/dist/browser.js.map +1 -1
- package/dist/chains/definitions.cjs +92 -0
- package/dist/chains/definitions.cjs.map +1 -0
- package/dist/chains/definitions.d.cts +53 -0
- package/dist/chains/definitions.d.ts +53 -0
- package/dist/chains/definitions.js +64 -0
- package/dist/chains/definitions.js.map +1 -0
- package/dist/chains/index.cjs +37 -0
- package/dist/chains/index.cjs.map +1 -0
- package/dist/chains/index.d.cts +2 -0
- package/dist/chains/index.d.ts +2 -0
- package/dist/chains/index.js +15 -0
- package/dist/chains/index.js.map +1 -0
- package/dist/chains.browser.cjs +6 -65
- package/dist/chains.browser.cjs.map +1 -1
- package/dist/chains.browser.d.cts +2 -53
- package/dist/chains.browser.d.ts +2 -53
- package/dist/chains.browser.js +7 -57
- package/dist/chains.browser.js.map +1 -1
- package/dist/chains.cjs +6 -65
- package/dist/chains.cjs.map +1 -1
- package/dist/chains.d.cts +1 -1
- package/dist/chains.d.ts +1 -1
- package/dist/chains.js +7 -57
- package/dist/chains.js.map +1 -1
- package/dist/chains.node.cjs +6 -65
- package/dist/chains.node.cjs.map +1 -1
- package/dist/chains.node.d.cts +1 -1
- package/dist/chains.node.d.ts +1 -1
- package/dist/chains.node.js +7 -57
- package/dist/chains.node.js.map +1 -1
- package/dist/config/addresses.cjs +325 -0
- package/dist/config/addresses.cjs.map +1 -0
- package/dist/config/addresses.d.cts +401 -0
- package/dist/config/addresses.d.ts +401 -0
- package/dist/config/addresses.js +295 -0
- package/dist/config/addresses.js.map +1 -0
- package/dist/config/chains.cjs +93 -0
- package/dist/config/chains.cjs.map +1 -0
- package/dist/config/chains.d.cts +85 -0
- package/dist/config/chains.d.ts +85 -0
- package/dist/config/chains.js +67 -0
- package/dist/config/chains.js.map +1 -0
- package/dist/config/features.cjs +52 -0
- package/dist/config/features.cjs.map +1 -0
- package/dist/config/features.d.cts +64 -0
- package/dist/config/features.d.ts +64 -0
- package/dist/config/features.js +28 -0
- package/dist/config/features.js.map +1 -0
- package/dist/contracts/contractController.cjs +126 -0
- package/dist/contracts/contractController.cjs.map +1 -0
- package/dist/contracts/contractController.d.cts +117 -0
- package/dist/contracts/contractController.d.ts +117 -0
- package/dist/contracts/contractController.js +103 -0
- package/dist/contracts/contractController.js.map +1 -0
- package/dist/controllers/data.cjs +2251 -0
- package/dist/controllers/data.cjs.map +1 -0
- package/dist/controllers/data.d.cts +915 -0
- package/dist/controllers/data.d.ts +915 -0
- package/dist/controllers/data.js +2234 -0
- package/dist/controllers/data.js.map +1 -0
- package/dist/controllers/permissions.cjs +3949 -0
- package/dist/controllers/permissions.cjs.map +1 -0
- package/dist/controllers/permissions.d.cts +1383 -0
- package/dist/controllers/permissions.d.ts +1383 -0
- package/dist/controllers/permissions.js +3925 -0
- package/dist/controllers/permissions.js.map +1 -0
- package/dist/controllers/protocol.cjs +179 -0
- package/dist/controllers/protocol.cjs.map +1 -0
- package/dist/controllers/protocol.d.cts +188 -0
- package/dist/controllers/protocol.d.ts +188 -0
- package/dist/controllers/protocol.js +162 -0
- package/dist/controllers/protocol.js.map +1 -0
- package/dist/controllers/schemas.cjs +606 -0
- package/dist/controllers/schemas.cjs.map +1 -0
- package/dist/controllers/schemas.d.cts +260 -0
- package/dist/controllers/schemas.d.ts +260 -0
- package/dist/controllers/schemas.js +582 -0
- package/dist/controllers/schemas.js.map +1 -0
- package/dist/controllers/server.cjs +427 -0
- package/dist/controllers/server.cjs.map +1 -0
- package/dist/controllers/server.d.cts +230 -0
- package/dist/controllers/server.d.ts +230 -0
- package/dist/controllers/server.js +408 -0
- package/dist/controllers/server.js.map +1 -0
- package/dist/core/apiClient.cjs +325 -0
- package/dist/core/apiClient.cjs.map +1 -0
- package/dist/core/apiClient.d.cts +165 -0
- package/dist/core/apiClient.d.ts +165 -0
- package/dist/core/apiClient.js +309 -0
- package/dist/core/apiClient.js.map +1 -0
- package/dist/core/client.cjs +70 -0
- package/dist/core/client.cjs.map +1 -0
- package/dist/core/client.d.cts +92 -0
- package/dist/core/client.d.ts +92 -0
- package/dist/core/client.js +47 -0
- package/dist/core/client.js.map +1 -0
- package/dist/core/generics.cjs +388 -0
- package/dist/core/generics.cjs.map +1 -0
- package/dist/core/generics.d.cts +120 -0
- package/dist/core/generics.d.ts +120 -0
- package/dist/core/generics.js +366 -0
- package/dist/core/generics.js.map +1 -0
- package/dist/core.cjs +658 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.d.cts +493 -0
- package/dist/core.d.ts +493 -0
- package/dist/core.js +636 -0
- package/dist/core.js.map +1 -0
- package/dist/crypto/ecies/__tests__/test-vectors.cjs +102 -0
- package/dist/crypto/ecies/__tests__/test-vectors.cjs.map +1 -0
- package/dist/crypto/ecies/__tests__/test-vectors.d.cts +40 -0
- package/dist/crypto/ecies/__tests__/test-vectors.d.ts +40 -0
- package/dist/crypto/ecies/__tests__/test-vectors.js +77 -0
- package/dist/crypto/ecies/__tests__/test-vectors.js.map +1 -0
- package/dist/crypto/ecies/base.cjs +231 -0
- package/dist/crypto/ecies/base.cjs.map +1 -0
- package/dist/crypto/ecies/base.d.cts +143 -0
- package/dist/crypto/ecies/base.d.ts +143 -0
- package/dist/crypto/ecies/base.js +211 -0
- package/dist/crypto/ecies/base.js.map +1 -0
- package/dist/crypto/ecies/browser.cjs +164 -0
- package/dist/crypto/ecies/browser.cjs.map +1 -0
- package/dist/crypto/ecies/browser.d.cts +48 -0
- package/dist/crypto/ecies/browser.d.ts +48 -0
- package/dist/crypto/ecies/browser.js +130 -0
- package/dist/crypto/ecies/browser.js.map +1 -0
- package/dist/crypto/ecies/constants.cjs +131 -0
- package/dist/crypto/ecies/constants.cjs.map +1 -0
- package/dist/crypto/ecies/constants.d.cts +122 -0
- package/dist/crypto/ecies/constants.d.ts +122 -0
- package/dist/crypto/ecies/constants.js +101 -0
- package/dist/crypto/ecies/constants.js.map +1 -0
- package/dist/crypto/ecies/index.cjs +35 -0
- package/dist/crypto/ecies/index.cjs.map +1 -0
- package/dist/crypto/ecies/index.d.cts +1 -0
- package/dist/crypto/ecies/index.d.ts +1 -0
- package/dist/crypto/ecies/index.js +13 -0
- package/dist/crypto/ecies/index.js.map +1 -0
- package/dist/crypto/ecies/interface.cjs +88 -0
- package/dist/crypto/ecies/interface.cjs.map +1 -0
- package/dist/crypto/ecies/interface.d.cts +176 -0
- package/dist/crypto/ecies/interface.d.ts +176 -0
- package/dist/crypto/ecies/interface.js +61 -0
- package/dist/crypto/ecies/interface.js.map +1 -0
- package/dist/crypto/ecies/node.cjs +166 -0
- package/dist/crypto/ecies/node.cjs.map +1 -0
- package/dist/crypto/ecies/node.d.cts +50 -0
- package/dist/crypto/ecies/node.d.ts +50 -0
- package/dist/crypto/ecies/node.js +144 -0
- package/dist/crypto/ecies/node.js.map +1 -0
- package/dist/crypto/ecies/test-vectors/eccrypto-vectors.d.cts +76 -0
- package/dist/crypto/ecies/test-vectors/eccrypto-vectors.d.ts +76 -0
- package/dist/crypto/ecies/test-vectors/eccrypto-vectors.json +72 -0
- package/dist/crypto/ecies/utils.cjs +91 -0
- package/dist/crypto/ecies/utils.cjs.map +1 -0
- package/dist/crypto/ecies/utils.d.cts +67 -0
- package/dist/crypto/ecies/utils.d.ts +67 -0
- package/dist/crypto/ecies/utils.js +60 -0
- package/dist/crypto/ecies/utils.js.map +1 -0
- package/dist/crypto/services/WalletKeyEncryptionService.cjs +128 -0
- package/dist/crypto/services/WalletKeyEncryptionService.cjs.map +1 -0
- package/dist/crypto/services/WalletKeyEncryptionService.d.cts +92 -0
- package/dist/crypto/services/WalletKeyEncryptionService.d.ts +92 -0
- package/dist/crypto/services/WalletKeyEncryptionService.js +112 -0
- package/dist/crypto/services/WalletKeyEncryptionService.js.map +1 -0
- package/dist/diagnostics.cjs +37 -0
- package/dist/diagnostics.cjs.map +1 -0
- package/dist/diagnostics.d.cts +26 -0
- package/dist/diagnostics.d.ts +26 -0
- package/dist/diagnostics.js +13 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/errors.cjs +141 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.cts +350 -0
- package/dist/errors.d.ts +350 -0
- package/dist/errors.js +108 -0
- package/dist/errors.js.map +1 -0
- package/dist/generated/abi/ComputeEngineImplementation.cjs +1313 -0
- package/dist/generated/abi/ComputeEngineImplementation.cjs.map +1 -0
- package/dist/generated/abi/ComputeEngineImplementation.d.cts +996 -0
- package/dist/generated/abi/ComputeEngineImplementation.d.ts +996 -0
- package/dist/generated/abi/ComputeEngineImplementation.js +1289 -0
- package/dist/generated/abi/ComputeEngineImplementation.js.map +1 -0
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.cjs +734 -0
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.cjs.map +1 -0
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.d.cts +545 -0
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.d.ts +545 -0
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.js +710 -0
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.js.map +1 -0
- package/dist/generated/abi/DATFactoryImplementation.cjs +882 -0
- package/dist/generated/abi/DATFactoryImplementation.cjs.map +1 -0
- package/dist/generated/abi/DATFactoryImplementation.d.cts +661 -0
- package/dist/generated/abi/DATFactoryImplementation.d.ts +661 -0
- package/dist/generated/abi/DATFactoryImplementation.js +858 -0
- package/dist/generated/abi/DATFactoryImplementation.js.map +1 -0
- package/dist/generated/abi/DATImplementation.cjs +934 -0
- package/dist/generated/abi/DATImplementation.cjs.map +1 -0
- package/dist/generated/abi/DATImplementation.d.cts +693 -0
- package/dist/generated/abi/DATImplementation.d.ts +693 -0
- package/dist/generated/abi/DATImplementation.js +910 -0
- package/dist/generated/abi/DATImplementation.js.map +1 -0
- package/dist/generated/abi/DATPausableImplementation.cjs +1523 -0
- package/dist/generated/abi/DATPausableImplementation.cjs.map +1 -0
- package/dist/generated/abi/DATPausableImplementation.d.cts +1145 -0
- package/dist/generated/abi/DATPausableImplementation.d.ts +1145 -0
- package/dist/generated/abi/DATPausableImplementation.js +1499 -0
- package/dist/generated/abi/DATPausableImplementation.js.map +1 -0
- package/dist/generated/abi/DATVotesImplementation.cjs +1460 -0
- package/dist/generated/abi/DATVotesImplementation.cjs.map +1 -0
- package/dist/generated/abi/DATVotesImplementation.d.cts +1095 -0
- package/dist/generated/abi/DATVotesImplementation.d.ts +1095 -0
- package/dist/generated/abi/DATVotesImplementation.js +1436 -0
- package/dist/generated/abi/DATVotesImplementation.js.map +1 -0
- package/dist/generated/abi/DLPPerformanceImplementation.cjs +1160 -0
- package/dist/generated/abi/DLPPerformanceImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPPerformanceImplementation.d.cts +883 -0
- package/dist/generated/abi/DLPPerformanceImplementation.d.ts +883 -0
- package/dist/generated/abi/DLPPerformanceImplementation.js +1136 -0
- package/dist/generated/abi/DLPPerformanceImplementation.js.map +1 -0
- package/dist/generated/abi/DLPRegistryImplementation.cjs +1469 -0
- package/dist/generated/abi/DLPRegistryImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPRegistryImplementation.d.cts +1123 -0
- package/dist/generated/abi/DLPRegistryImplementation.d.ts +1123 -0
- package/dist/generated/abi/DLPRegistryImplementation.js +1445 -0
- package/dist/generated/abi/DLPRegistryImplementation.js.map +1 -0
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.cjs +612 -0
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.d.cts +452 -0
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.d.ts +452 -0
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.js +588 -0
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.js.map +1 -0
- package/dist/generated/abi/DLPRewardDeployerImplementation.cjs +948 -0
- package/dist/generated/abi/DLPRewardDeployerImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPRewardDeployerImplementation.d.cts +714 -0
- package/dist/generated/abi/DLPRewardDeployerImplementation.d.ts +714 -0
- package/dist/generated/abi/DLPRewardDeployerImplementation.js +924 -0
- package/dist/generated/abi/DLPRewardDeployerImplementation.js.map +1 -0
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.cjs +612 -0
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.d.cts +452 -0
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.d.ts +452 -0
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.js +588 -0
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.js.map +1 -0
- package/dist/generated/abi/DLPRewardSwapImplementation.cjs +939 -0
- package/dist/generated/abi/DLPRewardSwapImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPRewardSwapImplementation.d.cts +706 -0
- package/dist/generated/abi/DLPRewardSwapImplementation.d.ts +706 -0
- package/dist/generated/abi/DLPRewardSwapImplementation.js +915 -0
- package/dist/generated/abi/DLPRewardSwapImplementation.js.map +1 -0
- package/dist/generated/abi/DLPRootImplementation.cjs +1644 -0
- package/dist/generated/abi/DLPRootImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPRootImplementation.d.cts +1248 -0
- package/dist/generated/abi/DLPRootImplementation.d.ts +1248 -0
- package/dist/generated/abi/DLPRootImplementation.js +1620 -0
- package/dist/generated/abi/DLPRootImplementation.js.map +1 -0
- package/dist/generated/abi/DLPTreasuryImplementation.cjs +612 -0
- package/dist/generated/abi/DLPTreasuryImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPTreasuryImplementation.d.cts +452 -0
- package/dist/generated/abi/DLPTreasuryImplementation.d.ts +452 -0
- package/dist/generated/abi/DLPTreasuryImplementation.js +588 -0
- package/dist/generated/abi/DLPTreasuryImplementation.js.map +1 -0
- package/dist/generated/abi/DataLiquidityPoolImplementation.cjs +985 -0
- package/dist/generated/abi/DataLiquidityPoolImplementation.cjs.map +1 -0
- package/dist/generated/abi/DataLiquidityPoolImplementation.d.cts +737 -0
- package/dist/generated/abi/DataLiquidityPoolImplementation.d.ts +737 -0
- package/dist/generated/abi/DataLiquidityPoolImplementation.js +961 -0
- package/dist/generated/abi/DataLiquidityPoolImplementation.js.map +1 -0
- package/dist/generated/abi/DataPortabilityGranteesImplementation.cjs +888 -0
- package/dist/generated/abi/DataPortabilityGranteesImplementation.cjs.map +1 -0
- package/dist/generated/abi/DataPortabilityGranteesImplementation.d.cts +661 -0
- package/dist/generated/abi/DataPortabilityGranteesImplementation.d.ts +661 -0
- package/dist/generated/abi/DataPortabilityGranteesImplementation.js +864 -0
- package/dist/generated/abi/DataPortabilityGranteesImplementation.js.map +1 -0
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.cjs +1317 -0
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.cjs.map +1 -0
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.d.cts +989 -0
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.d.ts +989 -0
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.js +1293 -0
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.js.map +1 -0
- package/dist/generated/abi/DataPortabilityServersImplementation.cjs +1438 -0
- package/dist/generated/abi/DataPortabilityServersImplementation.cjs.map +1 -0
- package/dist/generated/abi/DataPortabilityServersImplementation.d.cts +1086 -0
- package/dist/generated/abi/DataPortabilityServersImplementation.d.ts +1086 -0
- package/dist/generated/abi/DataPortabilityServersImplementation.js +1414 -0
- package/dist/generated/abi/DataPortabilityServersImplementation.js.map +1 -0
- package/dist/generated/abi/DataRefinerRegistryImplementation.cjs +984 -0
- package/dist/generated/abi/DataRefinerRegistryImplementation.cjs.map +1 -0
- package/dist/generated/abi/DataRefinerRegistryImplementation.d.cts +737 -0
- package/dist/generated/abi/DataRefinerRegistryImplementation.d.ts +737 -0
- package/dist/generated/abi/DataRefinerRegistryImplementation.js +960 -0
- package/dist/generated/abi/DataRefinerRegistryImplementation.js.map +1 -0
- package/dist/generated/abi/DataRegistryImplementation.cjs +1341 -0
- package/dist/generated/abi/DataRegistryImplementation.cjs.map +1 -0
- package/dist/generated/abi/DataRegistryImplementation.d.cts +1014 -0
- package/dist/generated/abi/DataRegistryImplementation.d.ts +1014 -0
- package/dist/generated/abi/DataRegistryImplementation.js +1317 -0
- package/dist/generated/abi/DataRegistryImplementation.js.map +1 -0
- package/dist/generated/abi/QueryEngineImplementation.cjs +1319 -0
- package/dist/generated/abi/QueryEngineImplementation.cjs.map +1 -0
- package/dist/generated/abi/QueryEngineImplementation.d.cts +1001 -0
- package/dist/generated/abi/QueryEngineImplementation.d.ts +1001 -0
- package/dist/generated/abi/QueryEngineImplementation.js +1295 -0
- package/dist/generated/abi/QueryEngineImplementation.js.map +1 -0
- package/dist/generated/abi/SwapHelperImplementation.cjs +1019 -0
- package/dist/generated/abi/SwapHelperImplementation.cjs.map +1 -0
- package/dist/generated/abi/SwapHelperImplementation.d.cts +764 -0
- package/dist/generated/abi/SwapHelperImplementation.d.ts +764 -0
- package/dist/generated/abi/SwapHelperImplementation.js +995 -0
- package/dist/generated/abi/SwapHelperImplementation.js.map +1 -0
- package/dist/generated/abi/TeePoolDedicatedGpuImplementation.cjs +936 -0
- package/dist/generated/abi/TeePoolDedicatedGpuImplementation.cjs.map +1 -0
- package/dist/generated/abi/TeePoolDedicatedGpuImplementation.d.cts +701 -0
- package/dist/generated/abi/TeePoolDedicatedGpuImplementation.d.ts +701 -0
- package/dist/generated/abi/TeePoolDedicatedGpuImplementation.js +912 -0
- package/dist/generated/abi/TeePoolDedicatedGpuImplementation.js.map +1 -0
- package/dist/generated/abi/TeePoolDedicatedStandardImplementation.cjs +936 -0
- package/dist/generated/abi/TeePoolDedicatedStandardImplementation.cjs.map +1 -0
- package/dist/generated/abi/TeePoolDedicatedStandardImplementation.d.cts +701 -0
- package/dist/generated/abi/TeePoolDedicatedStandardImplementation.d.ts +701 -0
- package/dist/generated/abi/TeePoolDedicatedStandardImplementation.js +912 -0
- package/dist/generated/abi/TeePoolDedicatedStandardImplementation.js.map +1 -0
- package/dist/generated/abi/TeePoolEphemeralStandardImplementation.cjs +936 -0
- package/dist/generated/abi/TeePoolEphemeralStandardImplementation.cjs.map +1 -0
- package/dist/generated/abi/TeePoolEphemeralStandardImplementation.d.cts +701 -0
- package/dist/generated/abi/TeePoolEphemeralStandardImplementation.d.ts +701 -0
- package/dist/generated/abi/TeePoolEphemeralStandardImplementation.js +912 -0
- package/dist/generated/abi/TeePoolEphemeralStandardImplementation.js.map +1 -0
- package/dist/generated/abi/TeePoolImplementation.cjs +1313 -0
- package/dist/generated/abi/TeePoolImplementation.cjs.map +1 -0
- package/dist/generated/abi/TeePoolImplementation.d.cts +993 -0
- package/dist/generated/abi/TeePoolImplementation.d.ts +993 -0
- package/dist/generated/abi/TeePoolImplementation.js +1289 -0
- package/dist/generated/abi/TeePoolImplementation.js.map +1 -0
- package/dist/generated/abi/TeePoolPersistentGpuImplementation.cjs +936 -0
- package/dist/generated/abi/TeePoolPersistentGpuImplementation.cjs.map +1 -0
- package/dist/generated/abi/TeePoolPersistentGpuImplementation.d.cts +701 -0
- package/dist/generated/abi/TeePoolPersistentGpuImplementation.d.ts +701 -0
- package/dist/generated/abi/TeePoolPersistentGpuImplementation.js +912 -0
- package/dist/generated/abi/TeePoolPersistentGpuImplementation.js.map +1 -0
- package/dist/generated/abi/TeePoolPersistentStandardImplementation.cjs +936 -0
- package/dist/generated/abi/TeePoolPersistentStandardImplementation.cjs.map +1 -0
- package/dist/generated/abi/TeePoolPersistentStandardImplementation.d.cts +701 -0
- package/dist/generated/abi/TeePoolPersistentStandardImplementation.d.ts +701 -0
- package/dist/generated/abi/TeePoolPersistentStandardImplementation.js +912 -0
- package/dist/generated/abi/TeePoolPersistentStandardImplementation.js.map +1 -0
- package/dist/generated/abi/TeePoolPhalaImplementation.cjs +1313 -0
- package/dist/generated/abi/TeePoolPhalaImplementation.cjs.map +1 -0
- package/dist/generated/abi/TeePoolPhalaImplementation.d.cts +993 -0
- package/dist/generated/abi/TeePoolPhalaImplementation.d.ts +993 -0
- package/dist/generated/abi/TeePoolPhalaImplementation.js +1289 -0
- package/dist/generated/abi/TeePoolPhalaImplementation.js.map +1 -0
- package/dist/generated/abi/VanaEpochImplementation.cjs +1188 -0
- package/dist/generated/abi/VanaEpochImplementation.cjs.map +1 -0
- package/dist/generated/abi/VanaEpochImplementation.d.cts +900 -0
- package/dist/generated/abi/VanaEpochImplementation.d.ts +900 -0
- package/dist/generated/abi/VanaEpochImplementation.js +1164 -0
- package/dist/generated/abi/VanaEpochImplementation.js.map +1 -0
- package/dist/generated/abi/VanaPoolEntityImplementation.cjs +1234 -0
- package/dist/generated/abi/VanaPoolEntityImplementation.cjs.map +1 -0
- package/dist/generated/abi/VanaPoolEntityImplementation.d.cts +934 -0
- package/dist/generated/abi/VanaPoolEntityImplementation.d.ts +934 -0
- package/dist/generated/abi/VanaPoolEntityImplementation.js +1210 -0
- package/dist/generated/abi/VanaPoolEntityImplementation.js.map +1 -0
- package/dist/generated/abi/VanaPoolStakingImplementation.cjs +921 -0
- package/dist/generated/abi/VanaPoolStakingImplementation.cjs.map +1 -0
- package/dist/generated/abi/VanaPoolStakingImplementation.d.cts +693 -0
- package/dist/generated/abi/VanaPoolStakingImplementation.d.ts +693 -0
- package/dist/generated/abi/VanaPoolStakingImplementation.js +897 -0
- package/dist/generated/abi/VanaPoolStakingImplementation.js.map +1 -0
- package/dist/generated/abi/VanaPoolTreasuryImplementation.cjs +538 -0
- package/dist/generated/abi/VanaPoolTreasuryImplementation.cjs.map +1 -0
- package/dist/generated/abi/VanaPoolTreasuryImplementation.d.cts +394 -0
- package/dist/generated/abi/VanaPoolTreasuryImplementation.d.ts +394 -0
- package/dist/generated/abi/VanaPoolTreasuryImplementation.js +514 -0
- package/dist/generated/abi/VanaPoolTreasuryImplementation.js.map +1 -0
- package/dist/generated/abi/index.cjs +177 -0
- package/dist/generated/abi/index.cjs.map +1 -0
- package/dist/generated/abi/index.d.cts +26547 -0
- package/dist/generated/abi/index.d.ts +26547 -0
- package/dist/generated/abi/index.js +120 -0
- package/dist/generated/abi/index.js.map +1 -0
- package/dist/generated/event-types.cjs +17 -0
- package/dist/generated/event-types.cjs.map +1 -0
- package/dist/generated/event-types.d.cts +855 -0
- package/dist/generated/event-types.d.ts +855 -0
- package/dist/generated/event-types.js +1 -0
- package/dist/generated/event-types.js.map +1 -0
- package/dist/generated/eventRegistry.cjs +3351 -0
- package/dist/generated/eventRegistry.cjs.map +1 -0
- package/dist/generated/eventRegistry.d.cts +18 -0
- package/dist/generated/eventRegistry.d.ts +18 -0
- package/dist/generated/eventRegistry.js +3326 -0
- package/dist/generated/eventRegistry.js.map +1 -0
- package/dist/generated/server/server-exports.cjs +23 -0
- package/dist/generated/server/server-exports.cjs.map +1 -0
- package/dist/generated/server/server-exports.d.cts +21 -0
- package/dist/generated/server/server-exports.d.ts +21 -0
- package/dist/generated/server/server-exports.js +2 -0
- package/dist/generated/server/server-exports.js.map +1 -0
- package/dist/generated/server/server.cjs +17 -0
- package/dist/generated/server/server.cjs.map +1 -0
- package/dist/generated/server/server.d.cts +512 -0
- package/dist/generated/server/server.d.ts +512 -0
- package/dist/generated/server/server.js +1 -0
- package/dist/generated/server/server.js.map +1 -0
- package/dist/generated/subgraph.cjs +675 -0
- package/dist/generated/subgraph.cjs.map +1 -0
- package/dist/generated/subgraph.d.cts +5981 -0
- package/dist/generated/subgraph.d.ts +5981 -0
- package/dist/generated/subgraph.js +644 -0
- package/dist/generated/subgraph.js.map +1 -0
- package/dist/index.browser.cjs +151 -0
- package/dist/index.browser.cjs.map +1 -0
- package/dist/index.browser.d.cts +201 -0
- package/dist/index.browser.d.ts +92 -37352
- package/dist/index.browser.js +64 -46773
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.node.cjs +87 -47260
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.cts +86 -37621
- package/dist/index.node.d.ts +86 -37621
- package/dist/index.node.js +68 -47146
- package/dist/index.node.js.map +1 -1
- package/dist/node.cjs +2 -321
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.cts +2 -1
- package/dist/node.d.ts +2 -1
- package/dist/node.js +1 -307
- package/dist/node.js.map +1 -1
- package/dist/platform/browser-only.cjs +37 -0
- package/dist/platform/browser-only.cjs.map +1 -0
- package/dist/platform/browser-only.d.cts +25 -0
- package/dist/platform/browser-only.d.ts +25 -0
- package/dist/platform/browser-only.js +12 -0
- package/dist/platform/browser-only.js.map +1 -0
- package/dist/platform/browser-safe.cjs +57 -0
- package/dist/platform/browser-safe.cjs.map +1 -0
- package/dist/platform/browser-safe.d.cts +32 -0
- package/dist/platform/browser-safe.d.ts +32 -0
- package/dist/platform/browser-safe.js +31 -0
- package/dist/platform/browser-safe.js.map +1 -0
- package/dist/platform/browser.cjs +329 -0
- package/dist/platform/browser.cjs.map +1 -0
- package/dist/platform/browser.d.cts +74 -0
- package/dist/platform/browser.d.ts +74 -0
- package/dist/platform/browser.js +304 -0
- package/dist/platform/browser.js.map +1 -0
- package/dist/platform/index.cjs +50 -0
- package/dist/platform/index.cjs.map +1 -0
- package/dist/platform/index.d.cts +5 -0
- package/dist/platform/index.d.ts +5 -0
- package/dist/platform/index.js +27 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/platform/interface.cjs +17 -0
- package/dist/platform/interface.cjs.map +1 -0
- package/dist/{node-D9-F9uEP.d.cts → platform/interface.d.cts} +1 -21
- package/dist/{node-D9-F9uEP.d.ts → platform/interface.d.ts} +1 -21
- package/dist/platform/interface.js +1 -0
- package/dist/platform/interface.js.map +1 -0
- package/dist/platform/node.cjs +351 -0
- package/dist/platform/node.cjs.map +1 -0
- package/dist/platform/node.d.cts +27 -0
- package/dist/platform/node.d.ts +27 -0
- package/dist/platform/node.js +327 -0
- package/dist/platform/node.js.map +1 -0
- package/dist/platform/shared/error-utils.cjs +43 -0
- package/dist/platform/shared/error-utils.cjs.map +1 -0
- package/dist/platform/shared/error-utils.d.cts +25 -0
- package/dist/platform/shared/error-utils.d.ts +25 -0
- package/dist/platform/shared/error-utils.js +18 -0
- package/dist/platform/shared/error-utils.js.map +1 -0
- package/dist/platform/shared/pgp-utils.cjs +55 -0
- package/dist/platform/shared/pgp-utils.cjs.map +1 -0
- package/dist/platform/shared/pgp-utils.d.cts +61 -0
- package/dist/platform/shared/pgp-utils.d.ts +61 -0
- package/dist/platform/shared/pgp-utils.js +29 -0
- package/dist/platform/shared/pgp-utils.js.map +1 -0
- package/dist/platform/shared/stream-utils.cjs +49 -0
- package/dist/platform/shared/stream-utils.cjs.map +1 -0
- package/dist/platform/shared/stream-utils.d.cts +16 -0
- package/dist/platform/shared/stream-utils.d.ts +16 -0
- package/dist/platform/shared/stream-utils.js +25 -0
- package/dist/platform/shared/stream-utils.js.map +1 -0
- package/dist/platform/utils.cjs +114 -0
- package/dist/platform/utils.cjs.map +1 -0
- package/dist/platform/utils.d.cts +53 -0
- package/dist/platform/utils.d.ts +53 -0
- package/dist/platform/utils.js +76 -0
- package/dist/platform/utils.js.map +1 -0
- package/dist/platform.browser.cjs +41 -0
- package/dist/platform.browser.cjs.map +1 -0
- package/dist/platform.browser.d.cts +4 -0
- package/dist/platform.browser.d.ts +4 -60
- package/dist/platform.browser.js +10 -379
- package/dist/platform.browser.js.map +1 -1
- package/dist/platform.cjs +14 -708
- package/dist/platform.cjs.map +1 -1
- package/dist/platform.d.cts +5 -2
- package/dist/platform.d.ts +5 -2
- package/dist/platform.js +14 -694
- package/dist/platform.js.map +1 -1
- package/dist/platform.node.cjs +14 -708
- package/dist/platform.node.cjs.map +1 -1
- package/dist/platform.node.d.cts +5 -105
- package/dist/platform.node.d.ts +5 -105
- package/dist/platform.node.js +14 -694
- package/dist/platform.node.js.map +1 -1
- package/dist/schemas/dataSchema.schema.d.cts +88 -0
- package/dist/schemas/dataSchema.schema.d.ts +88 -0
- package/dist/schemas/dataSchema.schema.json +53 -0
- package/dist/schemas/grantFile.schema.d.cts +57 -0
- package/dist/schemas/grantFile.schema.d.ts +57 -0
- package/dist/schemas/grantFile.schema.json +43 -0
- package/dist/server/handler.cjs +101 -0
- package/dist/server/handler.cjs.map +1 -0
- package/dist/server/handler.d.cts +306 -0
- package/dist/server/handler.d.ts +306 -0
- package/dist/server/handler.js +77 -0
- package/dist/server/handler.js.map +1 -0
- package/dist/storage/index.cjs +44 -0
- package/dist/storage/index.cjs.map +1 -0
- package/dist/storage/index.d.cts +10 -0
- package/dist/storage/index.d.ts +10 -0
- package/dist/storage/index.js +15 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/manager.cjs +189 -0
- package/dist/storage/manager.cjs.map +1 -0
- package/dist/storage/manager.d.cts +150 -0
- package/dist/storage/manager.d.ts +150 -0
- package/dist/storage/manager.js +172 -0
- package/dist/storage/manager.js.map +1 -0
- package/dist/storage/providers/callback-storage.cjs +177 -0
- package/dist/storage/providers/callback-storage.cjs.map +1 -0
- package/dist/storage/providers/callback-storage.d.cts +100 -0
- package/dist/storage/providers/callback-storage.d.ts +100 -0
- package/dist/storage/providers/callback-storage.js +155 -0
- package/dist/storage/providers/callback-storage.js.map +1 -0
- package/dist/storage/providers/google-drive.cjs +516 -0
- package/dist/storage/providers/google-drive.cjs.map +1 -0
- package/dist/storage/providers/google-drive.d.cts +156 -0
- package/dist/storage/providers/google-drive.d.ts +156 -0
- package/dist/storage/providers/google-drive.js +497 -0
- package/dist/storage/providers/google-drive.js.map +1 -0
- package/dist/storage/providers/ipfs.cjs +283 -0
- package/dist/storage/providers/ipfs.cjs.map +1 -0
- package/dist/storage/providers/ipfs.d.cts +163 -0
- package/dist/storage/providers/ipfs.d.ts +163 -0
- package/dist/storage/providers/ipfs.js +264 -0
- package/dist/storage/providers/ipfs.js.map +1 -0
- package/dist/storage/providers/pinata.cjs +339 -0
- package/dist/storage/providers/pinata.cjs.map +1 -0
- package/dist/storage/providers/pinata.d.cts +173 -0
- package/dist/storage/providers/pinata.d.ts +173 -0
- package/dist/storage/providers/pinata.js +320 -0
- package/dist/storage/providers/pinata.js.map +1 -0
- package/dist/types/blockchain.cjs +17 -0
- package/dist/types/blockchain.cjs.map +1 -0
- package/dist/types/blockchain.d.cts +52 -0
- package/dist/types/blockchain.d.ts +52 -0
- package/dist/types/blockchain.js +1 -0
- package/dist/types/blockchain.js.map +1 -0
- package/dist/types/chains.cjs +36 -0
- package/dist/types/chains.cjs.map +1 -0
- package/dist/types/chains.d.cts +34 -0
- package/dist/types/chains.d.ts +34 -0
- package/dist/types/chains.js +11 -0
- package/dist/types/chains.js.map +1 -0
- package/dist/types/config.cjs +41 -0
- package/dist/types/config.cjs.map +1 -0
- package/dist/types/config.d.cts +726 -0
- package/dist/types/config.d.ts +726 -0
- package/dist/types/config.js +15 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/contracts.cjs +17 -0
- package/dist/types/contracts.cjs.map +1 -0
- package/dist/types/contracts.d.cts +68 -0
- package/dist/types/contracts.d.ts +68 -0
- package/dist/types/contracts.js +1 -0
- package/dist/types/contracts.js.map +1 -0
- package/dist/types/controller-context.cjs +17 -0
- package/dist/types/controller-context.cjs.map +1 -0
- package/dist/types/controller-context.d.cts +71 -0
- package/dist/types/controller-context.d.ts +71 -0
- package/dist/types/controller-context.js +1 -0
- package/dist/types/controller-context.js.map +1 -0
- package/dist/types/data.cjs +17 -0
- package/dist/types/data.cjs.map +1 -0
- package/dist/types/data.d.cts +694 -0
- package/dist/types/data.d.ts +694 -0
- package/dist/types/data.js +1 -0
- package/dist/types/data.js.map +1 -0
- package/dist/types/eccrypto-js.d.cjs +2 -0
- package/dist/types/eccrypto-js.d.cjs.map +1 -0
- package/dist/types/eccrypto-js.d.d.cts +13 -0
- package/dist/types/eccrypto-js.d.d.ts +13 -0
- package/dist/types/eccrypto-js.d.js +1 -0
- package/dist/types/eccrypto-js.d.js.map +1 -0
- package/dist/types/external-apis.cjs +61 -0
- package/dist/types/external-apis.cjs.map +1 -0
- package/dist/types/external-apis.d.cts +186 -0
- package/dist/types/external-apis.d.ts +186 -0
- package/dist/types/external-apis.js +34 -0
- package/dist/types/external-apis.js.map +1 -0
- package/dist/types/generics.cjs +17 -0
- package/dist/types/generics.cjs.map +1 -0
- package/dist/types/generics.d.cts +450 -0
- package/dist/types/generics.d.ts +450 -0
- package/dist/types/generics.js +1 -0
- package/dist/types/generics.js.map +1 -0
- package/dist/types/index.cjs +64 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.cts +22 -0
- package/dist/types/index.d.ts +22 -0
- package/dist/types/index.js +35 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/operations.cjs +65 -0
- package/dist/types/operations.cjs.map +1 -0
- package/dist/types/operations.d.cts +116 -0
- package/dist/types/operations.d.ts +116 -0
- package/dist/types/operations.js +37 -0
- package/dist/types/operations.js.map +1 -0
- package/dist/types/permissions.cjs +17 -0
- package/dist/types/permissions.cjs.map +1 -0
- package/dist/types/permissions.d.cts +957 -0
- package/dist/types/permissions.d.ts +957 -0
- package/dist/types/permissions.js +1 -0
- package/dist/types/permissions.js.map +1 -0
- package/dist/types/personal.cjs +17 -0
- package/dist/types/personal.cjs.map +1 -0
- package/dist/types/personal.d.cts +40 -0
- package/dist/types/personal.d.ts +40 -0
- package/dist/types/personal.js +1 -0
- package/dist/types/personal.js.map +1 -0
- package/dist/types/relayer.cjs +17 -0
- package/dist/types/relayer.cjs.map +1 -0
- package/dist/types/relayer.d.cts +284 -0
- package/dist/types/relayer.d.ts +284 -0
- package/dist/types/relayer.js +1 -0
- package/dist/types/relayer.js.map +1 -0
- package/dist/types/storage.cjs +39 -0
- package/dist/types/storage.cjs.map +1 -0
- package/dist/types/storage.d.cts +131 -0
- package/dist/types/storage.d.ts +131 -0
- package/dist/types/storage.js +18 -0
- package/dist/types/storage.js.map +1 -0
- package/dist/types/transactionResults.cjs +17 -0
- package/dist/types/transactionResults.cjs.map +1 -0
- package/dist/types/transactionResults.d.cts +195 -0
- package/dist/types/transactionResults.d.ts +195 -0
- package/dist/types/transactionResults.js +1 -0
- package/dist/types/transactionResults.js.map +1 -0
- package/dist/types/utils.cjs +17 -0
- package/dist/types/utils.cjs.map +1 -0
- package/dist/types/utils.d.cts +819 -0
- package/dist/types/utils.d.ts +819 -0
- package/dist/types/utils.js +1 -0
- package/dist/types/utils.js.map +1 -0
- package/dist/types.cjs +23 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +54 -0
- package/dist/types.d.ts +54 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/blockchain/registry.cjs +81 -0
- package/dist/utils/blockchain/registry.cjs.map +1 -0
- package/dist/utils/blockchain/registry.d.cts +34 -0
- package/dist/utils/blockchain/registry.d.ts +34 -0
- package/dist/utils/blockchain/registry.js +56 -0
- package/dist/utils/blockchain/registry.js.map +1 -0
- package/dist/utils/crypto-utils.cjs +120 -0
- package/dist/utils/crypto-utils.cjs.map +1 -0
- package/dist/utils/crypto-utils.d.cts +118 -0
- package/dist/utils/crypto-utils.d.ts +118 -0
- package/dist/utils/crypto-utils.js +87 -0
- package/dist/utils/crypto-utils.js.map +1 -0
- package/dist/utils/download.cjs +69 -0
- package/dist/utils/download.cjs.map +1 -0
- package/dist/utils/download.d.cts +41 -0
- package/dist/utils/download.d.ts +41 -0
- package/dist/utils/download.js +45 -0
- package/dist/utils/download.js.map +1 -0
- package/dist/utils/encoding.cjs +66 -0
- package/dist/utils/encoding.cjs.map +1 -0
- package/dist/utils/encoding.d.cts +54 -0
- package/dist/utils/encoding.d.ts +54 -0
- package/dist/utils/encoding.js +39 -0
- package/dist/utils/encoding.js.map +1 -0
- package/dist/utils/encryption.cjs +170 -0
- package/dist/utils/encryption.cjs.map +1 -0
- package/dist/utils/encryption.d.cts +275 -0
- package/dist/utils/encryption.d.ts +275 -0
- package/dist/utils/encryption.js +136 -0
- package/dist/utils/encryption.js.map +1 -0
- package/dist/utils/formatters.cjs +53 -0
- package/dist/utils/formatters.cjs.map +1 -0
- package/dist/utils/formatters.d.cts +120 -0
- package/dist/utils/formatters.d.ts +120 -0
- package/dist/utils/formatters.js +26 -0
- package/dist/utils/formatters.js.map +1 -0
- package/dist/utils/grantFiles.cjs +175 -0
- package/dist/utils/grantFiles.cjs.map +1 -0
- package/dist/utils/grantFiles.d.cts +186 -0
- package/dist/utils/grantFiles.d.ts +186 -0
- package/dist/utils/grantFiles.js +137 -0
- package/dist/utils/grantFiles.js.map +1 -0
- package/dist/utils/grantValidation.cjs +243 -0
- package/dist/utils/grantValidation.cjs.map +1 -0
- package/dist/utils/grantValidation.d.cts +150 -0
- package/dist/utils/grantValidation.d.ts +150 -0
- package/dist/utils/grantValidation.js +201 -0
- package/dist/utils/grantValidation.js.map +1 -0
- package/dist/utils/grants.cjs +108 -0
- package/dist/utils/grants.cjs.map +1 -0
- package/dist/utils/grants.d.cts +70 -0
- package/dist/utils/grants.d.ts +70 -0
- package/dist/utils/grants.js +82 -0
- package/dist/utils/grants.js.map +1 -0
- package/dist/utils/ipfs.cjs +130 -0
- package/dist/utils/ipfs.cjs.map +1 -0
- package/dist/utils/ipfs.d.cts +90 -0
- package/dist/utils/ipfs.d.ts +90 -0
- package/dist/utils/ipfs.js +99 -0
- package/dist/utils/ipfs.js.map +1 -0
- package/dist/utils/lazy-import.cjs +40 -0
- package/dist/utils/lazy-import.cjs.map +1 -0
- package/dist/utils/lazy-import.d.cts +20 -0
- package/dist/utils/lazy-import.d.ts +20 -0
- package/dist/utils/lazy-import.js +16 -0
- package/dist/utils/lazy-import.js.map +1 -0
- package/dist/utils/multicall.cjs +231 -0
- package/dist/utils/multicall.cjs.map +1 -0
- package/dist/utils/multicall.d.cts +129 -0
- package/dist/utils/multicall.d.ts +129 -0
- package/dist/utils/multicall.js +206 -0
- package/dist/utils/multicall.js.map +1 -0
- package/dist/utils/parseTransactionPojo.cjs +87 -0
- package/dist/utils/parseTransactionPojo.cjs.map +1 -0
- package/dist/utils/parseTransactionPojo.d.cts +37 -0
- package/dist/utils/parseTransactionPojo.d.ts +37 -0
- package/dist/utils/parseTransactionPojo.js +63 -0
- package/dist/utils/parseTransactionPojo.js.map +1 -0
- package/dist/utils/schemaValidation.cjs +258 -0
- package/dist/utils/schemaValidation.cjs.map +1 -0
- package/dist/utils/schemaValidation.d.cts +172 -0
- package/dist/utils/schemaValidation.d.ts +172 -0
- package/dist/utils/schemaValidation.js +222 -0
- package/dist/utils/schemaValidation.js.map +1 -0
- package/dist/utils/signatureCache.cjs +187 -0
- package/dist/utils/signatureCache.cjs.map +1 -0
- package/dist/utils/signatureCache.d.cts +134 -0
- package/dist/utils/signatureCache.d.ts +134 -0
- package/dist/utils/signatureCache.js +165 -0
- package/dist/utils/signatureCache.js.map +1 -0
- package/dist/utils/signatureFormatter.cjs +45 -0
- package/dist/utils/signatureFormatter.cjs.map +1 -0
- package/dist/utils/signatureFormatter.d.cts +39 -0
- package/dist/utils/signatureFormatter.d.ts +39 -0
- package/dist/utils/signatureFormatter.js +21 -0
- package/dist/utils/signatureFormatter.js.map +1 -0
- package/dist/utils/transactionHelpers.cjs +54 -0
- package/dist/utils/transactionHelpers.cjs.map +1 -0
- package/dist/utils/transactionHelpers.d.cts +86 -0
- package/dist/utils/transactionHelpers.d.ts +86 -0
- package/dist/utils/transactionHelpers.js +29 -0
- package/dist/utils/transactionHelpers.js.map +1 -0
- package/dist/utils/typedDataConverter.cjs +43 -0
- package/dist/utils/typedDataConverter.cjs.map +1 -0
- package/dist/utils/typedDataConverter.d.cts +13 -0
- package/dist/utils/typedDataConverter.d.ts +13 -0
- package/dist/utils/typedDataConverter.js +19 -0
- package/dist/utils/typedDataConverter.js.map +1 -0
- package/dist/utils/urlResolver.cjs +55 -0
- package/dist/utils/urlResolver.cjs.map +1 -0
- package/dist/utils/urlResolver.d.cts +40 -0
- package/dist/utils/urlResolver.d.ts +40 -0
- package/dist/utils/urlResolver.js +30 -0
- package/dist/utils/urlResolver.js.map +1 -0
- package/dist/utils/withEvents.cjs +44 -0
- package/dist/utils/withEvents.cjs.map +1 -0
- package/dist/utils/withEvents.d.cts +63 -0
- package/dist/utils/withEvents.d.ts +63 -0
- package/dist/utils/withEvents.js +18 -0
- package/dist/utils/withEvents.js.map +1 -0
- package/package.json +45 -19
- package/dist/browser-DY8XDblx.d.ts +0 -241
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ECIES (Elliptic Curve Integrated Encryption Scheme) Interface
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Defines the contract for platform-specific ECIES implementations.
|
|
6
|
+
* All implementations maintain compatibility with the eccrypto format to ensure
|
|
7
|
+
* backward compatibility with existing encrypted data.
|
|
8
|
+
*
|
|
9
|
+
* **Format specification:**
|
|
10
|
+
* `[iv (16 bytes)][ephemPublicKey (65 bytes)][ciphertext (variable)][mac (32 bytes)]`
|
|
11
|
+
*
|
|
12
|
+
* @category Cryptography
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Represents ECIES encrypted data in eccrypto-compatible format.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* This structure maintains backward compatibility with data encrypted using
|
|
19
|
+
* the legacy eccrypto library.
|
|
20
|
+
*/
|
|
21
|
+
interface ECIESEncrypted {
|
|
22
|
+
/** Initialization vector (16 bytes) */
|
|
23
|
+
iv: Uint8Array;
|
|
24
|
+
/** Ephemeral public key (65 bytes uncompressed) */
|
|
25
|
+
ephemPublicKey: Uint8Array;
|
|
26
|
+
/** Encrypted data */
|
|
27
|
+
ciphertext: Uint8Array;
|
|
28
|
+
/** Message authentication code (32 bytes) */
|
|
29
|
+
mac: Uint8Array;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Provides ECIES encryption and decryption operations.
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* Platform-specific implementations handle the underlying cryptographic primitives
|
|
36
|
+
* while maintaining consistent data format across environments.
|
|
37
|
+
*
|
|
38
|
+
* @category Cryptography
|
|
39
|
+
*/
|
|
40
|
+
interface ECIESProvider {
|
|
41
|
+
/**
|
|
42
|
+
* Encrypts data using ECIES with secp256k1.
|
|
43
|
+
*
|
|
44
|
+
* @param publicKey - Recipient's public key (65 bytes uncompressed or 33 bytes compressed).
|
|
45
|
+
* Obtain via `vana.server.getIdentity(userAddress).public_key`.
|
|
46
|
+
* @param message - Data to encrypt.
|
|
47
|
+
* @returns Encrypted data structure compatible with eccrypto format.
|
|
48
|
+
* @throws {ECIESError} When public key is invalid.
|
|
49
|
+
* Verify key format matches secp256k1 requirements.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const encrypted = await provider.encrypt(
|
|
54
|
+
* hexToBytes(publicKey),
|
|
55
|
+
* new TextEncoder().encode('sensitive data')
|
|
56
|
+
* );
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
encrypt(publicKey: Uint8Array, message: Uint8Array): Promise<ECIESEncrypted>;
|
|
60
|
+
/**
|
|
61
|
+
* Decrypts ECIES encrypted data.
|
|
62
|
+
*
|
|
63
|
+
* @param privateKey - Recipient's private key (32 bytes).
|
|
64
|
+
* @param encrypted - Encrypted data structure from `encrypt()` or legacy eccrypto.
|
|
65
|
+
* @returns Decrypted message as Uint8Array.
|
|
66
|
+
* @throws {ECIESError} When MAC verification fails.
|
|
67
|
+
* Ensure the private key matches the public key used for encryption.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* const decrypted = await provider.decrypt(
|
|
72
|
+
* hexToBytes(privateKey),
|
|
73
|
+
* encrypted
|
|
74
|
+
* );
|
|
75
|
+
* const message = new TextDecoder().decode(decrypted);
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
decrypt(privateKey: Uint8Array, encrypted: ECIESEncrypted): Promise<Uint8Array>;
|
|
79
|
+
/**
|
|
80
|
+
* Normalizes a public key to uncompressed format (65 bytes with 0x04 prefix).
|
|
81
|
+
*
|
|
82
|
+
* @remarks
|
|
83
|
+
* Strict policy: Only accepts properly formatted compressed (33 bytes) or
|
|
84
|
+
* uncompressed (65 bytes) public keys. Does not accept 64-byte raw coordinates
|
|
85
|
+
* to ensure data integrity and prevent masking of malformed inputs.
|
|
86
|
+
*
|
|
87
|
+
* @param publicKey - Public key in compressed or uncompressed format
|
|
88
|
+
* @returns Normalized uncompressed public key (65 bytes with 0x04 prefix)
|
|
89
|
+
* @throws {Error} When public key format is invalid, including raw coordinates (64 bytes)
|
|
90
|
+
* @throws {Error} When decompression of compressed key fails
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* // Compressed key (33 bytes)
|
|
95
|
+
* const compressed = new Uint8Array(33);
|
|
96
|
+
* compressed[0] = 0x02;
|
|
97
|
+
* const uncompressed = provider.normalizeToUncompressed(compressed);
|
|
98
|
+
* console.log(uncompressed.length); // 65
|
|
99
|
+
* console.log(uncompressed[0]); // 0x04
|
|
100
|
+
*
|
|
101
|
+
* // Already uncompressed (65 bytes)
|
|
102
|
+
* const already = provider.normalizeToUncompressed(uncompressedKey);
|
|
103
|
+
* console.log(already === uncompressedKey); // true (returns same reference)
|
|
104
|
+
*
|
|
105
|
+
* // Raw coordinates rejected (64 bytes)
|
|
106
|
+
* const raw = new Uint8Array(64);
|
|
107
|
+
* provider.normalizeToUncompressed(raw); // Throws error
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
normalizeToUncompressed(publicKey: Uint8Array): Uint8Array;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Configures ECIES operation behavior.
|
|
114
|
+
*/
|
|
115
|
+
interface ECIESOptions {
|
|
116
|
+
/** Use compressed public keys (33 bytes) instead of uncompressed (65 bytes) */
|
|
117
|
+
useCompressed?: boolean;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Represents failures in ECIES cryptographic operations.
|
|
121
|
+
*
|
|
122
|
+
* @remarks
|
|
123
|
+
* Provides specific error codes to help identify and recover from
|
|
124
|
+
* different failure scenarios.
|
|
125
|
+
*
|
|
126
|
+
* @category Errors
|
|
127
|
+
*/
|
|
128
|
+
declare class ECIESError extends Error {
|
|
129
|
+
readonly code: "INVALID_KEY" | "ENCRYPTION_FAILED" | "DECRYPTION_FAILED" | "MAC_MISMATCH" | "ECDH_FAILED";
|
|
130
|
+
readonly cause?: Error | undefined;
|
|
131
|
+
constructor(message: string, code: "INVALID_KEY" | "ENCRYPTION_FAILED" | "DECRYPTION_FAILED" | "MAC_MISMATCH" | "ECDH_FAILED", cause?: Error | undefined);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Validates if an object conforms to the ECIESEncrypted structure.
|
|
135
|
+
*
|
|
136
|
+
* @param obj - Object to validate.
|
|
137
|
+
* @returns `true` if object is a valid ECIESEncrypted structure.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```typescript
|
|
141
|
+
* if (isECIESEncrypted(data)) {
|
|
142
|
+
* const decrypted = await provider.decrypt(privateKey, data);
|
|
143
|
+
* }
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
declare function isECIESEncrypted(obj: unknown): obj is ECIESEncrypted;
|
|
147
|
+
/**
|
|
148
|
+
* Serializes ECIESEncrypted to hex string for storage or transmission.
|
|
149
|
+
*
|
|
150
|
+
* @param encrypted - Encrypted data structure from `encrypt()`.
|
|
151
|
+
* @returns Hex string representation.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* const hexString = serializeECIES(encrypted);
|
|
156
|
+
* // Store hexString in database or send over network
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
declare function serializeECIES(encrypted: ECIESEncrypted): string;
|
|
160
|
+
/**
|
|
161
|
+
* Deserializes hex string to ECIESEncrypted structure.
|
|
162
|
+
*
|
|
163
|
+
* @param hex - Hex string from `serializeECIES()` or storage.
|
|
164
|
+
* @returns ECIESEncrypted structure ready for decryption.
|
|
165
|
+
* @throws {ECIESError} When hex string format is invalid.
|
|
166
|
+
* Verify the hex string is complete and uncorrupted.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```typescript
|
|
170
|
+
* const encrypted = deserializeECIES(hexString);
|
|
171
|
+
* const decrypted = await provider.decrypt(privateKey, encrypted);
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
declare function deserializeECIES(hex: string): ECIESEncrypted;
|
|
175
|
+
|
|
176
|
+
export { type ECIESEncrypted, ECIESError, type ECIESOptions, type ECIESProvider, deserializeECIES, isECIESEncrypted, serializeECIES };
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ECIES (Elliptic Curve Integrated Encryption Scheme) Interface
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Defines the contract for platform-specific ECIES implementations.
|
|
6
|
+
* All implementations maintain compatibility with the eccrypto format to ensure
|
|
7
|
+
* backward compatibility with existing encrypted data.
|
|
8
|
+
*
|
|
9
|
+
* **Format specification:**
|
|
10
|
+
* `[iv (16 bytes)][ephemPublicKey (65 bytes)][ciphertext (variable)][mac (32 bytes)]`
|
|
11
|
+
*
|
|
12
|
+
* @category Cryptography
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Represents ECIES encrypted data in eccrypto-compatible format.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* This structure maintains backward compatibility with data encrypted using
|
|
19
|
+
* the legacy eccrypto library.
|
|
20
|
+
*/
|
|
21
|
+
interface ECIESEncrypted {
|
|
22
|
+
/** Initialization vector (16 bytes) */
|
|
23
|
+
iv: Uint8Array;
|
|
24
|
+
/** Ephemeral public key (65 bytes uncompressed) */
|
|
25
|
+
ephemPublicKey: Uint8Array;
|
|
26
|
+
/** Encrypted data */
|
|
27
|
+
ciphertext: Uint8Array;
|
|
28
|
+
/** Message authentication code (32 bytes) */
|
|
29
|
+
mac: Uint8Array;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Provides ECIES encryption and decryption operations.
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* Platform-specific implementations handle the underlying cryptographic primitives
|
|
36
|
+
* while maintaining consistent data format across environments.
|
|
37
|
+
*
|
|
38
|
+
* @category Cryptography
|
|
39
|
+
*/
|
|
40
|
+
interface ECIESProvider {
|
|
41
|
+
/**
|
|
42
|
+
* Encrypts data using ECIES with secp256k1.
|
|
43
|
+
*
|
|
44
|
+
* @param publicKey - Recipient's public key (65 bytes uncompressed or 33 bytes compressed).
|
|
45
|
+
* Obtain via `vana.server.getIdentity(userAddress).public_key`.
|
|
46
|
+
* @param message - Data to encrypt.
|
|
47
|
+
* @returns Encrypted data structure compatible with eccrypto format.
|
|
48
|
+
* @throws {ECIESError} When public key is invalid.
|
|
49
|
+
* Verify key format matches secp256k1 requirements.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const encrypted = await provider.encrypt(
|
|
54
|
+
* hexToBytes(publicKey),
|
|
55
|
+
* new TextEncoder().encode('sensitive data')
|
|
56
|
+
* );
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
encrypt(publicKey: Uint8Array, message: Uint8Array): Promise<ECIESEncrypted>;
|
|
60
|
+
/**
|
|
61
|
+
* Decrypts ECIES encrypted data.
|
|
62
|
+
*
|
|
63
|
+
* @param privateKey - Recipient's private key (32 bytes).
|
|
64
|
+
* @param encrypted - Encrypted data structure from `encrypt()` or legacy eccrypto.
|
|
65
|
+
* @returns Decrypted message as Uint8Array.
|
|
66
|
+
* @throws {ECIESError} When MAC verification fails.
|
|
67
|
+
* Ensure the private key matches the public key used for encryption.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* const decrypted = await provider.decrypt(
|
|
72
|
+
* hexToBytes(privateKey),
|
|
73
|
+
* encrypted
|
|
74
|
+
* );
|
|
75
|
+
* const message = new TextDecoder().decode(decrypted);
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
decrypt(privateKey: Uint8Array, encrypted: ECIESEncrypted): Promise<Uint8Array>;
|
|
79
|
+
/**
|
|
80
|
+
* Normalizes a public key to uncompressed format (65 bytes with 0x04 prefix).
|
|
81
|
+
*
|
|
82
|
+
* @remarks
|
|
83
|
+
* Strict policy: Only accepts properly formatted compressed (33 bytes) or
|
|
84
|
+
* uncompressed (65 bytes) public keys. Does not accept 64-byte raw coordinates
|
|
85
|
+
* to ensure data integrity and prevent masking of malformed inputs.
|
|
86
|
+
*
|
|
87
|
+
* @param publicKey - Public key in compressed or uncompressed format
|
|
88
|
+
* @returns Normalized uncompressed public key (65 bytes with 0x04 prefix)
|
|
89
|
+
* @throws {Error} When public key format is invalid, including raw coordinates (64 bytes)
|
|
90
|
+
* @throws {Error} When decompression of compressed key fails
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* // Compressed key (33 bytes)
|
|
95
|
+
* const compressed = new Uint8Array(33);
|
|
96
|
+
* compressed[0] = 0x02;
|
|
97
|
+
* const uncompressed = provider.normalizeToUncompressed(compressed);
|
|
98
|
+
* console.log(uncompressed.length); // 65
|
|
99
|
+
* console.log(uncompressed[0]); // 0x04
|
|
100
|
+
*
|
|
101
|
+
* // Already uncompressed (65 bytes)
|
|
102
|
+
* const already = provider.normalizeToUncompressed(uncompressedKey);
|
|
103
|
+
* console.log(already === uncompressedKey); // true (returns same reference)
|
|
104
|
+
*
|
|
105
|
+
* // Raw coordinates rejected (64 bytes)
|
|
106
|
+
* const raw = new Uint8Array(64);
|
|
107
|
+
* provider.normalizeToUncompressed(raw); // Throws error
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
normalizeToUncompressed(publicKey: Uint8Array): Uint8Array;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Configures ECIES operation behavior.
|
|
114
|
+
*/
|
|
115
|
+
interface ECIESOptions {
|
|
116
|
+
/** Use compressed public keys (33 bytes) instead of uncompressed (65 bytes) */
|
|
117
|
+
useCompressed?: boolean;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Represents failures in ECIES cryptographic operations.
|
|
121
|
+
*
|
|
122
|
+
* @remarks
|
|
123
|
+
* Provides specific error codes to help identify and recover from
|
|
124
|
+
* different failure scenarios.
|
|
125
|
+
*
|
|
126
|
+
* @category Errors
|
|
127
|
+
*/
|
|
128
|
+
declare class ECIESError extends Error {
|
|
129
|
+
readonly code: "INVALID_KEY" | "ENCRYPTION_FAILED" | "DECRYPTION_FAILED" | "MAC_MISMATCH" | "ECDH_FAILED";
|
|
130
|
+
readonly cause?: Error | undefined;
|
|
131
|
+
constructor(message: string, code: "INVALID_KEY" | "ENCRYPTION_FAILED" | "DECRYPTION_FAILED" | "MAC_MISMATCH" | "ECDH_FAILED", cause?: Error | undefined);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Validates if an object conforms to the ECIESEncrypted structure.
|
|
135
|
+
*
|
|
136
|
+
* @param obj - Object to validate.
|
|
137
|
+
* @returns `true` if object is a valid ECIESEncrypted structure.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```typescript
|
|
141
|
+
* if (isECIESEncrypted(data)) {
|
|
142
|
+
* const decrypted = await provider.decrypt(privateKey, data);
|
|
143
|
+
* }
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
declare function isECIESEncrypted(obj: unknown): obj is ECIESEncrypted;
|
|
147
|
+
/**
|
|
148
|
+
* Serializes ECIESEncrypted to hex string for storage or transmission.
|
|
149
|
+
*
|
|
150
|
+
* @param encrypted - Encrypted data structure from `encrypt()`.
|
|
151
|
+
* @returns Hex string representation.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* const hexString = serializeECIES(encrypted);
|
|
156
|
+
* // Store hexString in database or send over network
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
declare function serializeECIES(encrypted: ECIESEncrypted): string;
|
|
160
|
+
/**
|
|
161
|
+
* Deserializes hex string to ECIESEncrypted structure.
|
|
162
|
+
*
|
|
163
|
+
* @param hex - Hex string from `serializeECIES()` or storage.
|
|
164
|
+
* @returns ECIESEncrypted structure ready for decryption.
|
|
165
|
+
* @throws {ECIESError} When hex string format is invalid.
|
|
166
|
+
* Verify the hex string is complete and uncorrupted.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```typescript
|
|
170
|
+
* const encrypted = deserializeECIES(hexString);
|
|
171
|
+
* const decrypted = await provider.decrypt(privateKey, encrypted);
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
declare function deserializeECIES(hex: string): ECIESEncrypted;
|
|
175
|
+
|
|
176
|
+
export { type ECIESEncrypted, ECIESError, type ECIESOptions, type ECIESProvider, deserializeECIES, isECIESEncrypted, serializeECIES };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { CIPHER, CURVE, MAC, FORMAT } from "./constants";
|
|
2
|
+
class ECIESError extends Error {
|
|
3
|
+
constructor(message, code, cause) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.code = code;
|
|
6
|
+
this.cause = cause;
|
|
7
|
+
this.name = "ECIESError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function isECIESEncrypted(obj) {
|
|
11
|
+
if (!obj || typeof obj !== "object") return false;
|
|
12
|
+
const enc = obj;
|
|
13
|
+
const isUint8Array = (value) => {
|
|
14
|
+
return value instanceof Uint8Array || typeof Buffer !== "undefined" && Buffer.isBuffer(value);
|
|
15
|
+
};
|
|
16
|
+
return isUint8Array(enc.iv) && enc.iv.length === CIPHER.IV_LENGTH && isUint8Array(enc.ephemPublicKey) && (enc.ephemPublicKey.length === CURVE.UNCOMPRESSED_PUBLIC_KEY_LENGTH || enc.ephemPublicKey.length === CURVE.COMPRESSED_PUBLIC_KEY_LENGTH) && isUint8Array(enc.ciphertext) && enc.ciphertext.length > 0 && isUint8Array(enc.mac) && enc.mac.length === MAC.LENGTH;
|
|
17
|
+
}
|
|
18
|
+
function serializeECIES(encrypted) {
|
|
19
|
+
const combined = new Uint8Array(
|
|
20
|
+
encrypted.iv.length + encrypted.ephemPublicKey.length + encrypted.ciphertext.length + encrypted.mac.length
|
|
21
|
+
);
|
|
22
|
+
let offset = 0;
|
|
23
|
+
combined.set(encrypted.iv, offset);
|
|
24
|
+
offset += encrypted.iv.length;
|
|
25
|
+
combined.set(encrypted.ephemPublicKey, offset);
|
|
26
|
+
offset += encrypted.ephemPublicKey.length;
|
|
27
|
+
combined.set(encrypted.ciphertext, offset);
|
|
28
|
+
offset += encrypted.ciphertext.length;
|
|
29
|
+
combined.set(encrypted.mac, offset);
|
|
30
|
+
return Array.from(combined).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
31
|
+
}
|
|
32
|
+
function deserializeECIES(hex) {
|
|
33
|
+
const bytes = new Uint8Array(hex.length / 2);
|
|
34
|
+
for (let i = 0; i < hex.length; i += 2) {
|
|
35
|
+
bytes[i / 2] = parseInt(hex.substr(i, 2), 16);
|
|
36
|
+
}
|
|
37
|
+
const ephemKeySize = bytes[FORMAT.EPHEMERAL_KEY_OFFSET] === CURVE.PREFIX.UNCOMPRESSED ? CURVE.UNCOMPRESSED_PUBLIC_KEY_LENGTH : CURVE.COMPRESSED_PUBLIC_KEY_LENGTH;
|
|
38
|
+
const minLength = FORMAT.IV_LENGTH + ephemKeySize + MAC.LENGTH + 1;
|
|
39
|
+
if (bytes.length < minLength) {
|
|
40
|
+
throw new ECIESError("Invalid ECIES data: too short", "DECRYPTION_FAILED");
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
iv: bytes.subarray(FORMAT.IV_OFFSET, FORMAT.IV_OFFSET + FORMAT.IV_LENGTH),
|
|
44
|
+
ephemPublicKey: bytes.subarray(
|
|
45
|
+
FORMAT.EPHEMERAL_KEY_OFFSET,
|
|
46
|
+
FORMAT.EPHEMERAL_KEY_OFFSET + ephemKeySize
|
|
47
|
+
),
|
|
48
|
+
ciphertext: bytes.subarray(
|
|
49
|
+
FORMAT.EPHEMERAL_KEY_OFFSET + ephemKeySize,
|
|
50
|
+
bytes.length - MAC.LENGTH
|
|
51
|
+
),
|
|
52
|
+
mac: bytes.subarray(bytes.length - MAC.LENGTH)
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
ECIESError,
|
|
57
|
+
deserializeECIES,
|
|
58
|
+
isECIESEncrypted,
|
|
59
|
+
serializeECIES
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=interface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/crypto/ecies/interface.ts"],"sourcesContent":["/**\n * ECIES (Elliptic Curve Integrated Encryption Scheme) Interface\n *\n * @remarks\n * Defines the contract for platform-specific ECIES implementations.\n * All implementations maintain compatibility with the eccrypto format to ensure\n * backward compatibility with existing encrypted data.\n *\n * **Format specification:**\n * `[iv (16 bytes)][ephemPublicKey (65 bytes)][ciphertext (variable)][mac (32 bytes)]`\n *\n * @category Cryptography\n */\n\nimport { CIPHER, CURVE, MAC, FORMAT } from \"./constants\";\n\n/**\n * Represents ECIES encrypted data in eccrypto-compatible format.\n *\n * @remarks\n * This structure maintains backward compatibility with data encrypted using\n * the legacy eccrypto library.\n */\nexport interface ECIESEncrypted {\n /** Initialization vector (16 bytes) */\n iv: Uint8Array;\n /** Ephemeral public key (65 bytes uncompressed) */\n ephemPublicKey: Uint8Array;\n /** Encrypted data */\n ciphertext: Uint8Array;\n /** Message authentication code (32 bytes) */\n mac: Uint8Array;\n}\n\n/**\n * Provides ECIES encryption and decryption operations.\n *\n * @remarks\n * Platform-specific implementations handle the underlying cryptographic primitives\n * while maintaining consistent data format across environments.\n *\n * @category Cryptography\n */\nexport interface ECIESProvider {\n /**\n * Encrypts data using ECIES with secp256k1.\n *\n * @param publicKey - Recipient's public key (65 bytes uncompressed or 33 bytes compressed).\n * Obtain via `vana.server.getIdentity(userAddress).public_key`.\n * @param message - Data to encrypt.\n * @returns Encrypted data structure compatible with eccrypto format.\n * @throws {ECIESError} When public key is invalid.\n * Verify key format matches secp256k1 requirements.\n *\n * @example\n * ```typescript\n * const encrypted = await provider.encrypt(\n * hexToBytes(publicKey),\n * new TextEncoder().encode('sensitive data')\n * );\n * ```\n */\n encrypt(publicKey: Uint8Array, message: Uint8Array): Promise<ECIESEncrypted>;\n\n /**\n * Decrypts ECIES encrypted data.\n *\n * @param privateKey - Recipient's private key (32 bytes).\n * @param encrypted - Encrypted data structure from `encrypt()` or legacy eccrypto.\n * @returns Decrypted message as Uint8Array.\n * @throws {ECIESError} When MAC verification fails.\n * Ensure the private key matches the public key used for encryption.\n *\n * @example\n * ```typescript\n * const decrypted = await provider.decrypt(\n * hexToBytes(privateKey),\n * encrypted\n * );\n * const message = new TextDecoder().decode(decrypted);\n * ```\n */\n decrypt(\n privateKey: Uint8Array,\n encrypted: ECIESEncrypted,\n ): Promise<Uint8Array>;\n\n /**\n * Normalizes a public key to uncompressed format (65 bytes with 0x04 prefix).\n *\n * @remarks\n * Strict policy: Only accepts properly formatted compressed (33 bytes) or\n * uncompressed (65 bytes) public keys. Does not accept 64-byte raw coordinates\n * to ensure data integrity and prevent masking of malformed inputs.\n *\n * @param publicKey - Public key in compressed or uncompressed format\n * @returns Normalized uncompressed public key (65 bytes with 0x04 prefix)\n * @throws {Error} When public key format is invalid, including raw coordinates (64 bytes)\n * @throws {Error} When decompression of compressed key fails\n *\n * @example\n * ```typescript\n * // Compressed key (33 bytes)\n * const compressed = new Uint8Array(33);\n * compressed[0] = 0x02;\n * const uncompressed = provider.normalizeToUncompressed(compressed);\n * console.log(uncompressed.length); // 65\n * console.log(uncompressed[0]); // 0x04\n *\n * // Already uncompressed (65 bytes)\n * const already = provider.normalizeToUncompressed(uncompressedKey);\n * console.log(already === uncompressedKey); // true (returns same reference)\n *\n * // Raw coordinates rejected (64 bytes)\n * const raw = new Uint8Array(64);\n * provider.normalizeToUncompressed(raw); // Throws error\n * ```\n */\n normalizeToUncompressed(publicKey: Uint8Array): Uint8Array;\n}\n\n/**\n * Configures ECIES operation behavior.\n */\nexport interface ECIESOptions {\n /** Use compressed public keys (33 bytes) instead of uncompressed (65 bytes) */\n useCompressed?: boolean;\n}\n\n/**\n * Represents failures in ECIES cryptographic operations.\n *\n * @remarks\n * Provides specific error codes to help identify and recover from\n * different failure scenarios.\n *\n * @category Errors\n */\nexport class ECIESError extends Error {\n constructor(\n message: string,\n public readonly code:\n | \"INVALID_KEY\"\n | \"ENCRYPTION_FAILED\"\n | \"DECRYPTION_FAILED\"\n | \"MAC_MISMATCH\"\n | \"ECDH_FAILED\",\n public override readonly cause?: Error,\n ) {\n super(message);\n this.name = \"ECIESError\";\n }\n}\n\n/**\n * Validates if an object conforms to the ECIESEncrypted structure.\n *\n * @param obj - Object to validate.\n * @returns `true` if object is a valid ECIESEncrypted structure.\n *\n * @example\n * ```typescript\n * if (isECIESEncrypted(data)) {\n * const decrypted = await provider.decrypt(privateKey, data);\n * }\n * ```\n */\nexport function isECIESEncrypted(obj: unknown): obj is ECIESEncrypted {\n if (!obj || typeof obj !== \"object\") return false;\n const enc = obj as Record<string, unknown>;\n\n const isUint8Array = (value: unknown): value is Uint8Array => {\n return (\n value instanceof Uint8Array ||\n (typeof Buffer !== \"undefined\" && Buffer.isBuffer(value))\n );\n };\n\n return (\n isUint8Array(enc.iv) &&\n enc.iv.length === CIPHER.IV_LENGTH &&\n isUint8Array(enc.ephemPublicKey) &&\n (enc.ephemPublicKey.length === CURVE.UNCOMPRESSED_PUBLIC_KEY_LENGTH ||\n enc.ephemPublicKey.length === CURVE.COMPRESSED_PUBLIC_KEY_LENGTH) &&\n isUint8Array(enc.ciphertext) &&\n enc.ciphertext.length > 0 &&\n isUint8Array(enc.mac) &&\n enc.mac.length === MAC.LENGTH\n );\n}\n\n/**\n * Serializes ECIESEncrypted to hex string for storage or transmission.\n *\n * @param encrypted - Encrypted data structure from `encrypt()`.\n * @returns Hex string representation.\n *\n * @example\n * ```typescript\n * const hexString = serializeECIES(encrypted);\n * // Store hexString in database or send over network\n * ```\n */\nexport function serializeECIES(encrypted: ECIESEncrypted): string {\n const combined = new Uint8Array(\n encrypted.iv.length +\n encrypted.ephemPublicKey.length +\n encrypted.ciphertext.length +\n encrypted.mac.length,\n );\n\n let offset = 0;\n combined.set(encrypted.iv, offset);\n offset += encrypted.iv.length;\n combined.set(encrypted.ephemPublicKey, offset);\n offset += encrypted.ephemPublicKey.length;\n combined.set(encrypted.ciphertext, offset);\n offset += encrypted.ciphertext.length;\n combined.set(encrypted.mac, offset);\n\n return Array.from(combined)\n .map((b) => b.toString(16).padStart(2, \"0\"))\n .join(\"\");\n}\n\n/**\n * Deserializes hex string to ECIESEncrypted structure.\n *\n * @param hex - Hex string from `serializeECIES()` or storage.\n * @returns ECIESEncrypted structure ready for decryption.\n * @throws {ECIESError} When hex string format is invalid.\n * Verify the hex string is complete and uncorrupted.\n *\n * @example\n * ```typescript\n * const encrypted = deserializeECIES(hexString);\n * const decrypted = await provider.decrypt(privateKey, encrypted);\n * ```\n */\nexport function deserializeECIES(hex: string): ECIESEncrypted {\n const bytes = new Uint8Array(hex.length / 2);\n for (let i = 0; i < hex.length; i += 2) {\n bytes[i / 2] = parseInt(hex.substr(i, 2), 16);\n }\n\n // Determine ephemPublicKey size based on prefix\n const ephemKeySize =\n bytes[FORMAT.EPHEMERAL_KEY_OFFSET] === CURVE.PREFIX.UNCOMPRESSED\n ? CURVE.UNCOMPRESSED_PUBLIC_KEY_LENGTH\n : CURVE.COMPRESSED_PUBLIC_KEY_LENGTH;\n\n const minLength = FORMAT.IV_LENGTH + ephemKeySize + MAC.LENGTH + 1; // +1 for at least 1 byte of ciphertext\n if (bytes.length < minLength) {\n throw new ECIESError(\"Invalid ECIES data: too short\", \"DECRYPTION_FAILED\");\n }\n\n return {\n iv: bytes.subarray(FORMAT.IV_OFFSET, FORMAT.IV_OFFSET + FORMAT.IV_LENGTH),\n ephemPublicKey: bytes.subarray(\n FORMAT.EPHEMERAL_KEY_OFFSET,\n FORMAT.EPHEMERAL_KEY_OFFSET + ephemKeySize,\n ),\n ciphertext: bytes.subarray(\n FORMAT.EPHEMERAL_KEY_OFFSET + ephemKeySize,\n bytes.length - MAC.LENGTH,\n ),\n mac: bytes.subarray(bytes.length - MAC.LENGTH),\n };\n}\n"],"mappings":"AAcA,SAAS,QAAQ,OAAO,KAAK,cAAc;AA4HpC,MAAM,mBAAmB,MAAM;AAAA,EACpC,YACE,SACgB,MAMS,OACzB;AACA,UAAM,OAAO;AARG;AAMS;AAGzB,SAAK,OAAO;AAAA,EACd;AACF;AAeO,SAAS,iBAAiB,KAAqC;AACpE,MAAI,CAAC,OAAO,OAAO,QAAQ,SAAU,QAAO;AAC5C,QAAM,MAAM;AAEZ,QAAM,eAAe,CAAC,UAAwC;AAC5D,WACE,iBAAiB,cAChB,OAAO,WAAW,eAAe,OAAO,SAAS,KAAK;AAAA,EAE3D;AAEA,SACE,aAAa,IAAI,EAAE,KACnB,IAAI,GAAG,WAAW,OAAO,aACzB,aAAa,IAAI,cAAc,MAC9B,IAAI,eAAe,WAAW,MAAM,kCACnC,IAAI,eAAe,WAAW,MAAM,iCACtC,aAAa,IAAI,UAAU,KAC3B,IAAI,WAAW,SAAS,KACxB,aAAa,IAAI,GAAG,KACpB,IAAI,IAAI,WAAW,IAAI;AAE3B;AAcO,SAAS,eAAe,WAAmC;AAChE,QAAM,WAAW,IAAI;AAAA,IACnB,UAAU,GAAG,SACX,UAAU,eAAe,SACzB,UAAU,WAAW,SACrB,UAAU,IAAI;AAAA,EAClB;AAEA,MAAI,SAAS;AACb,WAAS,IAAI,UAAU,IAAI,MAAM;AACjC,YAAU,UAAU,GAAG;AACvB,WAAS,IAAI,UAAU,gBAAgB,MAAM;AAC7C,YAAU,UAAU,eAAe;AACnC,WAAS,IAAI,UAAU,YAAY,MAAM;AACzC,YAAU,UAAU,WAAW;AAC/B,WAAS,IAAI,UAAU,KAAK,MAAM;AAElC,SAAO,MAAM,KAAK,QAAQ,EACvB,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAC1C,KAAK,EAAE;AACZ;AAgBO,SAAS,iBAAiB,KAA6B;AAC5D,QAAM,QAAQ,IAAI,WAAW,IAAI,SAAS,CAAC;AAC3C,WAAS,IAAI,GAAG,IAAI,IAAI,QAAQ,KAAK,GAAG;AACtC,UAAM,IAAI,CAAC,IAAI,SAAS,IAAI,OAAO,GAAG,CAAC,GAAG,EAAE;AAAA,EAC9C;AAGA,QAAM,eACJ,MAAM,OAAO,oBAAoB,MAAM,MAAM,OAAO,eAChD,MAAM,iCACN,MAAM;AAEZ,QAAM,YAAY,OAAO,YAAY,eAAe,IAAI,SAAS;AACjE,MAAI,MAAM,SAAS,WAAW;AAC5B,UAAM,IAAI,WAAW,iCAAiC,mBAAmB;AAAA,EAC3E;AAEA,SAAO;AAAA,IACL,IAAI,MAAM,SAAS,OAAO,WAAW,OAAO,YAAY,OAAO,SAAS;AAAA,IACxE,gBAAgB,MAAM;AAAA,MACpB,OAAO;AAAA,MACP,OAAO,uBAAuB;AAAA,IAChC;AAAA,IACA,YAAY,MAAM;AAAA,MAChB,OAAO,uBAAuB;AAAA,MAC9B,MAAM,SAAS,IAAI;AAAA,IACrB;AAAA,IACA,KAAK,MAAM,SAAS,MAAM,SAAS,IAAI,MAAM;AAAA,EAC/C;AACF;","names":[]}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var node_exports = {};
|
|
30
|
+
__export(node_exports, {
|
|
31
|
+
NodeECIESUint8Provider: () => NodeECIESUint8Provider
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(node_exports);
|
|
34
|
+
var import_crypto = require("crypto");
|
|
35
|
+
var import_secp256k1 = __toESM(require("secp256k1"), 1);
|
|
36
|
+
var import_base = require("./base");
|
|
37
|
+
const secp256k1 = import_secp256k1.default;
|
|
38
|
+
class NodeECIESUint8Provider extends import_base.BaseECIESUint8 {
|
|
39
|
+
// Identity hash function for ECDH - returns raw X coordinate
|
|
40
|
+
// CRITICAL: Must handle (x, y, output) signature correctly
|
|
41
|
+
identityHashFn = (x, y, output) => {
|
|
42
|
+
if (output && output.length >= 32) {
|
|
43
|
+
output.set(x);
|
|
44
|
+
return output;
|
|
45
|
+
}
|
|
46
|
+
return x;
|
|
47
|
+
};
|
|
48
|
+
generateRandomBytes(length) {
|
|
49
|
+
return new Uint8Array((0, import_crypto.randomBytes)(length));
|
|
50
|
+
}
|
|
51
|
+
verifyPrivateKey(privateKey) {
|
|
52
|
+
return secp256k1.privateKeyVerify(Buffer.from(privateKey)) === true;
|
|
53
|
+
}
|
|
54
|
+
createPublicKey(privateKey, compressed) {
|
|
55
|
+
try {
|
|
56
|
+
return new Uint8Array(
|
|
57
|
+
secp256k1.publicKeyCreate(Buffer.from(privateKey), compressed)
|
|
58
|
+
);
|
|
59
|
+
} catch {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
validatePublicKey(publicKey) {
|
|
64
|
+
return secp256k1.publicKeyVerify(Buffer.from(publicKey)) === true;
|
|
65
|
+
}
|
|
66
|
+
decompressPublicKey(publicKey) {
|
|
67
|
+
try {
|
|
68
|
+
return new Uint8Array(
|
|
69
|
+
secp256k1.publicKeyConvert(Buffer.from(publicKey), false)
|
|
70
|
+
);
|
|
71
|
+
} catch {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
performECDH(publicKey, privateKey) {
|
|
76
|
+
try {
|
|
77
|
+
const output = Buffer.alloc(32);
|
|
78
|
+
secp256k1.ecdh(
|
|
79
|
+
Buffer.from(publicKey),
|
|
80
|
+
Buffer.from(privateKey),
|
|
81
|
+
{ hashfn: this.identityHashFn },
|
|
82
|
+
output
|
|
83
|
+
);
|
|
84
|
+
return new Uint8Array(output);
|
|
85
|
+
} catch (error) {
|
|
86
|
+
throw new Error(
|
|
87
|
+
`ECDH failed: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
sha512(data) {
|
|
92
|
+
return new Uint8Array(
|
|
93
|
+
(0, import_crypto.createHash)("sha512").update(Buffer.from(data)).digest()
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
hmacSha256(key, data) {
|
|
97
|
+
return new Uint8Array(
|
|
98
|
+
(0, import_crypto.createHmac)("sha256", Buffer.from(key)).update(Buffer.from(data)).digest()
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
async aesEncrypt(key, iv, plaintext) {
|
|
102
|
+
const cipher = (0, import_crypto.createCipheriv)(
|
|
103
|
+
"aes-256-cbc",
|
|
104
|
+
Buffer.from(key),
|
|
105
|
+
Buffer.from(iv)
|
|
106
|
+
);
|
|
107
|
+
const encrypted = Buffer.concat([
|
|
108
|
+
cipher.update(Buffer.from(plaintext)),
|
|
109
|
+
cipher.final()
|
|
110
|
+
]);
|
|
111
|
+
return new Uint8Array(encrypted);
|
|
112
|
+
}
|
|
113
|
+
async aesDecrypt(key, iv, ciphertext) {
|
|
114
|
+
const decipher = (0, import_crypto.createDecipheriv)(
|
|
115
|
+
"aes-256-cbc",
|
|
116
|
+
Buffer.from(key),
|
|
117
|
+
Buffer.from(iv)
|
|
118
|
+
);
|
|
119
|
+
const decrypted = Buffer.concat([
|
|
120
|
+
decipher.update(Buffer.from(ciphertext)),
|
|
121
|
+
decipher.final()
|
|
122
|
+
]);
|
|
123
|
+
return new Uint8Array(decrypted);
|
|
124
|
+
}
|
|
125
|
+
// No Buffer compatibility methods - Uint8Array only public API
|
|
126
|
+
/**
|
|
127
|
+
* Normalizes a public key to uncompressed format (65 bytes with 0x04 prefix).
|
|
128
|
+
* Handles compressed (33 bytes) and uncompressed (65 bytes) formats only.
|
|
129
|
+
*
|
|
130
|
+
* @remarks
|
|
131
|
+
* Strict policy: Does not accept 64-byte raw coordinates to avoid masking
|
|
132
|
+
* malformed data. Callers must provide properly formatted keys.
|
|
133
|
+
*
|
|
134
|
+
* @param publicKey - The public key to normalize (33 or 65 bytes)
|
|
135
|
+
* @returns The normalized uncompressed public key (65 bytes)
|
|
136
|
+
* @throws {Error} When public key format is invalid or decompression fails
|
|
137
|
+
*/
|
|
138
|
+
normalizeToUncompressed(publicKey) {
|
|
139
|
+
const len = publicKey.length;
|
|
140
|
+
if (len === 65 && publicKey[0] === 4) {
|
|
141
|
+
return publicKey;
|
|
142
|
+
}
|
|
143
|
+
if (len === 33 && (publicKey[0] === 2 || publicKey[0] === 3)) {
|
|
144
|
+
const decompressed = this.decompressPublicKey(publicKey);
|
|
145
|
+
if (!decompressed) {
|
|
146
|
+
throw new Error(
|
|
147
|
+
`Failed to decompress public key with prefix 0x${publicKey[0].toString(16).padStart(2, "0")}`
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
return decompressed;
|
|
151
|
+
}
|
|
152
|
+
if (len === 64) {
|
|
153
|
+
throw new Error(
|
|
154
|
+
"Raw public key coordinates (64 bytes) are not accepted. Please provide a properly formatted compressed (33 bytes) or uncompressed (65 bytes) public key."
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
throw new Error(
|
|
158
|
+
`Invalid public key format: expected compressed (33 bytes) or uncompressed (65 bytes), got ${len} bytes`
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
163
|
+
0 && (module.exports = {
|
|
164
|
+
NodeECIESUint8Provider
|
|
165
|
+
});
|
|
166
|
+
//# sourceMappingURL=node.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/crypto/ecies/node.ts"],"sourcesContent":["/**\n * Node.js implementation of ECIES using native secp256k1 for performance\n *\n * @remarks\n * Uses native secp256k1 bindings for all elliptic curve operations.\n * Uses Node.js crypto module for hashing and AES operations.\n * Provides Uint8Array-only interface with no Buffer exposure.\n */\n\nimport {\n randomBytes,\n createHash,\n createHmac,\n createCipheriv,\n createDecipheriv,\n} from \"crypto\";\nimport secp256k1Import from \"secp256k1\";\nimport { BaseECIESUint8 } from \"./base\";\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// Use the imported secp256k1 module\nconst secp256k1 = secp256k1Import as unknown as Secp256k1Module;\n\n/**\n * Node.js-specific ECIES provider using native secp256k1\n *\n * @remarks\n * This implementation:\n * - Uses native secp256k1 for all EC operations (optimal performance)\n * - Uses Node.js crypto for SHA-512, HMAC, and AES operations\n * - Internally works with Uint8Array\n * - Only uses Buffer at crypto API boundaries\n */\nexport class NodeECIESUint8Provider extends BaseECIESUint8 {\n // Identity hash function for ECDH - returns raw X coordinate\n // CRITICAL: Must handle (x, y, output) signature correctly\n private readonly identityHashFn = (\n x: Uint8Array,\n y: Uint8Array,\n output?: Uint8Array,\n ): Uint8Array => {\n // Copy x into output buffer if provided (prevents allocations)\n if (output && output.length >= 32) {\n output.set(x);\n return output;\n }\n return x;\n };\n protected generateRandomBytes(length: number): Uint8Array {\n return new Uint8Array(randomBytes(length));\n }\n\n protected verifyPrivateKey(privateKey: Uint8Array): boolean {\n // Native secp256k1 returns true for valid, false for invalid\n return secp256k1.privateKeyVerify(Buffer.from(privateKey)) === true;\n }\n\n protected createPublicKey(\n privateKey: Uint8Array,\n compressed: boolean,\n ): Uint8Array | null {\n try {\n return new Uint8Array(\n secp256k1.publicKeyCreate(Buffer.from(privateKey), compressed),\n );\n } catch {\n return null;\n }\n }\n\n protected validatePublicKey(publicKey: Uint8Array): boolean {\n // Native secp256k1 returns true for valid, false for invalid\n return secp256k1.publicKeyVerify(Buffer.from(publicKey)) === true;\n }\n\n protected decompressPublicKey(publicKey: Uint8Array): Uint8Array | null {\n try {\n // Convert to uncompressed format (65 bytes)\n return new Uint8Array(\n secp256k1.publicKeyConvert(Buffer.from(publicKey), false),\n );\n } catch {\n return null;\n }\n }\n\n protected performECDH(\n publicKey: Uint8Array,\n privateKey: Uint8Array,\n ): Uint8Array {\n try {\n // Use pre-allocated buffer for output (32 bytes)\n const output = Buffer.alloc(32);\n\n // CRITICAL: Use identity hash to get raw X coordinate\n // Default would apply SHA256 and break compatibility\n secp256k1.ecdh(\n Buffer.from(publicKey),\n Buffer.from(privateKey),\n { hashfn: this.identityHashFn },\n output,\n );\n\n return new Uint8Array(output);\n } catch (error) {\n throw new Error(\n `ECDH failed: ${error instanceof Error ? error.message : \"Unknown error\"}`,\n );\n }\n }\n\n protected sha512(data: Uint8Array): Uint8Array {\n // Use Node.js crypto for native performance\n return new Uint8Array(\n createHash(\"sha512\").update(Buffer.from(data)).digest(),\n );\n }\n\n protected hmacSha256(key: Uint8Array, data: Uint8Array): Uint8Array {\n // Use Node.js crypto for native performance\n return new Uint8Array(\n createHmac(\"sha256\", Buffer.from(key)).update(Buffer.from(data)).digest(),\n );\n }\n\n protected async aesEncrypt(\n key: Uint8Array,\n iv: Uint8Array,\n plaintext: Uint8Array,\n ): Promise<Uint8Array> {\n const cipher = createCipheriv(\n \"aes-256-cbc\",\n Buffer.from(key),\n Buffer.from(iv),\n );\n const encrypted = Buffer.concat([\n cipher.update(Buffer.from(plaintext)),\n cipher.final(),\n ]);\n return new Uint8Array(encrypted);\n }\n\n protected async aesDecrypt(\n key: Uint8Array,\n iv: Uint8Array,\n ciphertext: Uint8Array,\n ): Promise<Uint8Array> {\n const decipher = createDecipheriv(\n \"aes-256-cbc\",\n Buffer.from(key),\n Buffer.from(iv),\n );\n const decrypted = Buffer.concat([\n decipher.update(Buffer.from(ciphertext)),\n decipher.final(),\n ]);\n return new Uint8Array(decrypted);\n }\n\n // No Buffer compatibility methods - Uint8Array only public API\n\n /**\n * Normalizes a public key to uncompressed format (65 bytes with 0x04 prefix).\n * Handles compressed (33 bytes) and uncompressed (65 bytes) formats only.\n *\n * @remarks\n * Strict policy: Does not accept 64-byte raw coordinates to avoid masking\n * malformed data. Callers must provide properly formatted keys.\n *\n * @param publicKey - The public key to normalize (33 or 65 bytes)\n * @returns The normalized uncompressed public key (65 bytes)\n * @throws {Error} When public key format is invalid or decompression fails\n */\n normalizeToUncompressed(publicKey: Uint8Array): Uint8Array {\n const len = publicKey.length;\n\n // Already uncompressed\n if (len === 65 && publicKey[0] === 0x04) {\n return publicKey;\n }\n\n // Compressed - decompress using secp256k1\n if (len === 33 && (publicKey[0] === 0x02 || publicKey[0] === 0x03)) {\n const decompressed = this.decompressPublicKey(publicKey);\n if (!decompressed) {\n throw new Error(\n `Failed to decompress public key with prefix 0x${publicKey[0].toString(16).padStart(2, \"0\")}`,\n );\n }\n return decompressed;\n }\n\n // Reject raw coordinates (64 bytes) - require proper formatting\n if (len === 64) {\n throw new Error(\n \"Raw public key coordinates (64 bytes) are not accepted. \" +\n \"Please provide a properly formatted compressed (33 bytes) or uncompressed (65 bytes) public key.\",\n );\n }\n\n throw new Error(\n `Invalid public key format: expected compressed (33 bytes) or uncompressed (65 bytes), got ${len} bytes`,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,oBAMO;AACP,uBAA4B;AAC5B,kBAA+B;AAmB/B,MAAM,YAAY,iBAAAA;AAYX,MAAM,+BAA+B,2BAAe;AAAA;AAAA;AAAA,EAGxC,iBAAiB,CAChC,GACA,GACA,WACe;AAEf,QAAI,UAAU,OAAO,UAAU,IAAI;AACjC,aAAO,IAAI,CAAC;AACZ,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AAAA,EACU,oBAAoB,QAA4B;AACxD,WAAO,IAAI,eAAW,2BAAY,MAAM,CAAC;AAAA,EAC3C;AAAA,EAEU,iBAAiB,YAAiC;AAE1D,WAAO,UAAU,iBAAiB,OAAO,KAAK,UAAU,CAAC,MAAM;AAAA,EACjE;AAAA,EAEU,gBACR,YACA,YACmB;AACnB,QAAI;AACF,aAAO,IAAI;AAAA,QACT,UAAU,gBAAgB,OAAO,KAAK,UAAU,GAAG,UAAU;AAAA,MAC/D;AAAA,IACF,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AAAA,EAEU,kBAAkB,WAAgC;AAE1D,WAAO,UAAU,gBAAgB,OAAO,KAAK,SAAS,CAAC,MAAM;AAAA,EAC/D;AAAA,EAEU,oBAAoB,WAA0C;AACtE,QAAI;AAEF,aAAO,IAAI;AAAA,QACT,UAAU,iBAAiB,OAAO,KAAK,SAAS,GAAG,KAAK;AAAA,MAC1D;AAAA,IACF,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AAAA,EAEU,YACR,WACA,YACY;AACZ,QAAI;AAEF,YAAM,SAAS,OAAO,MAAM,EAAE;AAI9B,gBAAU;AAAA,QACR,OAAO,KAAK,SAAS;AAAA,QACrB,OAAO,KAAK,UAAU;AAAA,QACtB,EAAE,QAAQ,KAAK,eAAe;AAAA,QAC9B;AAAA,MACF;AAEA,aAAO,IAAI,WAAW,MAAM;AAAA,IAC9B,SAAS,OAAO;AACd,YAAM,IAAI;AAAA,QACR,gBAAgB,iBAAiB,QAAQ,MAAM,UAAU,eAAe;AAAA,MAC1E;AAAA,IACF;AAAA,EACF;AAAA,EAEU,OAAO,MAA8B;AAE7C,WAAO,IAAI;AAAA,UACT,0BAAW,QAAQ,EAAE,OAAO,OAAO,KAAK,IAAI,CAAC,EAAE,OAAO;AAAA,IACxD;AAAA,EACF;AAAA,EAEU,WAAW,KAAiB,MAA8B;AAElE,WAAO,IAAI;AAAA,UACT,0BAAW,UAAU,OAAO,KAAK,GAAG,CAAC,EAAE,OAAO,OAAO,KAAK,IAAI,CAAC,EAAE,OAAO;AAAA,IAC1E;AAAA,EACF;AAAA,EAEA,MAAgB,WACd,KACA,IACA,WACqB;AACrB,UAAM,aAAS;AAAA,MACb;AAAA,MACA,OAAO,KAAK,GAAG;AAAA,MACf,OAAO,KAAK,EAAE;AAAA,IAChB;AACA,UAAM,YAAY,OAAO,OAAO;AAAA,MAC9B,OAAO,OAAO,OAAO,KAAK,SAAS,CAAC;AAAA,MACpC,OAAO,MAAM;AAAA,IACf,CAAC;AACD,WAAO,IAAI,WAAW,SAAS;AAAA,EACjC;AAAA,EAEA,MAAgB,WACd,KACA,IACA,YACqB;AACrB,UAAM,eAAW;AAAA,MACf;AAAA,MACA,OAAO,KAAK,GAAG;AAAA,MACf,OAAO,KAAK,EAAE;AAAA,IAChB;AACA,UAAM,YAAY,OAAO,OAAO;AAAA,MAC9B,SAAS,OAAO,OAAO,KAAK,UAAU,CAAC;AAAA,MACvC,SAAS,MAAM;AAAA,IACjB,CAAC;AACD,WAAO,IAAI,WAAW,SAAS;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBA,wBAAwB,WAAmC;AACzD,UAAM,MAAM,UAAU;AAGtB,QAAI,QAAQ,MAAM,UAAU,CAAC,MAAM,GAAM;AACvC,aAAO;AAAA,IACT;AAGA,QAAI,QAAQ,OAAO,UAAU,CAAC,MAAM,KAAQ,UAAU,CAAC,MAAM,IAAO;AAClE,YAAM,eAAe,KAAK,oBAAoB,SAAS;AACvD,UAAI,CAAC,cAAc;AACjB,cAAM,IAAI;AAAA,UACR,iDAAiD,UAAU,CAAC,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC;AAAA,QAC7F;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAGA,QAAI,QAAQ,IAAI;AACd,YAAM,IAAI;AAAA,QACR;AAAA,MAEF;AAAA,IACF;AAEA,UAAM,IAAI;AAAA,MACR,6FAA6F,GAAG;AAAA,IAClG;AAAA,EACF;AACF;","names":["secp256k1Import"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { BaseECIESUint8 } from './base.cjs';
|
|
2
|
+
import './interface.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Node.js implementation of ECIES using native secp256k1 for performance
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Uses native secp256k1 bindings for all elliptic curve operations.
|
|
9
|
+
* Uses Node.js crypto module for hashing and AES operations.
|
|
10
|
+
* Provides Uint8Array-only interface with no Buffer exposure.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Node.js-specific ECIES provider using native secp256k1
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* This implementation:
|
|
18
|
+
* - Uses native secp256k1 for all EC operations (optimal performance)
|
|
19
|
+
* - Uses Node.js crypto for SHA-512, HMAC, and AES operations
|
|
20
|
+
* - Internally works with Uint8Array
|
|
21
|
+
* - Only uses Buffer at crypto API boundaries
|
|
22
|
+
*/
|
|
23
|
+
declare class NodeECIESUint8Provider extends BaseECIESUint8 {
|
|
24
|
+
private readonly identityHashFn;
|
|
25
|
+
protected generateRandomBytes(length: number): Uint8Array;
|
|
26
|
+
protected verifyPrivateKey(privateKey: Uint8Array): boolean;
|
|
27
|
+
protected createPublicKey(privateKey: Uint8Array, compressed: boolean): Uint8Array | null;
|
|
28
|
+
protected validatePublicKey(publicKey: Uint8Array): boolean;
|
|
29
|
+
protected decompressPublicKey(publicKey: Uint8Array): Uint8Array | null;
|
|
30
|
+
protected performECDH(publicKey: Uint8Array, privateKey: Uint8Array): Uint8Array;
|
|
31
|
+
protected sha512(data: Uint8Array): Uint8Array;
|
|
32
|
+
protected hmacSha256(key: Uint8Array, data: Uint8Array): Uint8Array;
|
|
33
|
+
protected aesEncrypt(key: Uint8Array, iv: Uint8Array, plaintext: Uint8Array): Promise<Uint8Array>;
|
|
34
|
+
protected aesDecrypt(key: Uint8Array, iv: Uint8Array, ciphertext: Uint8Array): Promise<Uint8Array>;
|
|
35
|
+
/**
|
|
36
|
+
* Normalizes a public key to uncompressed format (65 bytes with 0x04 prefix).
|
|
37
|
+
* Handles compressed (33 bytes) and uncompressed (65 bytes) formats only.
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* Strict policy: Does not accept 64-byte raw coordinates to avoid masking
|
|
41
|
+
* malformed data. Callers must provide properly formatted keys.
|
|
42
|
+
*
|
|
43
|
+
* @param publicKey - The public key to normalize (33 or 65 bytes)
|
|
44
|
+
* @returns The normalized uncompressed public key (65 bytes)
|
|
45
|
+
* @throws {Error} When public key format is invalid or decompression fails
|
|
46
|
+
*/
|
|
47
|
+
normalizeToUncompressed(publicKey: Uint8Array): Uint8Array;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { NodeECIESUint8Provider };
|