@phala/cloud 0.2.1-beta.2 → 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/provision_cvm.d.ts +40 -0
- package/dist/client.d.ts +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -1
- package/dist/index.mjs +7 -1
- package/package.json +3 -3
|
@@ -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<{
|
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) {
|
|
@@ -3596,6 +3602,7 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
3596
3602
|
RequestError,
|
|
3597
3603
|
ResourceError,
|
|
3598
3604
|
RestartCvmRequestSchema,
|
|
3605
|
+
SUPPORTED_API_VERSIONS,
|
|
3599
3606
|
SUPPORTED_CHAINS,
|
|
3600
3607
|
ServerError,
|
|
3601
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) {
|
|
@@ -3390,6 +3395,7 @@ export {
|
|
|
3390
3395
|
RequestError,
|
|
3391
3396
|
ResourceError,
|
|
3392
3397
|
RestartCvmRequestSchema,
|
|
3398
|
+
SUPPORTED_API_VERSIONS,
|
|
3393
3399
|
SUPPORTED_CHAINS,
|
|
3394
3400
|
ServerError,
|
|
3395
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",
|
|
@@ -43,7 +43,7 @@
|
|
|
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": {
|