@phala/cloud 0.2.1-beta.2 → 0.2.1-beta.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.
@@ -56,6 +56,25 @@ import { type Client } from "../../client";
56
56
  * compose_file: { /* ... *\/ },
57
57
  * });
58
58
  *
59
+ * // Example 4: Manual nonce specification (Advanced - PHALA KMS only)
60
+ * import { nextAppIds } from '@phala/cloud';
61
+ *
62
+ * // Step 1: Predict next available app_id and nonce
63
+ * const prediction = await nextAppIds(client, { counts: 1 });
64
+ * const { app_id, nonce } = prediction.app_ids[0];
65
+ *
66
+ * console.log(`Predicted app_id: ${app_id}, nonce: ${nonce}`);
67
+ *
68
+ * // Step 2: Provision with the predicted nonce and app_id
69
+ * const provision = await provisionCvm(client, {
70
+ * name: 'my-app-with-manual-nonce',
71
+ * instance_type: 'tdx.small',
72
+ * kms: 'PHALA', // Required: only works with PHALA KMS
73
+ * nonce: nonce, // Use predicted nonce
74
+ * app_id: app_id, // Use predicted app_id
75
+ * compose_file: { /* ... *\/ },
76
+ * });
77
+ *
59
78
  * console.log(provision.app_id);
60
79
  * console.log(provision.compose_hash); // Required for commitCvmProvision
61
80
  * ```
@@ -73,6 +92,19 @@ import { type Client } from "../../client";
73
92
  * - Examples: "tdx.small", "tdx.medium", "tdx.large"
74
93
  * - Omit to use the default small instance type
75
94
  *
95
+ * ### Manual Nonce Specification (Advanced - PHALA KMS only)
96
+ * - **nonce**: User-specified nonce for deterministic app_id generation
97
+ * - **app_id**: Expected app_id (must match the nonce)
98
+ * - Workflow:
99
+ * 1. Call `nextAppIds()` to predict available app_ids and nonces
100
+ * 2. Use the predicted `nonce` and `app_id` in provision request
101
+ * 3. System validates that the app_id matches the nonce
102
+ * - When `nonce` is provided:
103
+ * - `app_id` MUST also be provided
104
+ * - Only works with PHALA KMS type
105
+ * - Use case: Predicting app_id before deployment for smart contract integration
106
+ * - If both omitted, system automatically generates the next available nonce
107
+ *
76
108
  * ### Node Selection (all optional - system auto-selects if omitted)
77
109
  * - **node_id**: Specific node ID to deploy on
78
110
  * - **region**: Region preference (e.g., "us-east", "eu-west")
@@ -224,6 +256,8 @@ export declare const ProvisionCvmRequestSchema: z.ZodObject<{
224
256
  kms: z.ZodOptional<z.ZodEnum<["PHALA", "ETHEREUM", "BASE"]>>;
225
257
  kms_contract: z.ZodOptional<z.ZodString>;
226
258
  env_keys: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
259
+ nonce: z.ZodOptional<z.ZodNumber>;
260
+ app_id: z.ZodOptional<z.ZodString>;
227
261
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
228
262
  node_id: z.ZodOptional<z.ZodNumber>;
229
263
  teepod_id: z.ZodOptional<z.ZodNumber>;
@@ -270,6 +304,8 @@ export declare const ProvisionCvmRequestSchema: z.ZodObject<{
270
304
  kms: z.ZodOptional<z.ZodEnum<["PHALA", "ETHEREUM", "BASE"]>>;
271
305
  kms_contract: z.ZodOptional<z.ZodString>;
272
306
  env_keys: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
307
+ nonce: z.ZodOptional<z.ZodNumber>;
308
+ app_id: z.ZodOptional<z.ZodString>;
273
309
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
274
310
  node_id: z.ZodOptional<z.ZodNumber>;
275
311
  teepod_id: z.ZodOptional<z.ZodNumber>;
@@ -316,6 +352,8 @@ export declare const ProvisionCvmRequestSchema: z.ZodObject<{
316
352
  kms: z.ZodOptional<z.ZodEnum<["PHALA", "ETHEREUM", "BASE"]>>;
317
353
  kms_contract: z.ZodOptional<z.ZodString>;
318
354
  env_keys: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
355
+ nonce: z.ZodOptional<z.ZodNumber>;
356
+ app_id: z.ZodOptional<z.ZodString>;
319
357
  }, z.ZodTypeAny, "passthrough">>;
320
358
  export type ProvisionCvmRequest = z.input<typeof ProvisionCvmRequestSchema> & {
321
359
  node_id?: number;
@@ -325,6 +363,8 @@ export type ProvisionCvmRequest = z.input<typeof ProvisionCvmRequestSchema> & {
325
363
  tproxy_enabled?: boolean;
326
364
  [key: string]: unknown;
327
365
  };
366
+ nonce?: number;
367
+ app_id?: string;
328
368
  };
329
369
  declare const provisionCvm: {
330
370
  (client: Client, params: ProvisionCvmRequest): Promise<z.objectOutputType<{
@@ -0,0 +1,512 @@
1
+ import { z } from "zod";
2
+ import { type Client } from "../../client";
3
+ /**
4
+ * Update CVM environment variables
5
+ *
6
+ * Updates environment variables for a CVM. Supports two scenarios:
7
+ * 1. Encrypted environment only: Direct update without compose hash verification
8
+ * 2. Allowed environment keys change: Requires compose hash verification (two-phase)
9
+ *
10
+ * When allowed_envs changes and compose_hash/transaction_hash are not provided,
11
+ * the API returns HTTP 428 (Precondition Required) with the compose hash to sign.
12
+ * The client should then register the compose hash on-chain and retry the request
13
+ * with both compose_hash and transaction_hash.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * import { createClient, updateCvmEnvs } from '@phala/cloud'
18
+ *
19
+ * const client = createClient({ apiKey: 'your-api-key' })
20
+ *
21
+ * // Phase 1: Initial update (may return precondition_required)
22
+ * const result = await updateCvmEnvs(client, {
23
+ * id: 'cvm-123',
24
+ * encrypted_env: 'hex-encoded-encrypted-data',
25
+ * env_keys: ['API_KEY', 'DATABASE_URL']
26
+ * })
27
+ *
28
+ * if (result.status === 'precondition_required') {
29
+ * // Register compose hash on-chain and get transaction hash
30
+ * const txHash = await registerComposeHashOnChain(
31
+ * result.compose_hash,
32
+ * result.kms_info
33
+ * )
34
+ *
35
+ * // Phase 2: Retry with compose hash and transaction hash
36
+ * const finalResult = await updateCvmEnvs(client, {
37
+ * id: 'cvm-123',
38
+ * encrypted_env: 'hex-encoded-encrypted-data',
39
+ * env_keys: ['API_KEY', 'DATABASE_URL'],
40
+ * compose_hash: result.compose_hash,
41
+ * transaction_hash: txHash
42
+ * })
43
+ *
44
+ * if (finalResult.status === 'in_progress') {
45
+ * console.log(`Update started: ${finalResult.correlation_id}`)
46
+ * }
47
+ * }
48
+ * ```
49
+ *
50
+ * ## Returns
51
+ *
52
+ * `UpdateCvmEnvsResult | unknown`
53
+ *
54
+ * Returns either:
55
+ * - `{ status: "in_progress", ... }` - Update initiated successfully
56
+ * - `{ status: "precondition_required", compose_hash: "...", ... }` - Compose hash verification required
57
+ *
58
+ * Return type depends on schema parameter.
59
+ *
60
+ * ## Parameters
61
+ *
62
+ * ### request (required)
63
+ * - **Type:** `UpdateCvmEnvsRequest`
64
+ *
65
+ * Request parameters containing CVM ID, encrypted environment, and optional env_keys/compose_hash.
66
+ *
67
+ * ### parameters (optional)
68
+ * - **Type:** `UpdateCvmEnvsParameters`
69
+ *
70
+ * Optional behavior parameters for schema validation.
71
+ *
72
+ * ```typescript
73
+ * // Use default schema
74
+ * const result = await updateCvmEnvs(client, {
75
+ * id: 'cvm-123',
76
+ * encrypted_env: 'hex-data'
77
+ * })
78
+ *
79
+ * // Return raw data without validation
80
+ * const raw = await updateCvmEnvs(client, request, { schema: false })
81
+ *
82
+ * // Use custom schema
83
+ * const customSchema = z.object({ status: z.string() })
84
+ * const custom = await updateCvmEnvs(client, request, { schema: customSchema })
85
+ * ```
86
+ *
87
+ * ## Safe Version
88
+ *
89
+ * Use `safeUpdateCvmEnvs` for error handling without exceptions:
90
+ *
91
+ * ```typescript
92
+ * import { safeUpdateCvmEnvs } from '@phala/cloud'
93
+ *
94
+ * const result = await safeUpdateCvmEnvs(client, {
95
+ * id: 'cvm-123',
96
+ * encrypted_env: 'hex-data',
97
+ * env_keys: ['API_KEY']
98
+ * })
99
+ *
100
+ * if (result.success) {
101
+ * if (result.data.status === 'precondition_required') {
102
+ * console.log(`Compose hash: ${result.data.compose_hash}`)
103
+ * console.log(`App ID: ${result.data.app_id}`)
104
+ * // Register on-chain and retry with transaction_hash
105
+ * } else {
106
+ * console.log(`Update started: ${result.data.correlation_id}`)
107
+ * }
108
+ * } else {
109
+ * if ("isRequestError" in result.error) {
110
+ * console.error(`HTTP ${result.error.status}: ${result.error.message}`)
111
+ * } else {
112
+ * console.error(`Validation error: ${result.error.issues}`)
113
+ * }
114
+ * }
115
+ * ```
116
+ */
117
+ export declare const UpdateCvmEnvsRequestSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
118
+ id: z.ZodOptional<z.ZodString>;
119
+ uuid: z.ZodOptional<z.ZodString>;
120
+ app_id: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
121
+ instance_id: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
122
+ encrypted_env: z.ZodString;
123
+ env_keys: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
124
+ compose_hash: z.ZodOptional<z.ZodString>;
125
+ transaction_hash: z.ZodOptional<z.ZodString>;
126
+ }, "strip", z.ZodTypeAny, {
127
+ encrypted_env: string;
128
+ id?: string | undefined;
129
+ app_id?: string | undefined;
130
+ instance_id?: string | undefined;
131
+ uuid?: string | undefined;
132
+ compose_hash?: string | undefined;
133
+ env_keys?: string[] | undefined;
134
+ transaction_hash?: string | undefined;
135
+ }, {
136
+ encrypted_env: string;
137
+ id?: string | undefined;
138
+ app_id?: string | undefined;
139
+ instance_id?: string | undefined;
140
+ uuid?: string | undefined;
141
+ compose_hash?: string | undefined;
142
+ env_keys?: string[] | undefined;
143
+ transaction_hash?: string | undefined;
144
+ }>, {
145
+ encrypted_env: string;
146
+ id?: string | undefined;
147
+ app_id?: string | undefined;
148
+ instance_id?: string | undefined;
149
+ uuid?: string | undefined;
150
+ compose_hash?: string | undefined;
151
+ env_keys?: string[] | undefined;
152
+ transaction_hash?: string | undefined;
153
+ }, {
154
+ encrypted_env: string;
155
+ id?: string | undefined;
156
+ app_id?: string | undefined;
157
+ instance_id?: string | undefined;
158
+ uuid?: string | undefined;
159
+ compose_hash?: string | undefined;
160
+ env_keys?: string[] | undefined;
161
+ transaction_hash?: string | undefined;
162
+ }>, {
163
+ cvmId: string | undefined;
164
+ request: {
165
+ encrypted_env: string;
166
+ env_keys: string[] | undefined;
167
+ compose_hash: string | undefined;
168
+ transaction_hash: string | undefined;
169
+ };
170
+ _raw: {
171
+ encrypted_env: string;
172
+ id?: string | undefined;
173
+ app_id?: string | undefined;
174
+ instance_id?: string | undefined;
175
+ uuid?: string | undefined;
176
+ compose_hash?: string | undefined;
177
+ env_keys?: string[] | undefined;
178
+ transaction_hash?: string | undefined;
179
+ };
180
+ }, {
181
+ encrypted_env: string;
182
+ id?: string | undefined;
183
+ app_id?: string | undefined;
184
+ instance_id?: string | undefined;
185
+ uuid?: string | undefined;
186
+ compose_hash?: string | undefined;
187
+ env_keys?: string[] | undefined;
188
+ transaction_hash?: string | undefined;
189
+ }>;
190
+ declare const UpdateCvmEnvsInProgressSchema: z.ZodObject<{
191
+ status: z.ZodLiteral<"in_progress">;
192
+ message: z.ZodString;
193
+ correlation_id: z.ZodString;
194
+ allowed_envs_changed: z.ZodBoolean;
195
+ }, "strip", z.ZodTypeAny, {
196
+ status: "in_progress";
197
+ message: string;
198
+ correlation_id: string;
199
+ allowed_envs_changed: boolean;
200
+ }, {
201
+ status: "in_progress";
202
+ message: string;
203
+ correlation_id: string;
204
+ allowed_envs_changed: boolean;
205
+ }>;
206
+ declare const UpdateCvmEnvsPreconditionRequiredSchema: z.ZodObject<{
207
+ status: z.ZodLiteral<"precondition_required">;
208
+ message: z.ZodString;
209
+ compose_hash: z.ZodString;
210
+ app_id: z.ZodString;
211
+ device_id: z.ZodString;
212
+ kms_info: z.ZodEffects<z.ZodObject<{
213
+ id: z.ZodString;
214
+ slug: z.ZodNullable<z.ZodString>;
215
+ url: z.ZodString;
216
+ version: z.ZodString;
217
+ chain_id: z.ZodNullable<z.ZodNumber>;
218
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
219
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
220
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
221
+ id: z.ZodString;
222
+ slug: z.ZodNullable<z.ZodString>;
223
+ url: z.ZodString;
224
+ version: z.ZodString;
225
+ chain_id: z.ZodNullable<z.ZodNumber>;
226
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
227
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
228
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
229
+ id: z.ZodString;
230
+ slug: z.ZodNullable<z.ZodString>;
231
+ url: z.ZodString;
232
+ version: z.ZodString;
233
+ chain_id: z.ZodNullable<z.ZodNumber>;
234
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
235
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
236
+ }, z.ZodTypeAny, "passthrough">>, z.objectOutputType<{
237
+ id: z.ZodString;
238
+ slug: z.ZodNullable<z.ZodString>;
239
+ url: z.ZodString;
240
+ version: z.ZodString;
241
+ chain_id: z.ZodNullable<z.ZodNumber>;
242
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
243
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
244
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
245
+ id: z.ZodString;
246
+ slug: z.ZodNullable<z.ZodString>;
247
+ url: z.ZodString;
248
+ version: z.ZodString;
249
+ chain_id: z.ZodNullable<z.ZodNumber>;
250
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
251
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
252
+ }, z.ZodTypeAny, "passthrough">>;
253
+ }, "strip", z.ZodTypeAny, {
254
+ status: "precondition_required";
255
+ message: string;
256
+ device_id: string;
257
+ app_id: string;
258
+ kms_info: {
259
+ version: string;
260
+ id: string;
261
+ slug: string | null;
262
+ url: string;
263
+ chain_id: number | null;
264
+ kms_contract_address: `0x${string}`;
265
+ gateway_app_id: `0x${string}`;
266
+ } & {
267
+ [k: string]: unknown;
268
+ };
269
+ compose_hash: string;
270
+ }, {
271
+ status: "precondition_required";
272
+ message: string;
273
+ device_id: string;
274
+ app_id: string;
275
+ kms_info: {
276
+ version: string;
277
+ id: string;
278
+ slug: string | null;
279
+ url: string;
280
+ chain_id: number | null;
281
+ kms_contract_address: string | null;
282
+ gateway_app_id: string | null;
283
+ } & {
284
+ [k: string]: unknown;
285
+ };
286
+ compose_hash: string;
287
+ }>;
288
+ export declare const UpdateCvmEnvsResultSchema: z.ZodUnion<[z.ZodObject<{
289
+ status: z.ZodLiteral<"in_progress">;
290
+ message: z.ZodString;
291
+ correlation_id: z.ZodString;
292
+ allowed_envs_changed: z.ZodBoolean;
293
+ }, "strip", z.ZodTypeAny, {
294
+ status: "in_progress";
295
+ message: string;
296
+ correlation_id: string;
297
+ allowed_envs_changed: boolean;
298
+ }, {
299
+ status: "in_progress";
300
+ message: string;
301
+ correlation_id: string;
302
+ allowed_envs_changed: boolean;
303
+ }>, z.ZodObject<{
304
+ status: z.ZodLiteral<"precondition_required">;
305
+ message: z.ZodString;
306
+ compose_hash: z.ZodString;
307
+ app_id: z.ZodString;
308
+ device_id: z.ZodString;
309
+ kms_info: z.ZodEffects<z.ZodObject<{
310
+ id: z.ZodString;
311
+ slug: z.ZodNullable<z.ZodString>;
312
+ url: z.ZodString;
313
+ version: z.ZodString;
314
+ chain_id: z.ZodNullable<z.ZodNumber>;
315
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
316
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
317
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
318
+ id: z.ZodString;
319
+ slug: z.ZodNullable<z.ZodString>;
320
+ url: z.ZodString;
321
+ version: z.ZodString;
322
+ chain_id: z.ZodNullable<z.ZodNumber>;
323
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
324
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
325
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
326
+ id: z.ZodString;
327
+ slug: z.ZodNullable<z.ZodString>;
328
+ url: z.ZodString;
329
+ version: z.ZodString;
330
+ chain_id: z.ZodNullable<z.ZodNumber>;
331
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
332
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
333
+ }, z.ZodTypeAny, "passthrough">>, z.objectOutputType<{
334
+ id: z.ZodString;
335
+ slug: z.ZodNullable<z.ZodString>;
336
+ url: z.ZodString;
337
+ version: z.ZodString;
338
+ chain_id: z.ZodNullable<z.ZodNumber>;
339
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
340
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
341
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
342
+ id: z.ZodString;
343
+ slug: z.ZodNullable<z.ZodString>;
344
+ url: z.ZodString;
345
+ version: z.ZodString;
346
+ chain_id: z.ZodNullable<z.ZodNumber>;
347
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
348
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
349
+ }, z.ZodTypeAny, "passthrough">>;
350
+ }, "strip", z.ZodTypeAny, {
351
+ status: "precondition_required";
352
+ message: string;
353
+ device_id: string;
354
+ app_id: string;
355
+ kms_info: {
356
+ version: string;
357
+ id: string;
358
+ slug: string | null;
359
+ url: string;
360
+ chain_id: number | null;
361
+ kms_contract_address: `0x${string}`;
362
+ gateway_app_id: `0x${string}`;
363
+ } & {
364
+ [k: string]: unknown;
365
+ };
366
+ compose_hash: string;
367
+ }, {
368
+ status: "precondition_required";
369
+ message: string;
370
+ device_id: string;
371
+ app_id: string;
372
+ kms_info: {
373
+ version: string;
374
+ id: string;
375
+ slug: string | null;
376
+ url: string;
377
+ chain_id: number | null;
378
+ kms_contract_address: string | null;
379
+ gateway_app_id: string | null;
380
+ } & {
381
+ [k: string]: unknown;
382
+ };
383
+ compose_hash: string;
384
+ }>]>;
385
+ export type UpdateCvmEnvsRequest = z.input<typeof UpdateCvmEnvsRequestSchema>;
386
+ export type UpdateCvmEnvsResult = z.infer<typeof UpdateCvmEnvsResultSchema>;
387
+ export type UpdateCvmEnvsInProgress = z.infer<typeof UpdateCvmEnvsInProgressSchema>;
388
+ export type UpdateCvmEnvsPreconditionRequired = z.infer<typeof UpdateCvmEnvsPreconditionRequiredSchema>;
389
+ /**
390
+ * Update CVM environment variables
391
+ *
392
+ * @param client - The API client
393
+ * @param request - Request parameters containing CVM ID and environment data
394
+ * @param parameters - Optional behavior parameters
395
+ * @returns Update result (either in_progress or precondition_required)
396
+ */
397
+ declare const updateCvmEnvs: {
398
+ (client: Client, params: {
399
+ encrypted_env: string;
400
+ id?: string | undefined;
401
+ app_id?: string | undefined;
402
+ instance_id?: string | undefined;
403
+ uuid?: string | undefined;
404
+ compose_hash?: string | undefined;
405
+ env_keys?: string[] | undefined;
406
+ transaction_hash?: string | undefined;
407
+ }): Promise<{
408
+ status: "in_progress";
409
+ message: string;
410
+ correlation_id: string;
411
+ allowed_envs_changed: boolean;
412
+ } | {
413
+ status: "precondition_required";
414
+ message: string;
415
+ device_id: string;
416
+ app_id: string;
417
+ kms_info: {
418
+ version: string;
419
+ id: string;
420
+ slug: string | null;
421
+ url: string;
422
+ chain_id: number | null;
423
+ kms_contract_address: `0x${string}`;
424
+ gateway_app_id: `0x${string}`;
425
+ } & {
426
+ [k: string]: unknown;
427
+ };
428
+ compose_hash: string;
429
+ }>;
430
+ <T extends z.ZodTypeAny>(client: Client, params: {
431
+ encrypted_env: string;
432
+ id?: string | undefined;
433
+ app_id?: string | undefined;
434
+ instance_id?: string | undefined;
435
+ uuid?: string | undefined;
436
+ compose_hash?: string | undefined;
437
+ env_keys?: string[] | undefined;
438
+ transaction_hash?: string | undefined;
439
+ }, parameters: {
440
+ schema: T;
441
+ }): Promise<z.TypeOf<T>>;
442
+ (client: Client, params: {
443
+ encrypted_env: string;
444
+ id?: string | undefined;
445
+ app_id?: string | undefined;
446
+ instance_id?: string | undefined;
447
+ uuid?: string | undefined;
448
+ compose_hash?: string | undefined;
449
+ env_keys?: string[] | undefined;
450
+ transaction_hash?: string | undefined;
451
+ }, parameters: {
452
+ schema: false;
453
+ }): Promise<unknown>;
454
+ }, safeUpdateCvmEnvs: {
455
+ (client: Client, params: {
456
+ encrypted_env: string;
457
+ id?: string | undefined;
458
+ app_id?: string | undefined;
459
+ instance_id?: string | undefined;
460
+ uuid?: string | undefined;
461
+ compose_hash?: string | undefined;
462
+ env_keys?: string[] | undefined;
463
+ transaction_hash?: string | undefined;
464
+ }): Promise<import("../..").SafeResult<{
465
+ status: "in_progress";
466
+ message: string;
467
+ correlation_id: string;
468
+ allowed_envs_changed: boolean;
469
+ } | {
470
+ status: "precondition_required";
471
+ message: string;
472
+ device_id: string;
473
+ app_id: string;
474
+ kms_info: {
475
+ version: string;
476
+ id: string;
477
+ slug: string | null;
478
+ url: string;
479
+ chain_id: number | null;
480
+ kms_contract_address: `0x${string}`;
481
+ gateway_app_id: `0x${string}`;
482
+ } & {
483
+ [k: string]: unknown;
484
+ };
485
+ compose_hash: string;
486
+ }>>;
487
+ <T extends z.ZodTypeAny>(client: Client, params: {
488
+ encrypted_env: string;
489
+ id?: string | undefined;
490
+ app_id?: string | undefined;
491
+ instance_id?: string | undefined;
492
+ uuid?: string | undefined;
493
+ compose_hash?: string | undefined;
494
+ env_keys?: string[] | undefined;
495
+ transaction_hash?: string | undefined;
496
+ }, parameters: {
497
+ schema: T;
498
+ }): Promise<import("../..").SafeResult<z.TypeOf<T>>>;
499
+ (client: Client, params: {
500
+ encrypted_env: string;
501
+ id?: string | undefined;
502
+ app_id?: string | undefined;
503
+ instance_id?: string | undefined;
504
+ uuid?: string | undefined;
505
+ compose_hash?: string | undefined;
506
+ env_keys?: string[] | undefined;
507
+ transaction_hash?: string | undefined;
508
+ }, parameters: {
509
+ schema: false;
510
+ }): Promise<import("../..").SafeResult<unknown>>;
511
+ };
512
+ export { updateCvmEnvs, safeUpdateCvmEnvs };
@@ -7,6 +7,7 @@ export { addComposeHash, safeAddComposeHash, type AddComposeHashParameters, type
7
7
  export { getCvmComposeFile, safeGetCvmComposeFile, type GetCvmComposeFileResult, GetCvmComposeFileRequestSchema, type GetCvmComposeFileRequest, } from "./cvms/get_cvm_compose_file";
8
8
  export { provisionCvmComposeFileUpdate, safeProvisionCvmComposeFileUpdate, ProvisionCvmComposeFileUpdateRequestSchema, type ProvisionCvmComposeFileUpdateRequest, ProvisionCvmComposeFileUpdateResultSchema, type ProvisionCvmComposeFileUpdateResult, } from "./cvms/provision_cvm_compose_file_update";
9
9
  export { commitCvmComposeFileUpdate, safeCommitCvmComposeFileUpdate, CommitCvmComposeFileUpdateRequestSchema, type CommitCvmComposeFileUpdateRequest, CommitCvmComposeFileUpdateSchema, type CommitCvmComposeFileUpdate, } from "./cvms/commit_cvm_compose_file_update";
10
+ export { updateCvmEnvs, safeUpdateCvmEnvs, UpdateCvmEnvsRequestSchema, type UpdateCvmEnvsRequest, UpdateCvmEnvsResultSchema, type UpdateCvmEnvsResult, type UpdateCvmEnvsInProgress, type UpdateCvmEnvsPreconditionRequired, } from "./cvms/update_cvm_envs";
10
11
  export { getAppEnvEncryptPubKey, safeGetAppEnvEncryptPubKey, GetAppEnvEncryptPubKeySchema, type GetAppEnvEncryptPubKeyRequest, type GetAppEnvEncryptPubKey, GetAppEnvEncryptPubKeyRequestSchema, } from "./kms/get_app_env_encrypt_pubkey";
11
12
  export { getCvmInfo, safeGetCvmInfo, CvmLegacyDetailSchema, GetCvmInfoRequestSchema, type GetCvmInfoRequest, type GetCvmInfoResponse, } from "./cvms/get_cvm_info";
12
13
  export { getCvmList, safeGetCvmList, GetCvmListSchema, GetCvmListRequestSchema, type GetCvmListRequest, type GetCvmListResponse, } from "./cvms/get_cvm_list";
package/dist/client.d.ts CHANGED
@@ -4,6 +4,7 @@ import { type SafeResult, type ClientConfig } from "./types/client";
4
4
  import type { Prettify } from "./types/common";
5
5
  import { PhalaCloudError } from "./utils/errors";
6
6
  export type { SafeResult } from "./types/client";
7
+ export declare const SUPPORTED_API_VERSIONS: readonly ["2025-05-31", "2025-10-28"];
7
8
  /**
8
9
  * Client event types
9
10
  */
@@ -12,6 +12,7 @@ import { type CommitCvmProvisionRequest, type CommitCvmProvision } from "./actio
12
12
  import { type GetCvmComposeFileRequest, type GetCvmComposeFileResult } from "./actions/cvms/get_cvm_compose_file";
13
13
  import { type ProvisionCvmComposeFileUpdateRequest, type ProvisionCvmComposeFileUpdateResult } from "./actions/cvms/provision_cvm_compose_file_update";
14
14
  import { type CommitCvmComposeFileUpdateRequest, type CommitCvmComposeFileUpdate } from "./actions/cvms/commit_cvm_compose_file_update";
15
+ import { type UpdateCvmEnvsRequest, type UpdateCvmEnvsResult } from "./actions/cvms/update_cvm_envs";
15
16
  import { type GetKmsInfoRequest } from "./actions/kms/get_kms_info";
16
17
  import { type GetKmsListRequest, type GetKmsListResponse } from "./actions/kms/get_kms_list";
17
18
  import { type GetAppEnvEncryptPubKeyRequest, type GetAppEnvEncryptPubKey as GetAppEnvEncryptPubKeyResult } from "./actions/kms/get_app_env_encrypt_pubkey";
@@ -267,6 +268,20 @@ export interface Client extends BaseClient {
267
268
  safeCommitCvmComposeFileUpdate(request: CommitCvmComposeFileUpdateRequest, parameters: {
268
269
  schema: false;
269
270
  }): Promise<SafeResult<unknown>>;
271
+ updateCvmEnvs(request: UpdateCvmEnvsRequest): Promise<UpdateCvmEnvsResult>;
272
+ updateCvmEnvs<T extends z.ZodTypeAny>(request: UpdateCvmEnvsRequest, parameters: {
273
+ schema: T;
274
+ }): Promise<z.infer<T>>;
275
+ updateCvmEnvs(request: UpdateCvmEnvsRequest, parameters: {
276
+ schema: false;
277
+ }): Promise<unknown>;
278
+ safeUpdateCvmEnvs(request: UpdateCvmEnvsRequest): Promise<SafeResult<UpdateCvmEnvsResult>>;
279
+ safeUpdateCvmEnvs<T extends z.ZodTypeAny>(request: UpdateCvmEnvsRequest, parameters: {
280
+ schema: T;
281
+ }): Promise<SafeResult<z.infer<T>>>;
282
+ safeUpdateCvmEnvs(request: UpdateCvmEnvsRequest, parameters: {
283
+ schema: false;
284
+ }): Promise<SafeResult<unknown>>;
270
285
  getKmsInfo(request: GetKmsInfoRequest): Promise<KmsInfo>;
271
286
  getKmsInfo<T extends z.ZodTypeAny>(request: GetKmsInfoRequest, parameters: {
272
287
  schema: T;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { createClient as createBaseClient, type Client as BaseClient } from "./client";
1
+ export { createClient as createBaseClient, type Client as BaseClient, SUPPORTED_API_VERSIONS, } from "./client";
2
2
  export { createClient, type Client } from "./create-client";
3
3
  export * from "./types";
4
4
  export * from "./actions";