@phala/cloud 0.3.0 → 0.4.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 (45) hide show
  1. package/dist/actions/apps/get_app_attestation.d.ts +17 -7
  2. package/dist/actions/cvms/commit_cvm_provision.d.ts +6 -0
  3. package/dist/actions/cvms/get_cvm_compose_file.d.ts +156 -12
  4. package/dist/actions/cvms/get_cvm_list.d.ts +8 -10
  5. package/dist/actions/cvms/get_cvm_status_batch.d.ts +247 -24
  6. package/dist/actions/cvms/patch_cvm.d.ts +16 -0
  7. package/dist/actions/cvms/provision_cvm.d.ts +900 -51
  8. package/dist/actions/cvms/provision_cvm_compose_file_update.d.ts +215 -5
  9. package/dist/actions/cvms/update_cvm_envs.d.ts +16 -0
  10. package/dist/actions/cvms/update_cvm_resources.d.ts +24 -2
  11. package/dist/actions/cvms/update_cvm_visibility.d.ts +2 -0
  12. package/dist/actions/cvms/update_docker_compose.d.ts +31 -0
  13. package/dist/actions/cvms/update_prelaunch_script.d.ts +31 -0
  14. package/dist/actions/cvms/upgrade_prelaunch_script.d.ts +16 -0
  15. package/dist/actions/get_available_nodes.d.ts +259 -0
  16. package/dist/actions/get_cvm_create_resources.d.ts +351 -0
  17. package/dist/actions/index.d.ts +6 -2
  18. package/dist/actions/kms/get_kms_contract.d.ts +59 -0
  19. package/dist/actions/kms/get_kms_list.d.ts +15 -0
  20. package/dist/actions/kms/get_kms_onchain_detail.d.ts +54 -0
  21. package/dist/actions/kms/list_kms_contract_nodes.d.ts +98 -0
  22. package/dist/actions/kms/list_kms_contracts.d.ts +152 -0
  23. package/dist/actions/workspaces/get_workspace.d.ts +4 -0
  24. package/dist/actions/workspaces/get_workspace_nodes.d.ts +161 -0
  25. package/dist/actions/workspaces/list_workspaces.d.ts +126 -0
  26. package/dist/client.d.ts +4 -1
  27. package/dist/create-client.d.ts +48 -0
  28. package/dist/index.d.ts +1 -1
  29. package/dist/index.js +1527 -1207
  30. package/dist/index.mjs +1452 -1151
  31. package/dist/types/app_compose.d.ts +50 -5
  32. package/dist/types/app_info_v20251028.d.ts +44 -0
  33. package/dist/types/app_info_v20260121.d.ts +2324 -0
  34. package/dist/types/client.d.ts +2 -2
  35. package/dist/types/cvm_info_v20251028.d.ts +23 -0
  36. package/dist/types/cvm_info_v20260121.d.ts +977 -0
  37. package/dist/types/kms_contract.d.ts +64 -0
  38. package/dist/types/kms_info.d.ts +8 -0
  39. package/dist/types/version-mappings.d.ts +6 -6
  40. package/dist/utils/error_codes.d.ts +1 -0
  41. package/dist/utils/errors.d.ts +30 -1
  42. package/dist/utils/get_compose_hash.d.ts +24 -0
  43. package/dist/utils/get_mr_config_id.d.ts +55 -0
  44. package/dist/utils/index.d.ts +3 -2
  45. package/package.json +3 -3
@@ -0,0 +1,64 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * A KMS contract: a group of equivalent KMS node replicas sharing one root key.
4
+ *
5
+ * `contract_address` is an on-chain address for ETHEREUM/BASE contracts, or the
6
+ * sentinel `"phala"` for the off-chain PHALA KMS (where `chain_id` is `0`).
7
+ * `k256_pubkey` / `ca_pubkey` are the verification anchors.
8
+ *
9
+ * Available from API version 2026-06-23.
10
+ */
11
+ export declare const KmsContractInfoSchema: z.ZodObject<{
12
+ id: z.ZodString;
13
+ slug: z.ZodNullable<z.ZodString>;
14
+ label: z.ZodNullable<z.ZodString>;
15
+ contract_address: z.ZodString;
16
+ chain_id: z.ZodNumber;
17
+ k256_pubkey: z.ZodNullable<z.ZodString>;
18
+ ca_pubkey: z.ZodNullable<z.ZodString>;
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">>;
39
+ export type KmsContractInfo = z.infer<typeof KmsContractInfoSchema>;
40
+ /**
41
+ * A single KMS node (replica) under a contract, including its RPC `url`.
42
+ *
43
+ * Available from API version 2026-06-23.
44
+ */
45
+ export declare const KmsContractNodeSchema: z.ZodObject<{
46
+ id: z.ZodString;
47
+ slug: z.ZodNullable<z.ZodString>;
48
+ url: z.ZodString;
49
+ version: z.ZodString;
50
+ 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">>;
64
+ export type KmsContractNode = z.infer<typeof KmsContractNodeSchema>;
@@ -8,6 +8,7 @@ declare const KmsInfoBaseSchema: z.ZodObject<{
8
8
  chain_id: z.ZodNullable<z.ZodNumber>;
9
9
  kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
10
10
  gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
11
+ k256_pubkey: z.ZodOptional<z.ZodNullable<z.ZodString>>;
11
12
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
12
13
  id: z.ZodString;
13
14
  slug: z.ZodNullable<z.ZodString>;
@@ -16,6 +17,7 @@ declare const KmsInfoBaseSchema: z.ZodObject<{
16
17
  chain_id: z.ZodNullable<z.ZodNumber>;
17
18
  kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
18
19
  gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
20
+ k256_pubkey: z.ZodOptional<z.ZodNullable<z.ZodString>>;
19
21
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
20
22
  id: z.ZodString;
21
23
  slug: z.ZodNullable<z.ZodString>;
@@ -24,6 +26,7 @@ declare const KmsInfoBaseSchema: z.ZodObject<{
24
26
  chain_id: z.ZodNullable<z.ZodNumber>;
25
27
  kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
26
28
  gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
29
+ k256_pubkey: z.ZodOptional<z.ZodNullable<z.ZodString>>;
27
30
  }, z.ZodTypeAny, "passthrough">>;
28
31
  export declare const KmsInfoSchema: z.ZodEffects<z.ZodObject<{
29
32
  id: z.ZodString;
@@ -33,6 +36,7 @@ export declare const KmsInfoSchema: z.ZodEffects<z.ZodObject<{
33
36
  chain_id: z.ZodNullable<z.ZodNumber>;
34
37
  kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
35
38
  gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
39
+ k256_pubkey: z.ZodOptional<z.ZodNullable<z.ZodString>>;
36
40
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
37
41
  id: z.ZodString;
38
42
  slug: z.ZodNullable<z.ZodString>;
@@ -41,6 +45,7 @@ export declare const KmsInfoSchema: z.ZodEffects<z.ZodObject<{
41
45
  chain_id: z.ZodNullable<z.ZodNumber>;
42
46
  kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
43
47
  gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
48
+ k256_pubkey: z.ZodOptional<z.ZodNullable<z.ZodString>>;
44
49
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
45
50
  id: z.ZodString;
46
51
  slug: z.ZodNullable<z.ZodString>;
@@ -49,6 +54,7 @@ export declare const KmsInfoSchema: z.ZodEffects<z.ZodObject<{
49
54
  chain_id: z.ZodNullable<z.ZodNumber>;
50
55
  kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
51
56
  gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
57
+ k256_pubkey: z.ZodOptional<z.ZodNullable<z.ZodString>>;
52
58
  }, z.ZodTypeAny, "passthrough">>, z.objectOutputType<{
53
59
  id: z.ZodString;
54
60
  slug: z.ZodNullable<z.ZodString>;
@@ -57,6 +63,7 @@ export declare const KmsInfoSchema: z.ZodEffects<z.ZodObject<{
57
63
  chain_id: z.ZodNullable<z.ZodNumber>;
58
64
  kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
59
65
  gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
66
+ k256_pubkey: z.ZodOptional<z.ZodNullable<z.ZodString>>;
60
67
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
61
68
  id: z.ZodString;
62
69
  slug: z.ZodNullable<z.ZodString>;
@@ -65,6 +72,7 @@ export declare const KmsInfoSchema: z.ZodEffects<z.ZodObject<{
65
72
  chain_id: z.ZodNullable<z.ZodNumber>;
66
73
  kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
67
74
  gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
75
+ k256_pubkey: z.ZodOptional<z.ZodNullable<z.ZodString>>;
68
76
  }, z.ZodTypeAny, "passthrough">>;
69
77
  export type KmsInfo = (z.infer<typeof KmsInfoBaseSchema> & {
70
78
  chain_id: number;
@@ -22,27 +22,27 @@ import type { CvmInfoDetailV20260121, CvmInfoDetailV20260522, CvmInfoV20260121,
22
22
  /**
23
23
  * Maps API version to the auth/me response type
24
24
  */
25
- export type GetCurrentUserResponse<V extends ApiVersion> = V extends "2026-05-22" ? CurrentUserV20260121 : V extends "2026-01-21" ? CurrentUserV20260121 : V extends "2025-10-28" ? CurrentUserV20251028 : CurrentUserV20260121;
25
+ export type GetCurrentUserResponse<V extends ApiVersion> = V extends "2026-05-22" | "2026-06-23" ? CurrentUserV20260121 : V extends "2026-01-21" ? CurrentUserV20260121 : V extends "2025-10-28" ? CurrentUserV20251028 : CurrentUserV20260121;
26
26
  /**
27
27
  * Maps API version to the paginated CVM list response type
28
28
  */
29
- export type GetCvmListResponse<V extends ApiVersion> = V extends "2026-05-22" ? PaginatedCvmInfosV20260522 : V extends "2026-01-21" ? PaginatedCvmInfosV20260121 : V extends "2025-10-28" ? PaginatedCvmInfosV20251028 : PaginatedCvmInfosV20260121;
29
+ export type GetCvmListResponse<V extends ApiVersion> = V extends "2026-05-22" | "2026-06-23" ? PaginatedCvmInfosV20260522 : V extends "2026-01-21" ? PaginatedCvmInfosV20260121 : V extends "2025-10-28" ? PaginatedCvmInfosV20251028 : PaginatedCvmInfosV20260121;
30
30
  /**
31
31
  * Maps API version to the CVM info detail response type
32
32
  */
33
- export type GetCvmInfoResponse<V extends ApiVersion> = V extends "2026-05-22" ? CvmInfoDetailV20260522 : V extends "2026-01-21" ? CvmInfoDetailV20260121 : V extends "2025-10-28" ? CvmDetailV20251028 : CvmInfoDetailV20260121;
33
+ export type GetCvmInfoResponse<V extends ApiVersion> = V extends "2026-05-22" | "2026-06-23" ? CvmInfoDetailV20260522 : V extends "2026-01-21" ? CvmInfoDetailV20260121 : V extends "2025-10-28" ? CvmDetailV20251028 : CvmInfoDetailV20260121;
34
34
  /**
35
35
  * Maps API version to the app list response type
36
36
  */
37
- export type GetAppListResponse<V extends ApiVersion> = V extends "2026-05-22" ? DstackAppListResponseV20260522 : V extends "2026-01-21" ? DstackAppListResponseV20260121 : V extends "2025-10-28" ? DstackAppListResponseV20251028 : DstackAppListResponseV20260121;
37
+ export type GetAppListResponse<V extends ApiVersion> = V extends "2026-05-22" | "2026-06-23" ? DstackAppListResponseV20260522 : V extends "2026-01-21" ? DstackAppListResponseV20260121 : V extends "2025-10-28" ? DstackAppListResponseV20251028 : DstackAppListResponseV20260121;
38
38
  /**
39
39
  * Maps API version to the app info response type
40
40
  */
41
- export type GetAppInfoResponse<V extends ApiVersion> = V extends "2026-05-22" ? DstackAppWithCvmResponseV20260522 : V extends "2026-01-21" ? DstackAppWithCvmResponseV20260121 : V extends "2025-10-28" ? DstackAppWithCvmResponseV20251028 : DstackAppWithCvmResponseV20260121;
41
+ export type GetAppInfoResponse<V extends ApiVersion> = V extends "2026-05-22" | "2026-06-23" ? DstackAppWithCvmResponseV20260522 : V extends "2026-01-21" ? DstackAppWithCvmResponseV20260121 : V extends "2025-10-28" ? DstackAppWithCvmResponseV20251028 : DstackAppWithCvmResponseV20260121;
42
42
  /**
43
43
  * Maps API version to the app CVMs list response type
44
44
  */
45
- export type GetAppCvmsResponse<V extends ApiVersion> = V extends "2026-05-22" ? CvmInfoV20260522[] : V extends "2026-01-21" ? CvmInfoV20260121[] : V extends "2025-10-28" ? CvmInfoV20251028[] : CvmInfoV20260121[];
45
+ export type GetAppCvmsResponse<V extends ApiVersion> = V extends "2026-05-22" | "2026-06-23" ? CvmInfoV20260522[] : V extends "2026-01-21" ? CvmInfoV20260121[] : V extends "2025-10-28" ? CvmInfoV20251028[] : CvmInfoV20260121[];
46
46
  /**
47
47
  * Maps API version to the CVM lifecycle action response type (start/stop/restart/shutdown/replicate)
48
48
  */
@@ -44,5 +44,6 @@ export declare const ErrorCodes: {
44
44
  readonly TOKEN_LIMIT_EXCEEDED: "ERR-05-001";
45
45
  readonly TOKEN_RATE_LIMIT: "ERR-05-002";
46
46
  readonly OAUTH_EMAIL_INVALID: "ERR-06-001";
47
+ readonly PERMISSION_DENIED: "ERR-06-006";
47
48
  };
48
49
  export type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
@@ -72,6 +72,9 @@ export declare class PhalaCloudError extends Error {
72
72
  ctx?: Record<string, unknown>;
73
73
  }>;
74
74
  readonly requestId?: string;
75
+ readonly request?: FetchRequest | undefined;
76
+ readonly requestMethod?: string | undefined;
77
+ readonly data?: unknown;
75
78
  /** Machine-readable error code (e.g. "TIMEOUT", HTTP status as string). */
76
79
  readonly code?: string;
77
80
  constructor(message: string, data: {
@@ -83,6 +86,9 @@ export declare class PhalaCloudError extends Error {
83
86
  ctx?: Record<string, unknown>;
84
87
  }>;
85
88
  requestId?: string;
89
+ request?: FetchRequest | undefined;
90
+ requestMethod?: string | undefined;
91
+ data?: unknown;
86
92
  code?: string;
87
93
  });
88
94
  }
@@ -95,6 +101,7 @@ export declare class RequestError extends PhalaCloudError implements ApiError {
95
101
  readonly isRequestError: true;
96
102
  readonly data?: unknown;
97
103
  readonly request?: FetchRequest | undefined;
104
+ readonly requestMethod?: string | undefined;
98
105
  readonly response?: Response | undefined;
99
106
  readonly type?: string | undefined;
100
107
  constructor(message: string, options?: {
@@ -102,6 +109,7 @@ export declare class RequestError extends PhalaCloudError implements ApiError {
102
109
  statusText?: string | undefined;
103
110
  data?: unknown;
104
111
  request?: FetchRequest | undefined;
112
+ requestMethod?: string | undefined;
105
113
  response?: Response | undefined;
106
114
  cause?: unknown;
107
115
  detail?: string | Record<string, unknown> | Array<{
@@ -123,7 +131,7 @@ export declare class RequestError extends PhalaCloudError implements ApiError {
123
131
  /**
124
132
  * Create RequestError from generic Error
125
133
  */
126
- static fromError(error: Error, request?: FetchRequest): RequestError;
134
+ static fromError(error: Error, request?: FetchRequest, requestMethod?: string): RequestError;
127
135
  }
128
136
  /**
129
137
  * Validation error from FastAPI/Pydantic (422)
@@ -145,6 +153,8 @@ export declare class ValidationError extends PhalaCloudError {
145
153
  [key: string]: unknown;
146
154
  }>;
147
155
  validationErrors: ValidationErrorItem[];
156
+ request?: FetchRequest | undefined;
157
+ data?: unknown;
148
158
  });
149
159
  }
150
160
  /**
@@ -289,12 +299,28 @@ export declare function formatErrorMessage(error: PhalaCloudError, options?: {
289
299
  export declare function getErrorMessage(error: ApiError): string;
290
300
  /**
291
301
  * Structured error detail from new error format (ERR-xxxx codes)
302
+ *
303
+ * `value` is typed as `unknown` because the backend contract says it should be
304
+ * a primitive (string / number / boolean) but in practice some errors emit
305
+ * dict / array values (e.g. HashRegistrationRequired carries `kms_info` and
306
+ * `onchain_status` as objects). Consumers that need a string should use
307
+ * {@link formatStructuredErrorDetailValue}; consumers that need the original
308
+ * structure (e.g. CLI extracting `commit_token`) should access `value` directly.
292
309
  */
293
310
  export interface StructuredErrorDetail {
294
311
  field?: string;
295
312
  value?: unknown;
296
313
  message?: string;
297
314
  }
315
+ /**
316
+ * Coerce a {@link StructuredErrorDetail} `value` to a renderable string.
317
+ *
318
+ * - `string` returned as-is
319
+ * - `number` / `boolean` stringified via `String(...)`
320
+ * - `null` / `undefined` returned as `""` so callers never interpolate `null` literally
321
+ * - anything else (dict, array) serialized via `JSON.stringify` with a fallback to `String(...)`
322
+ */
323
+ export declare function formatStructuredErrorDetailValue(value: unknown): string;
298
324
  /**
299
325
  * Error link from structured error response
300
326
  */
@@ -338,6 +364,9 @@ export declare class ResourceError extends BusinessError {
338
364
  [key: string]: unknown;
339
365
  }>;
340
366
  requestId?: string;
367
+ request?: FetchRequest | undefined;
368
+ requestMethod?: string | undefined;
369
+ data?: unknown;
341
370
  errorCode?: string;
342
371
  structuredDetails?: StructuredErrorDetail[];
343
372
  suggestions?: string[];
@@ -5,9 +5,33 @@ export interface SortableObject {
5
5
  export interface SortableArray extends Array<SortableValue> {
6
6
  }
7
7
  export declare function sortObject(obj: SortableValue): SortableValue;
8
+ export type KeyProviderKind = "none" | "kms" | "local" | "tpm";
9
+ export interface DockerConfig extends SortableObject {
10
+ registry?: string;
11
+ username?: string;
12
+ token_key?: string;
13
+ }
8
14
  export interface AppCompose extends SortableObject {
15
+ manifest_version?: number;
16
+ name?: string;
17
+ features?: string[];
9
18
  runner?: string;
10
19
  docker_compose_file?: string;
20
+ docker_config?: DockerConfig;
21
+ public_logs?: boolean;
22
+ public_sysinfo?: boolean;
23
+ public_tcbinfo?: boolean;
24
+ kms_enabled?: boolean;
25
+ gateway_enabled?: boolean;
26
+ tproxy_enabled?: boolean;
27
+ local_key_provider_enabled?: boolean;
28
+ key_provider?: KeyProviderKind;
29
+ key_provider_id?: string;
30
+ allowed_envs?: string[];
31
+ no_instance_id?: boolean;
32
+ secure_time?: boolean;
33
+ storage_fs?: string;
34
+ swap_size?: string;
11
35
  bash_script?: string;
12
36
  pre_launch_script?: string;
13
37
  }
@@ -0,0 +1,55 @@
1
+ import { type Hex } from "viem";
2
+ /**
3
+ * Key provider kind, encoded as a single byte for mr_config_id computation.
4
+ *
5
+ * Maps to dstack-types KeyProviderKind:
6
+ * - None = 0
7
+ * - Local = 1
8
+ * - Kms = 2
9
+ * - Tpm = 3
10
+ */
11
+ declare const KEY_PROVIDER_BYTE: {
12
+ readonly none: 0;
13
+ readonly local: 1;
14
+ readonly kms: 2;
15
+ readonly tpm: 3;
16
+ };
17
+ export type KeyProviderKind = keyof typeof KEY_PROVIDER_BYTE;
18
+ export interface MrConfigIdInput {
19
+ /** SHA-256 compose hash, 32 bytes as 0x-prefixed hex */
20
+ compose_hash: Hex;
21
+ /** Application ID, 20 bytes as 0x-prefixed hex */
22
+ app_id: Hex;
23
+ /** Key provider kind */
24
+ key_provider_type: KeyProviderKind;
25
+ /** Key provider identity (CA pubkey for KMS, MR enclave for local-sgx, empty for none), hex bytes */
26
+ key_provider_id: Hex;
27
+ }
28
+ /**
29
+ * Compute mr_config_id V1 from compose_hash alone.
30
+ *
31
+ * Used when key_provider_id is empty (no key provider configured).
32
+ * Format: 0x01 || compose_hash (32 bytes) || zeros (15 bytes)
33
+ */
34
+ export declare function getMrConfigIdV1(composeHash: Hex): Hex;
35
+ /**
36
+ * Compute mr_config_id V2 from compose_hash, app_id, key_provider_type
37
+ * and key_provider_id.
38
+ *
39
+ * Mirrors dstack-types/src/mr_config.rs MrConfig::V2::to_mr_config_id().
40
+ *
41
+ * Hash input (concatenated raw bytes):
42
+ * - compose_hash: [u8; 32]
43
+ * - app_id: [u8; 20]
44
+ * - key_provider_type: u8 (none=0, local=1, kms=2, tpm=3)
45
+ * - key_provider_id: [u8] (variable length, hex-decoded)
46
+ *
47
+ * Output: 0x02 || keccak256(above) (32 bytes) || zeros (15 bytes) = 48 bytes
48
+ */
49
+ export declare function getMrConfigId(input: MrConfigIdInput): Hex;
50
+ /**
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.
53
+ */
54
+ export declare function verifyMrConfigId(mrConfigId: Hex, input: MrConfigIdInput): boolean;
55
+ export {};
@@ -1,9 +1,10 @@
1
1
  export { encryptEnvVars } from "@phala/dstack-sdk/encrypt-env-vars";
2
- export { getComposeHash, dumpAppCompose, preprocessAppCompose, sortObject, withComposeMethods, type AppCompose, type AppComposeWithMethods, type SortableValue, type SortableObject, type SortableArray, } from "./get_compose_hash";
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
4
  export { asHex } from "./as-hex";
4
5
  export { validateActionParameters, safeValidateActionParameters } from "./validate-parameters";
5
6
  export { isValidHostname, convertToHostname, generateFallbackHostname, generateDefaultCvmName, } from "./hostname";
6
- export { parseApiError, PhalaCloudError, RequestError, ValidationError, AuthError, BusinessError, ServerError, UnknownError, ResourceError, formatValidationErrors, formatErrorMessage, formatStructuredError, getErrorMessage, isConflictError, isAppIdConflictError, getValidationFields, type ValidationErrorItem, type StructuredErrorDetail, type ErrorLink, type StructuredErrorResponse, ApiErrorSchema, type ApiError, } from "./errors";
7
+ export { parseApiError, PhalaCloudError, RequestError, ValidationError, AuthError, BusinessError, ServerError, UnknownError, ResourceError, formatValidationErrors, formatErrorMessage, formatStructuredError, formatStructuredErrorDetailValue, getErrorMessage, isConflictError, isAppIdConflictError, getValidationFields, type ValidationErrorItem, type StructuredErrorDetail, type ErrorLink, type StructuredErrorResponse, ApiErrorSchema, type ApiError, } from "./errors";
7
8
  export { ErrorCodes, type ErrorCode } from "./error_codes";
8
9
  export { createNetworkClients, extractNetworkClients, checkNetworkStatus, checkBalance, validateNetworkPrerequisites, waitForTransactionReceipt, executeTransaction, NetworkError, WalletError, TransactionError, type NetworkConfig, type WalletConnection, type NetworkClients, type BalanceCheckResult, type TransactionOptions, type TransactionResult, } from "./network";
9
10
  export { createTransactionTracker, executeBatchTransactions, executeTransactionWithRetry, estimateTransactionGas, type TransactionState, type TransactionStatus, type TransactionTracker, type BatchTransactionOptions, type BatchTransactionResult, type RetryOptions, type GasEstimationOptions, } from "./transaction";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phala/cloud",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "TypeScript SDK for Phala Cloud API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -47,7 +47,7 @@
47
47
  "debug": "^4.4.1",
48
48
  "mitt": "^3.0.1",
49
49
  "ofetch": "^1.3.3",
50
- "viem": "^2.7.0",
50
+ "viem": "^2.52.2",
51
51
  "zod": "^3.24.1"
52
52
  },
53
53
  "devDependencies": {
@@ -57,7 +57,7 @@
57
57
  "dotenv": "^16.5.0",
58
58
  "tsup": "^8.5.1",
59
59
  "typescript": "^5.3.0",
60
- "vitest": "^1.0.0"
60
+ "vitest": "^4.1.8"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "typescript": ">=4.5.0"