@hsuite/smart-engines-sdk 3.14.0 → 4.0.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.
- package/CHANGELOG.md +21 -0
- package/README.md +10 -7
- package/dist/index.d.ts +58 -34
- package/dist/index.js +107 -108
- package/dist/index.js.map +1 -1
- package/dist/nestjs/index.d.ts +57 -46
- package/dist/nestjs/index.js +115 -111
- package/dist/nestjs/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.0.0 — 2026-06-25
|
|
4
|
+
|
|
5
|
+
**SDK revision — align the surface to the REAL reachable endpoints; remove the un-ingressed-tier footguns.** Two profiles, two tiers: `BaasClient` is the app-as-proxy / external profile (host BaaS tier, `{gateway}/host/api/v3/baas/*`); `SmartEngineClient` is the in-cluster / validator-direct profile (raw `/api/v3/*` tier, un-ingressed at the gateway). The web3 authorization proxy is the HOST, which already exposes the entity value-movement routes — so value-movement now lives on `BaasClient.entities`, and the raw-tier transactions arm is removed from `BaasClient`.
|
|
6
|
+
|
|
7
|
+
### Breaking changes
|
|
8
|
+
|
|
9
|
+
- **Removed `BaasClient.transactions` (the `TransactionsClient` sub-client) and `BaasClient`'s internal `txHttp`.** This arm rooted at the RAW `{hostUrl}/api/v3/transactions` origin — a sibling of `/host` that is un-ingressed at the public gateway (RFC #1236), so every call from a gateway-routed `BaasClient` 404'd. That was the footgun. The `TransactionsClient` class itself is unchanged and still ships on `SmartEngineClient` (the validator-direct profile). Migration: external/app-as-proxy callers use `BaasClient.entities.{transfer,withdraw,mint,burn,compliance,trustline}` (host BaaS tier) or, for in-cluster prepare/execute, construct a `SmartEngineClient` with an explicit `validatorBaseUrl`.
|
|
10
|
+
- **`SmartEngineClientConfig.baseUrl` → `validatorBaseUrl` (renamed, type-fence).** `SmartEngineClient` is now constructible ONLY with an explicit VALIDATOR origin. The rename makes it impossible to silently pass a gateway URL into the validator-direct client (whose raw `/api/v3/*` tier 404s at the gateway). Migration: `new SmartEngineClient({ baseUrl })` → `new SmartEngineClient({ validatorBaseUrl })`.
|
|
11
|
+
- **Removed `SmartEngineClient.connectToCluster()` (and its `ClusterConnectionConfig` / `ClusterConnectionSeed` / `ClusterConnectionResult` types).** It resolved a cluster's `gatewayUrl` and fed it into a gateway-pointed `SmartEngineClient` — the same footgun. To reach web3 through a cluster use `BaasClient.connectToCluster({ network })` (host BaaS tier); for an explicit in-cluster validator origin use `new SmartEngineClient({ validatorBaseUrl })` or `SmartEngineClient.connectToNetwork(...)` (which resolves a real validator `apiEndpoint` from the HCS registry — never a gateway URL). `connectToNetwork` is unchanged.
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- **`BaasClient.entities` value-movement (prepare-bytes only).** Six new methods mirroring the host's entity-scoped routes (`POST /api/v3/baas/entities/:entityId/{transfer,withdraw,mint,burn,compliance,trustline}`), each returning the host's `PreparedEntityTransactionResult` and threading `HttpCallOptions` (`onBehalfOf` / `customerToken` / `headers`) — owner-acting via the end user's Mode-1 customer-session JWT, exactly as `agents.execute`. The entity is the source / treasury / authority + fee-payer (resolved server-side; never named in the body), so a caller can never name a foreign payer or drain another account; a rule-deny surfaces as a 403 `rule_rejected` (use `isRuleRejected`), never as signed bytes. New signatures:
|
|
16
|
+
- `entities.transfer(entityId, body: TransferEntityRequest, opts?) → Promise<PreparedEntityTransactionResult>`
|
|
17
|
+
- `entities.withdraw(entityId, body: WithdrawEntityRequest, opts?) → Promise<PreparedEntityTransactionResult>`
|
|
18
|
+
- `entities.mint(entityId, body: MintEntityRequest, opts?) → Promise<PreparedEntityTransactionResult>`
|
|
19
|
+
- `entities.burn(entityId, body: BurnEntityRequest, opts?) → Promise<PreparedEntityTransactionResult>`
|
|
20
|
+
- `entities.compliance(entityId, body: ComplianceEntityRequest, opts?) → Promise<PreparedEntityTransactionResult>`
|
|
21
|
+
- `entities.trustline(entityId, body: TrustlineEntityRequest, opts?) → Promise<PreparedEntityTransactionResult>`
|
|
22
|
+
- New exported types: `TransferEntityRequest`, `WithdrawEntityRequest`, `MintEntityRequest`, `BurnEntityRequest`, `ComplianceEntityRequest`, `ComplianceAction`, `TrustlineEntityRequest`, `PreparedEntityTransactionResult`.
|
|
23
|
+
|
|
3
24
|
## 3.14.0 — 2026-06-25
|
|
4
25
|
|
|
5
26
|
### Added
|
package/README.md
CHANGED
|
@@ -79,15 +79,15 @@ baas.setAppId(init.appId);
|
|
|
79
79
|
```ts
|
|
80
80
|
import { SmartEngineClient } from '@hsuite/smart-engines-sdk';
|
|
81
81
|
|
|
82
|
-
const { client,
|
|
83
|
-
network: 'testnet', // resolves
|
|
82
|
+
const { client, validator, session } = await SmartEngineClient.connectToNetwork({
|
|
83
|
+
network: 'testnet', // resolves a real validator origin from the HCS registry
|
|
84
84
|
chain: 'xrpl',
|
|
85
85
|
address: wallet.address,
|
|
86
86
|
publicKey: wallet.publicKey,
|
|
87
87
|
signFn: (challenge) => /* sign the challenge */ '',
|
|
88
88
|
});
|
|
89
89
|
|
|
90
|
-
// All sub-clients are wired against the discovered
|
|
90
|
+
// All sub-clients are wired against the discovered validator
|
|
91
91
|
await client.tss.signMPC({ chain: 'hedera', entityId: '...', transactionBytes: '0x...' });
|
|
92
92
|
await client.ipfs.upload(file, 'document.pdf');
|
|
93
93
|
```
|
|
@@ -115,8 +115,11 @@ const baas = new BaasClient({
|
|
|
115
115
|
pathPrefix: '/host', // gateway routes /host/* → smart-host
|
|
116
116
|
});
|
|
117
117
|
|
|
118
|
+
// `SmartEngineClient` is validator-direct: `validatorBaseUrl` MUST be a
|
|
119
|
+
// validator origin, NEVER the gateway. Its raw `/api/v3/*` tier is un-ingressed
|
|
120
|
+
// at the gateway (RFC #1236), so a gateway URL here 404s every call.
|
|
118
121
|
const client = new SmartEngineClient({
|
|
119
|
-
|
|
122
|
+
validatorBaseUrl: 'http://smart-validator:3000', // in-cluster validator origin
|
|
120
123
|
authToken: '<jwt-from-validator-auth-verify>',
|
|
121
124
|
});
|
|
122
125
|
```
|
|
@@ -357,12 +360,12 @@ await baas.deployment.rollback(init.appId, { toTag: 'v0' });
|
|
|
357
360
|
|
|
358
361
|
For direct chain operations independent of BaaS — e.g., a custodial backend
|
|
359
362
|
that creates accounts and tokens on behalf of users — use the methods on the
|
|
360
|
-
`SmartEngineClient` returned by `
|
|
363
|
+
`SmartEngineClient` returned by `connectToNetwork`:
|
|
361
364
|
|
|
362
365
|
```ts
|
|
363
366
|
import { SmartEngineClient } from '@hsuite/smart-engines-sdk';
|
|
364
367
|
|
|
365
|
-
const { client } = await SmartEngineClient.
|
|
368
|
+
const { client } = await SmartEngineClient.connectToNetwork({
|
|
366
369
|
network: 'testnet',
|
|
367
370
|
chain: 'xrpl',
|
|
368
371
|
address: wallet.address,
|
|
@@ -420,7 +423,7 @@ import { SmartEngineModule } from '@hsuite/smart-engines-sdk/nestjs';
|
|
|
420
423
|
SmartEngineModule.forRootAsync({
|
|
421
424
|
imports: [ConfigModule],
|
|
422
425
|
useFactory: (config: ConfigService) => ({
|
|
423
|
-
|
|
426
|
+
validatorBaseUrl: config.get('VALIDATOR_URL')!,
|
|
424
427
|
timeout: 30000,
|
|
425
428
|
testConnection: true,
|
|
426
429
|
autoReconnect: true,
|
package/dist/index.d.ts
CHANGED
|
@@ -4741,7 +4741,7 @@ export declare class OperatorClient {
|
|
|
4741
4741
|
getTopup(chain: OperatorChain, accountId: string): Promise<OperatorTopUpResponse>;
|
|
4742
4742
|
}
|
|
4743
4743
|
export interface SmartEngineClientConfig {
|
|
4744
|
-
|
|
4744
|
+
validatorBaseUrl: string;
|
|
4745
4745
|
apiKey?: string;
|
|
4746
4746
|
authToken?: string;
|
|
4747
4747
|
timeout?: number;
|
|
@@ -4761,35 +4761,6 @@ export interface NetworkConnectionConfig {
|
|
|
4761
4761
|
mirrorNodeUrl?: string;
|
|
4762
4762
|
allowInsecure?: boolean;
|
|
4763
4763
|
}
|
|
4764
|
-
export interface ClusterConnectionAuth {
|
|
4765
|
-
chain: AuthChain;
|
|
4766
|
-
address: string;
|
|
4767
|
-
publicKey: string;
|
|
4768
|
-
signFn: (challenge: string) => string | Promise<string>;
|
|
4769
|
-
metadata?: {
|
|
4770
|
-
appId?: string;
|
|
4771
|
-
appName?: string;
|
|
4772
|
-
};
|
|
4773
|
-
trustAnchor?: {
|
|
4774
|
-
network: "mainnet" | "testnet" | "previewnet";
|
|
4775
|
-
registryTopicId: string;
|
|
4776
|
-
mirrorNodeUrl?: string;
|
|
4777
|
-
};
|
|
4778
|
-
allowInsecure?: boolean;
|
|
4779
|
-
}
|
|
4780
|
-
export type ClusterConnectionSeed = {
|
|
4781
|
-
bootstrap: string[];
|
|
4782
|
-
network?: never;
|
|
4783
|
-
} | {
|
|
4784
|
-
bootstrap?: never;
|
|
4785
|
-
network: NetworkName;
|
|
4786
|
-
};
|
|
4787
|
-
export type ClusterConnectionConfig = ClusterConnectionSeed & ClusterConnectionAuth;
|
|
4788
|
-
export interface ClusterConnectionResult {
|
|
4789
|
-
client: SmartEngineClient;
|
|
4790
|
-
cluster: ClusterInfo;
|
|
4791
|
-
session: AuthenticateResponse;
|
|
4792
|
-
}
|
|
4793
4764
|
export interface NetworkConnectionResult {
|
|
4794
4765
|
client: SmartEngineClient;
|
|
4795
4766
|
validator: ValidatorInfo;
|
|
@@ -4827,7 +4798,6 @@ export declare class SmartEngineClient {
|
|
|
4827
4798
|
constructor(config: SmartEngineClientConfig);
|
|
4828
4799
|
static fromEnv(env: Record<string, string | undefined>): SmartEngineClient;
|
|
4829
4800
|
static connectToNetwork(config: NetworkConnectionConfig): Promise<NetworkConnectionResult>;
|
|
4830
|
-
static connectToCluster(config: ClusterConnectionConfig): Promise<ClusterConnectionResult>;
|
|
4831
4801
|
getBaseUrl(): string;
|
|
4832
4802
|
isAuthenticated(): boolean;
|
|
4833
4803
|
getHttpHealth(): {
|
|
@@ -25409,6 +25379,56 @@ export type LaunchpadEntityResult = {
|
|
|
25409
25379
|
tokenId: string;
|
|
25410
25380
|
chainAccounts: Record<string, string>;
|
|
25411
25381
|
};
|
|
25382
|
+
export type TransferEntityRequest = {
|
|
25383
|
+
chain: ChainType;
|
|
25384
|
+
to: string;
|
|
25385
|
+
amount: string;
|
|
25386
|
+
tokenId?: string;
|
|
25387
|
+
memo?: string;
|
|
25388
|
+
};
|
|
25389
|
+
export type WithdrawEntityRequest = {
|
|
25390
|
+
chain: ChainType;
|
|
25391
|
+
destination: string;
|
|
25392
|
+
amount: string;
|
|
25393
|
+
tokenId?: string;
|
|
25394
|
+
memo?: string;
|
|
25395
|
+
};
|
|
25396
|
+
export type MintEntityRequest = {
|
|
25397
|
+
chain: ChainType;
|
|
25398
|
+
tokenId: string;
|
|
25399
|
+
amount: string;
|
|
25400
|
+
memo?: string;
|
|
25401
|
+
};
|
|
25402
|
+
export type BurnEntityRequest = {
|
|
25403
|
+
chain: ChainType;
|
|
25404
|
+
tokenId: string;
|
|
25405
|
+
amount: string;
|
|
25406
|
+
memo?: string;
|
|
25407
|
+
};
|
|
25408
|
+
export type ComplianceAction = "pause" | "restrict" | "wipe";
|
|
25409
|
+
export type ComplianceEntityRequest = {
|
|
25410
|
+
action: ComplianceAction;
|
|
25411
|
+
chain: ChainType;
|
|
25412
|
+
tokenId: string;
|
|
25413
|
+
account?: string;
|
|
25414
|
+
amount?: string;
|
|
25415
|
+
memo?: string;
|
|
25416
|
+
};
|
|
25417
|
+
export type TrustlineEntityRequest = {
|
|
25418
|
+
chain: ChainType;
|
|
25419
|
+
currency: string;
|
|
25420
|
+
issuerAddress: string;
|
|
25421
|
+
limit?: string;
|
|
25422
|
+
};
|
|
25423
|
+
export type PreparedEntityTransactionResult = {
|
|
25424
|
+
chain: string;
|
|
25425
|
+
transactionId: string;
|
|
25426
|
+
transactionBytes: string;
|
|
25427
|
+
transactionType?: string;
|
|
25428
|
+
payerAccountId?: string;
|
|
25429
|
+
expiresAt?: string;
|
|
25430
|
+
metadata?: Record<string, unknown>;
|
|
25431
|
+
};
|
|
25412
25432
|
export declare class EntitiesClient {
|
|
25413
25433
|
private readonly http;
|
|
25414
25434
|
constructor(http: HttpClient);
|
|
@@ -25453,6 +25473,12 @@ export declare class EntitiesClient {
|
|
|
25453
25473
|
launchpad(req: LaunchpadEntityRequest): Promise<LaunchpadEntityResult>;
|
|
25454
25474
|
get(entityId: string): Promise<EntityInfo>;
|
|
25455
25475
|
listByOwner(filter?: ListEntitiesFilter): Promise<ListEntitiesResponse>;
|
|
25476
|
+
transfer(entityId: string, body: TransferEntityRequest, opts?: HttpCallOptions): Promise<PreparedEntityTransactionResult>;
|
|
25477
|
+
withdraw(entityId: string, body: WithdrawEntityRequest, opts?: HttpCallOptions): Promise<PreparedEntityTransactionResult>;
|
|
25478
|
+
mint(entityId: string, body: MintEntityRequest, opts?: HttpCallOptions): Promise<PreparedEntityTransactionResult>;
|
|
25479
|
+
burn(entityId: string, body: BurnEntityRequest, opts?: HttpCallOptions): Promise<PreparedEntityTransactionResult>;
|
|
25480
|
+
compliance(entityId: string, body: ComplianceEntityRequest, opts?: HttpCallOptions): Promise<PreparedEntityTransactionResult>;
|
|
25481
|
+
trustline(entityId: string, body: TrustlineEntityRequest, opts?: HttpCallOptions): Promise<PreparedEntityTransactionResult>;
|
|
25456
25482
|
}
|
|
25457
25483
|
export type AuthenticateOptions = {
|
|
25458
25484
|
chain: BaasSupportedChain;
|
|
@@ -25486,7 +25512,6 @@ export declare class BaasClient {
|
|
|
25486
25512
|
private readonly timeout;
|
|
25487
25513
|
private readonly allowInsecure;
|
|
25488
25514
|
private readonly http;
|
|
25489
|
-
private readonly txHttp;
|
|
25490
25515
|
private lastHttpError?;
|
|
25491
25516
|
private authContext?;
|
|
25492
25517
|
readonly db: DatabaseClient;
|
|
@@ -25498,7 +25523,6 @@ export declare class BaasClient {
|
|
|
25498
25523
|
readonly customerSession: CustomerSessionClient;
|
|
25499
25524
|
readonly rules: RulesClient;
|
|
25500
25525
|
readonly entities: EntitiesClient;
|
|
25501
|
-
readonly transactions: TransactionsClient;
|
|
25502
25526
|
constructor(config: BaasClientConfig);
|
|
25503
25527
|
static connectToCluster(config: BaasConnectToClusterConfig): Promise<BaasClient>;
|
|
25504
25528
|
setAppId(appId: string): void;
|
|
@@ -25718,7 +25742,7 @@ declare namespace personhood {
|
|
|
25718
25742
|
export { PERSONHOOD_VERIFIER_NOT_CONFIGURED, PersonhoodAttestationMethod, PersonhoodCert, PersonhoodClient, PersonhoodProof, PersonhoodVerifyParams, isPersonhoodVerifierNotConfigured };
|
|
25719
25743
|
}
|
|
25720
25744
|
declare namespace baas {
|
|
25721
|
-
export { AgentBalance, AgentCertification, AgentEvent, AgentFundRequest, AgentInfo, AgentOperation, AgentPendingApprovalResponse, AgentPreparedTransactionResponse, AgentRegisterRequest, AgentRules, AgentRulesValidationResult, AgentStatus, AgentTradeRequest, AgentWithdrawRequest, AgentsClient, AuthenticateOptions, BaasAppListResponse, BaasAuthConfig, BaasAuthResult, BaasChallengeRequest, BaasChallengeResponse, BaasChannelConfig, BaasClient, BaasClientConfig, BaasConnectToClusterConfig, BaasDeleteResult, BaasDeployRequest, BaasDeployResponse, BaasDocument, BaasEndpoints, BaasError, BaasErrorDetails, BaasErrorResponse, BaasFileInfo, BaasFileMetadata, BaasFindResult, BaasFunctionCode, BaasFunctionDeployRequest, BaasFunctionDeployResult, BaasFunctionEvalRequest, BaasFunctionInfo, BaasFunctionLog, BaasFunctionLogOptions, BaasFunctionResources, BaasFunctionResult, BaasFunctionRuntime, BaasHistoryOptions, BaasInitRequest, BaasInitResponse, BaasInsertResult, BaasMerkleProof, BaasMessage, BaasPresenceInfo, BaasPresenceMember, BaasPublishResult, BaasQueryOptions, BaasReissuePushCredentialsResponse, BaasRevokeKekResponse, BaasRollbackRequest, BaasRotateKekResponse, BaasRuntimeStatus, BaasService, BaasSessionInfo, BaasSetWebhookResponse, BaasSignedCode, BaasStateTransition, BaasStorageUsage, BaasSupportedChain, BaasTriggerType, BaasUpdateResult, BaasUploadFrontendResponse, BaasUploadResult, BaasVerifyRequest, ChannelSubscription, CreateAccountRequest$1 as BaasCreateAccountRequest, CreateAgentRequest, CreateTokenRequest$1 as CreateTokenRequest, CreateTopicRequest, DatabaseClient, DatabaseStatsResponse, DbComparisonOperator, DbDocument, DbQuery, DeployedApp, DeployedAppInfo, DeployedAppLimits, DeployedAppStatus, DeployedAppUsage, DeploymentClient, DeprecateRuleResponse, DocumentProofResponse, EntitiesClient, EntityCreationResult, EntityInfo, EntitySecurityMode, EntityType$1 as BaasEntityType, FunctionsClient, FundWith, LaunchpadEntityRequest, LaunchpadEntityResult, ListEntitiesFilter, ListEntitiesResponse, ListRulesFilter, ListRulesResponse, MessageHandler, MessagingClient, PreparedEntityCreation, PublishRuleResponse, RulesClient, SimulateRuleRequest, StateRootResponse, StateTransitionsResponse, StorageClient, ValidationResult, VersionHistoryResponse, isAgentFundPending, validateAgentRules };
|
|
25745
|
+
export { AgentBalance, AgentCertification, AgentEvent, AgentFundRequest, AgentInfo, AgentOperation, AgentPendingApprovalResponse, AgentPreparedTransactionResponse, AgentRegisterRequest, AgentRules, AgentRulesValidationResult, AgentStatus, AgentTradeRequest, AgentWithdrawRequest, AgentsClient, AuthenticateOptions, BaasAppListResponse, BaasAuthConfig, BaasAuthResult, BaasChallengeRequest, BaasChallengeResponse, BaasChannelConfig, BaasClient, BaasClientConfig, BaasConnectToClusterConfig, BaasDeleteResult, BaasDeployRequest, BaasDeployResponse, BaasDocument, BaasEndpoints, BaasError, BaasErrorDetails, BaasErrorResponse, BaasFileInfo, BaasFileMetadata, BaasFindResult, BaasFunctionCode, BaasFunctionDeployRequest, BaasFunctionDeployResult, BaasFunctionEvalRequest, BaasFunctionInfo, BaasFunctionLog, BaasFunctionLogOptions, BaasFunctionResources, BaasFunctionResult, BaasFunctionRuntime, BaasHistoryOptions, BaasInitRequest, BaasInitResponse, BaasInsertResult, BaasMerkleProof, BaasMessage, BaasPresenceInfo, BaasPresenceMember, BaasPublishResult, BaasQueryOptions, BaasReissuePushCredentialsResponse, BaasRevokeKekResponse, BaasRollbackRequest, BaasRotateKekResponse, BaasRuntimeStatus, BaasService, BaasSessionInfo, BaasSetWebhookResponse, BaasSignedCode, BaasStateTransition, BaasStorageUsage, BaasSupportedChain, BaasTriggerType, BaasUpdateResult, BaasUploadFrontendResponse, BaasUploadResult, BaasVerifyRequest, BurnEntityRequest, ChannelSubscription, ComplianceAction, ComplianceEntityRequest, CreateAccountRequest$1 as BaasCreateAccountRequest, CreateAgentRequest, CreateTokenRequest$1 as CreateTokenRequest, CreateTopicRequest, DatabaseClient, DatabaseStatsResponse, DbComparisonOperator, DbDocument, DbQuery, DeployedApp, DeployedAppInfo, DeployedAppLimits, DeployedAppStatus, DeployedAppUsage, DeploymentClient, DeprecateRuleResponse, DocumentProofResponse, EntitiesClient, EntityCreationResult, EntityInfo, EntitySecurityMode, EntityType$1 as BaasEntityType, FunctionsClient, FundWith, LaunchpadEntityRequest, LaunchpadEntityResult, ListEntitiesFilter, ListEntitiesResponse, ListRulesFilter, ListRulesResponse, MessageHandler, MessagingClient, MintEntityRequest, PreparedEntityCreation, PreparedEntityTransactionResult, PublishRuleResponse, RulesClient, SimulateRuleRequest, StateRootResponse, StateTransitionsResponse, StorageClient, TransferEntityRequest, TrustlineEntityRequest, ValidationResult, VersionHistoryResponse, WithdrawEntityRequest, isAgentFundPending, validateAgentRules };
|
|
25722
25746
|
}
|
|
25723
25747
|
declare namespace pqcVerify {
|
|
25724
25748
|
export { FetchRegistryOptions, PqcCertV1, PqcCertV1Schema, PqcCertV1Signer, ValidatorRegistrySnapshot, VerifyResult, fetchRegistrySnapshot, parsePqcCert, verifyPqcAttestation };
|
package/dist/index.js
CHANGED
|
@@ -6478,9 +6478,11 @@ var ClusterDiscoveryClient = class {
|
|
|
6478
6478
|
}
|
|
6479
6479
|
/**
|
|
6480
6480
|
* Convenience wrapper returning just the gateway URL of a random
|
|
6481
|
-
* active cluster.
|
|
6482
|
-
*
|
|
6483
|
-
*
|
|
6481
|
+
* active cluster. Feed this to `BaasClient` (the host BaaS tier) — e.g.
|
|
6482
|
+
* `new BaasClient({ hostUrl, pathPrefix: '/host' })` or
|
|
6483
|
+
* `BaasClient.connectToCluster({ network })`. Do NOT feed it to
|
|
6484
|
+
* `SmartEngineClient`: that client's raw `/api/v3/*` tier is un-ingressed at
|
|
6485
|
+
* the gateway and will 404 (it requires an explicit `validatorBaseUrl`).
|
|
6484
6486
|
*/
|
|
6485
6487
|
async getRandomGatewayUrl(forceRefresh = false) {
|
|
6486
6488
|
const cluster = await this.getRandomCluster(forceRefresh);
|
|
@@ -9245,7 +9247,7 @@ var SmartEngineClient = class _SmartEngineClient {
|
|
|
9245
9247
|
discovery;
|
|
9246
9248
|
constructor(config) {
|
|
9247
9249
|
this.allowInsecure = config.allowInsecure ?? false;
|
|
9248
|
-
this.baseUrl = validateClientUrl(config.
|
|
9250
|
+
this.baseUrl = validateClientUrl(config.validatorBaseUrl, this.allowInsecure);
|
|
9249
9251
|
this.http = createHttpClient({
|
|
9250
9252
|
baseUrl: `${this.baseUrl}/api/v3`,
|
|
9251
9253
|
apiKey: config.apiKey,
|
|
@@ -9307,7 +9309,7 @@ var SmartEngineClient = class _SmartEngineClient {
|
|
|
9307
9309
|
const timeoutRaw = env["REQUEST_TIMEOUT"];
|
|
9308
9310
|
const timeout = timeoutRaw ? Number.parseInt(timeoutRaw, 10) : void 0;
|
|
9309
9311
|
return new _SmartEngineClient({
|
|
9310
|
-
baseUrl,
|
|
9312
|
+
validatorBaseUrl: baseUrl,
|
|
9311
9313
|
apiKey: env["VALIDATOR_API_KEY"],
|
|
9312
9314
|
authToken: env["APP_TOKEN"],
|
|
9313
9315
|
allowInsecure: env["ALLOW_INSECURE"] === "true",
|
|
@@ -9355,90 +9357,21 @@ var SmartEngineClient = class _SmartEngineClient {
|
|
|
9355
9357
|
config.metadata
|
|
9356
9358
|
);
|
|
9357
9359
|
const client = new _SmartEngineClient({
|
|
9358
|
-
|
|
9360
|
+
validatorBaseUrl: validatorUrl,
|
|
9359
9361
|
authToken: session.token,
|
|
9360
9362
|
allowInsecure
|
|
9361
9363
|
});
|
|
9362
9364
|
return { client, validator, session };
|
|
9363
9365
|
}
|
|
9364
|
-
|
|
9365
|
-
|
|
9366
|
-
|
|
9367
|
-
|
|
9368
|
-
|
|
9369
|
-
|
|
9370
|
-
|
|
9371
|
-
|
|
9372
|
-
|
|
9373
|
-
* 2. (Optional) HCS trust-anchor membership cross-check.
|
|
9374
|
-
* 3. Random-pick over the verified set.
|
|
9375
|
-
*
|
|
9376
|
-
* @param config - Seed + auth config. See {@link ClusterConnectionConfig}.
|
|
9377
|
-
* @returns The configured client, the selected cluster, and the auth session.
|
|
9378
|
-
* @throws SmartEngineError 400 if neither `bootstrap` nor `network` is given.
|
|
9379
|
-
* @throws SmartEngineError 503 if no active cluster can be reached.
|
|
9380
|
-
*
|
|
9381
|
-
* @example Zero-config (recommended for smart-app callers)
|
|
9382
|
-
* ```ts
|
|
9383
|
-
* const { client, cluster, session } = await SmartEngineClient.connectToCluster({
|
|
9384
|
-
* network: 'testnet', // resolves canonical gateway entrypoint
|
|
9385
|
-
* chain: 'xrpl',
|
|
9386
|
-
* address: '...',
|
|
9387
|
-
* publicKey: '...',
|
|
9388
|
-
* signFn: async (challenge) => sign(challenge),
|
|
9389
|
-
* });
|
|
9390
|
-
* ```
|
|
9391
|
-
*
|
|
9392
|
-
* @example Custom seeds (private deployments / local dev)
|
|
9393
|
-
* ```ts
|
|
9394
|
-
* const { client, cluster, session } = await SmartEngineClient.connectToCluster({
|
|
9395
|
-
* bootstrap: ['https://sn1.testnet.hsuite.network', 'https://sn2.testnet.hsuite.network'],
|
|
9396
|
-
* chain: 'xrpl',
|
|
9397
|
-
* address: '...',
|
|
9398
|
-
* publicKey: '...',
|
|
9399
|
-
* signFn: async (challenge) => sign(challenge),
|
|
9400
|
-
* });
|
|
9401
|
-
* ```
|
|
9402
|
-
*/
|
|
9403
|
-
static async connectToCluster(config) {
|
|
9404
|
-
const allowInsecure = config.allowInsecure ?? false;
|
|
9405
|
-
const resolved = await resolveClusterEndpoint({
|
|
9406
|
-
bootstrap: config.bootstrap,
|
|
9407
|
-
network: config.network,
|
|
9408
|
-
allowInsecure,
|
|
9409
|
-
trustAnchor: config.trustAnchor
|
|
9410
|
-
});
|
|
9411
|
-
if (!resolved.ok) {
|
|
9412
|
-
if (resolved.reason === "no-seeds") {
|
|
9413
|
-
throw new SmartEngineError2(
|
|
9414
|
-
"connectToCluster requires either a non-empty `bootstrap` list or a known `network` name.",
|
|
9415
|
-
400
|
|
9416
|
-
);
|
|
9417
|
-
}
|
|
9418
|
-
throw new SmartEngineError2(
|
|
9419
|
-
"No active clusters available via bootstrap seeds. Check bootstrap URLs and network reachability.",
|
|
9420
|
-
503
|
|
9421
|
-
);
|
|
9422
|
-
}
|
|
9423
|
-
const cluster = resolved.cluster;
|
|
9424
|
-
const gatewayUrl = cluster.endpoints.gatewayUrl;
|
|
9425
|
-
validateClientUrl(gatewayUrl, allowInsecure);
|
|
9426
|
-
const auth = new ValidatorAuthClient({ security: { allowInsecure } });
|
|
9427
|
-
const session = await auth.authenticateWithSigner(
|
|
9428
|
-
gatewayUrl,
|
|
9429
|
-
config.chain,
|
|
9430
|
-
config.address,
|
|
9431
|
-
config.publicKey,
|
|
9432
|
-
config.signFn,
|
|
9433
|
-
config.metadata
|
|
9434
|
-
);
|
|
9435
|
-
const client = new _SmartEngineClient({
|
|
9436
|
-
baseUrl: gatewayUrl,
|
|
9437
|
-
authToken: session.token,
|
|
9438
|
-
allowInsecure
|
|
9439
|
-
});
|
|
9440
|
-
return { client, cluster, session };
|
|
9441
|
-
}
|
|
9366
|
+
// NOTE (SDK 4.0 type-fence): the former `SmartEngineClient.connectToCluster`
|
|
9367
|
+
// was REMOVED. It resolved a cluster's `gatewayUrl` and fed it into
|
|
9368
|
+
// `new SmartEngineClient({ baseUrl: gatewayUrl })` — a gateway-pointed
|
|
9369
|
+
// validator-direct client whose raw `/api/v3/*` calls 404 (the raw tier is
|
|
9370
|
+
// un-ingressed at the gateway). That was the footgun. To reach web3 through a
|
|
9371
|
+
// cluster use `BaasClient.connectToCluster({ network })` (the host BaaS tier);
|
|
9372
|
+
// for an explicit in-cluster validator origin use `new SmartEngineClient({
|
|
9373
|
+
// validatorBaseUrl })` or `connectToNetwork` (which resolves a real validator
|
|
9374
|
+
// `apiEndpoint` from the HCS registry, never a gateway URL).
|
|
9442
9375
|
/** Get the current validator URL */
|
|
9443
9376
|
getBaseUrl() {
|
|
9444
9377
|
return this.baseUrl;
|
|
@@ -11760,6 +11693,96 @@ var EntitiesClient = class _EntitiesClient {
|
|
|
11760
11693
|
const path = filter?.type ? `/api/v3/baas/entities?type=${encodeURIComponent(filter.type)}` : "/api/v3/baas/entities";
|
|
11761
11694
|
return this.http.get(path);
|
|
11762
11695
|
}
|
|
11696
|
+
// ─── Value-movement (prepare-bytes only) ──────────────────────────────────
|
|
11697
|
+
//
|
|
11698
|
+
// Each method POSTs the host's entity-scoped value-movement route. The entity
|
|
11699
|
+
// is the source / treasury / authority + fee-payer (resolved server-side from
|
|
11700
|
+
// the entity record — never the body), so a caller can never name a foreign
|
|
11701
|
+
// payer or drain another account. The host authorises the call (session
|
|
11702
|
+
// caller identity + `loadOwnedEntity` ownership), delegates to the validator
|
|
11703
|
+
// preparer, and returns prepared bytes for the caller to sign + submit; the
|
|
11704
|
+
// host never submits and never pays. A rule-deny surfaces as an HTTP 403
|
|
11705
|
+
// `rule_rejected` (use `isRuleRejected`), never as signed bytes.
|
|
11706
|
+
//
|
|
11707
|
+
// `opts` threads {@link HttpCallOptions} (`onBehalfOf` / `customerToken` /
|
|
11708
|
+
// `headers`) so an app-as-proxy can act on behalf of an owner — the owner's
|
|
11709
|
+
// Mode-1 customer-session JWT rides as both `Authorization: Bearer` and
|
|
11710
|
+
// `X-Customer-Session-Claim`, exactly as `agents.execute` does.
|
|
11711
|
+
/**
|
|
11712
|
+
* Prepare a native or token transfer FROM an account entity.
|
|
11713
|
+
*
|
|
11714
|
+
* `POST /api/v3/baas/entities/:entityId/transfer`.
|
|
11715
|
+
*/
|
|
11716
|
+
async transfer(entityId, body, opts) {
|
|
11717
|
+
return this.http.post(
|
|
11718
|
+
`/api/v3/baas/entities/${encodePathParam(entityId)}/transfer`,
|
|
11719
|
+
body,
|
|
11720
|
+
opts
|
|
11721
|
+
);
|
|
11722
|
+
}
|
|
11723
|
+
/**
|
|
11724
|
+
* Prepare a withdrawal FROM an account entity to a destination.
|
|
11725
|
+
*
|
|
11726
|
+
* `POST /api/v3/baas/entities/:entityId/withdraw`.
|
|
11727
|
+
*/
|
|
11728
|
+
async withdraw(entityId, body, opts) {
|
|
11729
|
+
return this.http.post(
|
|
11730
|
+
`/api/v3/baas/entities/${encodePathParam(entityId)}/withdraw`,
|
|
11731
|
+
body,
|
|
11732
|
+
opts
|
|
11733
|
+
);
|
|
11734
|
+
}
|
|
11735
|
+
/**
|
|
11736
|
+
* Prepare a token/NFT mint whose supply authority is the account entity.
|
|
11737
|
+
*
|
|
11738
|
+
* `POST /api/v3/baas/entities/:entityId/mint`.
|
|
11739
|
+
*/
|
|
11740
|
+
async mint(entityId, body, opts) {
|
|
11741
|
+
return this.http.post(
|
|
11742
|
+
`/api/v3/baas/entities/${encodePathParam(entityId)}/mint`,
|
|
11743
|
+
body,
|
|
11744
|
+
opts
|
|
11745
|
+
);
|
|
11746
|
+
}
|
|
11747
|
+
/**
|
|
11748
|
+
* Prepare a token/NFT burn from the account entity's treasury.
|
|
11749
|
+
*
|
|
11750
|
+
* `POST /api/v3/baas/entities/:entityId/burn`.
|
|
11751
|
+
*/
|
|
11752
|
+
async burn(entityId, body, opts) {
|
|
11753
|
+
return this.http.post(
|
|
11754
|
+
`/api/v3/baas/entities/${encodePathParam(entityId)}/burn`,
|
|
11755
|
+
body,
|
|
11756
|
+
opts
|
|
11757
|
+
);
|
|
11758
|
+
}
|
|
11759
|
+
/**
|
|
11760
|
+
* Prepare a compliance action (pause / restrict / wipe) on a token whose
|
|
11761
|
+
* compliance authority is the account entity. The body `account` is the
|
|
11762
|
+
* per-account subject for restrict/wipe — never the payer.
|
|
11763
|
+
*
|
|
11764
|
+
* `POST /api/v3/baas/entities/:entityId/compliance`.
|
|
11765
|
+
*/
|
|
11766
|
+
async compliance(entityId, body, opts) {
|
|
11767
|
+
return this.http.post(
|
|
11768
|
+
`/api/v3/baas/entities/${encodePathParam(entityId)}/compliance`,
|
|
11769
|
+
body,
|
|
11770
|
+
opts
|
|
11771
|
+
);
|
|
11772
|
+
}
|
|
11773
|
+
/**
|
|
11774
|
+
* Prepare an XRPL TrustSet authorising the account entity to hold a currency
|
|
11775
|
+
* from an issuer.
|
|
11776
|
+
*
|
|
11777
|
+
* `POST /api/v3/baas/entities/:entityId/trustline`.
|
|
11778
|
+
*/
|
|
11779
|
+
async trustline(entityId, body, opts) {
|
|
11780
|
+
return this.http.post(
|
|
11781
|
+
`/api/v3/baas/entities/${encodePathParam(entityId)}/trustline`,
|
|
11782
|
+
body,
|
|
11783
|
+
opts
|
|
11784
|
+
);
|
|
11785
|
+
}
|
|
11763
11786
|
};
|
|
11764
11787
|
|
|
11765
11788
|
// src/baas/client.ts
|
|
@@ -11770,13 +11793,6 @@ var BaasClient = class _BaasClient {
|
|
|
11770
11793
|
timeout;
|
|
11771
11794
|
allowInsecure;
|
|
11772
11795
|
http;
|
|
11773
|
-
/**
|
|
11774
|
-
* Validator-routed HTTP client for the `/api/v3/transactions/*` prepare/execute
|
|
11775
|
-
* surface — a SIBLING of `/host`, NOT under the `pathPrefix`. Rooted at the
|
|
11776
|
-
* raw gateway/ingress origin (`hostUrl`) so transactions reach the validator
|
|
11777
|
-
* even when BaaS traffic is gateway-routed at `/host/*`.
|
|
11778
|
-
*/
|
|
11779
|
-
txHttp;
|
|
11780
11796
|
/** Last HTTP error (for getHttpHealth) */
|
|
11781
11797
|
lastHttpError;
|
|
11782
11798
|
/**
|
|
@@ -11805,14 +11821,6 @@ var BaasClient = class _BaasClient {
|
|
|
11805
11821
|
rules;
|
|
11806
11822
|
/** Canonical entity authoring surface (token/account/topic/agent + launchpad). */
|
|
11807
11823
|
entities;
|
|
11808
|
-
/**
|
|
11809
|
-
* Validator-routed transaction prepare/execute (sovereignty model). The
|
|
11810
|
-
* prepare endpoints accept an explicit `payerAccountId` for the session-less
|
|
11811
|
-
* payer path, OR carry the web3-auth session token for the JWT-wallet payer
|
|
11812
|
-
* path (kept in sync with the main client's token — see {@link authenticate}).
|
|
11813
|
-
* Targets `/api/v3/transactions/*`, a sibling of the `/host` BaaS surface.
|
|
11814
|
-
*/
|
|
11815
|
-
transactions;
|
|
11816
11824
|
constructor(config) {
|
|
11817
11825
|
this.allowInsecure = config.allowInsecure ?? false;
|
|
11818
11826
|
this.hostUrl = validateUrl2(config.hostUrl, this.allowInsecure);
|
|
@@ -11829,11 +11837,6 @@ var BaasClient = class _BaasClient {
|
|
|
11829
11837
|
// been called (authContext set). Excludes /api/v3/{,baas/}auth/* (see http client).
|
|
11830
11838
|
onUnauthorized: () => this.reauthenticate()
|
|
11831
11839
|
});
|
|
11832
|
-
this.txHttp = createHttpClient({
|
|
11833
|
-
baseUrl: `${this.hostUrl.replace(/\/$/, "")}/api/v3/transactions`,
|
|
11834
|
-
timeout: this.timeout,
|
|
11835
|
-
onUnauthorized: () => this.reauthenticate()
|
|
11836
|
-
});
|
|
11837
11840
|
const getAppId = () => this.requireAppId();
|
|
11838
11841
|
this.db = new DatabaseClient(this.http, getAppId);
|
|
11839
11842
|
this.storage = new StorageClient(this.http, getAppId);
|
|
@@ -11844,7 +11847,6 @@ var BaasClient = class _BaasClient {
|
|
|
11844
11847
|
this.customerSession = new CustomerSessionClient(baseUrlWithPrefix, this.timeout);
|
|
11845
11848
|
this.rules = new RulesClient(this.http);
|
|
11846
11849
|
this.entities = new EntitiesClient(this.http);
|
|
11847
|
-
this.transactions = new TransactionsClient(this.txHttp);
|
|
11848
11850
|
}
|
|
11849
11851
|
/**
|
|
11850
11852
|
* Connect to the Smart Engines BaaS via cluster auto-discovery.
|
|
@@ -11992,7 +11994,6 @@ var BaasClient = class _BaasClient {
|
|
|
11992
11994
|
throw asBaasError(err);
|
|
11993
11995
|
}
|
|
11994
11996
|
this.http.setAuthToken(result.token);
|
|
11995
|
-
this.txHttp.setAuthToken(result.token);
|
|
11996
11997
|
return result;
|
|
11997
11998
|
}
|
|
11998
11999
|
/**
|
|
@@ -12018,7 +12019,6 @@ var BaasClient = class _BaasClient {
|
|
|
12018
12019
|
publicKey: ctx.publicKey
|
|
12019
12020
|
});
|
|
12020
12021
|
this.http.setAuthToken(result.token);
|
|
12021
|
-
this.txHttp.setAuthToken(result.token);
|
|
12022
12022
|
}
|
|
12023
12023
|
/** Validate the current session */
|
|
12024
12024
|
async validateSession() {
|
|
@@ -12038,7 +12038,6 @@ var BaasClient = class _BaasClient {
|
|
|
12038
12038
|
}
|
|
12039
12039
|
}
|
|
12040
12040
|
this.http.setAuthToken(void 0);
|
|
12041
|
-
this.txHttp.setAuthToken(void 0);
|
|
12042
12041
|
}
|
|
12043
12042
|
// ========== HTTP Helpers ==========
|
|
12044
12043
|
requireAuth() {
|