@hsuite/smart-engines-cli 1.1.0 → 1.2.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 (55) hide show
  1. package/dist/__tests__/helpers/fixtures.d.ts +48 -0
  2. package/dist/__tests__/helpers/fixtures.d.ts.map +1 -0
  3. package/dist/__tests__/helpers/fixtures.js +79 -0
  4. package/dist/__tests__/helpers/fixtures.js.map +1 -0
  5. package/dist/_lib/cluster.d.ts +15 -0
  6. package/dist/_lib/cluster.d.ts.map +1 -0
  7. package/dist/_lib/cluster.js +18 -0
  8. package/dist/_lib/cluster.js.map +1 -0
  9. package/dist/_lib/subscription-client.d.ts +152 -0
  10. package/dist/_lib/subscription-client.d.ts.map +1 -0
  11. package/dist/_lib/subscription-client.js +84 -0
  12. package/dist/_lib/subscription-client.js.map +1 -0
  13. package/dist/_lib/subscription-env.d.ts +20 -0
  14. package/dist/_lib/subscription-env.d.ts.map +1 -0
  15. package/dist/_lib/subscription-env.js +28 -0
  16. package/dist/_lib/subscription-env.js.map +1 -0
  17. package/dist/commands/billing.d.ts +17 -0
  18. package/dist/commands/billing.d.ts.map +1 -0
  19. package/dist/commands/billing.js +59 -0
  20. package/dist/commands/billing.js.map +1 -0
  21. package/dist/commands/deploy.d.ts.map +1 -1
  22. package/dist/commands/deploy.js +32 -10
  23. package/dist/commands/deploy.js.map +1 -1
  24. package/dist/commands/downgrade.d.ts +22 -0
  25. package/dist/commands/downgrade.d.ts.map +1 -0
  26. package/dist/commands/downgrade.js +55 -0
  27. package/dist/commands/downgrade.js.map +1 -0
  28. package/dist/commands/init.d.ts.map +1 -1
  29. package/dist/commands/init.js +5 -7
  30. package/dist/commands/init.js.map +1 -1
  31. package/dist/commands/renew.d.ts +19 -0
  32. package/dist/commands/renew.d.ts.map +1 -0
  33. package/dist/commands/renew.js +58 -0
  34. package/dist/commands/renew.js.map +1 -0
  35. package/dist/commands/subscribe.d.ts +40 -4
  36. package/dist/commands/subscribe.d.ts.map +1 -1
  37. package/dist/commands/subscribe.js +156 -75
  38. package/dist/commands/subscribe.js.map +1 -1
  39. package/dist/commands/upgrade.d.ts +41 -0
  40. package/dist/commands/upgrade.d.ts.map +1 -0
  41. package/dist/commands/upgrade.js +128 -0
  42. package/dist/commands/upgrade.js.map +1 -0
  43. package/dist/commands/usage.d.ts +22 -0
  44. package/dist/commands/usage.d.ts.map +1 -0
  45. package/dist/commands/usage.js +81 -0
  46. package/dist/commands/usage.js.map +1 -0
  47. package/dist/commands/verify.d.ts +56 -0
  48. package/dist/commands/verify.d.ts.map +1 -0
  49. package/dist/commands/verify.js +291 -0
  50. package/dist/commands/verify.js.map +1 -0
  51. package/dist/index.d.ts +8 -2
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +21 -2
  54. package/dist/index.js.map +1 -1
  55. package/package.json +2 -2
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Deterministic XRPL ed25519 fixture.
3
+ *
4
+ * Provenance — derived once with:
5
+ * node -e "const {Wallet}=require('xrpl'); const w=Wallet.fromSeed('sEdTyaBYHfQhWt9ycB9QJsRKH8UUEuD'); console.log(w.address, w.publicKey)"
6
+ *
7
+ * Expected signature derived by running the validator's exact verifier
8
+ * path (libs/security-core/src/auth/web3-auth.service.ts:334-340):
9
+ * const hex = Buffer.from(message, 'utf-8').toString('hex').toUpperCase();
10
+ * sign(hex, wallet.privateKey) // ripple-keypairs
11
+ *
12
+ * If `EXPECTED_SIGNATURE` drifts, the CLI's signFn no longer produces what
13
+ * the validator's web3-auth verifier accepts. That's an auth-contract
14
+ * regression — every developer's `subscribe`/`deploy` breaks silently.
15
+ */
16
+ export declare const XRPL_FIXTURE: {
17
+ readonly seed: "sEdTyaBYHfQhWt9ycB9QJsRKH8UUEuD";
18
+ readonly address: "rNHjsSoFgEMPZi4kE5rfw6c8k6tTUX8eng";
19
+ readonly publicKey: "ED652CD3EAB154510CBFCF4AEDEE4EAEB295D32EA7CE358F0B25D26203003F5DED";
20
+ /** Plain-text payload signed in the deterministic-signature assertion. */
21
+ readonly payload: "hello-smart-engines";
22
+ /** Output of `sign(hex(payload).upper, fixture.privateKey)`. */
23
+ readonly expectedSignature: "CFF9ABD65D3BBC985FE8A8C899DAC26B16DAB95B13AE2B2CB3DEAC2CA0E54F7791307B22971180D6016422EEE2E36ACFECCC7B7C3A1CB7701CE28D243E16BF03";
24
+ };
25
+ /**
26
+ * Reproduce the validator's verifier check verbatim.
27
+ *
28
+ * Mirrors `verifyXRPLSignature` at
29
+ * libs/security-core/src/auth/web3-auth.service.ts:328-350 — same hex
30
+ * canonicalization, same ripple-keypairs.verify entry point. Used by the
31
+ * signFn spec to cross-check the CLI's output WITHOUT importing the heavy
32
+ * NestJS-bound web3-auth.service.ts class graph.
33
+ */
34
+ export declare function validatorVerifyXrplSignature(publicKey: string, message: string, signature: string): boolean;
35
+ /**
36
+ * Build a throwaway tmp directory and return its path + a cleanup fn.
37
+ *
38
+ * Usage:
39
+ * const { dir, cleanup } = makeTempDir('hsuite-init-');
40
+ * afterEach(cleanup);
41
+ */
42
+ export declare function makeTempDir(prefix?: string): {
43
+ dir: string;
44
+ cleanup: () => void;
45
+ };
46
+ /** Build the path for an env file inside a tmp dir. */
47
+ export declare function envPathIn(dir: string, name?: string): string;
48
+ //# sourceMappingURL=fixtures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../../src/__tests__/helpers/fixtures.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,YAAY;;;;IAIvB,0EAA0E;;IAE1E,gEAAgE;;CAGxD,CAAC;AAEX;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAChB,OAAO,CAKT;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,MAAM,SAAqB,GAAG;IACxD,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAMA;AAED,uDAAuD;AACvD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,SAAe,GAAG,MAAM,CAElE"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.XRPL_FIXTURE = void 0;
4
+ exports.validatorVerifyXrplSignature = validatorVerifyXrplSignature;
5
+ exports.makeTempDir = makeTempDir;
6
+ exports.envPathIn = envPathIn;
7
+ /**
8
+ * Shared test fixtures for the @hsuite/smart-engines-cli specs.
9
+ *
10
+ * Centralises the XRPL seed/address/pubkey we sign with, the expected
11
+ * deterministic signature for a canonical payload, and a tmp-dir helper
12
+ * so individual specs don't repeat boilerplate.
13
+ *
14
+ * The fixture seed is fresh (generated 2026-05-22 with xrpl.Wallet.generate)
15
+ * and is NOT funded on any network. Re-deriving from this seed yields the
16
+ * same address / pubkey / signature on every machine — that's the whole
17
+ * point of an ed25519-with-deterministic-K (RFC 8032) signer.
18
+ */
19
+ const fs_1 = require("fs");
20
+ const os_1 = require("os");
21
+ const path_1 = require("path");
22
+ /**
23
+ * Deterministic XRPL ed25519 fixture.
24
+ *
25
+ * Provenance — derived once with:
26
+ * node -e "const {Wallet}=require('xrpl'); const w=Wallet.fromSeed('sEdTyaBYHfQhWt9ycB9QJsRKH8UUEuD'); console.log(w.address, w.publicKey)"
27
+ *
28
+ * Expected signature derived by running the validator's exact verifier
29
+ * path (libs/security-core/src/auth/web3-auth.service.ts:334-340):
30
+ * const hex = Buffer.from(message, 'utf-8').toString('hex').toUpperCase();
31
+ * sign(hex, wallet.privateKey) // ripple-keypairs
32
+ *
33
+ * If `EXPECTED_SIGNATURE` drifts, the CLI's signFn no longer produces what
34
+ * the validator's web3-auth verifier accepts. That's an auth-contract
35
+ * regression — every developer's `subscribe`/`deploy` breaks silently.
36
+ */
37
+ exports.XRPL_FIXTURE = {
38
+ seed: 'sEdTyaBYHfQhWt9ycB9QJsRKH8UUEuD',
39
+ address: 'rNHjsSoFgEMPZi4kE5rfw6c8k6tTUX8eng',
40
+ publicKey: 'ED652CD3EAB154510CBFCF4AEDEE4EAEB295D32EA7CE358F0B25D26203003F5DED',
41
+ /** Plain-text payload signed in the deterministic-signature assertion. */
42
+ payload: 'hello-smart-engines',
43
+ /** Output of `sign(hex(payload).upper, fixture.privateKey)`. */
44
+ expectedSignature: 'CFF9ABD65D3BBC985FE8A8C899DAC26B16DAB95B13AE2B2CB3DEAC2CA0E54F7791307B22971180D6016422EEE2E36ACFECCC7B7C3A1CB7701CE28D243E16BF03',
45
+ };
46
+ /**
47
+ * Reproduce the validator's verifier check verbatim.
48
+ *
49
+ * Mirrors `verifyXRPLSignature` at
50
+ * libs/security-core/src/auth/web3-auth.service.ts:328-350 — same hex
51
+ * canonicalization, same ripple-keypairs.verify entry point. Used by the
52
+ * signFn spec to cross-check the CLI's output WITHOUT importing the heavy
53
+ * NestJS-bound web3-auth.service.ts class graph.
54
+ */
55
+ function validatorVerifyXrplSignature(publicKey, message, signature) {
56
+ const messageHex = Buffer.from(message, 'utf-8').toString('hex').toUpperCase();
57
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
58
+ const { verify } = require('ripple-keypairs');
59
+ return verify(messageHex, signature, publicKey);
60
+ }
61
+ /**
62
+ * Build a throwaway tmp directory and return its path + a cleanup fn.
63
+ *
64
+ * Usage:
65
+ * const { dir, cleanup } = makeTempDir('hsuite-init-');
66
+ * afterEach(cleanup);
67
+ */
68
+ function makeTempDir(prefix = 'hsuite-cli-spec-') {
69
+ const dir = (0, fs_1.mkdtempSync)((0, path_1.join)((0, os_1.tmpdir)(), prefix));
70
+ return {
71
+ dir,
72
+ cleanup: () => (0, fs_1.rmSync)(dir, { recursive: true, force: true }),
73
+ };
74
+ }
75
+ /** Build the path for an env file inside a tmp dir. */
76
+ function envPathIn(dir, name = '.env.local') {
77
+ return (0, path_1.join)(dir, name);
78
+ }
79
+ //# sourceMappingURL=fixtures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixtures.js","sourceRoot":"","sources":["../../../src/__tests__/helpers/fixtures.ts"],"names":[],"mappings":";;;AAmDA,oEASC;AASD,kCASC;AAGD,8BAEC;AAnFD;;;;;;;;;;;GAWG;AACH,2BAAyC;AACzC,2BAA4B;AAC5B,+BAA4B;AAE5B;;;;;;;;;;;;;;GAcG;AACU,QAAA,YAAY,GAAG;IAC1B,IAAI,EAAE,iCAAiC;IACvC,OAAO,EAAE,oCAAoC;IAC7C,SAAS,EAAE,oEAAoE;IAC/E,0EAA0E;IAC1E,OAAO,EAAE,qBAAqB;IAC9B,gEAAgE;IAChE,iBAAiB,EACf,kIAAkI;CAC5H,CAAC;AAEX;;;;;;;;GAQG;AACH,SAAgB,4BAA4B,CAC1C,SAAiB,EACjB,OAAe,EACf,SAAiB;IAEjB,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;IAC/E,8DAA8D;IAC9D,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC9C,OAAO,MAAM,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AAClD,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,WAAW,CAAC,MAAM,GAAG,kBAAkB;IAIrD,MAAM,GAAG,GAAG,IAAA,gBAAW,EAAC,IAAA,WAAI,EAAC,IAAA,WAAM,GAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IAChD,OAAO;QACL,GAAG;QACH,OAAO,EAAE,GAAG,EAAE,CAAC,IAAA,WAAM,EAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;KAC7D,CAAC;AACJ,CAAC;AAED,uDAAuD;AACvD,SAAgB,SAAS,CAAC,GAAW,EAAE,IAAI,GAAG,YAAY;IACxD,OAAO,IAAA,WAAI,EAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AACzB,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Cluster bootstrap constants.
3
+ *
4
+ * The CLI bootstraps against the public round-robin host
5
+ * `gateway.testnet.hsuite.network` — 3 DNS A-records over the 3 genesis
6
+ * cluster ingress LBs (HANDOFF arc-v13-do-deploy §11).
7
+ *
8
+ * Decentralized cluster discovery itself is no longer implemented here:
9
+ * the canonical `BaasClient.connectToCluster({ bootstrap: [...] })` factory
10
+ * in `@hsuite/smart-engines-sdk` (3.4.0+) owns it, and the CLI consumes
11
+ * that factory rather than maintaining a parallel discovery path.
12
+ */
13
+ /** Public SDK-bootstrap host for the Smart Engines testnet. */
14
+ export declare const DEFAULT_GATEWAY = "https://gateway.testnet.hsuite.network";
15
+ //# sourceMappingURL=cluster.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cluster.d.ts","sourceRoot":"","sources":["../../src/_lib/cluster.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,+DAA+D;AAC/D,eAAO,MAAM,eAAe,2CAA2C,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ /**
3
+ * Cluster bootstrap constants.
4
+ *
5
+ * The CLI bootstraps against the public round-robin host
6
+ * `gateway.testnet.hsuite.network` — 3 DNS A-records over the 3 genesis
7
+ * cluster ingress LBs (HANDOFF arc-v13-do-deploy §11).
8
+ *
9
+ * Decentralized cluster discovery itself is no longer implemented here:
10
+ * the canonical `BaasClient.connectToCluster({ bootstrap: [...] })` factory
11
+ * in `@hsuite/smart-engines-sdk` (3.4.0+) owns it, and the CLI consumes
12
+ * that factory rather than maintaining a parallel discovery path.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.DEFAULT_GATEWAY = void 0;
16
+ /** Public SDK-bootstrap host for the Smart Engines testnet. */
17
+ exports.DEFAULT_GATEWAY = 'https://gateway.testnet.hsuite.network';
18
+ //# sourceMappingURL=cluster.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cluster.js","sourceRoot":"","sources":["../../src/_lib/cluster.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAEH,+DAA+D;AAClD,QAAA,eAAe,GAAG,wCAAwC,CAAC"}
@@ -0,0 +1,152 @@
1
+ /**
2
+ * Thin HTTP client for the validator-side `/api/v3/subscription/*` surface.
3
+ *
4
+ * Wraps the routes implemented in `apps/smart-validator/src/subscription/
5
+ * subscription.controller.ts`. The endpoints are `@Public()` and live on
6
+ * the same gateway URL the CLI's `init` writes to env as `VALIDATOR_URL`.
7
+ *
8
+ * Kept dependency-free (uses global `fetch`) so the CLI command bodies
9
+ * stay small and easy to unit-test with the standard `jest.fn()` mock
10
+ * pattern. Tests inject a fake `fetch` via the constructor.
11
+ */
12
+ export type DepositInstructions = {
13
+ walletAddress: string;
14
+ tokenId: string;
15
+ amount: string;
16
+ chain: string;
17
+ };
18
+ export type SubscriptionRequestResponse = {
19
+ success: boolean;
20
+ subscriptionId?: string;
21
+ appId: string;
22
+ status?: string;
23
+ selectedTier: string;
24
+ selectedNetworks: string[];
25
+ depositInstructions?: DepositInstructions;
26
+ message?: string;
27
+ };
28
+ export type SubscriptionStatusResponse = {
29
+ appId: string;
30
+ hasSubscription: boolean;
31
+ subscriptionId?: string;
32
+ appName?: string;
33
+ status?: string;
34
+ subscriptionNftSerial?: number | string;
35
+ expiresAt?: string | number;
36
+ remainingBalance?: string;
37
+ createdAt?: string | number;
38
+ depositWallet?: {
39
+ walletAddress: string;
40
+ chain: string;
41
+ depositAmount: string;
42
+ status: string;
43
+ actualDepositAmount?: string;
44
+ lockedUntil?: string | number;
45
+ };
46
+ };
47
+ export type MintResponse = {
48
+ success: boolean;
49
+ subscriptionId?: string;
50
+ appId: string;
51
+ expiresAt?: string | number;
52
+ message?: string;
53
+ };
54
+ export type RenewResponse = {
55
+ success: boolean;
56
+ appId: string;
57
+ newExpiresAt?: string | number;
58
+ message?: string;
59
+ };
60
+ export type TierChangeResponse = {
61
+ success: boolean;
62
+ appId: string;
63
+ fromTier?: string;
64
+ toTier?: string;
65
+ effectiveAt?: string | number;
66
+ depositInstructions?: DepositInstructions;
67
+ message?: string;
68
+ };
69
+ export type UsageSummaryResponse = {
70
+ appId: string;
71
+ total: number;
72
+ byCategory: Record<string, number>;
73
+ recordCount: number;
74
+ lastUpdated?: string;
75
+ };
76
+ export type UsageStatusResponse = {
77
+ appId: string;
78
+ usagePercent: number;
79
+ currentUsage: number;
80
+ dailyLimit: number;
81
+ overagePercent: number;
82
+ inGracePeriod: boolean;
83
+ graceExpiresAt: string | null;
84
+ blocked: boolean;
85
+ suggestUpgrade: boolean;
86
+ nextTier: null | {
87
+ tier: string;
88
+ name: string;
89
+ apiCallsPerDay: number;
90
+ monthlyPriceHsuite: number;
91
+ };
92
+ projectedDaysUntilLimit: number | null;
93
+ };
94
+ export type BillingLedgerResponse = {
95
+ appId: string;
96
+ entries: Array<{
97
+ id: string;
98
+ subscriptionId: string;
99
+ operation: string;
100
+ amount: string;
101
+ balanceAfter: string;
102
+ timestamp: string;
103
+ metadata?: Record<string, unknown>;
104
+ }>;
105
+ total: number;
106
+ hasMore: boolean;
107
+ };
108
+ export type FetchLike = (input: string, init?: any) => Promise<{
109
+ ok: boolean;
110
+ status: number;
111
+ text(): Promise<string>;
112
+ json(): Promise<unknown>;
113
+ }>;
114
+ export type SubscriptionClientOptions = {
115
+ baseUrl: string;
116
+ fetchImpl?: FetchLike;
117
+ };
118
+ /**
119
+ * Validator-side subscription HTTP client.
120
+ *
121
+ * All routes match the controller at
122
+ * apps/smart-validator/src/subscription/subscription.controller.ts.
123
+ */
124
+ export declare class SubscriptionClient {
125
+ private readonly baseUrl;
126
+ private readonly fetchImpl;
127
+ constructor(opts: SubscriptionClientOptions);
128
+ request(payload: {
129
+ appId: string;
130
+ developerAccountId: string;
131
+ chain: string;
132
+ appName: string;
133
+ selectedTier: string;
134
+ selectedNetworks: string[];
135
+ appDescription?: string;
136
+ logoUrl?: string;
137
+ metadata?: Record<string, unknown>;
138
+ }): Promise<SubscriptionRequestResponse>;
139
+ status(appId: string): Promise<SubscriptionStatusResponse>;
140
+ mint(appId: string): Promise<MintResponse>;
141
+ renew(appId: string, additionalDays?: number): Promise<RenewResponse>;
142
+ upgrade(appId: string, toTier: string): Promise<TierChangeResponse>;
143
+ downgrade(appId: string, toTier: string): Promise<TierChangeResponse>;
144
+ cancelTierChange(appId: string): Promise<TierChangeResponse>;
145
+ usage(appId: string): Promise<UsageSummaryResponse>;
146
+ usageStatus(appId: string): Promise<UsageStatusResponse>;
147
+ billing(appId: string, limit?: number, offset?: number): Promise<BillingLedgerResponse>;
148
+ private post;
149
+ private get;
150
+ private send;
151
+ }
152
+ //# sourceMappingURL=subscription-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription-client.d.ts","sourceRoot":"","sources":["../../src/_lib/subscription-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,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,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAOnE,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAOrE,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAM5D,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAMnD,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAMxD,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAK,EAAE,MAAM,SAAI,GAAG,OAAO,CAAC,qBAAqB,CAAC;YAOtE,IAAI;YAIJ,GAAG;YAIH,IAAI;CAenB"}
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SubscriptionClient = void 0;
4
+ /**
5
+ * Validator-side subscription HTTP client.
6
+ *
7
+ * All routes match the controller at
8
+ * apps/smart-validator/src/subscription/subscription.controller.ts.
9
+ */
10
+ class SubscriptionClient {
11
+ baseUrl;
12
+ fetchImpl;
13
+ 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));
18
+ }
19
+ async request(payload) {
20
+ return this.post('/api/v3/subscription/request', payload);
21
+ }
22
+ async status(appId) {
23
+ return this.get(`/api/v3/subscription/status/${encodeURIComponent(appId)}`);
24
+ }
25
+ async mint(appId) {
26
+ return this.post(`/api/v3/subscription/mint/${encodeURIComponent(appId)}`, {});
27
+ }
28
+ async renew(appId, additionalDays) {
29
+ return this.post('/api/v3/subscription/renew', {
30
+ appId,
31
+ ...(additionalDays !== undefined ? { additionalDays } : {}),
32
+ });
33
+ }
34
+ async upgrade(appId, toTier) {
35
+ return this.post('/api/v3/subscription/upgrade', {
36
+ appId,
37
+ toTier,
38
+ });
39
+ }
40
+ async downgrade(appId, toTier) {
41
+ return this.post('/api/v3/subscription/downgrade', {
42
+ appId,
43
+ toTier,
44
+ });
45
+ }
46
+ async cancelTierChange(appId) {
47
+ return this.post('/api/v3/subscription/tier-change/cancel', {
48
+ appId,
49
+ });
50
+ }
51
+ async usage(appId) {
52
+ return this.get(`/api/v3/subscription/usage/${encodeURIComponent(appId)}`);
53
+ }
54
+ async usageStatus(appId) {
55
+ return this.get(`/api/v3/subscription/usage/status/${encodeURIComponent(appId)}`);
56
+ }
57
+ 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}`);
60
+ }
61
+ async post(path, body) {
62
+ return this.send('POST', path, body);
63
+ }
64
+ async get(path) {
65
+ return this.send('GET', path);
66
+ }
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' },
72
+ };
73
+ if (body !== undefined)
74
+ init.body = JSON.stringify(body);
75
+ const res = await this.fetchImpl(url, init);
76
+ if (!res.ok) {
77
+ const text = await res.text().catch(() => '');
78
+ throw new Error(`${method} ${path} → ${res.status}: ${text.slice(0, 500)}`);
79
+ }
80
+ return (await res.json());
81
+ }
82
+ }
83
+ exports.SubscriptionClient = SubscriptionClient;
84
+ //# sourceMappingURL=subscription-client.js.map
@@ -0,0 +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,EA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,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC5C,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,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;CACF;AA3GD,gDA2GC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Shared resolvers for the subscription command family.
3
+ *
4
+ * Reads VALIDATOR_URL / XRPL_ADDRESS / XRPL_SEED / SUBSCRIPTION_APP_ID from
5
+ * the env file written by `hsuite init` + `hsuite subscribe`. Centralised
6
+ * here so every companion command (renew/upgrade/downgrade/usage/billing)
7
+ * fails-fast with the same actionable error message.
8
+ */
9
+ import type { EnvMap } from './env';
10
+ export declare function requireValidatorUrl(env: EnvMap, opts: {
11
+ gateway?: string;
12
+ }): string;
13
+ export declare function requireAppId(env: EnvMap, opts: {
14
+ appId?: string;
15
+ }): string;
16
+ export declare function requireXrplCreds(env: EnvMap): {
17
+ address: string;
18
+ seed: string;
19
+ };
20
+ //# sourceMappingURL=subscription-env.d.ts.map
@@ -0,0 +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,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAQnF;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAQ1E;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAS/E"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.requireValidatorUrl = requireValidatorUrl;
4
+ exports.requireAppId = requireAppId;
5
+ exports.requireXrplCreds = requireXrplCreds;
6
+ function requireValidatorUrl(env, opts) {
7
+ const url = opts.gateway ?? env.get('VALIDATOR_URL') ?? env.get('SMART_HOST_URL');
8
+ if (!url) {
9
+ throw new Error('VALIDATOR_URL not set. Pass --gateway <url> or run `hsuite init` to populate the env file.');
10
+ }
11
+ return url.replace(/\/$/, '');
12
+ }
13
+ function requireAppId(env, opts) {
14
+ const appId = opts.appId ?? env.get('SUBSCRIPTION_APP_ID');
15
+ if (!appId) {
16
+ throw new Error('SUBSCRIPTION_APP_ID not set. Pass --app-id <id> or run `hsuite subscribe` first.');
17
+ }
18
+ return appId;
19
+ }
20
+ function requireXrplCreds(env) {
21
+ const address = env.get('XRPL_ADDRESS');
22
+ const seed = env.get('XRPL_SEED');
23
+ if (!address || !seed) {
24
+ throw new Error('XRPL_ADDRESS + XRPL_SEED required. Run `hsuite init` to generate a fresh wallet.');
25
+ }
26
+ return { address, seed };
27
+ }
28
+ //# sourceMappingURL=subscription-env.js.map
@@ -0,0 +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,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAChC,CAAC;AAED,SAAgB,YAAY,CAAC,GAAW,EAAE,IAAwB;IAChE,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,GAAG,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;IAC3D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACb,kFAAkF,CACnF,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAgB,gBAAgB,CAAC,GAAW;IAC1C,MAAM,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACxC,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAClC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACb,kFAAkF,CACnF,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * `hsuite billing` — pretty-print the billing ledger.
3
+ */
4
+ import { Command } from 'commander';
5
+ import { SubscriptionClient } from '../_lib/subscription-client';
6
+ type BillingOpts = {
7
+ env: string;
8
+ gateway?: string;
9
+ appId?: string;
10
+ limit?: string;
11
+ offset?: string;
12
+ clientFactory?: (baseUrl: string) => SubscriptionClient;
13
+ };
14
+ export declare function runBilling(opts: BillingOpts): Promise<import("../_lib/subscription-client").BillingLedgerResponse>;
15
+ export declare const billingCommand: Command;
16
+ export {};
17
+ //# sourceMappingURL=billing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing.d.ts","sourceRoot":"","sources":["../../src/commands/billing.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAGjE,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,kBAAkB,CAAC;CACzD,CAAC;AAEF,wBAAsB,UAAU,CAAC,IAAI,EAAE,WAAW,wEAUjD;AAED,eAAO,MAAM,cAAc,SAoCvB,CAAC"}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.billingCommand = void 0;
7
+ exports.runBilling = runBilling;
8
+ /**
9
+ * `hsuite billing` — pretty-print the billing ledger.
10
+ */
11
+ const commander_1 = require("commander");
12
+ const chalk_1 = __importDefault(require("chalk"));
13
+ const env_1 = require("../_lib/env");
14
+ const subscription_client_1 = require("../_lib/subscription-client");
15
+ const subscription_env_1 = require("../_lib/subscription-env");
16
+ async function runBilling(opts) {
17
+ const env = (0, env_1.readEnv)(opts.env);
18
+ const baseUrl = (0, subscription_env_1.requireValidatorUrl)(env, { gateway: opts.gateway });
19
+ const appId = (0, subscription_env_1.requireAppId)(env, { appId: opts.appId });
20
+ const limit = opts.limit ? Number(opts.limit) : 50;
21
+ const offset = opts.offset ? Number(opts.offset) : 0;
22
+ if (!Number.isFinite(limit) || limit <= 0)
23
+ throw new Error('--limit must be a positive number');
24
+ if (!Number.isFinite(offset) || offset < 0)
25
+ throw new Error('--offset must be >= 0');
26
+ const client = (opts.clientFactory ?? ((b) => new subscription_client_1.SubscriptionClient({ baseUrl: b })))(baseUrl);
27
+ return client.billing(appId, limit, offset);
28
+ }
29
+ exports.billingCommand = new commander_1.Command('billing')
30
+ .description('Print the subscription billing-ledger entries')
31
+ .option('--env <file>', 'Env file with subscription appId', '.env.local')
32
+ .option('--gateway <url>', 'Validator/gateway URL (defaults to VALIDATOR_URL in env)')
33
+ .option('--app-id <id>', 'Override SUBSCRIPTION_APP_ID from env')
34
+ .option('--limit <n>', 'Page size (default 50)')
35
+ .option('--offset <n>', 'Pagination offset (default 0)')
36
+ .action(async (opts) => {
37
+ console.log(chalk_1.default.bold.cyan('\n hsuite billing\n'));
38
+ try {
39
+ const res = await runBilling(opts);
40
+ console.log(chalk_1.default.gray(` app: ${res.appId}`));
41
+ console.log(chalk_1.default.gray(` total: ${res.total} hasMore: ${res.hasMore}\n`));
42
+ if (res.entries.length === 0) {
43
+ console.log(chalk_1.default.gray(' (no entries)\n'));
44
+ return;
45
+ }
46
+ const headers = ['operation', 'amount', 'balanceAfter', 'timestamp'];
47
+ console.log(chalk_1.default.bold.white(` ${headers[0].padEnd(22)} ${headers[1].padEnd(14)} ${headers[2].padEnd(14)} ${headers[3]}`));
48
+ console.log(chalk_1.default.gray(' ' + '-'.repeat(78)));
49
+ for (const e of res.entries) {
50
+ console.log(chalk_1.default.gray(` ${(e.operation ?? '').padEnd(22)} ${String(e.amount ?? '').padEnd(14)} ${String(e.balanceAfter ?? '').padEnd(14)} ${e.timestamp ?? ''}`));
51
+ }
52
+ console.log('');
53
+ }
54
+ catch (err) {
55
+ console.error(chalk_1.default.red(` ${err.message}\n`));
56
+ process.exit(1);
57
+ }
58
+ });
59
+ //# sourceMappingURL=billing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing.js","sourceRoot":"","sources":["../../src/commands/billing.ts"],"names":[],"mappings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AAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAC7F,CACF,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC/C,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;YAC5B,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,IAAI,CACR,KAAK,CAAC,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,SAAS,IAAI,EAAE,EAAE,CAC3I,CACF,CAAC;QACJ,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,KAAM,GAAa,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC;QAC1D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA+DpC,eAAO,MAAM,aAAa,SA6HtB,CAAC"}
1
+ {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgEpC,eAAO,MAAM,aAAa,SAiJtB,CAAC"}