keyvault-api-sdk
Version:
Official SDK for KeyVault - Secure API key management with user-specific encryption and team support
109 lines • 3.34 kB
TypeScript
interface ServiceKeyBuilder {
key(keyName: string): Promise<string>;
}
interface TeamContext {
service(serviceName: string): ServiceKeyBuilder;
endpoint(endpointName: string): Promise<string>;
}
export declare class KeyVaultSDK {
private apiUrl;
private apiToken?;
private cache;
private defaultTTL;
private userPrivateKey?;
private currentTeam?;
private config?;
constructor(config?: {
apiUrl?: string;
apiToken?: string;
ttl?: number;
});
/**
* Load configuration from ~/.keyvault/config.json (like CLI does)
* Sets up user private key and authentication automatically
*/
configfile(): Promise<void>;
/**
* Get or generate user's private key for client-side encryption
*/
private getUserPrivateKey;
/**
* Save current config back to file
*/
private saveConfig;
/**
* Client-side encryption using user's private key
*/
private encryptValue;
/**
* Client-side decryption using user's private key
*/
private decryptValue;
/**
* Switch team context for subsequent operations
*/
team(teamName: string): TeamContext;
/**
* Direct service access (uses current team context if set)
*/
service(serviceName: string): ServiceKeyBuilder;
/**
* Get key from team context by service and key name
*/
private getTeamServiceKey;
/**
* Get team endpoint by name
*/
private getTeamEndpoint;
getKey(keyId: string, useCache?: boolean): Promise<string>;
getKeyByService(service: string, name?: string, useCache?: boolean): Promise<string>;
createKey(keyData: {
name: string;
service: string;
value: string;
metadata?: Record<string, any>;
rotationSchedule?: string;
teamId?: string;
}): Promise<{
id: string;
name: string;
service: string;
maskedValue: string;
}>;
updateKey(keyId: string, updates: {
name?: string;
service?: string;
value?: string;
metadata?: Record<string, any>;
rotationSchedule?: string;
}): Promise<void>;
deleteKey(keyId: string): Promise<void>;
listKeys(): Promise<Array<{
id: string;
name: string;
service: string;
maskedValue: string;
lastUsed?: string;
createdAt: string;
}>>;
/**
* Get endpoint URL (supports current team context)
*/
endpoint(endpointName: string): Promise<string>;
/**
* Get personal endpoint by name
*/
private getPersonalEndpoint;
clearCache(): void;
getCacheSize(): number;
}
export declare const createKeyVaultFromEnv: () => KeyVaultSDK;
export declare const createKeyVaultFromConfig: () => Promise<KeyVaultSDK>;
export declare const getAPIKey: (keyId: string) => Promise<string>;
export declare const getAPIKeyByService: (service: string, name?: string) => Promise<string>;
export declare const getStripeKey: (type?: "live" | "test") => Promise<string>;
export declare const getOpenAIKey: () => Promise<string>;
export declare const getAWSKey: (type?: "access" | "secret") => Promise<string>;
export declare const getGitHubToken: () => Promise<string>;
export default KeyVaultSDK;
//# sourceMappingURL=index.d.ts.map