
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
@phala/dstack-sdk
Advanced tools
This SDK provides a JavaScript/TypeScript client for communicating with the dstack server, which available inside dstack.
npm install @phala/dstack-sdk
import { DstackClient } from '@phala/dstack-sdk';
const client = new DstackClient();
// Causion: You don't need to do this most of the time.
const httpClient = new DstackClient('http://localhost:8000');
// Get the information of the Base Image.
await client.info();
// Derive a key with optional path and subject
const keyResult = await client.getKey('<unique-id>');
console.log(keyResult.key); // X.509 private key in PEM format
console.log(keyResult.signature_chain); // Certificate chain
const keyBytes = keyResult.key; // Get key as Uint8Array
// Generate TDX quote
const quoteResult = await client.getQuote('some-data');
console.log(quoteResult.quote); // TDX quote in hex format
console.log(quoteResult.event_log); // Event log
const rtmrs = quoteResult.replayRtmrs(); // Replay RTMRs
The SDK provides integration with viem for Ethereum account management:
import { toViemAccount } from '@phala/dstack-sdk/viem';
const keyResult = await client.getKey('<unique-id>');
const account = toViemAccount(keyResult);
// Use the account with viem operations
The SDK provides integration with Solana Web3.js for Solana account management:
import { toKeypair } from '@phala/dstack-sdk/solana';
const keyResult = await client.getKey('<unique-id>');
const keypair = toKeypair(keyResult);
// Use the keypair with Solana Web3.js operations
The SDK includes utilities for encrypting environment variables using X25519 key exchange and AES-GCM. This feature is handy for interacting with the bare dstack-vmm API or the Phala Cloud API.
import { encryptEnvVars, type EnvVar } from '@phala/dstack-sdk/encrypt-env-vars';
const envVars: EnvVar[] = [
{ key: 'API_KEY', value: 'secret123' },
{ key: 'DATABASE_URL', value: 'postgresql://...' }
];
const publicKeyHex = '0x...'; // You need get that from dstack-vmm API or Phala Cloud API.
const encrypted = await encryptEnvVars(envVars, publicKeyHex);
// encrypted is a hex string containing: ephemeral public key + iv + encrypted data
For local development without TDX devices, you can use the simulator under sdk/simulator
.
Run the simulator with:
git clone https://github.com/Dstack-TEE/dstack.git
cd dstack/sdk/simulator
./build.sh
./dstack-simulator
new DstackClient(endpoint?: string)
endpoint
: Unix socket path or HTTP(S) URL. Defaults to '/var/run/dstack.sock'.DSTACK_SIMULATOR_ENDPOINT
environment variable if setNOTE: Leave it empty in production. You only need to add volumes
in your docker-compose file:
volumes:
- /var/run/dstack.sock:/var/run/dstack.sock
info(): Promise<InfoResponse>
Retrieves information about the CVM instance.
getKey(path: string, purpose?: string): Promise<GetKeyResponse>
Derives a key for the given path and purpose.
path
: Path for key derivationpurpose
: Optional purpose for key derivationGetKeyResponse
containing key and signature chaingetQuote(reportData: string | Buffer | Uint8Array): Promise<GetQuoteResponse>
Generates a TDX quote with given report data.
reportData
: Data to include in the quoteGetQuoteResponse
containing quote and event loggetTlsKey(options: TlsKeyOptions): Promise<GetTlsKeyResponse>
Derives a TLS key for the given options.
options
: Options for TLS key derivation
subject
: Optional subject namealtNames
: Optional alternative names for the certificateusageRaTls
: Optional flag to enable RA-TLS usageusageServerAuth
: Optional flag to enable server authenticationusageClientAuth
: Optional flag to enable client authenticationGetTlsKeyResponse
containing key and certificate chainApache License
FAQs
dstack SDK
The npm package @phala/dstack-sdk receives a total of 4,971 weekly downloads. As such, @phala/dstack-sdk popularity was classified as popular.
We found that @phala/dstack-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.