@hsuite/smart-engines-cli 1.2.0 → 1.4.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.
Files changed (109) hide show
  1. package/README.md +272 -58
  2. package/dist/_lib/attestation.d.ts +45 -0
  3. package/dist/_lib/attestation.d.ts.map +1 -0
  4. package/dist/_lib/attestation.js +76 -0
  5. package/dist/_lib/attestation.js.map +1 -0
  6. package/dist/_lib/baas.d.ts +147 -0
  7. package/dist/_lib/baas.d.ts.map +1 -0
  8. package/dist/_lib/baas.js +260 -0
  9. package/dist/_lib/baas.js.map +1 -0
  10. package/dist/_lib/cluster.d.ts +6 -6
  11. package/dist/_lib/cluster.js +6 -6
  12. package/dist/_lib/deploy-manifest.d.ts +69 -0
  13. package/dist/_lib/deploy-manifest.d.ts.map +1 -0
  14. package/dist/_lib/deploy-manifest.js +87 -0
  15. package/dist/_lib/deploy-manifest.js.map +1 -0
  16. package/dist/_lib/docker.d.ts +82 -0
  17. package/dist/_lib/docker.d.ts.map +1 -0
  18. package/dist/_lib/docker.js +164 -0
  19. package/dist/_lib/docker.js.map +1 -0
  20. package/dist/_lib/faucet-client.d.ts +64 -0
  21. package/dist/_lib/faucet-client.d.ts.map +1 -0
  22. package/dist/_lib/faucet-client.js +92 -0
  23. package/dist/_lib/faucet-client.js.map +1 -0
  24. package/dist/_lib/framework.d.ts +59 -0
  25. package/dist/_lib/framework.d.ts.map +1 -0
  26. package/dist/_lib/framework.js +149 -0
  27. package/dist/_lib/framework.js.map +1 -0
  28. package/dist/_lib/frontend-guard.d.ts +13 -0
  29. package/dist/_lib/frontend-guard.d.ts.map +1 -0
  30. package/dist/_lib/frontend-guard.js +41 -0
  31. package/dist/_lib/frontend-guard.js.map +1 -0
  32. package/dist/_lib/registry-fanout.d.ts +114 -0
  33. package/dist/_lib/registry-fanout.d.ts.map +1 -0
  34. package/dist/_lib/registry-fanout.js +435 -0
  35. package/dist/_lib/registry-fanout.js.map +1 -0
  36. package/dist/_lib/runtime-env.d.ts +126 -0
  37. package/dist/_lib/runtime-env.d.ts.map +1 -0
  38. package/dist/_lib/runtime-env.js +172 -0
  39. package/dist/_lib/runtime-env.js.map +1 -0
  40. package/dist/_lib/subscription-client.d.ts +129 -18
  41. package/dist/_lib/subscription-client.d.ts.map +1 -1
  42. package/dist/_lib/subscription-client.js +268 -40
  43. package/dist/_lib/subscription-client.js.map +1 -1
  44. package/dist/_lib/subscription-env.d.ts +35 -0
  45. package/dist/_lib/subscription-env.d.ts.map +1 -1
  46. package/dist/_lib/subscription-env.js +46 -2
  47. package/dist/_lib/subscription-env.js.map +1 -1
  48. package/dist/commands/app-lifecycle.d.ts +36 -0
  49. package/dist/commands/app-lifecycle.d.ts.map +1 -0
  50. package/dist/commands/app-lifecycle.js +145 -0
  51. package/dist/commands/app-lifecycle.js.map +1 -0
  52. package/dist/commands/ci.d.ts +45 -0
  53. package/dist/commands/ci.d.ts.map +1 -0
  54. package/dist/commands/ci.js +174 -0
  55. package/dist/commands/ci.js.map +1 -0
  56. package/dist/commands/deploy-manifest.d.ts +11 -0
  57. package/dist/commands/deploy-manifest.d.ts.map +1 -0
  58. package/dist/commands/deploy-manifest.js +17 -0
  59. package/dist/commands/deploy-manifest.js.map +1 -0
  60. package/dist/commands/deploy.d.ts +70 -11
  61. package/dist/commands/deploy.d.ts.map +1 -1
  62. package/dist/commands/deploy.js +263 -150
  63. package/dist/commands/deploy.js.map +1 -1
  64. package/dist/commands/downgrade.js +1 -1
  65. package/dist/commands/downgrade.js.map +1 -1
  66. package/dist/commands/faucet.d.ts +78 -0
  67. package/dist/commands/faucet.d.ts.map +1 -0
  68. package/dist/commands/faucet.js +184 -0
  69. package/dist/commands/faucet.js.map +1 -0
  70. package/dist/commands/governance.js +1 -1
  71. package/dist/commands/governance.js.map +1 -1
  72. package/dist/commands/hist-balance.d.ts +1 -1
  73. package/dist/commands/hist-balance.js +1 -1
  74. package/dist/commands/init.js +1 -1
  75. package/dist/commands/list.d.ts +22 -0
  76. package/dist/commands/list.d.ts.map +1 -0
  77. package/dist/commands/list.js +81 -0
  78. package/dist/commands/list.js.map +1 -0
  79. package/dist/commands/personhood.js +2 -2
  80. package/dist/commands/personhood.js.map +1 -1
  81. package/dist/commands/redeploy.d.ts +62 -0
  82. package/dist/commands/redeploy.d.ts.map +1 -0
  83. package/dist/commands/redeploy.js +310 -0
  84. package/dist/commands/redeploy.js.map +1 -0
  85. package/dist/commands/status.d.ts +51 -0
  86. package/dist/commands/status.d.ts.map +1 -0
  87. package/dist/commands/status.js +138 -0
  88. package/dist/commands/status.js.map +1 -0
  89. package/dist/commands/subscribe.d.ts +94 -17
  90. package/dist/commands/subscribe.d.ts.map +1 -1
  91. package/dist/commands/subscribe.js +450 -81
  92. package/dist/commands/subscribe.js.map +1 -1
  93. package/dist/commands/transactions.d.ts +60 -0
  94. package/dist/commands/transactions.d.ts.map +1 -0
  95. package/dist/commands/transactions.js +101 -0
  96. package/dist/commands/transactions.js.map +1 -0
  97. package/dist/commands/update.d.ts +40 -0
  98. package/dist/commands/update.d.ts.map +1 -0
  99. package/dist/commands/update.js +114 -0
  100. package/dist/commands/update.js.map +1 -0
  101. package/dist/commands/verify.d.ts +10 -19
  102. package/dist/commands/verify.d.ts.map +1 -1
  103. package/dist/commands/verify.js +14 -23
  104. package/dist/commands/verify.js.map +1 -1
  105. package/dist/index.d.ts +12 -3
  106. package/dist/index.d.ts.map +1 -1
  107. package/dist/index.js +32 -3
  108. package/dist/index.js.map +1 -1
  109. package/package.json +11 -4
@@ -1,84 +1,312 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.SubscriptionClient = void 0;
37
+ /**
38
+ * Thin CLI adapter over the SDK's subscription + validator-auth clients.
39
+ *
40
+ * The validator-side `/api/v3/subscription/*` surface and the Web3 validator
41
+ * auth (`/auth/validator/*`) are already covered by `SubscriptionClient` and
42
+ * `ValidatorAuthClient` in `@hsuite/smart-engines-sdk`. To keep the CLI from
43
+ * drifting from the SDK, this file no longer hand-rolls its own `fetch`/auth
44
+ * plumbing — it delegates to the SDK clients, built on the SDK's shared
45
+ * `createHttpClient`.
46
+ *
47
+ * The public shape (class name, method names, response types) is preserved so
48
+ * the CLI command bodies (subscribe/renew/upgrade/downgrade/billing/usage) and
49
+ * their unit tests are unchanged. Tests still inject a fake transport via the
50
+ * constructor's `fetchImpl` seam (and stub `authenticate()` to a no-op).
51
+ *
52
+ * Mapping to the SDK client:
53
+ * request → SubscriptionClient.request (flat body matches SubscriptionRequest)
54
+ * status → SubscriptionClient.getStatus
55
+ * mint → SubscriptionClient.mintNft
56
+ * renew → SubscriptionClient.renew({ appId, additionalDays })
57
+ * upgrade → SubscriptionClient.upgrade({ appId, toTier }) (+ flatten effectiveAt)
58
+ * downgrade → SubscriptionClient.downgrade({ appId, toTier }) (+ flatten effectiveAt)
59
+ * cancelTierChange → SubscriptionClient.cancelTierChange({ appId })
60
+ * usage → SubscriptionClient.getUsage
61
+ * usageStatus → SubscriptionClient.getUsageStatus
62
+ * billing → SubscriptionClient.getBilling(appId, { limit, offset })
63
+ *
64
+ * `createApp` (POST /api/v3/smart-apps) is NOT part of the SDK's subscription
65
+ * surface, so it is kept here as a thin shim against the validator's smart-app
66
+ * create route, posting on the same shared `${origin}/api/v3` client.
67
+ */
68
+ const smart_engines_sdk_1 = require("@hsuite/smart-engines-sdk");
4
69
  /**
5
70
  * Validator-side subscription HTTP client.
6
71
  *
7
- * All routes match the controller at
8
- * apps/smart-validator/src/subscription/subscription.controller.ts.
72
+ * Adapter over the SDK's {@link SdkSubscriptionClient} + {@link ValidatorAuthClient}.
73
+ * All HTTP/fetch + auth logic lives in the SDK; this class only adapts method
74
+ * names + base URL, flattens the SDK's `pendingTierChange` envelope onto the
75
+ * flat `effectiveAt`/`depositInstructions` the CLI consumers read, and (for
76
+ * tests) bridges the injectable `fetchImpl` seam onto the SDK transport.
9
77
  */
10
78
  class SubscriptionClient {
11
- baseUrl;
12
- fetchImpl;
79
+ /** Validator origin WITHOUT the /api/v3 prefix (auth routes are un-prefixed). */
80
+ origin;
81
+ sdk;
82
+ http;
83
+ auth;
13
84
  constructor(opts) {
14
- this.baseUrl = opts.baseUrl.replace(/\/$/, '');
15
- // Bind global fetch so `this` isn't lost when called as a property.
16
- this.fetchImpl =
17
- opts.fetchImpl ?? ((input, init) => globalThis.fetch(input, init));
85
+ this.origin = opts.baseUrl.replace(/\/$/, '');
86
+ this.auth = opts.auth;
87
+ // The validator routes (`/subscription/...`, `/smart-apps`) are all mounted
88
+ // under `/api/v3` carry that prefix on the HttpClient baseUrl so the full
89
+ // URL matches the validator controller mount.
90
+ const baseUrl = `${this.origin}/api/v3`;
91
+ // 3-min request timeout (SDK default is 30s). `POST /subscription/request`
92
+ // synchronously creates the deposit account — a DKG-multisig ceremony plus
93
+ // a Treasury-funded Payment + SignerListSet + HST TrustSet + DisableMaster,
94
+ // each a sign + on-chain submitAndWait. On a slow public XRPL endpoint that
95
+ // whole chain runs ~60-90s, so a 30s client timeout aborted mid-funding and
96
+ // the deposit account was never finished. (Server-side this could later be
97
+ // made async + polled; the generous client timeout is the pragmatic fix.)
98
+ // The same client serves the synchronous `createApp` DKG ceremony.
99
+ const timeout = opts.requestTimeoutMs ?? 180_000;
100
+ this.http = opts.fetchImpl
101
+ ? makeFetchBackedHttpClient(baseUrl, opts.fetchImpl)
102
+ : (0, smart_engines_sdk_1.createHttpClient)({ baseUrl, timeout });
103
+ this.sdk = new smart_engines_sdk_1.SubscriptionClient(this.http);
104
+ }
105
+ /**
106
+ * Web3-auth against the validator: challenge → sign → authenticate → bearer.
107
+ * The validator auth controller is mounted WITHOUT the `/api` prefix
108
+ * (`/auth/validator/...`). Call before request/mint; no-op without creds.
109
+ *
110
+ * Delegates to the SDK's {@link ValidatorAuthClient} for the
111
+ * challenge/authenticate round-trip; signing stays here (ripple-keypairs)
112
+ * because it owns the dev wallet seed. The resulting bearer is attached to
113
+ * the shared HTTP client via `setAuthToken`, so subsequent SDK calls carry it.
114
+ */
115
+ async authenticate() {
116
+ if (!this.auth)
117
+ return;
118
+ // ripple-keypairs ships with xrpl (a CLI dep); import lazily.
119
+ const kp = await Promise.resolve().then(() => __importStar(require('ripple-keypairs')));
120
+ const { publicKey, privateKey } = kp.deriveKeypair(this.auth.seed);
121
+ const authClient = new smart_engines_sdk_1.ValidatorAuthClient({ security: { allowInsecure: true } });
122
+ const res = await authClient.authenticateWithSigner(this.origin, this.auth.chain, this.auth.address, publicKey, (challenge) => {
123
+ const messageHex = Buffer.from(challenge, 'utf-8').toString('hex').toUpperCase();
124
+ return kp.sign(messageHex, privateKey);
125
+ });
126
+ if (!res.token)
127
+ throw new Error('validator auth: no session token returned');
128
+ this.http.setAuthToken(res.token);
129
+ }
130
+ /**
131
+ * Run a bearer-authenticated call with transparent re-auth on token expiry.
132
+ *
133
+ * The deposit-account creation behind `POST /subscription/request` is a
134
+ * synchronous multi-step on-chain ceremony (~60-90s on a slow public XRPL
135
+ * endpoint — see the constructor's timeout note). The validator session
136
+ * bearer obtained in {@link authenticate} can expire DURING that window, so
137
+ * the next session-guarded call (`status`/`mint`) comes back 401
138
+ * "Invalid or expired authentication token" and the CLI's post-payment NFT
139
+ * mint/accept steps never run.
140
+ *
141
+ * This wrapper makes every bearer call robust to ANY request duration (not
142
+ * just a fixed-but-longer TTL): on a 401 / expired-token error it re-runs
143
+ * {@link authenticate} (re-signs a fresh challenge → fresh bearer) ONCE and
144
+ * retries the call. A second failure surfaces unchanged. No-op re-auth (no
145
+ * creds configured) is skipped — a retry without a fresh bearer can't help.
146
+ */
147
+ async withReauth(fn) {
148
+ try {
149
+ return await fn();
150
+ }
151
+ catch (err) {
152
+ if (!this.auth || !isAuthExpiredError(err))
153
+ throw err;
154
+ // Refresh the bearer (challenge → sign → setAuthToken) and retry once.
155
+ await this.authenticate();
156
+ return fn();
157
+ }
158
+ }
159
+ /**
160
+ * Create the canonical smart-app entity via `POST /api/v3/smart-apps`
161
+ * (`SmartAppController.create`) — runs the per-entity DKG ceremony to derive
162
+ * `entityId` AND creates the paid pending-deposit subscription on that id,
163
+ * returning `{ appId: entityId, depositInstructions, subscriptionId }`.
164
+ *
165
+ * The MINT-FIRST entry point for `hsuite subscribe`: the returned `entityId`
166
+ * becomes the subscription appId end-to-end (no throwaway `app-${uuid}`).
167
+ * Auth-gated (developer session) — uses the same validator bearer obtained by
168
+ * {@link authenticate}, and reuses the long request timeout (the synchronous
169
+ * DKG ceremony + on-chain deposit-account funding exceeds the SDK's 30s
170
+ * default). Wrapped in {@link withReauth} so a session expiry during the slow
171
+ * ceremony re-signs + retries once.
172
+ *
173
+ * Posts on the shared `${origin}/api/v3` client (the same base the
174
+ * subscription calls use), so the path is the controller-relative
175
+ * `/smart-apps` and the full URL is `${origin}/api/v3/smart-apps`.
176
+ */
177
+ async createApp(payload) {
178
+ return this.withReauth(() => this.http.post('/smart-apps', payload));
18
179
  }
19
180
  async request(payload) {
20
- return this.post('/api/v3/subscription/request', payload);
181
+ return this.withReauth(() => this.sdk.request(payload));
21
182
  }
22
183
  async status(appId) {
23
- return this.get(`/api/v3/subscription/status/${encodeURIComponent(appId)}`);
184
+ return this.withReauth(() => this.sdk.getStatus(appId));
24
185
  }
25
186
  async mint(appId) {
26
- return this.post(`/api/v3/subscription/mint/${encodeURIComponent(appId)}`, {});
187
+ return this.withReauth(() => this.sdk.mintNft(appId));
27
188
  }
28
189
  async renew(appId, additionalDays) {
29
- return this.post('/api/v3/subscription/renew', {
190
+ return this.withReauth(() => this.sdk.renew({
30
191
  appId,
31
192
  ...(additionalDays !== undefined ? { additionalDays } : {}),
32
- });
193
+ }));
33
194
  }
34
195
  async upgrade(appId, toTier) {
35
- return this.post('/api/v3/subscription/upgrade', {
36
- appId,
37
- toTier,
38
- });
196
+ const res = await this.withReauth(() => this.sdk.upgrade({ appId, toTier: toTier }));
197
+ return flattenTierChange(res);
39
198
  }
40
199
  async downgrade(appId, toTier) {
41
- return this.post('/api/v3/subscription/downgrade', {
42
- appId,
43
- toTier,
44
- });
200
+ const res = await this.withReauth(() => this.sdk.downgrade({ appId, toTier: toTier }));
201
+ return flattenTierChange(res);
45
202
  }
46
203
  async cancelTierChange(appId) {
47
- return this.post('/api/v3/subscription/tier-change/cancel', {
48
- appId,
49
- });
204
+ const res = await this.withReauth(() => this.sdk.cancelTierChange({ appId }));
205
+ return res;
50
206
  }
51
207
  async usage(appId) {
52
- return this.get(`/api/v3/subscription/usage/${encodeURIComponent(appId)}`);
208
+ return this.withReauth(() => this.sdk.getUsage(appId));
53
209
  }
54
210
  async usageStatus(appId) {
55
- return this.get(`/api/v3/subscription/usage/status/${encodeURIComponent(appId)}`);
211
+ return this.withReauth(() => this.sdk.getUsageStatus(appId));
56
212
  }
57
213
  async billing(appId, limit = 50, offset = 0) {
58
- const qs = `?limit=${limit}&offset=${offset}`;
59
- return this.get(`/api/v3/subscription/billing/${encodeURIComponent(appId)}${qs}`);
214
+ return this.withReauth(() => this.sdk.getBilling(appId, { limit, offset }));
60
215
  }
61
- async post(path, body) {
62
- return this.send('POST', path, body);
63
- }
64
- async get(path) {
65
- return this.send('GET', path);
216
+ }
217
+ exports.SubscriptionClient = SubscriptionClient;
218
+ /**
219
+ * Detect a validator-session expiry / 401 across the two error shapes the
220
+ * subscription transport can raise:
221
+ *
222
+ * - the SDK's {@link SdkHttpError} (real `createHttpClient` path) — carries a
223
+ * structured `statusCode` (401) and the server message
224
+ * ("Invalid or expired authentication token").
225
+ * - a plain `Error` from the CLI's fetch-backed test seam
226
+ * ({@link makeFetchBackedHttpClient}) — message is
227
+ * `"${method} ${path} → ${status}: ${body}"`.
228
+ *
229
+ * Matches a 401 status from either shape, plus an "expired/invalid …
230
+ * authentication token" message as a defensive fallback (some session guards
231
+ * answer 403 with that wording).
232
+ */
233
+ function isAuthExpiredError(err) {
234
+ if (err instanceof smart_engines_sdk_1.SdkHttpError) {
235
+ if (err.statusCode === 401)
236
+ return true;
66
237
  }
67
- async send(method, path, body) {
68
- const url = `${this.baseUrl}${path}`;
69
- const init = {
70
- method,
71
- headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
238
+ const message = err instanceof Error ? err.message : String(err ?? '');
239
+ if (/→\s*401\b/.test(message))
240
+ return true;
241
+ if (/\b401\b/.test(message) && /token|auth/i.test(message))
242
+ return true;
243
+ return /(invalid|expired)[^.]*authentication token/i.test(message);
244
+ }
245
+ /**
246
+ * Normalize the SDK's tier-change envelope onto the flat shape the CLI
247
+ * consumers read. The SDK nests `effectiveAt`/`depositInstructions` under
248
+ * `pendingTierChange` (with `depositInstructions` also surfaced top-level on
249
+ * upgrade); the CLI's upgrade/downgrade commands read `res.effectiveAt`,
250
+ * `res.depositInstructions`, `res.toTier` directly.
251
+ */
252
+ function flattenTierChange(res) {
253
+ const ptc = res.pendingTierChange;
254
+ return {
255
+ success: res.success,
256
+ appId: res.appId,
257
+ message: res.message,
258
+ fromTier: ptc?.fromTier,
259
+ toTier: ptc?.toTier,
260
+ effectiveAt: ptc?.effectiveAt,
261
+ depositInstructions: res.depositInstructions ?? ptc?.depositInstructions,
262
+ };
263
+ }
264
+ /**
265
+ * Adapt an injected `fetchImpl` (the CLI's test seam) onto the SDK's
266
+ * {@link HttpClient} interface so the SDK client can be exercised with a fake
267
+ * transport. Carries a mutable bearer token so `authenticate()` →
268
+ * `setAuthToken` → subsequent calls behave like the real client.
269
+ *
270
+ * Mirrors the SDK's own `createHttpClient` request/error semantics (JSON body,
271
+ * Bearer header, `${method} ${path} → ${status}` error on non-2xx).
272
+ */
273
+ function makeFetchBackedHttpClient(baseUrl, fetchImpl) {
274
+ let token;
275
+ async function send(method, path, body) {
276
+ const url = `${baseUrl}${path}`;
277
+ const headers = {
278
+ 'Content-Type': 'application/json',
279
+ Accept: 'application/json',
72
280
  };
281
+ if (token)
282
+ headers.Authorization = `Bearer ${token}`;
283
+ const init = { method, headers };
73
284
  if (body !== undefined)
74
285
  init.body = JSON.stringify(body);
75
- const res = await this.fetchImpl(url, init);
286
+ const res = await fetchImpl(url, init);
76
287
  if (!res.ok) {
77
288
  const text = await res.text().catch(() => '');
78
289
  throw new Error(`${method} ${path} → ${res.status}: ${text.slice(0, 500)}`);
79
290
  }
80
291
  return (await res.json());
81
292
  }
293
+ const unsupported = (verb) => () => {
294
+ throw new Error(`fetch-backed HttpClient: ${verb} not supported in CLI subscription adapter`);
295
+ };
296
+ return {
297
+ get: (path) => send('GET', path),
298
+ post: (path, b) => send('POST', path, b),
299
+ put: unsupported('put'),
300
+ patch: unsupported('patch'),
301
+ delete: unsupported('delete'),
302
+ getText: unsupported('getText'),
303
+ getBinary: unsupported('getBinary'),
304
+ getBinaryWithMeta: unsupported('getBinaryWithMeta'),
305
+ upload: unsupported('upload'),
306
+ setAuthToken: (t) => {
307
+ token = t;
308
+ },
309
+ getAuthToken: () => token,
310
+ };
82
311
  }
83
- exports.SubscriptionClient = SubscriptionClient;
84
312
  //# sourceMappingURL=subscription-client.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"subscription-client.js","sourceRoot":"","sources":["../../src/_lib/subscription-client.ts"],"names":[],"mappings":";;;AAgIA;;;;;GAKG;AACH,MAAa,kBAAkB;IACZ,OAAO,CAAS;IAChB,SAAS,CAAY;IAEtC,YAAY,IAA+B;QACzC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC/C,oEAAoE;QACpE,IAAI,CAAC,SAAS;YACZ,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAE,UAAU,CAAC,KAA8B,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;IACjG,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,OAUb;QACC,OAAO,IAAI,CAAC,IAAI,CAA8B,8BAA8B,EAAE,OAAO,CAAC,CAAC;IACzF,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAAa;QACxB,OAAO,IAAI,CAAC,GAAG,CACb,+BAA+B,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAC3D,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,KAAa;QACtB,OAAO,IAAI,CAAC,IAAI,CACd,6BAA6B,kBAAkB,CAAC,KAAK,CAAC,EAAE,EACxD,EAAE,CACH,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,KAAa,EAAE,cAAuB;QAChD,OAAO,IAAI,CAAC,IAAI,CAAgB,4BAA4B,EAAE;YAC5D,KAAK;YACL,GAAG,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC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E,CAAC,CAAC;YAC9C,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,IAAI,IAAI,MAAM,GAAG,CAAC,MAAM,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;QAC9E,CAAC;QACD,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAM,CAAC;IACjC,CAAC;IACD,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,GAAU,EAAE;QAChD,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,4CAA4C,CAAC,CAAC;IAChG,CAAC,CAAC;IACF,OAAO;QACL,GAAG,EAAE,CAAI,IAAY,EAAE,EAAE,CAAC,IAAI,CAAI,KAAK,EAAE,IAAI,CAAC;QAC9C,IAAI,EAAE,CAAI,IAAY,EAAE,CAAU,EAAE,EAAE,CAAC,IAAI,CAAI,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/D,GAAG,EAAE,WAAW,CAAC,KAAK,CAAsB;QAC5C,KAAK,EAAE,WAAW,CAAC,OAAO,CAAwB;QAClD,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAyB;QACrD,OAAO,EAAE,WAAW,CAAC,SAAS,CAA0B;QACxD,SAAS,EAAE,WAAW,CAAC,WAAW,CAA4B;QAC9D,iBAAiB,EAAE,WAAW,CAAC,mBAAmB,CAAoC;QACtF,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAyB;QACrD,YAAY,EAAE,CAAC,CAAqB,EAAE,EAAE;YACtC,KAAK,GAAG,CAAC,CAAC;QACZ,CAAC;QACD,YAAY,EAAE,GAAG,EAAE,CAAC,KAAK;KAC1B,CAAC;AACJ,CAAC"}
@@ -13,6 +13,41 @@ export declare function requireValidatorUrl(env: EnvMap, opts: {
13
13
  export declare function requireAppId(env: EnvMap, opts: {
14
14
  appId?: string;
15
15
  }): string;
16
+ /**
17
+ * Resolve the developer's SUBSCRIPTION appId — the identity the CLI must
18
+ * AUTHENTICATE as for every app-management call (`status` / `update` /
19
+ * `suspend` / `resume` / `delete` / `deploy`).
20
+ *
21
+ * This is deliberately distinct from {@link requireAppId} (which resolves the
22
+ * management TARGET — the deployed app). The host gates `/api/v3/baas/auth/{challenge,
23
+ * verify}` on the appId being authenticated: the keystone all-paid gate
24
+ * (`BaasAuthService.resolveActiveSubscriptionOrDeny`) AND the global
25
+ * `SubscriptionRateLimitGuard` both 403 unless that appId holds a valid,
26
+ * ACTIVE subscription. A DEPLOYED app (`smart-app-XXXX`) never holds the
27
+ * subscription — the subscription NFT lives on the developer's subscription
28
+ * appId — so authenticating AS the deployed app 403s every management command.
29
+ *
30
+ * Precedence: explicit `--subscription-app-id` flag → `SUBSCRIPTION_APP_ID`
31
+ * env (written by `hsuite subscribe`). Never falls back to `DEPLOYED_APP_ID`:
32
+ * the deployed app is the target, never the auth identity. Throws an
33
+ * actionable error when neither is present.
34
+ *
35
+ * @throws when no subscription appId can be resolved.
36
+ */
37
+ export declare function requireSubscriptionAppId(env: EnvMap, opts?: {
38
+ subscriptionAppId?: string;
39
+ }): string;
40
+ /**
41
+ * Resolve the deploy-family appId WITHOUT throwing.
42
+ *
43
+ * Precedence: explicit flag → `DEPLOYED_APP_ID` → `SUBSCRIPTION_APP_ID`.
44
+ * Returns `undefined` when none is set — `hsuite deploy` runs a fresh `init`
45
+ * that allocates an appId, so an absent one is not an error (unlike
46
+ * {@link requireAppId}, used by lifecycle commands that act on an EXISTING app).
47
+ */
48
+ export declare function resolveAppId(env: EnvMap, opts?: {
49
+ appId?: string;
50
+ }): string | undefined;
16
51
  export declare function requireXrplCreds(env: EnvMap): {
17
52
  address: string;
18
53
  seed: string;
@@ -1 +1 @@
1
- {"version":3,"file":"subscription-env.d.ts","sourceRoot":"","sources":["../../src/_lib/subscription-env.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEpC,wBAAgB,mBA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defineProperty(exports, "__esModule", { value: true });
3
3
  exports.requireValidatorUrl = requireValidatorUrl;
4
4
  exports.requireAppId = requireAppId;
5
+ exports.requireSubscriptionAppId = requireSubscriptionAppId;
6
+ exports.resolveAppId = resolveAppId;
5
7
  exports.requireXrplCreds = requireXrplCreds;
6
8
  function requireValidatorUrl(env, opts) {
7
9
  const url = opts.gateway ?? env.get('VALIDATOR_URL') ?? env.get('SMART_HOST_URL');
@@ -11,12 +13,54 @@ function requireValidatorUrl(env, opts) {
11
13
  return url.replace(/\/$/, '');
12
14
  }
13
15
  function requireAppId(env, opts) {
14
- const appId = opts.appId ?? env.get('SUBSCRIPTION_APP_ID');
16
+ const appId = opts.appId ?? env.get('DEPLOYED_APP_ID') ?? env.get('SUBSCRIPTION_APP_ID');
15
17
  if (!appId) {
16
- throw new Error('SUBSCRIPTION_APP_ID not set. Pass --app-id <id> or run `hsuite subscribe` first.');
18
+ throw new Error('No appId. Pass --app-id <id>, or run `hsuite deploy` / `hsuite subscribe` first ' +
19
+ '(sets DEPLOYED_APP_ID / SUBSCRIPTION_APP_ID).');
17
20
  }
18
21
  return appId;
19
22
  }
23
+ /**
24
+ * Resolve the developer's SUBSCRIPTION appId — the identity the CLI must
25
+ * AUTHENTICATE as for every app-management call (`status` / `update` /
26
+ * `suspend` / `resume` / `delete` / `deploy`).
27
+ *
28
+ * This is deliberately distinct from {@link requireAppId} (which resolves the
29
+ * management TARGET — the deployed app). The host gates `/api/v3/baas/auth/{challenge,
30
+ * verify}` on the appId being authenticated: the keystone all-paid gate
31
+ * (`BaasAuthService.resolveActiveSubscriptionOrDeny`) AND the global
32
+ * `SubscriptionRateLimitGuard` both 403 unless that appId holds a valid,
33
+ * ACTIVE subscription. A DEPLOYED app (`smart-app-XXXX`) never holds the
34
+ * subscription — the subscription NFT lives on the developer's subscription
35
+ * appId — so authenticating AS the deployed app 403s every management command.
36
+ *
37
+ * Precedence: explicit `--subscription-app-id` flag → `SUBSCRIPTION_APP_ID`
38
+ * env (written by `hsuite subscribe`). Never falls back to `DEPLOYED_APP_ID`:
39
+ * the deployed app is the target, never the auth identity. Throws an
40
+ * actionable error when neither is present.
41
+ *
42
+ * @throws when no subscription appId can be resolved.
43
+ */
44
+ function requireSubscriptionAppId(env, opts = {}) {
45
+ const appId = opts.subscriptionAppId ?? env.get('SUBSCRIPTION_APP_ID');
46
+ if (!appId) {
47
+ throw new Error('No subscription appId. Management commands authenticate as your SUBSCRIPTION ' +
48
+ '(which holds the subscription NFT), not as the deployed app. Pass ' +
49
+ '--subscription-app-id <id>, or run `hsuite subscribe` first (sets SUBSCRIPTION_APP_ID).');
50
+ }
51
+ return appId;
52
+ }
53
+ /**
54
+ * Resolve the deploy-family appId WITHOUT throwing.
55
+ *
56
+ * Precedence: explicit flag → `DEPLOYED_APP_ID` → `SUBSCRIPTION_APP_ID`.
57
+ * Returns `undefined` when none is set — `hsuite deploy` runs a fresh `init`
58
+ * that allocates an appId, so an absent one is not an error (unlike
59
+ * {@link requireAppId}, used by lifecycle commands that act on an EXISTING app).
60
+ */
61
+ function resolveAppId(env, opts = {}) {
62
+ return (opts.appId ?? env.get('DEPLOYED_APP_ID') ?? env.get('SUBSCRIPTION_APP_ID') ?? undefined);
63
+ }
20
64
  function requireXrplCreds(env) {
21
65
  const address = env.get('XRPL_ADDRESS');
22
66
  const seed = env.get('XRPL_SEED');
@@ -1 +1 @@
1
- {"version":3,"file":"subscription-env.js","sourceRoot":"","sources":["../../src/_lib/subscription-env.ts"],"names":[],"mappings":";;AAUA,kDAQC;AAED,oCAQC;AAED,4CASC;AA7BD,SAAgB,mBAAmB,CAAC,GAAW,EAAE,IAA0B;IACzE,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,IAAI,GAAG,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAClF,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CACb,4FAA4F,CAC7F,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1
+ /**
2
+ * `hsuite suspend` / `resume` / `delete` — runtime lifecycle controls for a
3
+ * deployed app.
4
+ *
5
+ * - suspend → scale the runtime to zero (`deployment.suspend`).
6
+ * - resume → scale it back up (`deployment.resume`).
7
+ * - delete → tear the namespace down (`deployment.delete`). Destructive, so
8
+ * it confirms first UNLESS `--yes` is passed or stdin is not a TTY
9
+ * (non-interactive contexts must opt in explicitly via `--yes`).
10
+ */
11
+ import { Command } from 'commander';
12
+ import { connectAndAuth } from '../_lib/baas';
13
+ export type LifecycleAction = 'suspend' | 'resume' | 'delete';
14
+ export type LifecycleOpts = {
15
+ action: LifecycleAction;
16
+ envPath: string;
17
+ gateway: string;
18
+ /** Management TARGET — the deployed app to act on. */
19
+ appId?: string;
20
+ /** Auth IDENTITY — the developer's subscription appId. */
21
+ subscriptionAppId?: string;
22
+ /** delete: skip the confirmation prompt. */
23
+ yes?: boolean;
24
+ clientFactory?: Parameters<typeof connectAndAuth>[0]['clientFactory'];
25
+ /** Test seam — confirm prompt. Defaults to a readline y/N. */
26
+ confirmFn?: (message: string) => Promise<boolean>;
27
+ };
28
+ /** Pure orchestration body — exported for unit tests. */
29
+ export declare function runLifecycle(opts: LifecycleOpts): Promise<{
30
+ appId: string;
31
+ performed: boolean;
32
+ }>;
33
+ export declare const suspendCommand: Command;
34
+ export declare const resumeCommand: Command;
35
+ export declare const deleteCommand: Command;
36
+ //# sourceMappingURL=app-lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-lifecycle.d.ts","sourceRoot":"","sources":["../../src/commands/app-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE9D,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,4CAA4C;IAC5C,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,aAAa,CAAC,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;IACtE,8DAA8D;IAC9D,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CACnD,CAAC;AAeF,yDAAyD;AACzD,wBAAsB,YAAY,CAChC,IAAI,EAAE,aAAa,GAClB,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC,CA8BhD;AAiDD,eAAO,MAAM,cAAc,SAA8B,CAAC;AAC1D,eAAO,MAAM,aAAa,SAA6B,CAAC;AACxD,eAAO,MAAM,aAAa,SAA6B,CAAC"}