@phala/cloud 0.4.0 → 0.6.0

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.
Files changed (114) hide show
  1. package/README.md +20 -0
  2. package/dist/actions/api_tokens/revoke_current_api_token.d.ts +47 -0
  3. package/dist/actions/apps/app_launch_token.d.ts +121 -0
  4. package/dist/actions/apps/check_app_cvms_is_allowed.d.ts +17 -311
  5. package/dist/actions/apps/check_app_is_allowed.d.ts +20 -32
  6. package/dist/actions/apps/create_app_instance.d.ts +43 -63
  7. package/dist/actions/apps/get_app_attestation.d.ts +113 -779
  8. package/dist/actions/apps/get_app_cvms.d.ts +1 -5
  9. package/dist/actions/apps/get_app_device_allowlist.d.ts +26 -272
  10. package/dist/actions/apps/get_app_filter_options.d.ts +8 -24
  11. package/dist/actions/apps/get_app_info.d.ts +1 -5
  12. package/dist/actions/apps/get_app_list.d.ts +2 -26
  13. package/dist/actions/apps/get_app_revision_detail.d.ts +1 -9
  14. package/dist/actions/apps/get_app_revisions.d.ts +1 -9
  15. package/dist/actions/blockchains/add_compose_hash.d.ts +1 -13
  16. package/dist/actions/blockchains/add_device.d.ts +1 -13
  17. package/dist/actions/blockchains/deploy_app_auth.d.ts +3 -95
  18. package/dist/actions/blockchains/get_allowed_devices.d.ts +2 -12
  19. package/dist/actions/blockchains/remove_device.d.ts +1 -13
  20. package/dist/actions/blockchains/set_allow_any_device.d.ts +1 -13
  21. package/dist/actions/cvms/check_cvm_is_allowed.d.ts +13 -138
  22. package/dist/actions/cvms/commit_cvm_compose_file_update.d.ts +9 -45
  23. package/dist/actions/cvms/commit_cvm_provision.d.ts +32 -422
  24. package/dist/actions/cvms/commit_cvm_update.d.ts +70 -41
  25. package/dist/actions/cvms/confirm_cvm_patch.d.ts +62 -35
  26. package/dist/actions/cvms/cvm_annotations.d.ts +152 -0
  27. package/dist/actions/cvms/delete_cvm.d.ts +8 -14
  28. package/dist/actions/cvms/get_available_os_images.d.ts +70 -111
  29. package/dist/actions/cvms/get_cvm_attestation.d.ts +34 -392
  30. package/dist/actions/cvms/get_cvm_compose_file.d.ts +384 -614
  31. package/dist/actions/cvms/get_cvm_containers_stats.d.ts +25 -91
  32. package/dist/actions/cvms/get_cvm_docker_compose.d.ts +8 -14
  33. package/dist/actions/cvms/get_cvm_info.d.ts +6 -12
  34. package/dist/actions/cvms/get_cvm_init_scripts.d.ts +92 -0
  35. package/dist/actions/cvms/get_cvm_list.d.ts +7 -13
  36. package/dist/actions/cvms/get_cvm_network.d.ts +18 -50
  37. package/dist/actions/cvms/get_cvm_prelaunch_script.d.ts +8 -14
  38. package/dist/actions/cvms/get_cvm_state.d.ts +11 -37
  39. package/dist/actions/cvms/get_cvm_stats.d.ts +23 -149
  40. package/dist/actions/cvms/get_cvm_status_batch.d.ts +19 -209
  41. package/dist/actions/cvms/get_cvm_user_config.d.ts +13 -24
  42. package/dist/actions/cvms/get_prelaunch_script_upgrade_status.d.ts +9 -27
  43. package/dist/actions/cvms/log-time.d.ts +5 -0
  44. package/dist/actions/cvms/logs.d.ts +64 -0
  45. package/dist/actions/cvms/patch_cvm.d.ts +665 -295
  46. package/dist/actions/cvms/provision_cvm.d.ts +329 -1561
  47. package/dist/actions/cvms/provision_cvm_compose_file_update.d.ts +550 -953
  48. package/dist/actions/cvms/put_cvm_init_scripts.d.ts +150 -0
  49. package/dist/actions/cvms/refresh_cvm_instance_id.d.ts +74 -131
  50. package/dist/actions/cvms/refresh_cvm_instance_ids.d.ts +77 -297
  51. package/dist/actions/cvms/replicate_cvm.d.ts +7 -21
  52. package/dist/actions/cvms/restart_cvm.d.ts +3 -18
  53. package/dist/actions/cvms/shutdown_cvm.d.ts +6 -12
  54. package/dist/actions/cvms/start_cvm.d.ts +6 -12
  55. package/dist/actions/cvms/stop_cvm.d.ts +6 -12
  56. package/dist/actions/cvms/update_cvm_envs.d.ts +136 -203
  57. package/dist/actions/cvms/update_cvm_resources.d.ts +82 -48
  58. package/dist/actions/cvms/update_cvm_visibility.d.ts +90 -132
  59. package/dist/actions/cvms/update_docker_compose.d.ts +127 -202
  60. package/dist/actions/cvms/update_os_image.d.ts +55 -28
  61. package/dist/actions/cvms/update_prelaunch_script.d.ts +127 -202
  62. package/dist/actions/cvms/upgrade_prelaunch_script.d.ts +118 -193
  63. package/dist/actions/cvms/watch_cvm_state.d.ts +5 -15
  64. package/dist/actions/get_available_nodes.d.ts +186 -1067
  65. package/dist/actions/get_cvm_create_resources.d.ts +138 -2489
  66. package/dist/actions/index.d.ts +9 -2
  67. package/dist/actions/kms/get_app_env_encrypt_pubkey.d.ts +11 -23
  68. package/dist/actions/kms/get_kms_contract.d.ts +25 -27
  69. package/dist/actions/kms/get_kms_info.d.ts +3 -7
  70. package/dist/actions/kms/get_kms_list.d.ts +34 -88
  71. package/dist/actions/kms/get_kms_onchain_detail.d.ts +66 -664
  72. package/dist/actions/kms/list_kms_contract_nodes.d.ts +21 -53
  73. package/dist/actions/kms/list_kms_contracts.d.ts +33 -87
  74. package/dist/actions/kms/next_app_ids.d.ts +5 -25
  75. package/dist/actions/list-instance-types.d.ts +77 -257
  76. package/dist/actions/os_images/get_os_images.d.ts +38 -152
  77. package/dist/actions/ssh_keys/create_ssh_key.d.ts +11 -17
  78. package/dist/actions/ssh_keys/delete_ssh_key.d.ts +3 -7
  79. package/dist/actions/ssh_keys/get_cvm_ssh_keys.d.ts +113 -0
  80. package/dist/actions/ssh_keys/import_github_profile.d.ts +7 -21
  81. package/dist/actions/ssh_keys/list_ssh_keys.d.ts +2 -50
  82. package/dist/actions/ssh_keys/sync_github_ssh_keys.d.ts +8 -20
  83. package/dist/actions/ssh_keys/update_cvm_ssh_keys.d.ts +140 -0
  84. package/dist/actions/workspaces/get_workspace.d.ts +32 -28
  85. package/dist/actions/workspaces/get_workspace_nodes.d.ts +34 -321
  86. package/dist/actions/workspaces/get_workspace_quotas.d.ts +107 -1021
  87. package/dist/actions/workspaces/list_workspaces.d.ts +67 -369
  88. package/dist/client.d.ts +23 -4
  89. package/dist/create-client.d.ts +1900 -1
  90. package/dist/credentials/current_user_v20251028.d.ts +1 -17
  91. package/dist/credentials/current_user_v20260121.d.ts +22 -227
  92. package/dist/index.d.ts +1 -1
  93. package/dist/index.js +6004 -4537
  94. package/dist/index.mjs +6033 -4625
  95. package/dist/types/app_compose.d.ts +108 -221
  96. package/dist/types/app_info_v20251028.d.ts +22 -1067
  97. package/dist/types/app_info_v20260121.d.ts +442 -8900
  98. package/dist/types/app_revision.d.ts +15 -371
  99. package/dist/types/client.d.ts +16 -0
  100. package/dist/types/common.d.ts +6 -0
  101. package/dist/types/cvm_id.d.ts +12 -57
  102. package/dist/types/cvm_info.d.ts +33 -460
  103. package/dist/types/cvm_info_v20251028.d.ts +100 -821
  104. package/dist/types/cvm_info_v20260121.d.ts +254 -3160
  105. package/dist/types/kms_contract.d.ts +2 -32
  106. package/dist/types/kms_info.d.ts +34 -68
  107. package/dist/user-agent.d.ts +30 -0
  108. package/dist/utils/define-action.d.ts +4 -4
  109. package/dist/utils/errors.d.ts +4 -36
  110. package/dist/utils/get_compose_hash.d.ts +36 -5
  111. package/dist/utils/get_mr_config_id.d.ts +94 -3
  112. package/dist/utils/index.d.ts +1 -1
  113. package/dist/utils/placement-request.d.ts +3 -0
  114. package/package.json +4 -4
@@ -17,25 +17,7 @@ export declare const KmsContractInfoSchema: z.ZodObject<{
17
17
  k256_pubkey: z.ZodNullable<z.ZodString>;
18
18
  ca_pubkey: z.ZodNullable<z.ZodString>;
19
19
  node_count: z.ZodNumber;
20
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
21
- id: z.ZodString;
22
- slug: z.ZodNullable<z.ZodString>;
23
- label: z.ZodNullable<z.ZodString>;
24
- contract_address: z.ZodString;
25
- chain_id: z.ZodNumber;
26
- k256_pubkey: z.ZodNullable<z.ZodString>;
27
- ca_pubkey: z.ZodNullable<z.ZodString>;
28
- node_count: z.ZodNumber;
29
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
30
- id: z.ZodString;
31
- slug: z.ZodNullable<z.ZodString>;
32
- label: z.ZodNullable<z.ZodString>;
33
- contract_address: z.ZodString;
34
- chain_id: z.ZodNumber;
35
- k256_pubkey: z.ZodNullable<z.ZodString>;
36
- ca_pubkey: z.ZodNullable<z.ZodString>;
37
- node_count: z.ZodNumber;
38
- }, z.ZodTypeAny, "passthrough">>;
20
+ }, z.core.$loose>;
39
21
  export type KmsContractInfo = z.infer<typeof KmsContractInfoSchema>;
40
22
  /**
41
23
  * A single KMS node (replica) under a contract, including its RPC `url`.
@@ -48,17 +30,5 @@ export declare const KmsContractNodeSchema: z.ZodObject<{
48
30
  url: z.ZodString;
49
31
  version: z.ZodString;
50
32
  kms_type: z.ZodString;
51
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
52
- id: z.ZodString;
53
- slug: z.ZodNullable<z.ZodString>;
54
- url: z.ZodString;
55
- version: z.ZodString;
56
- kms_type: z.ZodString;
57
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
58
- id: z.ZodString;
59
- slug: z.ZodNullable<z.ZodString>;
60
- url: z.ZodString;
61
- version: z.ZodString;
62
- kms_type: z.ZodString;
63
- }, z.ZodTypeAny, "passthrough">>;
33
+ }, z.core.$loose>;
64
34
  export type KmsContractNode = z.infer<typeof KmsContractNodeSchema>;
@@ -6,74 +6,40 @@ declare const KmsInfoBaseSchema: z.ZodObject<{
6
6
  url: z.ZodString;
7
7
  version: z.ZodString;
8
8
  chain_id: z.ZodNullable<z.ZodNumber>;
9
- kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
10
- gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
11
- k256_pubkey: z.ZodOptional<z.ZodNullable<z.ZodString>>;
12
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
13
- id: z.ZodString;
14
- slug: z.ZodNullable<z.ZodString>;
15
- url: z.ZodString;
16
- version: z.ZodString;
17
- chain_id: z.ZodNullable<z.ZodNumber>;
18
- kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
19
- gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
20
- k256_pubkey: z.ZodOptional<z.ZodNullable<z.ZodString>>;
21
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
22
- id: z.ZodString;
23
- slug: z.ZodNullable<z.ZodString>;
24
- url: z.ZodString;
25
- version: z.ZodString;
26
- chain_id: z.ZodNullable<z.ZodNumber>;
27
- kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
28
- gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
29
- k256_pubkey: z.ZodOptional<z.ZodNullable<z.ZodString>>;
30
- }, z.ZodTypeAny, "passthrough">>;
31
- export declare const KmsInfoSchema: z.ZodEffects<z.ZodObject<{
32
- id: z.ZodString;
33
- slug: z.ZodNullable<z.ZodString>;
34
- url: z.ZodString;
35
- version: z.ZodString;
36
- chain_id: z.ZodNullable<z.ZodNumber>;
37
- kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
38
- gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
39
- k256_pubkey: z.ZodOptional<z.ZodNullable<z.ZodString>>;
40
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
41
- id: z.ZodString;
42
- slug: z.ZodNullable<z.ZodString>;
43
- url: z.ZodString;
44
- version: z.ZodString;
45
- chain_id: z.ZodNullable<z.ZodNumber>;
46
- kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
47
- gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
48
- k256_pubkey: z.ZodOptional<z.ZodNullable<z.ZodString>>;
49
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
50
- id: z.ZodString;
51
- slug: z.ZodNullable<z.ZodString>;
52
- url: z.ZodString;
53
- version: z.ZodString;
54
- chain_id: z.ZodNullable<z.ZodNumber>;
55
- kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
56
- gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
57
- k256_pubkey: z.ZodOptional<z.ZodNullable<z.ZodString>>;
58
- }, z.ZodTypeAny, "passthrough">>, z.objectOutputType<{
59
- id: z.ZodString;
60
- slug: z.ZodNullable<z.ZodString>;
61
- url: z.ZodString;
62
- version: z.ZodString;
63
- chain_id: z.ZodNullable<z.ZodNumber>;
64
- kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
65
- gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
66
- k256_pubkey: z.ZodOptional<z.ZodNullable<z.ZodString>>;
67
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
68
- id: z.ZodString;
69
- slug: z.ZodNullable<z.ZodString>;
70
- url: z.ZodString;
71
- version: z.ZodString;
72
- chain_id: z.ZodNullable<z.ZodNumber>;
73
- kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
74
- gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
75
- k256_pubkey: z.ZodOptional<z.ZodNullable<z.ZodString>>;
76
- }, z.ZodTypeAny, "passthrough">>;
9
+ kms_contract_address: z.ZodPipe<z.ZodNullable<z.ZodString>, z.ZodTransform<`0x${string}`, string | null>>;
10
+ gateway_app_id: z.ZodPipe<z.ZodNullable<z.ZodString>, z.ZodTransform<`0x${string}`, string | null>>;
11
+ k256_pubkey: z.ZodOptional<z.ZodNullable<z.ZodString>>;
12
+ }, z.core.$loose>;
13
+ export declare const KmsInfoSchema: z.ZodPipe<z.ZodObject<{
14
+ id: z.ZodString;
15
+ slug: z.ZodNullable<z.ZodString>;
16
+ url: z.ZodString;
17
+ version: z.ZodString;
18
+ chain_id: z.ZodNullable<z.ZodNumber>;
19
+ kms_contract_address: z.ZodPipe<z.ZodNullable<z.ZodString>, z.ZodTransform<`0x${string}`, string | null>>;
20
+ gateway_app_id: z.ZodPipe<z.ZodNullable<z.ZodString>, z.ZodTransform<`0x${string}`, string | null>>;
21
+ k256_pubkey: z.ZodOptional<z.ZodNullable<z.ZodString>>;
22
+ }, z.core.$loose>, z.ZodTransform<{
23
+ [x: string]: unknown;
24
+ id: string;
25
+ slug: string | null;
26
+ url: string;
27
+ version: string;
28
+ chain_id: number | null;
29
+ kms_contract_address: `0x${string}`;
30
+ gateway_app_id: `0x${string}`;
31
+ k256_pubkey?: string | null | undefined;
32
+ }, {
33
+ [x: string]: unknown;
34
+ id: string;
35
+ slug: string | null;
36
+ url: string;
37
+ version: string;
38
+ chain_id: number | null;
39
+ kms_contract_address: `0x${string}`;
40
+ gateway_app_id: `0x${string}`;
41
+ k256_pubkey?: string | null | undefined;
42
+ }>>;
77
43
  export type KmsInfo = (z.infer<typeof KmsInfoBaseSchema> & {
78
44
  chain_id: number;
79
45
  chain: Chain;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Runtime view used to build the default User-Agent. Tests pass a stub;
3
+ * production uses globalThis.
4
+ */
5
+ export interface UserAgentRuntime {
6
+ Deno?: {
7
+ version?: {
8
+ deno?: string;
9
+ };
10
+ };
11
+ Bun?: {
12
+ version?: string;
13
+ };
14
+ process?: {
15
+ versions?: {
16
+ node?: string;
17
+ };
18
+ };
19
+ navigator?: {
20
+ userAgent?: string;
21
+ };
22
+ window?: unknown;
23
+ document?: unknown;
24
+ }
25
+ /**
26
+ * RFC 9110 product tokens for non-browser runtimes.
27
+ * Browsers return undefined so the client omits User-Agent (a custom UA
28
+ * would force a CORS preflight and the browser would ignore it anyway).
29
+ */
30
+ export declare function defaultUserAgent(runtime?: UserAgentRuntime): string | undefined;
@@ -17,7 +17,7 @@ export declare function defineSimpleAction<TSchema extends z.ZodTypeAny, TReturn
17
17
  <T extends z.ZodTypeAny>(client: Client<ApiVersion>, parameters: {
18
18
  schema: T;
19
19
  }): Promise<z.infer<T>>;
20
- (client: Client<ApiVersion>): Promise<[TReturnOverride] extends [never] ? z.TypeOf<TSchema> : TReturnOverride>;
20
+ (client: Client<ApiVersion>): Promise<[TReturnOverride] extends [never] ? z.core.output<TSchema> : TReturnOverride>;
21
21
  };
22
22
  safeAction: {
23
23
  (client: Client<ApiVersion>, parameters: {
@@ -26,7 +26,7 @@ export declare function defineSimpleAction<TSchema extends z.ZodTypeAny, TReturn
26
26
  <T extends z.ZodTypeAny>(client: Client<ApiVersion>, parameters: {
27
27
  schema: T;
28
28
  }): Promise<SafeResult<z.infer<T>>>;
29
- (client: Client<ApiVersion>): Promise<SafeResult<[TReturnOverride] extends [never] ? z.TypeOf<TSchema> : TReturnOverride>>;
29
+ (client: Client<ApiVersion>): Promise<SafeResult<[TReturnOverride] extends [never] ? z.core.output<TSchema> : TReturnOverride>>;
30
30
  };
31
31
  };
32
32
  /**
@@ -34,7 +34,7 @@ export declare function defineSimpleAction<TSchema extends z.ZodTypeAny, TReturn
34
34
  */
35
35
  export declare function defineAction<TParams, TSchema extends z.ZodTypeAny, TReturnOverride = never>(schema: TSchema, fn: (client: Client<ApiVersion>, params: TParams) => Promise<unknown>): {
36
36
  action: {
37
- (client: Client<ApiVersion>, ...args: (undefined extends TParams ? true : false) extends true ? [params?: TParams] : [params: TParams]): Promise<[TReturnOverride] extends [never] ? z.TypeOf<TSchema> : TReturnOverride>;
37
+ (client: Client<ApiVersion>, ...args: (undefined extends TParams ? true : false) extends true ? [params?: TParams] : [params: TParams]): Promise<[TReturnOverride] extends [never] ? z.core.output<TSchema> : TReturnOverride>;
38
38
  <T extends z.ZodTypeAny>(client: Client<ApiVersion>, ...args: (undefined extends TParams ? true : false) extends true ? [params?: TParams, parameters?: {
39
39
  schema: T;
40
40
  }] : [params: TParams, parameters: {
@@ -47,7 +47,7 @@ export declare function defineAction<TParams, TSchema extends z.ZodTypeAny, TRet
47
47
  }]): Promise<unknown>;
48
48
  };
49
49
  safeAction: {
50
- (client: Client<ApiVersion>, ...args: (undefined extends TParams ? true : false) extends true ? [params?: TParams] : [params: TParams]): Promise<SafeResult<[TReturnOverride] extends [never] ? z.TypeOf<TSchema> : TReturnOverride>>;
50
+ (client: Client<ApiVersion>, ...args: (undefined extends TParams ? true : false) extends true ? [params?: TParams] : [params: TParams]): Promise<SafeResult<[TReturnOverride] extends [never] ? z.core.output<TSchema> : TReturnOverride>>;
51
51
  <T extends z.ZodTypeAny>(client: Client<ApiVersion>, ...args: (undefined extends TParams ? true : false) extends true ? [params?: TParams, parameters?: {
52
52
  schema: T;
53
53
  }] : [params: TParams, parameters: {
@@ -4,48 +4,16 @@ import type { FetchError, FetchRequest } from "ofetch";
4
4
  * API Error Response Schema
5
5
  */
6
6
  export declare const ApiErrorSchema: z.ZodObject<{
7
- detail: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodObject<{
7
+ detail: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodObject<{
8
8
  msg: z.ZodString;
9
9
  type: z.ZodOptional<z.ZodString>;
10
10
  ctx: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
11
- loc: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">>;
11
+ loc: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
12
12
  input: z.ZodOptional<z.ZodUnknown>;
13
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
14
- msg: z.ZodString;
15
- type: z.ZodOptional<z.ZodString>;
16
- ctx: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
17
- loc: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">>;
18
- input: z.ZodOptional<z.ZodUnknown>;
19
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
20
- msg: z.ZodString;
21
- type: z.ZodOptional<z.ZodString>;
22
- ctx: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
23
- loc: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">>;
24
- input: z.ZodOptional<z.ZodUnknown>;
25
- }, z.ZodTypeAny, "passthrough">>, "many">, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
13
+ }, z.core.$loose>>, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
26
14
  type: z.ZodOptional<z.ZodString>;
27
15
  code: z.ZodOptional<z.ZodString>;
28
- }, "strip", z.ZodTypeAny, {
29
- code?: string | undefined;
30
- type?: string | undefined;
31
- detail?: string | Record<string, unknown> | z.objectOutputType<{
32
- msg: z.ZodString;
33
- type: z.ZodOptional<z.ZodString>;
34
- ctx: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
35
- loc: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">>;
36
- input: z.ZodOptional<z.ZodUnknown>;
37
- }, z.ZodTypeAny, "passthrough">[] | undefined;
38
- }, {
39
- code?: string | undefined;
40
- type?: string | undefined;
41
- detail?: string | Record<string, unknown> | z.objectInputType<{
42
- msg: z.ZodString;
43
- type: z.ZodOptional<z.ZodString>;
44
- ctx: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
45
- loc: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">>;
46
- input: z.ZodOptional<z.ZodUnknown>;
47
- }, z.ZodTypeAny, "passthrough">[] | undefined;
48
- }>;
16
+ }, z.core.$strip>;
49
17
  export type ApiError = z.infer<typeof ApiErrorSchema>;
50
18
  /**
51
19
  * Structured validation error item from FastAPI/Pydantic
@@ -12,7 +12,7 @@ export interface DockerConfig extends SortableObject {
12
12
  token_key?: string;
13
13
  }
14
14
  export interface AppCompose extends SortableObject {
15
- manifest_version?: number;
15
+ manifest_version?: number | string;
16
16
  name?: string;
17
17
  features?: string[];
18
18
  runner?: string;
@@ -32,12 +32,43 @@ export interface AppCompose extends SortableObject {
32
32
  secure_time?: boolean;
33
33
  storage_fs?: string;
34
34
  swap_size?: string;
35
- bash_script?: string;
36
- pre_launch_script?: string;
35
+ bash_script?: string | null;
36
+ pre_launch_script?: string | null;
37
+ init_script?: string | string[];
38
+ storage_discard?: boolean | null;
39
+ event_log_version?: number | null;
40
+ snapshotter?: string | null;
41
+ verity_volumes?: SortableArray | null;
42
+ requirements?: SortableObject | null;
43
+ port_policy?: SortableObject | null;
37
44
  }
38
- export declare function preprocessAppCompose(dic: AppCompose): AppCompose;
45
+ /**
46
+ * Apply the same normalization as the Phala Cloud backend before hashing:
47
+ * drop the script field the runner does not use, drop optional fields that are
48
+ * null (or empty for string fields), and always emit `tproxy_enabled`.
49
+ *
50
+ * With `osImageVersion` (the OS image the CVM runs, e.g. "0.6.0"), also write
51
+ * the OS-dependent wire format: below 0.6.0, `manifest_version` 2 and
52
+ * `init_script` as a single string (omitted when empty); from 0.6.0,
53
+ * `manifest_version` "3" and `init_script` as a list. Without it,
54
+ * `manifest_version` and `init_script` are hashed as given, which is right for
55
+ * a compose read back from Phala Cloud.
56
+ */
57
+ export declare function preprocessAppCompose(dic: AppCompose, osImageVersion?: string): AppCompose;
58
+ /**
59
+ * Serialize like the backend: sorted keys, compact separators, and non-ASCII
60
+ * text left as UTF-8. Nested keys are sorted too, which matches the backend
61
+ * because its nested models declare their fields alphabetically.
62
+ */
39
63
  export declare function dumpAppCompose(dic: AppCompose): string;
40
- export declare function getComposeHash(app_compose: AppCompose): string;
64
+ /**
65
+ * Compute the compose hash exactly as the Phala Cloud backend does.
66
+ *
67
+ * Pass `osImageVersion` when hashing a compose you built yourself, so the
68
+ * OS-dependent `manifest_version` and `init_script` wire format is applied (see
69
+ * `preprocessAppCompose`).
70
+ */
71
+ export declare function getComposeHash(app_compose: AppCompose, osImageVersion?: string): string;
41
72
  /**
42
73
  * Attach utility methods to an AppCompose-compatible object
43
74
  *
@@ -36,6 +36,12 @@ export declare function getMrConfigIdV1(composeHash: Hex): Hex;
36
36
  * Compute mr_config_id V2 from compose_hash, app_id, key_provider_type
37
37
  * and key_provider_id.
38
38
  *
39
+ * LEGACY VMMs ONLY. dstack stopped generating V2 for new VMs: a TDX VM that
40
+ * declares `key_provider_id` now measures MrConfigV3, and V2 survives only as
41
+ * the fallback for VMs that predate the stored mr_config document
42
+ * (`dstack/vmm/src/app/mr_config.rs`). Keep it for verifying those quotes;
43
+ * never use it to describe a new deployment.
44
+ *
39
45
  * Mirrors dstack-types/src/mr_config.rs MrConfig::V2::to_mr_config_id().
40
46
  *
41
47
  * Hash input (concatenated raw bytes):
@@ -47,9 +53,94 @@ export declare function getMrConfigIdV1(composeHash: Hex): Hex;
47
53
  * Output: 0x02 || keccak256(above) (32 bytes) || zeros (15 bytes) = 48 bytes
48
54
  */
49
55
  export declare function getMrConfigId(input: MrConfigIdInput): Hex;
56
+ /** dstack refuses to bind more than this many init scripts. */
57
+ export declare const MAX_INIT_SCRIPTS = 5;
58
+ /**
59
+ * The MrConfigV3 document, field for field as dstack serializes it
60
+ * (`dstack-types/src/mr_config.rs` `MrConfigV3`).
61
+ *
62
+ * Byte fields carry the exact spelling the canonical JSON uses: lowercase hex,
63
+ * no `0x` prefix. Optional fields are absent — never null, never empty — which
64
+ * is what `#[skip_serializing_none]` produces on the Rust side.
65
+ */
66
+ export interface MrConfigV3Document {
67
+ /** Always 3, and the only numeric field in the document. */
68
+ version: 3;
69
+ app_id?: string;
70
+ compose_hash: string;
71
+ gpu_policy_hash?: string;
72
+ key_provider: KeyProviderKind;
73
+ key_provider_id?: string;
74
+ instance_id?: string;
75
+ /** Present only for manifest_version >= 3; an empty list is meaningful. */
76
+ init_script_hashes?: string[];
77
+ }
78
+ /** Loose inputs accepted when building a document: `0x`-prefixed or bare hex. */
79
+ export interface MrConfigV3Input {
80
+ /** 20 bytes. Absent or empty means dstack pins no application identity. */
81
+ app_id?: string;
82
+ /** 32 bytes. */
83
+ compose_hash: string;
84
+ /** 32 bytes. Present only when the VM has GPUs attached. */
85
+ gpu_policy_hash?: string;
86
+ key_provider: KeyProviderKind;
87
+ /** Variable length. Absent or empty for `key_provider: "none"`. */
88
+ key_provider_id?: string;
89
+ /** 20 bytes. Absent when the compose sets `no_instance_id`. */
90
+ instance_id?: string;
91
+ /** 32 bytes each, in execution order. Absent disables the check. */
92
+ init_script_hashes?: string[];
93
+ }
94
+ /**
95
+ * Build the MrConfigV3 document dstack would generate for these inputs.
96
+ *
97
+ * Mirrors `VmWorkDir::prepare_mr_config_v3` in `dstack/vmm/src/app/mr_config.rs`:
98
+ * empty optional byte fields are dropped rather than serialized as empty
99
+ * strings, so a `no_instance_id` compose yields a document with no
100
+ * `instance_id` key at all.
101
+ */
102
+ export declare function buildMrConfigV3Document(input: MrConfigV3Input): MrConfigV3Document;
103
+ /**
104
+ * RFC 8785 (JCS) serialization of an MrConfigV3 document, byte for byte what
105
+ * `serde_jcs::to_string` produces for the Rust struct.
106
+ *
107
+ * The document is a flat object whose values are hex strings, one enum string,
108
+ * one small integer, and an array of hex strings. That means JCS reduces to
109
+ * three rules here: sort the member names by UTF-16 code unit (which is what
110
+ * `Array.prototype.sort` does), emit no whitespace, and print the one number as
111
+ * a bare integer. No value needs JSON string escaping, because every string is
112
+ * `[0-9a-f]*` or one of `none`/`kms`/`local`/`tpm`.
113
+ */
114
+ export declare function canonicalizeMrConfigV3Document(document: MrConfigV3Document): string;
115
+ /**
116
+ * Compute the TDX mr_config_id V3 for a document.
117
+ *
118
+ * Output: 0x03 || sha256(domain ‖ 0x00 ‖ JCS(document)) (32 bytes) || zeros (15 bytes).
119
+ *
120
+ * Mirrors `MrConfigV3::tdx_mr_config_id_from_document` in
121
+ * `dstack-types/src/mr_config.rs`.
122
+ */
123
+ export declare function getMrConfigIdV3(document: MrConfigV3Document): Hex;
50
124
  /**
51
- * Verify that a mr_config_id matches the expected value computed from
52
- * the given inputs. Automatically selects V1 or V2 based on version byte.
125
+ * Compute the AMD SEV-SNP `host_data` for a document: the same 32-byte digest
126
+ * as `getMrConfigIdV3`, carried without the version byte or the padding.
127
+ */
128
+ export declare function getSnpHostDataV3(document: MrConfigV3Document): Hex;
129
+ /** Everything `verifyMrConfigId` may need, across all three layouts. */
130
+ export interface MrConfigVerifyInput extends MrConfigIdInput {
131
+ /** V3 only: present when the VM has GPUs attached. */
132
+ gpu_policy_hash?: Hex;
133
+ /** V3 only: absent when the compose sets `no_instance_id`. */
134
+ instance_id?: Hex;
135
+ /** V3 only: present when the compose is manifest_version >= 3. */
136
+ init_script_hashes?: Hex[];
137
+ }
138
+ /**
139
+ * Verify a mr_config_id against the inputs it should have been derived from.
140
+ *
141
+ * The version byte decides the layout, so a single call verifies quotes from
142
+ * legacy VMMs (V1 compose-hash-only, V2 keccak) and current ones (V3 document
143
+ * digest) alike.
53
144
  */
54
- export declare function verifyMrConfigId(mrConfigId: Hex, input: MrConfigIdInput): boolean;
145
+ export declare function verifyMrConfigId(mrConfigId: Hex, input: MrConfigVerifyInput): boolean;
55
146
  export {};
@@ -1,6 +1,6 @@
1
1
  export { encryptEnvVars } from "@phala/dstack-sdk/encrypt-env-vars";
2
2
  export { getComposeHash, dumpAppCompose, preprocessAppCompose, sortObject, withComposeMethods, type AppCompose, type AppComposeWithMethods, type DockerConfig, type KeyProviderKind, type SortableValue, type SortableObject, type SortableArray, } from "./get_compose_hash";
3
- export { getMrConfigId, getMrConfigIdV1, verifyMrConfigId, type MrConfigIdInput, type KeyProviderKind as MrConfigKeyProviderKind, } from "./get_mr_config_id";
3
+ export { buildMrConfigV3Document, canonicalizeMrConfigV3Document, getMrConfigId, getMrConfigIdV1, getMrConfigIdV3, getSnpHostDataV3, verifyMrConfigId, MAX_INIT_SCRIPTS, type MrConfigIdInput, type MrConfigV3Document, type MrConfigV3Input, type MrConfigVerifyInput, type KeyProviderKind as MrConfigKeyProviderKind, } from "./get_mr_config_id";
4
4
  export { asHex } from "./as-hex";
5
5
  export { validateActionParameters, safeValidateActionParameters } from "./validate-parameters";
6
6
  export { isValidHostname, convertToHostname, generateFallbackHostname, generateDefaultCvmName, } from "./hostname";
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+ /** Reject legacy placement keys before object schemas strip unknown fields. */
3
+ export declare function placementRequest<T extends z.ZodTypeAny>(schema: T): z.ZodPipe<z.ZodUnknown, T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phala/cloud",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "TypeScript SDK for Phala Cloud API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -47,8 +47,8 @@
47
47
  "debug": "^4.4.1",
48
48
  "mitt": "^3.0.1",
49
49
  "ofetch": "^1.3.3",
50
- "viem": "^2.52.2",
51
- "zod": "^3.24.1"
50
+ "viem": "^2.55.8",
51
+ "zod": "^4.6.7"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@biomejs/biome": "^1.9.4",
@@ -57,7 +57,7 @@
57
57
  "dotenv": "^16.5.0",
58
58
  "tsup": "^8.5.1",
59
59
  "typescript": "^5.3.0",
60
- "vitest": "^4.1.8"
60
+ "vitest": "^4.1.12"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "typescript": ">=4.5.0"