@phala/cloud 0.2.1-beta.1 → 0.2.1-beta.3
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_state.d.ts +31 -11
- package/dist/actions/cvms/provision_cvm.d.ts +41 -1
- package/dist/client.d.ts +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +16 -6
- package/dist/index.mjs +15 -6
- package/package.json +4 -4
|
@@ -5,23 +5,35 @@ import { type CvmIdInput } from "../../types/cvm_id";
|
|
|
5
5
|
* CVM state response schema
|
|
6
6
|
*/
|
|
7
7
|
export declare const CvmStateSchema: z.ZodObject<{
|
|
8
|
-
|
|
9
|
-
derived_status: z.ZodOptional<z.ZodString>;
|
|
10
|
-
vm_uuid: z.ZodOptional<z.ZodString>;
|
|
8
|
+
id: z.ZodOptional<z.ZodString>;
|
|
11
9
|
instance_id: z.ZodOptional<z.ZodString>;
|
|
10
|
+
name: z.ZodString;
|
|
11
|
+
status: z.ZodString;
|
|
12
12
|
uptime: z.ZodOptional<z.ZodString>;
|
|
13
|
+
exited_at: z.ZodOptional<z.ZodString>;
|
|
14
|
+
boot_progress: z.ZodOptional<z.ZodString>;
|
|
15
|
+
boot_error: z.ZodOptional<z.ZodString>;
|
|
16
|
+
shutdown_progress: z.ZodOptional<z.ZodString>;
|
|
13
17
|
}, "strip", z.ZodTypeAny, {
|
|
14
18
|
status: string;
|
|
19
|
+
name: string;
|
|
20
|
+
id?: string | undefined;
|
|
15
21
|
uptime?: string | undefined;
|
|
16
22
|
instance_id?: string | undefined;
|
|
17
|
-
|
|
18
|
-
|
|
23
|
+
exited_at?: string | undefined;
|
|
24
|
+
boot_progress?: string | undefined;
|
|
25
|
+
boot_error?: string | undefined;
|
|
26
|
+
shutdown_progress?: string | undefined;
|
|
19
27
|
}, {
|
|
20
28
|
status: string;
|
|
29
|
+
name: string;
|
|
30
|
+
id?: string | undefined;
|
|
21
31
|
uptime?: string | undefined;
|
|
22
32
|
instance_id?: string | undefined;
|
|
23
|
-
|
|
24
|
-
|
|
33
|
+
exited_at?: string | undefined;
|
|
34
|
+
boot_progress?: string | undefined;
|
|
35
|
+
boot_error?: string | undefined;
|
|
36
|
+
shutdown_progress?: string | undefined;
|
|
25
37
|
}>;
|
|
26
38
|
export type CvmState = z.infer<typeof CvmStateSchema>;
|
|
27
39
|
export declare const GetCvmStateRequestSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
@@ -64,10 +76,14 @@ export type GetCvmStateRequest = CvmIdInput;
|
|
|
64
76
|
declare const getCvmState: {
|
|
65
77
|
(client: Client, params: CvmIdInput): Promise<{
|
|
66
78
|
status: string;
|
|
79
|
+
name: string;
|
|
80
|
+
id?: string | undefined;
|
|
67
81
|
uptime?: string | undefined;
|
|
68
82
|
instance_id?: string | undefined;
|
|
69
|
-
|
|
70
|
-
|
|
83
|
+
exited_at?: string | undefined;
|
|
84
|
+
boot_progress?: string | undefined;
|
|
85
|
+
boot_error?: string | undefined;
|
|
86
|
+
shutdown_progress?: string | undefined;
|
|
71
87
|
}>;
|
|
72
88
|
<T extends z.ZodTypeAny>(client: Client, params: CvmIdInput, parameters: {
|
|
73
89
|
schema: T;
|
|
@@ -78,10 +94,14 @@ declare const getCvmState: {
|
|
|
78
94
|
}, safeGetCvmState: {
|
|
79
95
|
(client: Client, params: CvmIdInput): Promise<import("../..").SafeResult<{
|
|
80
96
|
status: string;
|
|
97
|
+
name: string;
|
|
98
|
+
id?: string | undefined;
|
|
81
99
|
uptime?: string | undefined;
|
|
82
100
|
instance_id?: string | undefined;
|
|
83
|
-
|
|
84
|
-
|
|
101
|
+
exited_at?: string | undefined;
|
|
102
|
+
boot_progress?: string | undefined;
|
|
103
|
+
boot_error?: string | undefined;
|
|
104
|
+
shutdown_progress?: string | undefined;
|
|
85
105
|
}>>;
|
|
86
106
|
<T extends z.ZodTypeAny>(client: Client, params: CvmIdInput, parameters: {
|
|
87
107
|
schema: T;
|
|
@@ -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,8 +352,10 @@ 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
|
-
export type ProvisionCvmRequest = z.
|
|
358
|
+
export type ProvisionCvmRequest = z.input<typeof ProvisionCvmRequestSchema> & {
|
|
321
359
|
node_id?: number;
|
|
322
360
|
teepod_id?: number;
|
|
323
361
|
compose_file?: {
|
|
@@ -325,6 +363,8 @@ export type ProvisionCvmRequest = z.infer<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<{
|
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
|
*/
|
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";
|
package/dist/index.js
CHANGED
|
@@ -94,6 +94,7 @@ __export(index_exports, {
|
|
|
94
94
|
RequestError: () => RequestError,
|
|
95
95
|
ResourceError: () => ResourceError,
|
|
96
96
|
RestartCvmRequestSchema: () => RestartCvmRequestSchema,
|
|
97
|
+
SUPPORTED_API_VERSIONS: () => SUPPORTED_API_VERSIONS,
|
|
97
98
|
SUPPORTED_CHAINS: () => SUPPORTED_CHAINS,
|
|
98
99
|
ServerError: () => ServerError,
|
|
99
100
|
ShutdownCvmRequestSchema: () => ShutdownCvmRequestSchema,
|
|
@@ -1413,7 +1414,12 @@ var ProvisionCvmRequestSchema = import_zod10.z.object({
|
|
|
1413
1414
|
// KMS type selection (defaults to PHALA)
|
|
1414
1415
|
kms_contract: import_zod10.z.string().optional(),
|
|
1415
1416
|
// KMS contract address for on-chain KMS
|
|
1416
|
-
env_keys: import_zod10.z.array(import_zod10.z.string()).optional()
|
|
1417
|
+
env_keys: import_zod10.z.array(import_zod10.z.string()).optional(),
|
|
1418
|
+
// Manual nonce specification (Advanced - PHALA KMS only)
|
|
1419
|
+
nonce: import_zod10.z.number().optional(),
|
|
1420
|
+
// User-specified nonce for deterministic app_id generation
|
|
1421
|
+
app_id: import_zod10.z.string().optional()
|
|
1422
|
+
// Expected app_id (must match calculated app_id from nonce)
|
|
1417
1423
|
}).passthrough();
|
|
1418
1424
|
function handleGatewayCompatibility(appCompose) {
|
|
1419
1425
|
if (!appCompose.compose_file) {
|
|
@@ -2004,12 +2010,15 @@ var { action: updateOsImage, safeAction: safeUpdateOsImage } = defineAction(impo
|
|
|
2004
2010
|
// src/actions/cvms/get_cvm_state.ts
|
|
2005
2011
|
var import_zod30 = require("zod");
|
|
2006
2012
|
var CvmStateSchema = import_zod30.z.object({
|
|
2007
|
-
|
|
2008
|
-
derived_status: import_zod30.z.string().optional(),
|
|
2009
|
-
vm_uuid: import_zod30.z.string().optional(),
|
|
2013
|
+
id: import_zod30.z.string().optional(),
|
|
2010
2014
|
instance_id: import_zod30.z.string().optional(),
|
|
2011
|
-
|
|
2012
|
-
|
|
2015
|
+
name: import_zod30.z.string(),
|
|
2016
|
+
status: import_zod30.z.string(),
|
|
2017
|
+
uptime: import_zod30.z.string().optional(),
|
|
2018
|
+
exited_at: import_zod30.z.string().optional(),
|
|
2019
|
+
boot_progress: import_zod30.z.string().optional(),
|
|
2020
|
+
boot_error: import_zod30.z.string().optional(),
|
|
2021
|
+
shutdown_progress: import_zod30.z.string().optional()
|
|
2013
2022
|
});
|
|
2014
2023
|
var GetCvmStateRequestSchema = CvmIdSchema;
|
|
2015
2024
|
var { action: getCvmState, safeAction: safeGetCvmState } = defineAction(CvmStateSchema, async (client, request) => {
|
|
@@ -3593,6 +3602,7 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
3593
3602
|
RequestError,
|
|
3594
3603
|
ResourceError,
|
|
3595
3604
|
RestartCvmRequestSchema,
|
|
3605
|
+
SUPPORTED_API_VERSIONS,
|
|
3596
3606
|
SUPPORTED_CHAINS,
|
|
3597
3607
|
ServerError,
|
|
3598
3608
|
ShutdownCvmRequestSchema,
|
package/dist/index.mjs
CHANGED
|
@@ -1189,7 +1189,12 @@ var ProvisionCvmRequestSchema = z10.object({
|
|
|
1189
1189
|
// KMS type selection (defaults to PHALA)
|
|
1190
1190
|
kms_contract: z10.string().optional(),
|
|
1191
1191
|
// KMS contract address for on-chain KMS
|
|
1192
|
-
env_keys: z10.array(z10.string()).optional()
|
|
1192
|
+
env_keys: z10.array(z10.string()).optional(),
|
|
1193
|
+
// Manual nonce specification (Advanced - PHALA KMS only)
|
|
1194
|
+
nonce: z10.number().optional(),
|
|
1195
|
+
// User-specified nonce for deterministic app_id generation
|
|
1196
|
+
app_id: z10.string().optional()
|
|
1197
|
+
// Expected app_id (must match calculated app_id from nonce)
|
|
1193
1198
|
}).passthrough();
|
|
1194
1199
|
function handleGatewayCompatibility(appCompose) {
|
|
1195
1200
|
if (!appCompose.compose_file) {
|
|
@@ -1780,12 +1785,15 @@ var { action: updateOsImage, safeAction: safeUpdateOsImage } = defineAction(z29.
|
|
|
1780
1785
|
// src/actions/cvms/get_cvm_state.ts
|
|
1781
1786
|
import { z as z30 } from "zod";
|
|
1782
1787
|
var CvmStateSchema = z30.object({
|
|
1783
|
-
|
|
1784
|
-
derived_status: z30.string().optional(),
|
|
1785
|
-
vm_uuid: z30.string().optional(),
|
|
1788
|
+
id: z30.string().optional(),
|
|
1786
1789
|
instance_id: z30.string().optional(),
|
|
1787
|
-
|
|
1788
|
-
|
|
1790
|
+
name: z30.string(),
|
|
1791
|
+
status: z30.string(),
|
|
1792
|
+
uptime: z30.string().optional(),
|
|
1793
|
+
exited_at: z30.string().optional(),
|
|
1794
|
+
boot_progress: z30.string().optional(),
|
|
1795
|
+
boot_error: z30.string().optional(),
|
|
1796
|
+
shutdown_progress: z30.string().optional()
|
|
1789
1797
|
});
|
|
1790
1798
|
var GetCvmStateRequestSchema = CvmIdSchema;
|
|
1791
1799
|
var { action: getCvmState, safeAction: safeGetCvmState } = defineAction(CvmStateSchema, async (client, request) => {
|
|
@@ -3387,6 +3395,7 @@ export {
|
|
|
3387
3395
|
RequestError,
|
|
3388
3396
|
ResourceError,
|
|
3389
3397
|
RestartCvmRequestSchema,
|
|
3398
|
+
SUPPORTED_API_VERSIONS,
|
|
3390
3399
|
SUPPORTED_CHAINS,
|
|
3391
3400
|
ServerError,
|
|
3392
3401
|
ShutdownCvmRequestSchema,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phala/cloud",
|
|
3
|
-
"version": "0.2.1-beta.
|
|
3
|
+
"version": "0.2.1-beta.3",
|
|
4
4
|
"description": "TypeScript SDK for Phala Cloud API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
"author": "Leechael Yim",
|
|
39
39
|
"license": "Apache-2.0",
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@phala/dstack-sdk": "0.5.
|
|
41
|
+
"@phala/dstack-sdk": "0.5.7",
|
|
42
42
|
"debug": "^4.4.1",
|
|
43
43
|
"mitt": "^3.0.1",
|
|
44
44
|
"ofetch": "^1.3.3",
|
|
45
45
|
"viem": "^2.7.0",
|
|
46
|
-
"zod": "^3.
|
|
46
|
+
"zod": "^3.24.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@biomejs/biome": "^1.9.4",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
},
|
|
60
60
|
"repository": {
|
|
61
61
|
"type": "git",
|
|
62
|
-
"url": "https://github.com/Phala-Network/phala-cloud
|
|
62
|
+
"url": "https://github.com/Phala-Network/phala-cloud",
|
|
63
63
|
"directory": "js"
|
|
64
64
|
},
|
|
65
65
|
"engines": {
|