@phala/cloud 0.2.2 → 0.2.4

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.
@@ -0,0 +1,101 @@
1
+ import { z } from "zod";
2
+ import type { Client, SafeResult } from "../../client";
3
+ import type { ApiVersion } from "../../types/client";
4
+ export declare const SshKeySchema: z.ZodObject<{
5
+ id: z.ZodString;
6
+ user_id: z.ZodString;
7
+ name: z.ZodString;
8
+ public_key: z.ZodString;
9
+ fingerprint: z.ZodString;
10
+ key_type: z.ZodString;
11
+ source: z.ZodString;
12
+ key_metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
13
+ last_synced_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
14
+ created_at: z.ZodString;
15
+ updated_at: z.ZodString;
16
+ }, "strip", z.ZodTypeAny, {
17
+ name: string;
18
+ id: string;
19
+ source: string;
20
+ updated_at: string;
21
+ created_at: string;
22
+ user_id: string;
23
+ public_key: string;
24
+ fingerprint: string;
25
+ key_type: string;
26
+ key_metadata?: Record<string, unknown> | null | undefined;
27
+ last_synced_at?: string | null | undefined;
28
+ }, {
29
+ name: string;
30
+ id: string;
31
+ source: string;
32
+ updated_at: string;
33
+ created_at: string;
34
+ user_id: string;
35
+ public_key: string;
36
+ fingerprint: string;
37
+ key_type: string;
38
+ key_metadata?: Record<string, unknown> | null | undefined;
39
+ last_synced_at?: string | null | undefined;
40
+ }>;
41
+ export type SshKey = z.infer<typeof SshKeySchema>;
42
+ export declare const ListSshKeysResponseSchema: z.ZodArray<z.ZodObject<{
43
+ id: z.ZodString;
44
+ user_id: z.ZodString;
45
+ name: z.ZodString;
46
+ public_key: z.ZodString;
47
+ fingerprint: z.ZodString;
48
+ key_type: z.ZodString;
49
+ source: z.ZodString;
50
+ key_metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
51
+ last_synced_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
52
+ created_at: z.ZodString;
53
+ updated_at: z.ZodString;
54
+ }, "strip", z.ZodTypeAny, {
55
+ name: string;
56
+ id: string;
57
+ source: string;
58
+ updated_at: string;
59
+ created_at: string;
60
+ user_id: string;
61
+ public_key: string;
62
+ fingerprint: string;
63
+ key_type: string;
64
+ key_metadata?: Record<string, unknown> | null | undefined;
65
+ last_synced_at?: string | null | undefined;
66
+ }, {
67
+ name: string;
68
+ id: string;
69
+ source: string;
70
+ updated_at: string;
71
+ created_at: string;
72
+ user_id: string;
73
+ public_key: string;
74
+ fingerprint: string;
75
+ key_type: string;
76
+ key_metadata?: Record<string, unknown> | null | undefined;
77
+ last_synced_at?: string | null | undefined;
78
+ }>, "many">;
79
+ export type ListSshKeysResponse = z.infer<typeof ListSshKeysResponseSchema>;
80
+ /**
81
+ * List SSH keys for the current user
82
+ *
83
+ * Returns all active (non-revoked) SSH keys belonging to the authenticated user,
84
+ * ordered by creation date descending.
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * import { createClient, listSshKeys } from '@phala/cloud'
89
+ *
90
+ * const client = createClient({ apiKey: 'your-api-key' })
91
+ * const keys = await listSshKeys(client)
92
+ * for (const key of keys) {
93
+ * console.log(key.name, key.key_type, key.fingerprint)
94
+ * }
95
+ * ```
96
+ */
97
+ export declare function listSshKeys(client: Client<ApiVersion>): Promise<ListSshKeysResponse>;
98
+ /**
99
+ * Safe version of listSshKeys that returns a SafeResult instead of throwing
100
+ */
101
+ export declare function safeListSshKeys(client: Client<ApiVersion>): Promise<SafeResult<ListSshKeysResponse>>;
@@ -0,0 +1,78 @@
1
+ import { z } from "zod";
2
+ export declare const SyncGithubSshKeysResponseSchema: z.ZodObject<{
3
+ synced_count: z.ZodNumber;
4
+ keys_added: z.ZodNumber;
5
+ keys_updated: z.ZodNumber;
6
+ keys_removed: z.ZodNumber;
7
+ errors: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ errors: string[];
10
+ keys_added: number;
11
+ synced_count: number;
12
+ keys_updated: number;
13
+ keys_removed: number;
14
+ }, {
15
+ keys_added: number;
16
+ synced_count: number;
17
+ keys_updated: number;
18
+ keys_removed: number;
19
+ errors?: string[] | undefined;
20
+ }>;
21
+ export type SyncGithubSshKeysResponse = z.infer<typeof SyncGithubSshKeysResponseSchema>;
22
+ /**
23
+ * Sync SSH keys from the user's linked GitHub account
24
+ *
25
+ * Fetches SSH keys from the authenticated user's linked GitHub account and
26
+ * synchronises them. New keys are added, existing keys are updated, and
27
+ * keys removed from GitHub are revoked locally.
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * import { createClient, syncGithubSshKeys } from '@phala/cloud'
32
+ *
33
+ * const client = createClient({ apiKey: 'your-api-key' })
34
+ * const result = await syncGithubSshKeys(client)
35
+ * console.log(`Added: ${result.keys_added}, Removed: ${result.keys_removed}`)
36
+ * ```
37
+ *
38
+ * ## Safe Version
39
+ *
40
+ * ```typescript
41
+ * const result = await safeSyncGithubSshKeys(client)
42
+ * if (result.success) {
43
+ * console.log('Synced', result.data.synced_count, 'key(s)')
44
+ * } else {
45
+ * console.error(result.error.message)
46
+ * }
47
+ * ```
48
+ */
49
+ declare const syncGithubSshKeys: {
50
+ (client: import("../..").BaseClient<import("../..").ApiVersion>, parameters: {
51
+ schema: false;
52
+ }): Promise<unknown>;
53
+ <T extends z.ZodTypeAny>(client: import("../..").BaseClient<import("../..").ApiVersion>, parameters: {
54
+ schema: T;
55
+ }): Promise<z.TypeOf<T>>;
56
+ (client: import("../..").BaseClient<import("../..").ApiVersion>): Promise<{
57
+ errors: string[];
58
+ keys_added: number;
59
+ synced_count: number;
60
+ keys_updated: number;
61
+ keys_removed: number;
62
+ }>;
63
+ }, safeSyncGithubSshKeys: {
64
+ (client: import("../..").BaseClient<import("../..").ApiVersion>, parameters: {
65
+ schema: false;
66
+ }): Promise<import("../..").SafeResult<unknown>>;
67
+ <T extends z.ZodTypeAny>(client: import("../..").BaseClient<import("../..").ApiVersion>, parameters: {
68
+ schema: T;
69
+ }): Promise<import("../..").SafeResult<z.TypeOf<T>>>;
70
+ (client: import("../..").BaseClient<import("../..").ApiVersion>): Promise<import("../..").SafeResult<{
71
+ errors: string[];
72
+ keys_added: number;
73
+ synced_count: number;
74
+ keys_updated: number;
75
+ keys_removed: number;
76
+ }>>;
77
+ };
78
+ export { syncGithubSshKeys, safeSyncGithubSshKeys };
@@ -35,6 +35,12 @@ import { type UpdateCvmVisibilityRequest } from "./actions/cvms/update_cvm_visib
35
35
  import { type GetAvailableOSImagesRequest, type GetAvailableOSImagesResponse } from "./actions/cvms/get_available_os_images";
36
36
  import { type UpdateOsImageRequest } from "./actions/cvms/update_os_image";
37
37
  import { type GetCvmStateRequest, type CvmState } from "./actions/cvms/get_cvm_state";
38
+ import { type ListSshKeysResponse } from "./actions/ssh_keys/list_ssh_keys";
39
+ import { type ImportGithubProfileRequest, type ImportGithubProfileResponse } from "./actions/ssh_keys/import_github_profile";
40
+ import { type CreateSshKeyRequest } from "./actions/ssh_keys/create_ssh_key";
41
+ import { type DeleteSshKeyRequest } from "./actions/ssh_keys/delete_ssh_key";
42
+ import { type SyncGithubSshKeysResponse } from "./actions/ssh_keys/sync_github_ssh_keys";
43
+ import type { SshKey } from "./actions/ssh_keys/list_ssh_keys";
38
44
  import type { KmsInfo } from "./types/kms_info";
39
45
  import type { VM } from "./types/cvm_info";
40
46
  import type { SafeResult } from "./types/client";
@@ -570,4 +576,74 @@ export interface Client<V extends ApiVersion = DefaultApiVersion> extends BaseCl
570
576
  safeGetCvmState(request: GetCvmStateRequest, parameters: {
571
577
  schema: false;
572
578
  }): Promise<SafeResult<unknown>>;
579
+ listSshKeys(): Promise<ListSshKeysResponse>;
580
+ listSshKeys<T extends z.ZodTypeAny>(parameters: {
581
+ schema: T;
582
+ }): Promise<z.infer<T>>;
583
+ listSshKeys(parameters: {
584
+ schema: false;
585
+ }): Promise<unknown>;
586
+ safeListSshKeys(): Promise<SafeResult<ListSshKeysResponse>>;
587
+ safeListSshKeys<T extends z.ZodTypeAny>(parameters: {
588
+ schema: T;
589
+ }): Promise<SafeResult<z.infer<T>>>;
590
+ safeListSshKeys(parameters: {
591
+ schema: false;
592
+ }): Promise<SafeResult<unknown>>;
593
+ importGithubProfileSshKeys(request: ImportGithubProfileRequest): Promise<ImportGithubProfileResponse>;
594
+ importGithubProfileSshKeys<T extends z.ZodTypeAny>(request: ImportGithubProfileRequest, parameters: {
595
+ schema: T;
596
+ }): Promise<z.infer<T>>;
597
+ importGithubProfileSshKeys(request: ImportGithubProfileRequest, parameters: {
598
+ schema: false;
599
+ }): Promise<unknown>;
600
+ safeImportGithubProfileSshKeys(request: ImportGithubProfileRequest): Promise<SafeResult<ImportGithubProfileResponse>>;
601
+ safeImportGithubProfileSshKeys<T extends z.ZodTypeAny>(request: ImportGithubProfileRequest, parameters: {
602
+ schema: T;
603
+ }): Promise<SafeResult<z.infer<T>>>;
604
+ safeImportGithubProfileSshKeys(request: ImportGithubProfileRequest, parameters: {
605
+ schema: false;
606
+ }): Promise<SafeResult<unknown>>;
607
+ createSshKey(request: CreateSshKeyRequest): Promise<SshKey>;
608
+ createSshKey<T extends z.ZodTypeAny>(request: CreateSshKeyRequest, parameters: {
609
+ schema: T;
610
+ }): Promise<z.infer<T>>;
611
+ createSshKey(request: CreateSshKeyRequest, parameters: {
612
+ schema: false;
613
+ }): Promise<unknown>;
614
+ safeCreateSshKey(request: CreateSshKeyRequest): Promise<SafeResult<SshKey>>;
615
+ safeCreateSshKey<T extends z.ZodTypeAny>(request: CreateSshKeyRequest, parameters: {
616
+ schema: T;
617
+ }): Promise<SafeResult<z.infer<T>>>;
618
+ safeCreateSshKey(request: CreateSshKeyRequest, parameters: {
619
+ schema: false;
620
+ }): Promise<SafeResult<unknown>>;
621
+ deleteSshKey(request: DeleteSshKeyRequest): Promise<void>;
622
+ deleteSshKey<T extends z.ZodTypeAny>(request: DeleteSshKeyRequest, parameters: {
623
+ schema: T;
624
+ }): Promise<z.infer<T>>;
625
+ deleteSshKey(request: DeleteSshKeyRequest, parameters: {
626
+ schema: false;
627
+ }): Promise<unknown>;
628
+ safeDeleteSshKey(request: DeleteSshKeyRequest): Promise<SafeResult<void>>;
629
+ safeDeleteSshKey<T extends z.ZodTypeAny>(request: DeleteSshKeyRequest, parameters: {
630
+ schema: T;
631
+ }): Promise<SafeResult<z.infer<T>>>;
632
+ safeDeleteSshKey(request: DeleteSshKeyRequest, parameters: {
633
+ schema: false;
634
+ }): Promise<SafeResult<unknown>>;
635
+ syncGithubSshKeys(): Promise<SyncGithubSshKeysResponse>;
636
+ syncGithubSshKeys<T extends z.ZodTypeAny>(parameters: {
637
+ schema: T;
638
+ }): Promise<z.infer<T>>;
639
+ syncGithubSshKeys(parameters: {
640
+ schema: false;
641
+ }): Promise<unknown>;
642
+ safeSyncGithubSshKeys(): Promise<SafeResult<SyncGithubSshKeysResponse>>;
643
+ safeSyncGithubSshKeys<T extends z.ZodTypeAny>(parameters: {
644
+ schema: T;
645
+ }): Promise<SafeResult<z.infer<T>>>;
646
+ safeSyncGithubSshKeys(parameters: {
647
+ schema: false;
648
+ }): Promise<SafeResult<unknown>>;
573
649
  }