@phala/cloud 0.2.3 → 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.
- package/dist/actions/cvms/get_cvm_user_config.d.ts +92 -0
- package/dist/actions/index.d.ts +6 -0
- package/dist/actions/ssh_keys/create_ssh_key.d.ts +104 -0
- package/dist/actions/ssh_keys/delete_ssh_key.d.ts +65 -0
- package/dist/actions/ssh_keys/import_github_profile.d.ts +93 -0
- package/dist/actions/ssh_keys/list_ssh_keys.d.ts +101 -0
- package/dist/actions/ssh_keys/sync_github_ssh_keys.d.ts +78 -0
- package/dist/create-client.d.ts +76 -0
- package/dist/index.js +403 -243
- package/dist/index.mjs +382 -243
- package/package.json +1 -1
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type CvmIdInput } from "../../types/cvm_id";
|
|
3
|
+
export declare const CvmUserConfigSchema: z.ZodObject<{
|
|
4
|
+
hostname: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
5
|
+
ssh_authorized_keys: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
6
|
+
default_gateway_domain: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
ssh_authorized_keys: string[];
|
|
9
|
+
hostname?: string | null | undefined;
|
|
10
|
+
default_gateway_domain?: string | null | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
hostname?: string | null | undefined;
|
|
13
|
+
ssh_authorized_keys?: string[] | undefined;
|
|
14
|
+
default_gateway_domain?: string | null | undefined;
|
|
15
|
+
}>;
|
|
16
|
+
export type CvmUserConfig = z.infer<typeof CvmUserConfigSchema>;
|
|
17
|
+
export declare const GetCvmUserConfigRequestSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
18
|
+
id: z.ZodOptional<z.ZodString>;
|
|
19
|
+
uuid: z.ZodOptional<z.ZodString>;
|
|
20
|
+
app_id: z.ZodOptional<z.ZodString>;
|
|
21
|
+
instance_id: z.ZodOptional<z.ZodString>;
|
|
22
|
+
name: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
name?: string | undefined;
|
|
25
|
+
id?: string | undefined;
|
|
26
|
+
app_id?: string | undefined;
|
|
27
|
+
instance_id?: string | undefined;
|
|
28
|
+
uuid?: string | undefined;
|
|
29
|
+
}, {
|
|
30
|
+
name?: string | undefined;
|
|
31
|
+
id?: string | undefined;
|
|
32
|
+
app_id?: string | undefined;
|
|
33
|
+
instance_id?: string | undefined;
|
|
34
|
+
uuid?: string | undefined;
|
|
35
|
+
}>, any, any>, {
|
|
36
|
+
cvmId: any;
|
|
37
|
+
}, any>;
|
|
38
|
+
export type GetCvmUserConfigRequest = CvmIdInput;
|
|
39
|
+
/**
|
|
40
|
+
* Get the runtime user_config of a CVM
|
|
41
|
+
*
|
|
42
|
+
* Reads the live user_config stored in Teepod for the given CVM.
|
|
43
|
+
* Contains the hostname, injected SSH authorized keys, and default gateway domain
|
|
44
|
+
* set at launch time.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* import { createClient, getCvmUserConfig } from '@phala/cloud'
|
|
49
|
+
*
|
|
50
|
+
* const client = createClient({ apiKey: 'your-api-key' })
|
|
51
|
+
* const config = await getCvmUserConfig(client, { cvmId: 'app_123' })
|
|
52
|
+
* console.log(config.hostname)
|
|
53
|
+
* console.log(config.ssh_authorized_keys) // string[]
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* ## Safe Version
|
|
57
|
+
*
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const result = await safeGetCvmUserConfig(client, { cvmId: 'app_123' })
|
|
60
|
+
* if (result.success) {
|
|
61
|
+
* console.log(result.data.ssh_authorized_keys.length, 'keys')
|
|
62
|
+
* } else {
|
|
63
|
+
* console.error(result.error.message)
|
|
64
|
+
* }
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
declare const getCvmUserConfig: {
|
|
68
|
+
(client: import("../..").BaseClient<import("../..").ApiVersion>, params: CvmIdInput): Promise<{
|
|
69
|
+
ssh_authorized_keys: string[];
|
|
70
|
+
hostname?: string | null | undefined;
|
|
71
|
+
default_gateway_domain?: string | null | undefined;
|
|
72
|
+
}>;
|
|
73
|
+
<T extends z.ZodTypeAny>(client: import("../..").BaseClient<import("../..").ApiVersion>, params: CvmIdInput, parameters: {
|
|
74
|
+
schema: T;
|
|
75
|
+
}): Promise<z.TypeOf<T>>;
|
|
76
|
+
(client: import("../..").BaseClient<import("../..").ApiVersion>, params: CvmIdInput, parameters: {
|
|
77
|
+
schema: false;
|
|
78
|
+
}): Promise<unknown>;
|
|
79
|
+
}, safeGetCvmUserConfig: {
|
|
80
|
+
(client: import("../..").BaseClient<import("../..").ApiVersion>, params: CvmIdInput): Promise<import("../..").SafeResult<{
|
|
81
|
+
ssh_authorized_keys: string[];
|
|
82
|
+
hostname?: string | null | undefined;
|
|
83
|
+
default_gateway_domain?: string | null | undefined;
|
|
84
|
+
}>>;
|
|
85
|
+
<T extends z.ZodTypeAny>(client: import("../..").BaseClient<import("../..").ApiVersion>, params: CvmIdInput, parameters: {
|
|
86
|
+
schema: T;
|
|
87
|
+
}): Promise<import("../..").SafeResult<z.TypeOf<T>>>;
|
|
88
|
+
(client: import("../..").BaseClient<import("../..").ApiVersion>, params: CvmIdInput, parameters: {
|
|
89
|
+
schema: false;
|
|
90
|
+
}): Promise<import("../..").SafeResult<unknown>>;
|
|
91
|
+
};
|
|
92
|
+
export { getCvmUserConfig, safeGetCvmUserConfig };
|
package/dist/actions/index.d.ts
CHANGED
|
@@ -39,6 +39,12 @@ export { updateDockerCompose, safeUpdateDockerCompose, UpdateDockerComposeReques
|
|
|
39
39
|
export { updatePreLaunchScript, safeUpdatePreLaunchScript, UpdatePreLaunchScriptRequestSchema, type UpdatePreLaunchScriptRequest, UpdatePreLaunchScriptResultSchema, type UpdatePreLaunchScriptResult, type UpdatePreLaunchScriptInProgress, type UpdatePreLaunchScriptPreconditionRequired, } from "./cvms/update_prelaunch_script";
|
|
40
40
|
export { getCvmPreLaunchScript, safeGetCvmPreLaunchScript, GetCvmPreLaunchScriptRequestSchema, type GetCvmPreLaunchScriptRequest, } from "./cvms/get_cvm_prelaunch_script";
|
|
41
41
|
export { getCvmStatusBatch, safeGetCvmStatusBatch, CvmStatusSchema, GetCvmStatusBatchResponseSchema, GetCvmStatusBatchRequestSchema, type CvmStatus, type GetCvmStatusBatchResponse, type GetCvmStatusBatchRequest, } from "./cvms/get_cvm_status_batch";
|
|
42
|
+
export { getCvmUserConfig, safeGetCvmUserConfig, CvmUserConfigSchema, GetCvmUserConfigRequestSchema, type CvmUserConfig, type GetCvmUserConfigRequest, } from "./cvms/get_cvm_user_config";
|
|
43
|
+
export { listSshKeys, safeListSshKeys, SshKeySchema, ListSshKeysResponseSchema, type SshKey, type ListSshKeysResponse, } from "./ssh_keys/list_ssh_keys";
|
|
44
|
+
export { importGithubProfileSshKeys, safeImportGithubProfileSshKeys, ImportGithubProfileRequestSchema, ImportGithubProfileResponseSchema, type ImportGithubProfileRequest, type ImportGithubProfileResponse, } from "./ssh_keys/import_github_profile";
|
|
45
|
+
export { createSshKey, safeCreateSshKey, CreateSshKeyRequestSchema, type CreateSshKeyRequest, } from "./ssh_keys/create_ssh_key";
|
|
46
|
+
export { deleteSshKey, safeDeleteSshKey, DeleteSshKeyRequestSchema, type DeleteSshKeyRequest, } from "./ssh_keys/delete_ssh_key";
|
|
47
|
+
export { syncGithubSshKeys, safeSyncGithubSshKeys, SyncGithubSshKeysResponseSchema, type SyncGithubSshKeysResponse, } from "./ssh_keys/sync_github_ssh_keys";
|
|
42
48
|
export { getAppList, safeGetAppList, GetAppListRequestSchema, type GetAppListRequest, } from "./apps/get_app_list";
|
|
43
49
|
export { getAppInfo, safeGetAppInfo, GetAppInfoRequestSchema, type GetAppInfoRequest, } from "./apps/get_app_info";
|
|
44
50
|
export { getAppCvms, safeGetAppCvms, GetAppCvmsRequestSchema, type GetAppCvmsRequest, } from "./apps/get_app_cvms";
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const CreateSshKeyRequestSchema: z.ZodObject<{
|
|
3
|
+
name: z.ZodString;
|
|
4
|
+
public_key: z.ZodString;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
name: string;
|
|
7
|
+
public_key: string;
|
|
8
|
+
}, {
|
|
9
|
+
name: string;
|
|
10
|
+
public_key: string;
|
|
11
|
+
}>;
|
|
12
|
+
export type CreateSshKeyRequest = z.infer<typeof CreateSshKeyRequestSchema>;
|
|
13
|
+
/**
|
|
14
|
+
* Create a new SSH key for the current user
|
|
15
|
+
*
|
|
16
|
+
* Adds a manually-provided public key. The server computes the SHA256
|
|
17
|
+
* fingerprint and detects the key type automatically.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { createClient, createSshKey } from '@phala/cloud'
|
|
22
|
+
*
|
|
23
|
+
* const client = createClient({ apiKey: 'your-api-key' })
|
|
24
|
+
* const key = await createSshKey(client, {
|
|
25
|
+
* name: 'my-laptop',
|
|
26
|
+
* public_key: 'ssh-ed25519 AAAA...',
|
|
27
|
+
* })
|
|
28
|
+
* console.log(key.fingerprint)
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* ## Safe Version
|
|
32
|
+
*
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const result = await safeCreateSshKey(client, {
|
|
35
|
+
* name: 'my-laptop',
|
|
36
|
+
* public_key: 'ssh-ed25519 AAAA...',
|
|
37
|
+
* })
|
|
38
|
+
* if (result.success) {
|
|
39
|
+
* console.log('Created key:', result.data.id)
|
|
40
|
+
* } else {
|
|
41
|
+
* console.error(result.error.message)
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
declare const createSshKey: {
|
|
46
|
+
(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
47
|
+
name: string;
|
|
48
|
+
public_key: string;
|
|
49
|
+
}): Promise<{
|
|
50
|
+
name: string;
|
|
51
|
+
id: string;
|
|
52
|
+
source: string;
|
|
53
|
+
updated_at: string;
|
|
54
|
+
created_at: string;
|
|
55
|
+
user_id: string;
|
|
56
|
+
public_key: string;
|
|
57
|
+
fingerprint: string;
|
|
58
|
+
key_type: string;
|
|
59
|
+
key_metadata?: Record<string, unknown> | null | undefined;
|
|
60
|
+
last_synced_at?: string | null | undefined;
|
|
61
|
+
}>;
|
|
62
|
+
<T extends z.ZodTypeAny>(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
63
|
+
name: string;
|
|
64
|
+
public_key: string;
|
|
65
|
+
}, parameters: {
|
|
66
|
+
schema: T;
|
|
67
|
+
}): Promise<z.TypeOf<T>>;
|
|
68
|
+
(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
69
|
+
name: string;
|
|
70
|
+
public_key: string;
|
|
71
|
+
}, parameters: {
|
|
72
|
+
schema: false;
|
|
73
|
+
}): Promise<unknown>;
|
|
74
|
+
}, safeCreateSshKey: {
|
|
75
|
+
(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
76
|
+
name: string;
|
|
77
|
+
public_key: string;
|
|
78
|
+
}): Promise<import("../..").SafeResult<{
|
|
79
|
+
name: string;
|
|
80
|
+
id: string;
|
|
81
|
+
source: string;
|
|
82
|
+
updated_at: string;
|
|
83
|
+
created_at: string;
|
|
84
|
+
user_id: string;
|
|
85
|
+
public_key: string;
|
|
86
|
+
fingerprint: string;
|
|
87
|
+
key_type: string;
|
|
88
|
+
key_metadata?: Record<string, unknown> | null | undefined;
|
|
89
|
+
last_synced_at?: string | null | undefined;
|
|
90
|
+
}>>;
|
|
91
|
+
<T extends z.ZodTypeAny>(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
92
|
+
name: string;
|
|
93
|
+
public_key: string;
|
|
94
|
+
}, parameters: {
|
|
95
|
+
schema: T;
|
|
96
|
+
}): Promise<import("../..").SafeResult<z.TypeOf<T>>>;
|
|
97
|
+
(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
98
|
+
name: string;
|
|
99
|
+
public_key: string;
|
|
100
|
+
}, parameters: {
|
|
101
|
+
schema: false;
|
|
102
|
+
}): Promise<import("../..").SafeResult<unknown>>;
|
|
103
|
+
};
|
|
104
|
+
export { createSshKey, safeCreateSshKey };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const DeleteSshKeyRequestSchema: z.ZodObject<{
|
|
3
|
+
keyId: z.ZodString;
|
|
4
|
+
}, "strip", z.ZodTypeAny, {
|
|
5
|
+
keyId: string;
|
|
6
|
+
}, {
|
|
7
|
+
keyId: string;
|
|
8
|
+
}>;
|
|
9
|
+
export type DeleteSshKeyRequest = z.infer<typeof DeleteSshKeyRequestSchema>;
|
|
10
|
+
/**
|
|
11
|
+
* Delete an SSH key
|
|
12
|
+
*
|
|
13
|
+
* Permanently removes an SSH key from the current user's account.
|
|
14
|
+
* This operation cannot be undone.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { createClient, deleteSshKey } from '@phala/cloud'
|
|
19
|
+
*
|
|
20
|
+
* const client = createClient({ apiKey: 'your-api-key' })
|
|
21
|
+
* await deleteSshKey(client, { keyId: 'sshkey_xxx' })
|
|
22
|
+
* console.log('Key deleted')
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* ## Safe Version
|
|
26
|
+
*
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const result = await safeDeleteSshKey(client, { keyId: 'sshkey_xxx' })
|
|
29
|
+
* if (result.success) {
|
|
30
|
+
* console.log('Key deleted')
|
|
31
|
+
* } else {
|
|
32
|
+
* console.error(result.error.message)
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
declare const deleteSshKey: {
|
|
37
|
+
(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
38
|
+
keyId: string;
|
|
39
|
+
}): Promise<void>;
|
|
40
|
+
<T extends z.ZodTypeAny>(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
41
|
+
keyId: string;
|
|
42
|
+
}, parameters: {
|
|
43
|
+
schema: T;
|
|
44
|
+
}): Promise<z.TypeOf<T>>;
|
|
45
|
+
(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
46
|
+
keyId: string;
|
|
47
|
+
}, parameters: {
|
|
48
|
+
schema: false;
|
|
49
|
+
}): Promise<unknown>;
|
|
50
|
+
}, safeDeleteSshKey: {
|
|
51
|
+
(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
52
|
+
keyId: string;
|
|
53
|
+
}): Promise<import("../..").SafeResult<void>>;
|
|
54
|
+
<T extends z.ZodTypeAny>(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
55
|
+
keyId: string;
|
|
56
|
+
}, parameters: {
|
|
57
|
+
schema: T;
|
|
58
|
+
}): Promise<import("../..").SafeResult<z.TypeOf<T>>>;
|
|
59
|
+
(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
60
|
+
keyId: string;
|
|
61
|
+
}, parameters: {
|
|
62
|
+
schema: false;
|
|
63
|
+
}): Promise<import("../..").SafeResult<unknown>>;
|
|
64
|
+
};
|
|
65
|
+
export { deleteSshKey, safeDeleteSshKey };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const ImportGithubProfileRequestSchema: z.ZodObject<{
|
|
3
|
+
github_username: z.ZodString;
|
|
4
|
+
}, "strip", z.ZodTypeAny, {
|
|
5
|
+
github_username: string;
|
|
6
|
+
}, {
|
|
7
|
+
github_username: string;
|
|
8
|
+
}>;
|
|
9
|
+
export type ImportGithubProfileRequest = z.infer<typeof ImportGithubProfileRequestSchema>;
|
|
10
|
+
export declare const ImportGithubProfileResponseSchema: z.ZodObject<{
|
|
11
|
+
github_username: z.ZodString;
|
|
12
|
+
keys_added: z.ZodNumber;
|
|
13
|
+
keys_skipped: z.ZodNumber;
|
|
14
|
+
errors: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
errors: string[];
|
|
17
|
+
github_username: string;
|
|
18
|
+
keys_added: number;
|
|
19
|
+
keys_skipped: number;
|
|
20
|
+
}, {
|
|
21
|
+
github_username: string;
|
|
22
|
+
keys_added: number;
|
|
23
|
+
keys_skipped: number;
|
|
24
|
+
errors?: string[] | undefined;
|
|
25
|
+
}>;
|
|
26
|
+
export type ImportGithubProfileResponse = z.infer<typeof ImportGithubProfileResponseSchema>;
|
|
27
|
+
/**
|
|
28
|
+
* Import SSH keys from a GitHub user's public profile
|
|
29
|
+
*
|
|
30
|
+
* Fetches public SSH keys from any GitHub user's profile via the unauthenticated
|
|
31
|
+
* GitHub API. Keys already present (matched by SHA256 fingerprint) are skipped.
|
|
32
|
+
* Per-key parse errors are collected in `errors` rather than aborting the import.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* import { createClient, importGithubProfileSshKeys } from '@phala/cloud'
|
|
37
|
+
*
|
|
38
|
+
* const client = createClient({ apiKey: 'your-api-key' })
|
|
39
|
+
* const result = await importGithubProfileSshKeys(client, { github_username: 'octocat' })
|
|
40
|
+
* console.log(`Added: ${result.keys_added}, Skipped: ${result.keys_skipped}`)
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* ## Safe Version
|
|
44
|
+
*
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const result = await safeImportGithubProfileSshKeys(client, { github_username: 'octocat' })
|
|
47
|
+
* if (result.success) {
|
|
48
|
+
* console.log('Added', result.data.keys_added, 'key(s)')
|
|
49
|
+
* } else {
|
|
50
|
+
* console.error(result.error.message)
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
declare const importGithubProfileSshKeys: {
|
|
55
|
+
(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
56
|
+
github_username: string;
|
|
57
|
+
}): Promise<{
|
|
58
|
+
errors: string[];
|
|
59
|
+
github_username: string;
|
|
60
|
+
keys_added: number;
|
|
61
|
+
keys_skipped: number;
|
|
62
|
+
}>;
|
|
63
|
+
<T extends z.ZodTypeAny>(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
64
|
+
github_username: string;
|
|
65
|
+
}, parameters: {
|
|
66
|
+
schema: T;
|
|
67
|
+
}): Promise<z.TypeOf<T>>;
|
|
68
|
+
(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
69
|
+
github_username: string;
|
|
70
|
+
}, parameters: {
|
|
71
|
+
schema: false;
|
|
72
|
+
}): Promise<unknown>;
|
|
73
|
+
}, safeImportGithubProfileSshKeys: {
|
|
74
|
+
(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
75
|
+
github_username: string;
|
|
76
|
+
}): Promise<import("../..").SafeResult<{
|
|
77
|
+
errors: string[];
|
|
78
|
+
github_username: string;
|
|
79
|
+
keys_added: number;
|
|
80
|
+
keys_skipped: number;
|
|
81
|
+
}>>;
|
|
82
|
+
<T extends z.ZodTypeAny>(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
83
|
+
github_username: string;
|
|
84
|
+
}, parameters: {
|
|
85
|
+
schema: T;
|
|
86
|
+
}): Promise<import("../..").SafeResult<z.TypeOf<T>>>;
|
|
87
|
+
(client: import("../..").BaseClient<import("../..").ApiVersion>, params: {
|
|
88
|
+
github_username: string;
|
|
89
|
+
}, parameters: {
|
|
90
|
+
schema: false;
|
|
91
|
+
}): Promise<import("../..").SafeResult<unknown>>;
|
|
92
|
+
};
|
|
93
|
+
export { importGithubProfileSshKeys, safeImportGithubProfileSshKeys };
|
|
@@ -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 };
|
package/dist/create-client.d.ts
CHANGED
|
@@ -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
|
}
|