@hsuite/smart-engines-sdk 3.0.1 → 3.0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.2.1 — 2026-05-16
4
+
5
+ **Documentation-only fix.** No runtime behavior change.
6
+
7
+ ### Fixed
8
+ - `DeploymentClient.init` JSDoc and `BaasInitResponse` type docs no longer
9
+ describe the registry as DOCR. The runtime arc routes pushes through a
10
+ per-tenant Harbor project (`hsuite-customers-<appId>`), and the credentials
11
+ returned in `registry.{server, username, password, repository}` are an
12
+ ephemeral project-scoped robot account whose secret is single-use and not
13
+ persisted server-side. README example aligned with the same wording.
14
+
15
+ ## 3.2.0 — undocumented (PR-A → PR-I, 2026-05-12 → 2026-05-13)
16
+
17
+ Smart-app runtime arc surface — added `DeploymentClient` with the full
18
+ init → push → uploadFrontend → deploy flow plus lifecycle (suspend/
19
+ resume/update/rollback/delete) and ownership-gated metrics. See PRs
20
+ #516 (PR-A), #523 (PR-C), and #530 (PR-H) for details.
21
+
22
+ ## 3.1.0 — undocumented (2026-05-12)
23
+
24
+ Added `CustomerSessionClient` for NFT-gated customer→smart-app auth (PR #496).
25
+
26
+ ## 3.0.2 — undocumented (2026-05-12)
27
+
28
+ Dropped `nestjs` re-exports from the root entry to keep tree-shaking clean for
29
+ non-Nest consumers (PR #494).
30
+
3
31
  ## 3.0.0 — 2026-05-11
4
32
 
5
33
  **First publishable release.**
package/README.md CHANGED
@@ -52,14 +52,24 @@ await baas.authenticate({
52
52
  },
53
53
  });
54
54
 
55
- // 4. Register a free_testnet smart-app (no HSUITE deposit on testnet; cluster runs DKG)
56
- const app = await baas.register({
57
- name: 'My Smart App',
55
+ // 4. Initialise a free_testnet smart-app via the four-step deploy flow
56
+ // (init docker push → optional uploadFrontend → deploy). `init` runs
57
+ // the per-entity DKG ceremony on the cluster and returns the DKG entityId
58
+ // as `appId`, plus ephemeral push credentials for the cluster's per-tenant
59
+ // Harbor project (single-use secret — not persisted server-side).
60
+ const init = await baas.deployment.init({
61
+ name: 'my-smart-app',
62
+ port: 3000,
58
63
  services: ['database', 'storage', 'messaging', 'functions'],
59
64
  });
60
65
 
61
- console.log(`Registered smart-app ${app.appId} — status: ${app.status}`);
62
- baas.setAppId(app.appId);
66
+ console.log(`Allocated smart-app ${init.appId}`);
67
+ console.log(`Push to: ${init.registry.server}/${init.registry.repository}:<tag>`);
68
+ baas.setAppId(init.appId);
69
+
70
+ // (out-of-band) docker login + docker push <init.registry.server>/<init.registry.repository>:v1
71
+ // (optional) await baas.deployment.uploadFrontend(init.appId, await fs.readFile('./bundle.tar.gz'));
72
+ // (deploy) await baas.deployment.deploy(init.appId, { tag: 'v1', replicas: 1 });
63
73
  ```
64
74
 
65
75
  **Why XRPL?** Per the Smart Engines V3 architecture, XRPL is canonical for
@@ -166,19 +176,40 @@ await baas.agents.resume(agent.agentId);
166
176
  const events = await baas.agents.getEvents(agent.agentId);
167
177
  ```
168
178
 
169
- ### Deployment
179
+ ### Deployment (runtime orchestration — spec §6.1)
180
+
181
+ The four-step deploy flow: **init → docker push → (optional) uploadFrontend → deploy**.
170
182
 
171
183
  ```ts
172
- const deployment = await baas.deployment.create({
173
- name: 'My Smart App v2',
184
+ // 1. init allocate appId via DKG + receive ephemeral Harbor push credentials
185
+ const init = await baas.deployment.init({
186
+ name: 'my-smart-app',
187
+ port: 3000,
174
188
  services: ['database', 'storage', 'messaging'],
175
- config: { /* app-specific */ },
176
189
  });
177
190
 
191
+ // 2. docker push — out-of-band, using the ephemeral creds returned above
192
+ // docker login -u <init.registry.username> -p <init.registry.password> <init.registry.server>
193
+ // docker push <init.registry.server>/<init.registry.repository>:v1
194
+
195
+ // 3. uploadFrontend — optional SPA tarball (content-addressed, mounted read-only)
196
+ await baas.deployment.uploadFrontend(init.appId, await fs.readFile('./bundle.tar.gz'));
197
+
198
+ // 4. deploy — reconcile to k8s
199
+ const deployed = await baas.deployment.deploy(init.appId, {
200
+ tag: 'v1',
201
+ replicas: 1,
202
+ env: { NODE_ENV: 'production' },
203
+ });
204
+ console.log(`live at ${deployed.url}`);
205
+
206
+ // Lifecycle + listing
178
207
  const apps = await baas.deployment.list();
179
- const info = await baas.deployment.get(appId);
180
- await baas.deployment.suspend(appId);
181
- await baas.deployment.resume(appId);
208
+ const info = await baas.deployment.get(init.appId);
209
+ const status = await baas.deployment.status(init.appId);
210
+ await baas.deployment.suspend(init.appId);
211
+ await baas.deployment.resume(init.appId);
212
+ await baas.deployment.rollback(init.appId, { toTag: 'v0' });
182
213
  ```
183
214
 
184
215
  ---
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  // Generated by dts-bundle-generator v9.5.1
2
2
 
3
- import { DynamicModule, OnModuleDestroy, OnModuleInit, Type } from '@nestjs/common';
4
3
  import { z } from 'zod';
5
4
 
6
5
  export type CircuitState = "closed" | "open" | "half_open";
@@ -1056,7 +1055,7 @@ export type HttpClient = {
1056
1055
  get<T = any>(path: string): Promise<T>;
1057
1056
  put<T = any>(path: string, body: unknown): Promise<T>;
1058
1057
  delete<T = any>(path: string): Promise<T>;
1059
- upload<T = any>(path: string, file: Blob | Buffer, filename: string, metadata?: Record<string, string>): Promise<T>;
1058
+ upload<T = any>(path: string, file: Blob | Buffer, filename: string, metadata?: Record<string, string>, fieldName?: string): Promise<T>;
1060
1059
  };
1061
1060
  export type HttpClientConfig = {
1062
1061
  baseUrl: string;
@@ -1198,7 +1197,6 @@ export type EntityCreationResponse = {
1198
1197
  success: boolean;
1199
1198
  entityId: string;
1200
1199
  publicKeys: string[];
1201
- signerIndices: number[];
1202
1200
  threshold: number;
1203
1201
  ceremonyIds: string[];
1204
1202
  };
@@ -1218,7 +1216,6 @@ export type ReshareResponse = {
1218
1216
  export type EntityDetails = {
1219
1217
  success: boolean;
1220
1218
  payload?: unknown;
1221
- signerIndices?: number[];
1222
1219
  validators?: string[];
1223
1220
  publicKeys?: string[];
1224
1221
  error?: string;
@@ -2099,7 +2096,7 @@ declare function xlmToStroops(xlm: string | number): string;
2099
2096
  declare function validateBitcoinAddress(address: string): boolean;
2100
2097
  declare function satoshisToBtc(satoshis: string | number): string;
2101
2098
  declare function btcToSatoshis(btc: string | number): string;
2102
- export type BaasService = "auth" | "database" | "storage" | "functions" | "messaging";
2099
+ export type BaasService = "auth" | "database" | "storage" | "functions" | "messaging" | "customer-session";
2103
2100
  export type BaasSupportedChain = "hedera" | "xrpl" | "polkadot" | "solana";
2104
2101
  export type BaasEndpoints = {
2105
2102
  auth: string;
@@ -2194,24 +2191,6 @@ export type BaasSessionInfo = {
2194
2191
  expiresAt?: number;
2195
2192
  error?: string;
2196
2193
  };
2197
- export type BaasRegisterRequest = {
2198
- name: string;
2199
- services: BaasService[];
2200
- environment?: Record<string, string>;
2201
- limits?: {
2202
- storage?: string;
2203
- functions?: number;
2204
- channels?: number;
2205
- };
2206
- };
2207
- export type BaasRegisterResponse = {
2208
- appId: string;
2209
- name: string;
2210
- status: DeployedAppStatus;
2211
- services: string[];
2212
- endpoints: BaasEndpoints;
2213
- createdAt: string;
2214
- };
2215
2194
  export type BaasDocument = {
2216
2195
  _id: string;
2217
2196
  data: Record<string, unknown>;
@@ -2417,18 +2396,56 @@ export type BaasPublishResult = {
2417
2396
  channel: string;
2418
2397
  timestamp: string;
2419
2398
  };
2420
- export type BaasDeployRequest = {
2399
+ export type BaasInitRequest = {
2421
2400
  name: string;
2401
+ port: number;
2422
2402
  services: BaasService[];
2423
- config?: Record<string, unknown>;
2403
+ limits?: {
2404
+ cpu?: string;
2405
+ memory?: string;
2406
+ };
2424
2407
  };
2425
- export type BaasDeployResult = {
2408
+ export type BaasInitResponse = {
2426
2409
  appId: string;
2427
- name: string;
2428
- status: "active" | "deploying" | "error";
2429
- services: string[];
2430
- endpoints: BaasEndpoints;
2431
- createdAt: string;
2410
+ registry: {
2411
+ server: string;
2412
+ username: string;
2413
+ password: string;
2414
+ repository: string;
2415
+ };
2416
+ };
2417
+ export type BaasDeployRequest = {
2418
+ tag: string;
2419
+ replicas?: number;
2420
+ env?: Record<string, string>;
2421
+ resources?: {
2422
+ cpu?: string;
2423
+ memory?: string;
2424
+ };
2425
+ strategy?: "rolling" | "recreate";
2426
+ };
2427
+ export type BaasDeployResponse = {
2428
+ appId: string;
2429
+ status: string;
2430
+ url: string;
2431
+ };
2432
+ export type BaasUploadFrontendResponse = {
2433
+ bundleSha256: string;
2434
+ bundleSizeBytes: number;
2435
+ };
2436
+ export type BaasRollbackRequest = {
2437
+ toTag: string;
2438
+ };
2439
+ export type BaasRuntimeStatus = {
2440
+ appId: string;
2441
+ state: "PENDING_SUBSCRIPTION" | "ACTIVE" | "SUSPENDED" | "RETIRED";
2442
+ runtime?: {
2443
+ image: string;
2444
+ runtimeState: "NOT_DEPLOYED" | "DEPLOYING" | "RUNNING" | "FAILED" | "DEGRADED";
2445
+ replicas: number;
2446
+ lastReconciledAt?: string;
2447
+ lastError?: string;
2448
+ };
2432
2449
  };
2433
2450
  export type BaasAppListResponse = {
2434
2451
  apps: DeployedAppInfo[];
@@ -2572,7 +2589,11 @@ export declare class MessagingClient {
2572
2589
  export declare class DeploymentClient {
2573
2590
  private readonly http;
2574
2591
  constructor(http: HttpClient);
2575
- create(request: BaasDeployRequest): Promise<BaasDeployResult>;
2592
+ init(request: BaasInitRequest): Promise<BaasInitResponse>;
2593
+ uploadFrontend(appId: string, bundle: Blob | Buffer, filename?: string): Promise<BaasUploadFrontendResponse>;
2594
+ deploy(appId: string, request: BaasDeployRequest): Promise<BaasDeployResponse>;
2595
+ rollback(appId: string, request: BaasRollbackRequest): Promise<BaasDeployResponse>;
2596
+ status(appId: string): Promise<BaasRuntimeStatus>;
2576
2597
  list(): Promise<BaasAppListResponse>;
2577
2598
  get(appId: string): Promise<DeployedAppInfo>;
2578
2599
  update(appId: string, updates: Partial<BaasDeployRequest>): Promise<DeployedAppInfo>;
@@ -2587,7 +2608,11 @@ export declare class DeploymentClient {
2587
2608
  success: boolean;
2588
2609
  status: string;
2589
2610
  }>;
2590
- getStats(): Promise<any>;
2611
+ getStats(): Promise<{
2612
+ totalApps: number;
2613
+ activeApps: number;
2614
+ totalOwners: number;
2615
+ }>;
2591
2616
  }
2592
2617
  export type AgentStatus = "active" | "paused" | "revoked" | "pending";
2593
2618
  export type AgentRegisterRequest = {
@@ -2712,6 +2737,55 @@ export declare class AgentsClient {
2712
2737
  success: boolean;
2713
2738
  }>;
2714
2739
  }
2740
+ export type CustomerSessionChallenge = {
2741
+ challenge: string;
2742
+ };
2743
+ export type CustomerSessionVerifyRequest = {
2744
+ appId: string;
2745
+ chain: string;
2746
+ address: string;
2747
+ publicKey?: string;
2748
+ signature: string;
2749
+ challenge: string;
2750
+ };
2751
+ export type CustomerSessionToken = {
2752
+ token: string;
2753
+ sessionId: string;
2754
+ validatorId: string;
2755
+ expiresAt: string;
2756
+ sessionSecret: string;
2757
+ };
2758
+ export type CustomerSessionInfo = {
2759
+ sessionId: string;
2760
+ appId: string;
2761
+ customerChain: string;
2762
+ customerAddress: string;
2763
+ subscriptionContext?: {
2764
+ nftSerial: number;
2765
+ tier: "free_testnet" | "starter" | "professional" | "enterprise";
2766
+ expiresAt: string;
2767
+ allowedAutomations?: string[];
2768
+ };
2769
+ createdAt: string;
2770
+ expiresAt: string;
2771
+ lastActivityAt: string;
2772
+ };
2773
+ export declare class CustomerSessionClient {
2774
+ private readonly baseUrl;
2775
+ private readonly timeoutMs;
2776
+ constructor(baseUrl: string, timeoutMs?: number);
2777
+ challenge(input: {
2778
+ chain: string;
2779
+ address: string;
2780
+ }): Promise<CustomerSessionChallenge>;
2781
+ verify(req: CustomerSessionVerifyRequest): Promise<CustomerSessionToken>;
2782
+ validate(bearer: string): Promise<CustomerSessionInfo>;
2783
+ end(bearer: string): Promise<{
2784
+ revoked: boolean;
2785
+ sessionId: string;
2786
+ }>;
2787
+ private fetch;
2788
+ }
2715
2789
  export type AuthenticateOptions = {
2716
2790
  chain: BaasSupportedChain;
2717
2791
  walletAddress: string;
@@ -2733,6 +2807,7 @@ export declare class BaasClient {
2733
2807
  readonly messaging: MessagingClient;
2734
2808
  readonly deployment: DeploymentClient;
2735
2809
  readonly agents: AgentsClient;
2810
+ readonly customerSession: CustomerSessionClient;
2736
2811
  constructor(config: BaasClientConfig);
2737
2812
  setAppId(appId: string): void;
2738
2813
  isAuthenticated(): boolean;
@@ -2745,7 +2820,6 @@ export declare class BaasClient {
2745
2820
  authenticate(options: AuthenticateOptions): Promise<BaasAuthResult>;
2746
2821
  validateSession(): Promise<BaasSessionInfo>;
2747
2822
  logout(): Promise<void>;
2748
- register(request: BaasRegisterRequest): Promise<BaasRegisterResponse>;
2749
2823
  private requireAuth;
2750
2824
  private getHeaders;
2751
2825
  private post;
@@ -2757,77 +2831,7 @@ export declare class BaasError extends Error {
2757
2831
  readonly details?: BaasErrorDetails | undefined;
2758
2832
  constructor(message: string, statusCode: number, details?: BaasErrorDetails | undefined);
2759
2833
  }
2760
- export interface SmartEngineServiceConfig extends SmartEngineClientConfig {
2761
- testConnection?: boolean;
2762
- autoReconnect?: boolean;
2763
- reconnectInterval?: number;
2764
- maxReconnectAttempts?: number;
2765
- }
2766
- export declare const SMART_ENGINE_CONFIG = "SMART_ENGINE_CONFIG";
2767
- interface BaasClient$1 {
2768
- readonly client: SmartEngineClient;
2769
- isHealthy(): Promise<boolean>;
2770
- getBaseUrl(): string;
2771
- }
2772
- export declare class SmartEngineService implements OnModuleInit, OnModuleDestroy {
2773
- private readonly config?;
2774
- private readonly logger;
2775
- private client;
2776
- private baasClient;
2777
- private connected;
2778
- private reconnectTimer;
2779
- private reconnectAttempts;
2780
- constructor(config?: SmartEngineServiceConfig | undefined);
2781
- onModuleInit(): Promise<void>;
2782
- onModuleDestroy(): Promise<void>;
2783
- initialize(config: SmartEngineServiceConfig): Promise<void>;
2784
- shutdown(): Promise<void>;
2785
- getClient(): SmartEngineClient;
2786
- getBaasClient(): BaasClient$1;
2787
- isConnected(): boolean;
2788
- testConnection(): Promise<boolean>;
2789
- getStatus(): {
2790
- connected: boolean;
2791
- baseUrl: string | null;
2792
- authenticated: boolean;
2793
- reconnectAttempts: number;
2794
- };
2795
- createGatewayClient(config: {
2796
- baseUrl: string;
2797
- apiKey?: string;
2798
- authToken?: string;
2799
- timeout?: number;
2800
- allowInsecure?: boolean;
2801
- }): SmartGatewayClient;
2802
- createHostClient(config: {
2803
- hostUrl: string;
2804
- appId?: string;
2805
- timeout?: number;
2806
- allowInsecure?: boolean;
2807
- }): BaasClient;
2808
- private createBaasClient;
2809
- private scheduleReconnect;
2810
- }
2811
- export interface SmartEngineModuleAsyncOptions {
2812
- imports?: any[];
2813
- useFactory?: (...args: any[]) => Promise<SmartEngineServiceConfig> | SmartEngineServiceConfig;
2814
- inject?: any[];
2815
- useClass?: Type<SmartEngineOptionsFactory>;
2816
- useExisting?: Type<SmartEngineOptionsFactory>;
2817
- isGlobal?: boolean;
2818
- }
2819
- export interface SmartEngineOptionsFactory {
2820
- createSmartEngineOptions(): Promise<SmartEngineServiceConfig> | SmartEngineServiceConfig;
2821
- }
2822
- export declare class SmartEngineModule {
2823
- static forRoot(config: SmartEngineServiceConfig, isGlobal?: boolean): DynamicModule;
2824
- static forRootAsync(options: SmartEngineModuleAsyncOptions): DynamicModule;
2825
- private static createAsyncProviders;
2826
- }
2827
2834
 
2828
- declare namespace nestjs {
2829
- export { BaasClient$1 as BaasClient, SMART_ENGINE_CONFIG, SmartEngineModule, SmartEngineModuleAsyncOptions, SmartEngineOptionsFactory, SmartEngineService, SmartEngineServiceConfig };
2830
- }
2831
2835
  declare namespace bitcoin {
2832
2836
  export { btcToSatoshis, satoshisToBtc, validateBitcoinAddress };
2833
2837
  }
@@ -2846,6 +2850,9 @@ declare namespace solana {
2846
2850
  declare namespace stellar {
2847
2851
  export { stroopsToXlm, validateStellarAddress, xlmToStroops };
2848
2852
  }
2853
+ declare namespace baas {
2854
+ export { AgentBalance, AgentEvent, AgentFundRequest, AgentInfo, AgentOperation, AgentRegisterRequest, AgentRules, AgentRulesValidationResult, AgentStatus, AgentTradeRequest, AgentWithdrawRequest, AgentsClient, AuthenticateOptions, BaasAppListResponse, BaasAuthConfig, BaasAuthResult, BaasChallengeRequest, BaasChallengeResponse, BaasChannelConfig, BaasClient, BaasClientConfig, BaasDeleteResult, BaasDeployRequest, BaasDeployResponse, BaasDocument, BaasEndpoints, BaasError, BaasErrorDetails, BaasErrorResponse, BaasFileInfo, BaasFileMetadata, BaasFindResult, BaasFunctionDeployRequest, BaasFunctionDeployResult, BaasFunctionInfo, BaasFunctionLog, BaasFunctionLogOptions, BaasFunctionResources, BaasFunctionResult, BaasFunctionRuntime, BaasHistoryOptions, BaasInitRequest, BaasInitResponse, BaasInsertResult, BaasMerkleProof, BaasMessage, BaasPresenceInfo, BaasPresenceMember, BaasPublishResult, BaasQueryOptions, BaasRollbackRequest, BaasRuntimeStatus, BaasService, BaasSessionInfo, BaasStateTransition, BaasStorageUsage, BaasSupportedChain, BaasTriggerType, BaasUpdateResult, BaasUploadFrontendResponse, BaasUploadResult, BaasVerifyRequest, ChannelSubscription, DatabaseClient, DatabaseStatsResponse, DbComparisonOperator, DbDocument, DbQuery, DeployedApp, DeployedAppInfo, DeployedAppLimits, DeployedAppStatus, DeployedAppUsage, DeploymentClient, DocumentProofResponse, FunctionsClient, MessageHandler, MessagingClient, StateRootResponse, StateTransitionsResponse, StorageClient, validateAgentRules };
2855
+ }
2849
2856
  declare namespace discovery {
2850
2857
  export { MIRROR_NODE_URLS, MirrorNodeClient, MirrorNodeConfig, MirrorNodeError, TopicMessage, TopicMessagesResponse, ValidatorDiscoveryClient, ValidatorDiscoveryConfig, ValidatorInfo, ValidatorMetadata, ValidatorNetworkEndpoints };
2851
2858
  }
@@ -2861,19 +2868,14 @@ declare namespace subscription {
2861
2868
  declare namespace settlement {
2862
2869
  export { SettlementAsset, SettlementClient, SettlementHistoryEntry, SettlementInitiateRequest, SettlementPurpose, SettlementStatusResponse };
2863
2870
  }
2864
- declare namespace baas {
2865
- export { AgentBalance, AgentEvent, AgentFundRequest, AgentInfo, AgentOperation, AgentRegisterRequest, AgentRules, AgentRulesValidationResult, AgentStatus, AgentTradeRequest, AgentWithdrawRequest, AgentsClient, AuthenticateOptions, BaasAppListResponse, BaasAuthConfig, BaasAuthResult, BaasChallengeRequest, BaasChallengeResponse, BaasChannelConfig, BaasClient, BaasClientConfig, BaasDeleteResult, BaasDeployRequest, BaasDeployResult, BaasDocument, BaasEndpoints, BaasError, BaasErrorDetails, BaasErrorResponse, BaasFileInfo, BaasFileMetadata, BaasFindResult, BaasFunctionDeployRequest, BaasFunctionDeployResult, BaasFunctionInfo, BaasFunctionLog, BaasFunctionLogOptions, BaasFunctionResources, BaasFunctionResult, BaasFunctionRuntime, BaasHistoryOptions, BaasInsertResult, BaasMerkleProof, BaasMessage, BaasPresenceInfo, BaasPresenceMember, BaasPublishResult, BaasQueryOptions, BaasRegisterRequest, BaasRegisterResponse, BaasService, BaasSessionInfo, BaasStateTransition, BaasStorageUsage, BaasSupportedChain, BaasTriggerType, BaasUpdateResult, BaasUploadResult, BaasVerifyRequest, ChannelSubscription, DatabaseClient, DatabaseStatsResponse, DbComparisonOperator, DbDocument, DbQuery, DeployedApp, DeployedAppInfo, DeployedAppLimits, DeployedAppStatus, DeployedAppUsage, DeploymentClient, DocumentProofResponse, FunctionsClient, MessageHandler, MessagingClient, StateRootResponse, StateTransitionsResponse, StorageClient, validateAgentRules };
2866
- }
2867
2871
 
2868
2872
  export {
2869
- BaasClient$1 as NestJsBaasClient,
2870
2873
  RetryConfig as ResilienceRetryConfig,
2871
2874
  RetryConfig$1 as RetryConfig,
2872
2875
  auth,
2873
2876
  baas,
2874
2877
  chains,
2875
2878
  discovery,
2876
- nestjs,
2877
2879
  settlement,
2878
2880
  subscription,
2879
2881
  };