@hsuite/smart-engines-sdk 3.5.0 → 3.6.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/dist/index.d.ts +59 -2
- package/dist/index.js +211 -122
- package/dist/index.js.map +1 -1
- package/dist/ipfs-access-key/index.js.map +1 -1
- package/dist/k8s-secret-reader/index.js.map +1 -1
- package/dist/nestjs/index.d.ts +53 -1
- package/dist/nestjs/index.js +212 -84
- package/dist/nestjs/index.js.map +1 -1
- package/dist/pqc-verify/index.js.map +1 -1
- package/dist/pqc-verify-envelope/index.d.ts +1 -1
- package/dist/pqc-verify-envelope/index.js +2 -37
- package/dist/pqc-verify-envelope/index.js.map +1 -1
- package/package.json +16 -1
package/dist/index.js
CHANGED
|
@@ -5674,7 +5674,7 @@ var CreateAccountRequestSchema = zod.z.object({
|
|
|
5674
5674
|
* Smart node security mode for the account key structure.
|
|
5675
5675
|
* - 'partial': threshold(2, [appOwnerKey, tssKeyList]) — co-control
|
|
5676
5676
|
* - 'full': TSS KeyList only — full validator network control
|
|
5677
|
-
*
|
|
5677
|
+
* @defaultValue 'full'
|
|
5678
5678
|
*/
|
|
5679
5679
|
securityMode: zod.z.enum(["partial", "full"]).default("full"),
|
|
5680
5680
|
/**
|
|
@@ -6701,14 +6701,34 @@ function createHttpClient(config) {
|
|
|
6701
6701
|
throw new SdkHttpError(`Upload error: ${err.message}`, 0, error);
|
|
6702
6702
|
}
|
|
6703
6703
|
}
|
|
6704
|
+
let reauthInFlight = null;
|
|
6705
|
+
async function withAuthRetry(path, op) {
|
|
6706
|
+
try {
|
|
6707
|
+
return await op();
|
|
6708
|
+
} catch (error) {
|
|
6709
|
+
const refreshable = !!config.onUnauthorized && !path.startsWith("/api/auth/") && error instanceof SdkHttpError && error.statusCode === 401;
|
|
6710
|
+
if (!refreshable) throw error;
|
|
6711
|
+
if (!reauthInFlight) {
|
|
6712
|
+
reauthInFlight = Promise.resolve(config.onUnauthorized()).finally(() => {
|
|
6713
|
+
reauthInFlight = null;
|
|
6714
|
+
});
|
|
6715
|
+
}
|
|
6716
|
+
try {
|
|
6717
|
+
await reauthInFlight;
|
|
6718
|
+
} catch {
|
|
6719
|
+
throw error;
|
|
6720
|
+
}
|
|
6721
|
+
return await op();
|
|
6722
|
+
}
|
|
6723
|
+
}
|
|
6704
6724
|
const client = {
|
|
6705
|
-
post: (path, body) => request("POST", path, body),
|
|
6706
|
-
get: (path) => request("GET", path),
|
|
6707
|
-
put: (path, body) => request("PUT", path, body),
|
|
6708
|
-
patch: (path, body) => request("PATCH", path, body),
|
|
6709
|
-
delete: (path) => request("DELETE", path),
|
|
6710
|
-
getText,
|
|
6711
|
-
upload: ((path, file, filename, metadata, fieldName) => upload(path, file, filename, metadata, fieldName)),
|
|
6725
|
+
post: (path, body) => withAuthRetry(path, () => request("POST", path, body)),
|
|
6726
|
+
get: (path) => withAuthRetry(path, () => request("GET", path)),
|
|
6727
|
+
put: (path, body) => withAuthRetry(path, () => request("PUT", path, body)),
|
|
6728
|
+
patch: (path, body) => withAuthRetry(path, () => request("PATCH", path, body)),
|
|
6729
|
+
delete: (path) => withAuthRetry(path, () => request("DELETE", path)),
|
|
6730
|
+
getText: (path) => withAuthRetry(path, () => getText(path)),
|
|
6731
|
+
upload: ((path, file, filename, metadata, fieldName) => withAuthRetry(path, () => upload(path, file, filename, metadata, fieldName))),
|
|
6712
6732
|
setAuthToken,
|
|
6713
6733
|
getAuthToken
|
|
6714
6734
|
};
|
|
@@ -7116,8 +7136,8 @@ var ValidatorAuthClient = class {
|
|
|
7116
7136
|
*
|
|
7117
7137
|
* Structurally typed against the surface of xrpl's `Wallet` — see the
|
|
7118
7138
|
* comment on {@link HederaSigner} for the "no direct import" rationale.
|
|
7119
|
-
* Accepts both the
|
|
7120
|
-
*
|
|
7139
|
+
* Accepts both the `{ signedTransaction }` envelope and the bare-string
|
|
7140
|
+
* return shapes that xrpl signer libraries expose.
|
|
7121
7141
|
*
|
|
7122
7142
|
* @param challenge - Challenge string from validator
|
|
7123
7143
|
* @param wallet - XRPL Wallet instance (or compatible signer)
|
|
@@ -7360,6 +7380,44 @@ var SubscriptionClient = class {
|
|
|
7360
7380
|
}
|
|
7361
7381
|
};
|
|
7362
7382
|
|
|
7383
|
+
// src/faucet/index.ts
|
|
7384
|
+
var faucet_exports = {};
|
|
7385
|
+
__export(faucet_exports, {
|
|
7386
|
+
FaucetClient: () => FaucetClient
|
|
7387
|
+
});
|
|
7388
|
+
var FaucetClient = class {
|
|
7389
|
+
constructor(http) {
|
|
7390
|
+
this.http = http;
|
|
7391
|
+
}
|
|
7392
|
+
http;
|
|
7393
|
+
/**
|
|
7394
|
+
* Request a signing challenge for a recipient address. The returned
|
|
7395
|
+
* `message` must be signed by the key controlling `recipientAddress`.
|
|
7396
|
+
*/
|
|
7397
|
+
async requestChallenge(chain, recipientAddress) {
|
|
7398
|
+
return this.http.post("/faucet/hsuite/challenge", { chain, recipientAddress });
|
|
7399
|
+
}
|
|
7400
|
+
/**
|
|
7401
|
+
* Submit a signed challenge to dispense HST. The result is a discriminated
|
|
7402
|
+
* union on `status` — branch on `'dispensed' | 'trustline_required' |
|
|
7403
|
+
* 'rate_limited'`. On `'trustline_required'`, set the returned trust line on
|
|
7404
|
+
* the recipient and re-dispense with a fresh challenge.
|
|
7405
|
+
*/
|
|
7406
|
+
async dispense(req) {
|
|
7407
|
+
return this.http.post("/faucet/hsuite", req);
|
|
7408
|
+
}
|
|
7409
|
+
/**
|
|
7410
|
+
* Get today's dispense status for a recipient (e.g. amount already
|
|
7411
|
+
* dispensed today).
|
|
7412
|
+
*/
|
|
7413
|
+
async getStatus(chain, recipientAddress) {
|
|
7414
|
+
const params = new URLSearchParams();
|
|
7415
|
+
params.append("chain", chain);
|
|
7416
|
+
params.append("recipientAddress", recipientAddress);
|
|
7417
|
+
return this.http.get(`/faucet/hsuite/status?${params.toString()}`);
|
|
7418
|
+
}
|
|
7419
|
+
};
|
|
7420
|
+
|
|
7363
7421
|
// src/tss/index.ts
|
|
7364
7422
|
var TSSClient = class {
|
|
7365
7423
|
constructor(http) {
|
|
@@ -7367,20 +7425,29 @@ var TSSClient = class {
|
|
|
7367
7425
|
}
|
|
7368
7426
|
http;
|
|
7369
7427
|
/**
|
|
7370
|
-
* Create a multi-sig entity
|
|
7428
|
+
* Create a multi-sig entity via a synchronous DKG ceremony.
|
|
7429
|
+
*
|
|
7430
|
+
* @param options Entity-creation parameters (chain, threshold, participants).
|
|
7431
|
+
* @returns The created entity's identity (ids + group public keys).
|
|
7371
7432
|
*/
|
|
7372
7433
|
async createEntity(options) {
|
|
7373
7434
|
return this.http.post("/tss/entity/create", options);
|
|
7374
7435
|
}
|
|
7375
7436
|
/**
|
|
7376
|
-
* Reshare keys when cluster membership changes.
|
|
7377
|
-
*
|
|
7437
|
+
* Reshare keys when cluster membership changes. Redistributes secret shares
|
|
7438
|
+
* WITHOUT changing public keys.
|
|
7439
|
+
*
|
|
7440
|
+
* @param request The new membership / threshold to reshare to.
|
|
7441
|
+
* @returns The reshare outcome.
|
|
7378
7442
|
*/
|
|
7379
7443
|
async reshareCluster(request) {
|
|
7380
7444
|
return this.http.post("/tss/cluster/reshare", request);
|
|
7381
7445
|
}
|
|
7382
7446
|
/**
|
|
7383
|
-
* Get entity details by
|
|
7447
|
+
* Get entity details by id.
|
|
7448
|
+
*
|
|
7449
|
+
* @param entityId The entity id to look up.
|
|
7450
|
+
* @returns The entity's details.
|
|
7384
7451
|
*/
|
|
7385
7452
|
async getEntity(entityId) {
|
|
7386
7453
|
return this.http.get(`/tss/entity/${encodePathParam(entityId)}`);
|
|
@@ -7389,55 +7456,71 @@ var TSSClient = class {
|
|
|
7389
7456
|
* Sign a transaction using MPC.
|
|
7390
7457
|
*
|
|
7391
7458
|
* Routes to `POST /api/v3/tss/hedera/sign-mpc`. Only `'hedera'` is wired
|
|
7392
|
-
* server-side
|
|
7393
|
-
*
|
|
7394
|
-
*
|
|
7395
|
-
*
|
|
7396
|
-
*
|
|
7397
|
-
*
|
|
7459
|
+
* server-side; other chain signing paths run via their own controllers (XRPL
|
|
7460
|
+
* multisig, Polkadot MPC) and are not exposed through this sub-client. The
|
|
7461
|
+
* `chain` field is carried into the request body so the validator can log +
|
|
7462
|
+
* route, but any non-`'hedera'` value will 404.
|
|
7463
|
+
*
|
|
7464
|
+
* @param request The MPC signing request; `chain` is forced to `'hedera'`.
|
|
7465
|
+
* @returns The MPC signing result.
|
|
7398
7466
|
*/
|
|
7399
7467
|
async signMPC(request) {
|
|
7400
7468
|
const chain = "hedera";
|
|
7401
7469
|
return this.http.post(`/tss/${chain}/sign-mpc`, { ...request, chain });
|
|
7402
7470
|
}
|
|
7403
7471
|
/**
|
|
7404
|
-
* Get known validators and their public keys
|
|
7472
|
+
* Get known validators and their public keys.
|
|
7473
|
+
*
|
|
7474
|
+
* @returns The validator list with public keys.
|
|
7405
7475
|
*/
|
|
7406
7476
|
async getValidators() {
|
|
7407
7477
|
return this.http.get("/tss/validators");
|
|
7408
7478
|
}
|
|
7409
7479
|
/**
|
|
7410
|
-
* Force announcement of this node's public key
|
|
7480
|
+
* Force announcement of this node's public key.
|
|
7481
|
+
*
|
|
7482
|
+
* @returns Whether the announcement was accepted, plus a status message.
|
|
7411
7483
|
*/
|
|
7412
7484
|
async announceKey() {
|
|
7413
7485
|
return this.http.post("/tss/announce", {});
|
|
7414
7486
|
}
|
|
7415
7487
|
/**
|
|
7416
|
-
* Get TSS statistics
|
|
7488
|
+
* Get TSS statistics.
|
|
7489
|
+
*
|
|
7490
|
+
* @returns Aggregate TSS statistics.
|
|
7417
7491
|
*/
|
|
7418
7492
|
async getStats() {
|
|
7419
7493
|
return this.http.get("/tss/stats");
|
|
7420
7494
|
}
|
|
7421
7495
|
/**
|
|
7422
|
-
* List all TSS entities
|
|
7496
|
+
* List all TSS entities.
|
|
7497
|
+
*
|
|
7498
|
+
* @returns The full entity list.
|
|
7423
7499
|
*/
|
|
7424
7500
|
async listEntities() {
|
|
7425
7501
|
return this.http.get("/tss/entities");
|
|
7426
7502
|
}
|
|
7427
7503
|
/**
|
|
7428
|
-
* TSS health check
|
|
7504
|
+
* TSS health check.
|
|
7505
|
+
*
|
|
7506
|
+
* @returns The TSS subsystem health report.
|
|
7429
7507
|
*/
|
|
7430
7508
|
async getHealth() {
|
|
7431
7509
|
return this.http.get("/tss/health");
|
|
7432
7510
|
}
|
|
7433
7511
|
/**
|
|
7434
|
-
* List DKG ceremonies and their statistics
|
|
7512
|
+
* List DKG ceremonies and their statistics.
|
|
7513
|
+
*
|
|
7514
|
+
* @returns The ceremony list.
|
|
7435
7515
|
*/
|
|
7436
7516
|
async listCeremonies() {
|
|
7437
7517
|
return this.http.get("/tss/multisig/ceremonies");
|
|
7438
7518
|
}
|
|
7439
7519
|
/**
|
|
7440
|
-
* Get multi-sig transaction status by transaction
|
|
7520
|
+
* Get multi-sig transaction status by transaction id.
|
|
7521
|
+
*
|
|
7522
|
+
* @param txId The multi-sig transaction id.
|
|
7523
|
+
* @returns The current status of that transaction.
|
|
7441
7524
|
*/
|
|
7442
7525
|
async getMultiSigStatus(txId) {
|
|
7443
7526
|
return this.http.get(`/tss/multisig/transactions/${encodePathParam(txId)}`);
|
|
@@ -7448,6 +7531,9 @@ var TSSClient = class {
|
|
|
7448
7531
|
* Server returns 202 + `{ jobId, statusUrl, status: 'pending' }` immediately;
|
|
7449
7532
|
* the DKG ceremony runs in the background. Poll {@link getJob} until the
|
|
7450
7533
|
* status reaches `'success'` or `'failed'`.
|
|
7534
|
+
*
|
|
7535
|
+
* @param options Entity-creation parameters.
|
|
7536
|
+
* @returns A job descriptor (`jobId`, `statusUrl`, initial status).
|
|
7451
7537
|
*/
|
|
7452
7538
|
async createEntityAsync(options) {
|
|
7453
7539
|
return this.http.post("/tss/entity/create/async", options);
|
|
@@ -7455,6 +7541,9 @@ var TSSClient = class {
|
|
|
7455
7541
|
/**
|
|
7456
7542
|
* Async-job variant of {@link reshareCluster}. Returns 202 + a polling
|
|
7457
7543
|
* descriptor; resharing runs in the background.
|
|
7544
|
+
*
|
|
7545
|
+
* @param request The new membership / threshold to reshare to.
|
|
7546
|
+
* @returns A job descriptor to poll via {@link getJob}.
|
|
7458
7547
|
*/
|
|
7459
7548
|
async reshareClusterAsync(request) {
|
|
7460
7549
|
return this.http.post("/tss/cluster/reshare/async", request);
|
|
@@ -7462,6 +7551,9 @@ var TSSClient = class {
|
|
|
7462
7551
|
/**
|
|
7463
7552
|
* Poll the status of an async TSS-ceremony job kicked off via
|
|
7464
7553
|
* {@link createEntityAsync} or {@link reshareClusterAsync}.
|
|
7554
|
+
*
|
|
7555
|
+
* @param jobId The job id returned by the async kickoff call.
|
|
7556
|
+
* @returns The job's current status (and result once terminal).
|
|
7465
7557
|
*/
|
|
7466
7558
|
async getJob(jobId) {
|
|
7467
7559
|
return this.http.get(`/tss/jobs/${encodePathParam(jobId)}`);
|
|
@@ -7474,6 +7566,10 @@ var TSSClient = class {
|
|
|
7474
7566
|
* Payload constraints (enforced server-side):
|
|
7475
7567
|
* - even-length lowercase hex
|
|
7476
7568
|
* - ≥32 bytes, ≤8KB
|
|
7569
|
+
*
|
|
7570
|
+
* @param appId The smart-app entity id to sign as.
|
|
7571
|
+
* @param request The hex payload to sign.
|
|
7572
|
+
* @returns The aggregate signature over the payload.
|
|
7477
7573
|
*/
|
|
7478
7574
|
async signForApp(appId, request) {
|
|
7479
7575
|
return this.http.post(`/tss/entity/${encodePathParam(appId)}/sign`, request);
|
|
@@ -8546,25 +8642,29 @@ var DeploymentClient = class {
|
|
|
8546
8642
|
return this.http.get(`/api/deployment/apps/${encodePathParam(appId)}`);
|
|
8547
8643
|
}
|
|
8548
8644
|
/**
|
|
8549
|
-
* Update app configuration.
|
|
8645
|
+
* Update app configuration.
|
|
8646
|
+
*
|
|
8647
|
+
* @param appId - The app to update.
|
|
8648
|
+
* @param updates - Partial deploy-request fields to apply.
|
|
8649
|
+
* @returns The updated app info.
|
|
8550
8650
|
*/
|
|
8551
8651
|
async update(appId, updates) {
|
|
8552
8652
|
return this.http.put(`/api/deployment/apps/${encodePathParam(appId)}`, updates);
|
|
8553
8653
|
}
|
|
8554
8654
|
/**
|
|
8555
|
-
* Delete an app
|
|
8655
|
+
* Delete an app (runtime effect: namespace teardown).
|
|
8556
8656
|
*/
|
|
8557
8657
|
async delete(appId) {
|
|
8558
8658
|
return this.http.delete(`/api/deployment/apps/${encodePathParam(appId)}`);
|
|
8559
8659
|
}
|
|
8560
8660
|
/**
|
|
8561
|
-
* Suspend an app
|
|
8661
|
+
* Suspend an app (runtime effect: scale to zero).
|
|
8562
8662
|
*/
|
|
8563
8663
|
async suspend(appId) {
|
|
8564
8664
|
return this.http.post(`/api/deployment/apps/${encodePathParam(appId)}/suspend`, {});
|
|
8565
8665
|
}
|
|
8566
8666
|
/**
|
|
8567
|
-
* Resume a suspended app
|
|
8667
|
+
* Resume a suspended app (runtime effect: scale back up).
|
|
8568
8668
|
*/
|
|
8569
8669
|
async resume(appId) {
|
|
8570
8670
|
return this.http.post(`/api/deployment/apps/${encodePathParam(appId)}/resume`, {});
|
|
@@ -8613,7 +8713,7 @@ var DeploymentClient = class {
|
|
|
8613
8713
|
return this.http.getText(`/api/deployment/apps/${encodePathParam(appId)}/metrics`);
|
|
8614
8714
|
}
|
|
8615
8715
|
/**
|
|
8616
|
-
* Rotate the smart-app's tenant-secret KEK
|
|
8716
|
+
* Rotate the smart-app's tenant-secret KEK.
|
|
8617
8717
|
*
|
|
8618
8718
|
* Re-encrypts every `runtime.env` envelope at the new KEK version
|
|
8619
8719
|
* transparently. Previous versions remain valid until explicitly
|
|
@@ -8626,7 +8726,7 @@ var DeploymentClient = class {
|
|
|
8626
8726
|
);
|
|
8627
8727
|
}
|
|
8628
8728
|
/**
|
|
8629
|
-
* Revoke a tenant-secret KEK version (
|
|
8729
|
+
* Revoke a tenant-secret KEK version (emergency burn).
|
|
8630
8730
|
*
|
|
8631
8731
|
* Envelopes at the revoked version become operationally dead —
|
|
8632
8732
|
* decryption inside the smart-app pod fails. Owner-only and
|
|
@@ -8879,6 +8979,8 @@ var SmartEngineClient = class _SmartEngineClient {
|
|
|
8879
8979
|
// ========== Sub-Clients ==========
|
|
8880
8980
|
/** Application subscription management */
|
|
8881
8981
|
subscription;
|
|
8982
|
+
/** Testnet HST faucet (challenge -> sign -> dispense) */
|
|
8983
|
+
faucet;
|
|
8882
8984
|
/** Threshold Signature Scheme — chain-agnostic MPC operations */
|
|
8883
8985
|
tss;
|
|
8884
8986
|
/** IPFS decentralized file storage */
|
|
@@ -8937,6 +9039,7 @@ var SmartEngineClient = class _SmartEngineClient {
|
|
|
8937
9039
|
timeout: config.timeout
|
|
8938
9040
|
});
|
|
8939
9041
|
this.subscription = new SubscriptionClient(this.http);
|
|
9042
|
+
this.faucet = new FaucetClient(this.http);
|
|
8940
9043
|
this.tss = new TSSClient(this.http);
|
|
8941
9044
|
this.ipfs = new IPFSClient(this.http);
|
|
8942
9045
|
this.transactions = new TransactionsClient(this.txHttp);
|
|
@@ -8992,13 +9095,17 @@ var SmartEngineClient = class _SmartEngineClient {
|
|
|
8992
9095
|
});
|
|
8993
9096
|
}
|
|
8994
9097
|
/**
|
|
8995
|
-
* Connect to the smart-engines network with auto-discovery and authentication
|
|
9098
|
+
* Connect to the smart-engines network with auto-discovery and authentication.
|
|
9099
|
+
*
|
|
9100
|
+
* Steps:
|
|
9101
|
+
* 1. Discovers validators via the HCS registry topic.
|
|
9102
|
+
* 2. Selects a random validator with an API endpoint.
|
|
9103
|
+
* 3. Authenticates with Web3-style challenge-response.
|
|
9104
|
+
* 4. Returns a configured client ready to use.
|
|
8996
9105
|
*
|
|
8997
|
-
*
|
|
8998
|
-
*
|
|
8999
|
-
*
|
|
9000
|
-
* 3. Authenticates with Web3-style challenge-response
|
|
9001
|
-
* 4. Returns a configured client ready to use
|
|
9106
|
+
* @param config - Network, registry topic, and auth signer config.
|
|
9107
|
+
* @returns The configured client, the chosen validator, and the auth session.
|
|
9108
|
+
* @throws SmartEngineError 503 if no validator with an API endpoint is found.
|
|
9002
9109
|
*/
|
|
9003
9110
|
static async connectToNetwork(config) {
|
|
9004
9111
|
const allowInsecure = config.allowInsecure ?? false;
|
|
@@ -9035,18 +9142,22 @@ var SmartEngineClient = class _SmartEngineClient {
|
|
|
9035
9142
|
return { client, validator, session };
|
|
9036
9143
|
}
|
|
9037
9144
|
/**
|
|
9038
|
-
* Connect to the smart-engines network via the **service-registry
|
|
9039
|
-
*
|
|
9040
|
-
*
|
|
9041
|
-
*
|
|
9042
|
-
*
|
|
9043
|
-
* without code edits.
|
|
9145
|
+
* Connect to the smart-engines network via the **service-registry**.
|
|
9146
|
+
* Preferred over {@link connectToNetwork} once the validator pods in the
|
|
9147
|
+
* target network have published their cluster endpoints — the SDK
|
|
9148
|
+
* auto-balances across the active cluster set and rides permissionless
|
|
9149
|
+
* cluster join/leave without code edits.
|
|
9044
9150
|
*
|
|
9045
|
-
*
|
|
9151
|
+
* Resolution ladder:
|
|
9046
9152
|
* 1. HTTP fetch `/api/v3/discovery/clusters` from each bootstrap seed.
|
|
9047
9153
|
* 2. (Optional) HCS trust-anchor membership cross-check.
|
|
9048
9154
|
* 3. Random-pick over the verified set.
|
|
9049
9155
|
*
|
|
9156
|
+
* @param config - Seed + auth config. See {@link ClusterConnectionConfig}.
|
|
9157
|
+
* @returns The configured client, the selected cluster, and the auth session.
|
|
9158
|
+
* @throws SmartEngineError 400 if neither `bootstrap` nor `network` is given.
|
|
9159
|
+
* @throws SmartEngineError 503 if no active cluster can be reached.
|
|
9160
|
+
*
|
|
9050
9161
|
* @example Zero-config (recommended for smart-app callers)
|
|
9051
9162
|
* ```ts
|
|
9052
9163
|
* const { client, cluster, session } = await SmartEngineClient.connectToCluster({
|
|
@@ -9175,17 +9286,11 @@ var SmartEngineClient = class _SmartEngineClient {
|
|
|
9175
9286
|
return this.http.post("/tokens/mint", validated);
|
|
9176
9287
|
}
|
|
9177
9288
|
/**
|
|
9178
|
-
* Get token information.
|
|
9289
|
+
* Get token information for a token on the given chain.
|
|
9179
9290
|
*
|
|
9180
|
-
*
|
|
9181
|
-
*
|
|
9182
|
-
*
|
|
9183
|
-
* `TokenMigrationController` at
|
|
9184
|
-
* `apps/smart-validator/src/token-migration/token-migration.controller.ts:173`.
|
|
9185
|
-
* Nest resolves routes in `controllers: [...]` order — `ValidatorController`
|
|
9186
|
-
* is registered first (`apps/smart-validator/src/smart-validator.module.ts:1222`),
|
|
9187
|
-
* so `multiChain.getTokenInfo(chain, tokenId)` wins and the
|
|
9188
|
-
* token-migration handler is unreachable via this path.
|
|
9291
|
+
* @param chain - Chain identifier (e.g. `'hedera'`, `'xrpl'`).
|
|
9292
|
+
* @param tokenId - Chain-native token identifier.
|
|
9293
|
+
* @returns Token metadata and supply information.
|
|
9189
9294
|
*/
|
|
9190
9295
|
async getTokenInfo(chain, tokenId) {
|
|
9191
9296
|
return this.http.get(`/tokens/${encodePathParam(chain)}/${encodePathParam(tokenId)}`);
|
|
@@ -9414,8 +9519,7 @@ var DomainsClient = class {
|
|
|
9414
9519
|
}
|
|
9415
9520
|
/**
|
|
9416
9521
|
* Generate a verification token. Server accepts one of `dns-txt`,
|
|
9417
|
-
* `dns-cname`, `http-file`, `email
|
|
9418
|
-
* `apps/smart-gateway/src/domains/domains.controller.ts:226-234`).
|
|
9522
|
+
* `dns-cname`, `http-file`, `email`.
|
|
9419
9523
|
*/
|
|
9420
9524
|
async generateVerificationToken(domain, method) {
|
|
9421
9525
|
return this.http.post(`/domains/${encodePathParam(domain)}/verification`, { method });
|
|
@@ -9539,10 +9643,8 @@ var HealthClient = class {
|
|
|
9539
9643
|
}
|
|
9540
9644
|
http;
|
|
9541
9645
|
/**
|
|
9542
|
-
* Per-cluster aggregate health probe. Wraps
|
|
9543
|
-
*
|
|
9544
|
-
* `apps/smart-gateway/src/health/health.controller.ts:213-263`. Returns
|
|
9545
|
-
* local validator + host + genesis state in a single payload.
|
|
9646
|
+
* Per-cluster aggregate health probe. Wraps `GET /api/v3/cluster/health`.
|
|
9647
|
+
* Returns local validator + host + genesis state in a single payload.
|
|
9546
9648
|
*/
|
|
9547
9649
|
async getCluster() {
|
|
9548
9650
|
return this.http.get("/cluster/health");
|
|
@@ -10287,23 +10389,11 @@ var StorageClient = class {
|
|
|
10287
10389
|
return this.http.delete(`/api/storage/${encodePathParam(appId)}/${encodePathParam(cid)}`);
|
|
10288
10390
|
}
|
|
10289
10391
|
/**
|
|
10290
|
-
*
|
|
10392
|
+
* List all files for the app.
|
|
10291
10393
|
*
|
|
10292
|
-
* @
|
|
10293
|
-
*
|
|
10294
|
-
*
|
|
10295
|
-
* stream body via `download(cid)`. This alias forwards to `download`
|
|
10296
|
-
* for back-compat; **scheduled for removal in 4.0.0**.
|
|
10297
|
-
*/
|
|
10298
|
-
async getFile(cid) {
|
|
10299
|
-
return this.download(cid);
|
|
10300
|
-
}
|
|
10301
|
-
/**
|
|
10302
|
-
* List all files for the app
|
|
10303
|
-
*
|
|
10304
|
-
* @param pagination.offset Server reads `offset`; the legacy `skip`
|
|
10305
|
-
* option was a client-only synonym that the server silently ignored.
|
|
10306
|
-
* Use `offset` going forward.
|
|
10394
|
+
* @param pagination - Optional `limit` and `offset` (the server reads
|
|
10395
|
+
* `offset` for pagination).
|
|
10396
|
+
* @returns The file list and total count.
|
|
10307
10397
|
*/
|
|
10308
10398
|
async listFiles(pagination) {
|
|
10309
10399
|
const appId = this.getAppId();
|
|
@@ -10684,6 +10774,13 @@ var BaasClient = class _BaasClient {
|
|
|
10684
10774
|
http;
|
|
10685
10775
|
/** Last HTTP error (for getHttpHealth) */
|
|
10686
10776
|
lastHttpError;
|
|
10777
|
+
/**
|
|
10778
|
+
* Auth options from the last {@link authenticate} call, retained so the
|
|
10779
|
+
* client can transparently re-authenticate when the session token expires
|
|
10780
|
+
* (the http client invokes {@link reauthenticate} on a 401). Undefined until
|
|
10781
|
+
* the first successful authenticate.
|
|
10782
|
+
*/
|
|
10783
|
+
authContext;
|
|
10687
10784
|
// ========== Sub-Clients ==========
|
|
10688
10785
|
/** Trustless database with state proofs and Merkle verification */
|
|
10689
10786
|
db;
|
|
@@ -10713,7 +10810,11 @@ var BaasClient = class _BaasClient {
|
|
|
10713
10810
|
const baseUrlWithPrefix = this.pathPrefix ? this.hostUrl.replace(/\/$/, "") + this.pathPrefix : this.hostUrl;
|
|
10714
10811
|
this.http = createHttpClient({
|
|
10715
10812
|
baseUrl: baseUrlWithPrefix,
|
|
10716
|
-
timeout: this.timeout
|
|
10813
|
+
timeout: this.timeout,
|
|
10814
|
+
// Transparent session refresh: on a 401, re-run the challenge-response
|
|
10815
|
+
// with the retained signer and retry once. No-op until authenticate() has
|
|
10816
|
+
// been called (authContext set). Excludes /api/auth/* (see http client).
|
|
10817
|
+
onUnauthorized: () => this.reauthenticate()
|
|
10717
10818
|
});
|
|
10718
10819
|
const getAppId = () => this.requireAppId();
|
|
10719
10820
|
this.db = new DatabaseClient(this.http, getAppId);
|
|
@@ -10849,6 +10950,7 @@ var BaasClient = class _BaasClient {
|
|
|
10849
10950
|
*/
|
|
10850
10951
|
async authenticate(options) {
|
|
10851
10952
|
const { chain, walletAddress, publicKey, signFn } = options;
|
|
10953
|
+
this.authContext = options;
|
|
10852
10954
|
let challenge;
|
|
10853
10955
|
try {
|
|
10854
10956
|
challenge = await this.http.post("/api/auth/challenge", {
|
|
@@ -10873,6 +10975,30 @@ var BaasClient = class _BaasClient {
|
|
|
10873
10975
|
this.http.setAuthToken(result.token);
|
|
10874
10976
|
return result;
|
|
10875
10977
|
}
|
|
10978
|
+
/**
|
|
10979
|
+
* Re-run the challenge-response with the retained signer to mint a fresh
|
|
10980
|
+
* session token. Invoked by the http client's `onUnauthorized` hook when a
|
|
10981
|
+
* request 401s because the token expired — so long-lived clients keep working
|
|
10982
|
+
* without the caller re-implementing refresh. No-op if {@link authenticate}
|
|
10983
|
+
* was never called. The `/api/auth/*` calls below are excluded from the http
|
|
10984
|
+
* client's 401-retry path, so this can never recurse.
|
|
10985
|
+
*/
|
|
10986
|
+
async reauthenticate() {
|
|
10987
|
+
const ctx = this.authContext;
|
|
10988
|
+
if (!ctx) return;
|
|
10989
|
+
const challenge = await this.http.post("/api/auth/challenge", {
|
|
10990
|
+
chain: ctx.chain,
|
|
10991
|
+
walletAddress: ctx.walletAddress,
|
|
10992
|
+
appId: this.appId
|
|
10993
|
+
});
|
|
10994
|
+
const signature = await ctx.signFn(challenge.message);
|
|
10995
|
+
const result = await this.http.post("/api/auth/verify", {
|
|
10996
|
+
challengeId: challenge.challengeId,
|
|
10997
|
+
signature,
|
|
10998
|
+
publicKey: ctx.publicKey
|
|
10999
|
+
});
|
|
11000
|
+
this.http.setAuthToken(result.token);
|
|
11001
|
+
}
|
|
10876
11002
|
/** Validate the current session */
|
|
10877
11003
|
async validateSession() {
|
|
10878
11004
|
this.requireAuth();
|
|
@@ -11149,9 +11275,6 @@ function validateEnvelopeSchema(envelope) {
|
|
|
11149
11275
|
if (version === "kyber-aes-v1") {
|
|
11150
11276
|
return validateKyberAesV1(envelope);
|
|
11151
11277
|
}
|
|
11152
|
-
if (version === "aes-v0") {
|
|
11153
|
-
return validateAesV0(envelope);
|
|
11154
|
-
}
|
|
11155
11278
|
return {
|
|
11156
11279
|
ok: false,
|
|
11157
11280
|
reason: `unknown envelope version: ${JSON.stringify(version)}`
|
|
@@ -11245,38 +11368,6 @@ function validateKyberAesV1(env) {
|
|
|
11245
11368
|
}
|
|
11246
11369
|
return { ok: true, version: "kyber-aes-v1" };
|
|
11247
11370
|
}
|
|
11248
|
-
function validateAesV0(env) {
|
|
11249
|
-
if (!isNonEmptyString(env.aesIv)) {
|
|
11250
|
-
return { ok: false, reason: "aesIv must be a non-empty base64 string" };
|
|
11251
|
-
}
|
|
11252
|
-
const ivBytes = tryDecodeBase64(env.aesIv);
|
|
11253
|
-
if (!ivBytes) return { ok: false, reason: "aesIv is not valid base64" };
|
|
11254
|
-
if (ivBytes.length !== AES_IV_LEN) {
|
|
11255
|
-
return {
|
|
11256
|
-
ok: false,
|
|
11257
|
-
reason: `aesIv length ${ivBytes.length} != expected ${AES_IV_LEN} (AES-GCM 96-bit nonce)`
|
|
11258
|
-
};
|
|
11259
|
-
}
|
|
11260
|
-
if (typeof env.aesCiphertext !== "string") {
|
|
11261
|
-
return { ok: false, reason: "aesCiphertext must be a base64 string" };
|
|
11262
|
-
}
|
|
11263
|
-
if (env.aesCiphertext.length > 0) {
|
|
11264
|
-
const ctBytes = tryDecodeBase64(env.aesCiphertext);
|
|
11265
|
-
if (!ctBytes) return { ok: false, reason: "aesCiphertext is not valid base64" };
|
|
11266
|
-
}
|
|
11267
|
-
if (!isNonEmptyString(env.aesAuthTag)) {
|
|
11268
|
-
return { ok: false, reason: "aesAuthTag must be a non-empty base64 string" };
|
|
11269
|
-
}
|
|
11270
|
-
const tagBytes = tryDecodeBase64(env.aesAuthTag);
|
|
11271
|
-
if (!tagBytes) return { ok: false, reason: "aesAuthTag is not valid base64" };
|
|
11272
|
-
if (tagBytes.length !== AES_TAG_LEN) {
|
|
11273
|
-
return {
|
|
11274
|
-
ok: false,
|
|
11275
|
-
reason: `aesAuthTag length ${tagBytes.length} != expected ${AES_TAG_LEN} (AES-GCM 128-bit tag)`
|
|
11276
|
-
};
|
|
11277
|
-
}
|
|
11278
|
-
return { ok: true, version: "aes-v0" };
|
|
11279
|
-
}
|
|
11280
11371
|
|
|
11281
11372
|
// src/pqc-verify-envelope/verify-pqc-envelope.ts
|
|
11282
11373
|
var KYBER_MIN_TIMESTAMP_MS = 17040672e5;
|
|
@@ -11295,10 +11386,10 @@ async function verifyPqcEnvelope(envelope, options = {}) {
|
|
|
11295
11386
|
version,
|
|
11296
11387
|
schemaValid: true,
|
|
11297
11388
|
base64Valid: true,
|
|
11298
|
-
//
|
|
11389
|
+
// Set to false below if the timestamp plausibility check fails.
|
|
11299
11390
|
timestampPlausible: true
|
|
11300
11391
|
};
|
|
11301
|
-
|
|
11392
|
+
{
|
|
11302
11393
|
details.kemAlgorithm = env.kemAlgorithm;
|
|
11303
11394
|
details.recipientPkFingerprint = env.recipientPkFingerprint;
|
|
11304
11395
|
details.kdfLabel = env.kdfLabel;
|
|
@@ -12160,17 +12251,13 @@ var AgentRulesBuilder = class extends BaseRuleBuilder {
|
|
|
12160
12251
|
return this;
|
|
12161
12252
|
}
|
|
12162
12253
|
// ────────────────────────────────────────────────────────────────────────
|
|
12163
|
-
//
|
|
12254
|
+
// AI atom shortcuts
|
|
12164
12255
|
//
|
|
12165
12256
|
// `MaxTradesPerWindow` and `RequireStructuredOutput` are optional atoms
|
|
12166
12257
|
// (NOT registered as builtin organism modules) wired in the AI-inference
|
|
12167
12258
|
// path of the smart-app's BaaS function. Attached here as canonical
|
|
12168
12259
|
// `ModuleEntry`s so they ship inside the published rule and the cluster's
|
|
12169
12260
|
// canonical evaluator can dispatch them.
|
|
12170
|
-
//
|
|
12171
|
-
// Atom sources:
|
|
12172
|
-
// libs/rules-engine/src/atoms/max-trades-per-window.atom.ts
|
|
12173
|
-
// libs/rules-engine/src/atoms/require-structured-output.atom.ts
|
|
12174
12261
|
// ────────────────────────────────────────────────────────────────────────
|
|
12175
12262
|
/**
|
|
12176
12263
|
* Cap the agent at `maxTradesPerWindow` trades within a rolling `windowMs`
|
|
@@ -12282,7 +12369,7 @@ var module_ = {
|
|
|
12282
12369
|
version: "1.0.0",
|
|
12283
12370
|
config: withDexDefaults(config)
|
|
12284
12371
|
})
|
|
12285
|
-
//
|
|
12372
|
+
// No `agent` module — use `Rules.forAgent()` instead.
|
|
12286
12373
|
};
|
|
12287
12374
|
|
|
12288
12375
|
// src/rules/templates/index.ts
|
|
@@ -12770,6 +12857,7 @@ exports.DomainsClient = DomainsClient;
|
|
|
12770
12857
|
exports.EntitiesClient = EntitiesClient;
|
|
12771
12858
|
exports.EnvelopeClient = EnvelopeClient;
|
|
12772
12859
|
exports.ErrorCode = ErrorCode;
|
|
12860
|
+
exports.FaucetClient = FaucetClient;
|
|
12773
12861
|
exports.FeeConditionsSchema = FeeConditionsSchema;
|
|
12774
12862
|
exports.FixedFeeConditionSchema = FixedFeeConditionSchema;
|
|
12775
12863
|
exports.FractionalFeeConditionSchema = FractionalFeeConditionSchema;
|
|
@@ -12862,6 +12950,7 @@ exports.discovery = discovery_exports;
|
|
|
12862
12950
|
exports.encodePathParam = encodePathParam;
|
|
12863
12951
|
exports.envelope = envelope_exports;
|
|
12864
12952
|
exports.fairLaunch = fairLaunch;
|
|
12953
|
+
exports.faucet = faucet_exports;
|
|
12865
12954
|
exports.fetchRegistrySnapshot = fetchRegistrySnapshot;
|
|
12866
12955
|
exports.forAccount = forAccount;
|
|
12867
12956
|
exports.forAgent = forAgent;
|