@phala/dstack-sdk
Version:
dstack SDK
121 lines • 4.11 kB
TypeScript
export { getComposeHash } from './get-compose-hash';
export { verifyEnvEncryptPublicKey } from './verify-env-encrypt-public-key';
export interface GetTlsKeyResponse {
__name__: Readonly<'GetTlsKeyResponse'>;
key: string;
certificate_chain: string[];
asUint8Array: (max_length?: number) => Uint8Array;
}
export interface GetKeyResponse {
__name__: Readonly<'GetKeyResponse'>;
key: Uint8Array;
signature_chain: Uint8Array[];
}
export type Hex = `${string}`;
export type TdxQuoteHashAlgorithms = 'sha256' | 'sha384' | 'sha512' | 'sha3-256' | 'sha3-384' | 'sha3-512' | 'keccak256' | 'keccak384' | 'keccak512' | 'raw';
export interface EventLog {
imr: number;
event_type: number;
digest: string;
event: string;
event_payload: string;
}
export interface TcbInfo {
mrtd: string;
rtmr0: string;
rtmr1: string;
rtmr2: string;
rtmr3: string;
app_compose: string;
event_log: EventLog[];
}
export type TcbInfoV03x = TcbInfo & {
rootfs_hash?: string;
};
export type TcbInfoV05x = TcbInfo & {
mr_aggregated: string;
os_image_hash: string;
compose_hash: string;
device_id: string;
};
export interface InfoResponse<VersionTcbInfo extends TcbInfo> {
app_id: string;
instance_id: string;
app_cert: string;
tcb_info: VersionTcbInfo;
app_name: string;
device_id: string;
mr_aggregated?: string;
os_image_hash?: string;
key_provider_info: string;
compose_hash: string;
vm_config?: string;
}
export interface GetQuoteResponse {
quote: Hex;
event_log: string;
report_data?: Hex;
vm_config?: string;
replayRtmrs: () => string[];
}
export declare function to_hex(data: string | Buffer | Uint8Array): string;
export interface TlsKeyOptions {
path?: string;
subject?: string;
altNames?: string[];
usageRaTls?: boolean;
usageServerAuth?: boolean;
usageClientAuth?: boolean;
}
export declare class DstackClient<T extends TcbInfo = TcbInfoV05x> {
protected endpoint: string;
constructor(endpoint?: string | undefined);
getKey(path: string, purpose?: string): Promise<GetKeyResponse>;
getTlsKey(options?: TlsKeyOptions): Promise<GetTlsKeyResponse>;
getQuote(report_data: string | Buffer | Uint8Array): Promise<GetQuoteResponse>;
info(): Promise<InfoResponse<T>>;
isReachable(): Promise<boolean>;
/**
* Emit an event. This extends the event to RTMR3 on TDX platform.
*
* Requires dstack OS 0.5.0 or later.
*
* @param event The event name
* @param payload The event data as string or Buffer or Uint8Array
*/
emitEvent(event: string, payload: string | Buffer | Uint8Array): Promise<void>;
/**
* @deprecated Use getKey instead.
* @param path The path to the key.
* @param subject The subject of the key.
* @param altNames The alternative names of the key.
* @returns The key.
*/
deriveKey(path?: string, subject?: string, altNames?: string[]): Promise<GetTlsKeyResponse>;
/**
* @deprecated Use getQuote instead.
* @param report_data The report data.
* @param hash_algorithm The hash algorithm.
* @returns The quote.
*/
tdxQuote(report_data: string | Buffer | Uint8Array, hash_algorithm?: TdxQuoteHashAlgorithms): Promise<GetQuoteResponse>;
}
export declare class TappdClient extends DstackClient<TcbInfoV03x> {
constructor(endpoint?: string | undefined);
/**
* @deprecated Use getKey instead.
* @param path The path to the key.
* @param subject The subject of the key.
* @param altNames The alternative names of the key.
* @returns The key.
*/
deriveKey(path?: string, subject?: string, alt_names?: string[]): Promise<GetTlsKeyResponse>;
/**
* @deprecated Use getQuote instead.
* @param report_data The report data.
* @param hash_algorithm The hash algorithm.
* @returns The quote.
*/
tdxQuote(report_data: string | Buffer | Uint8Array, hash_algorithm?: TdxQuoteHashAlgorithms): Promise<GetQuoteResponse>;
}
//# sourceMappingURL=index.d.ts.map