ssh.d.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334
  1. import { IClient, IPaginator, PaginateArgs, PaginatorState, ResourceClientCreate, ResourceClientDelete, ResourceClientLoad, ResourceClientPaginate, Response, SSHKey } from '../definitions';
  2. import { ResourceClient } from './http';
  3. export declare const ERROR_SSH_MISSING_PRIVKEY = "SSH_MISSING_PRIVKEY";
  4. export declare const ERROR_SSH_INVALID_PUBKEY = "SSH_INVALID_PUBKEY";
  5. export declare const ERROR_SSH_INVALID_PRIVKEY = "SSH_INVALID_PRIVKEY";
  6. export declare function getGeneratedPrivateKeyPath(userId?: number): Promise<string>;
  7. export declare function parsePublicKeyFile(pubkeyPath: string): Promise<[string, string, string, string]>;
  8. /**
  9. * @return [full pubkey, algorithm, public numbers, annotation]
  10. */
  11. export declare function parsePublicKey(pubkey: string): [string, string, string, string];
  12. export declare function validatePrivateKey(keyPath: string): Promise<void>;
  13. export interface SSHKeyClientDeps {
  14. readonly client: IClient;
  15. readonly token: string;
  16. readonly user: {
  17. id: number;
  18. };
  19. }
  20. export interface SSHKeyCreateDetails {
  21. pubkey: string;
  22. }
  23. export declare class SSHKeyClient extends ResourceClient implements ResourceClientLoad<SSHKey>, ResourceClientDelete, ResourceClientCreate<SSHKey, SSHKeyCreateDetails>, ResourceClientPaginate<SSHKey> {
  24. protected client: IClient;
  25. protected token: string;
  26. protected user: {
  27. id: number;
  28. };
  29. constructor({ client, token, user }: SSHKeyClientDeps);
  30. create({ pubkey }: SSHKeyCreateDetails): Promise<SSHKey>;
  31. load(id: string): Promise<SSHKey>;
  32. delete(id: string): Promise<void>;
  33. paginate(args?: Partial<PaginateArgs<Response<SSHKey[]>>>): IPaginator<Response<SSHKey[]>, PaginatorState>;
  34. }