@hsuite/smart-engines-cli 1.8.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/README.md +1 -0
  2. package/dist/__tests__/helpers/xrpl-signing.d.ts +26 -0
  3. package/dist/__tests__/helpers/xrpl-signing.d.ts.map +1 -0
  4. package/dist/__tests__/helpers/xrpl-signing.js +39 -0
  5. package/dist/__tests__/helpers/xrpl-signing.js.map +1 -0
  6. package/dist/_lib/cluster-provisioning-report.d.ts +29 -0
  7. package/dist/_lib/cluster-provisioning-report.d.ts.map +1 -0
  8. package/dist/_lib/cluster-provisioning-report.js +35 -0
  9. package/dist/_lib/cluster-provisioning-report.js.map +1 -0
  10. package/dist/_lib/create-outcome.d.ts +43 -0
  11. package/dist/_lib/create-outcome.d.ts.map +1 -0
  12. package/dist/_lib/create-outcome.js +121 -0
  13. package/dist/_lib/create-outcome.js.map +1 -0
  14. package/dist/_lib/decimal-compare.d.ts +23 -0
  15. package/dist/_lib/decimal-compare.d.ts.map +1 -0
  16. package/dist/_lib/decimal-compare.js +69 -0
  17. package/dist/_lib/decimal-compare.js.map +1 -0
  18. package/dist/_lib/env.d.ts +6 -0
  19. package/dist/_lib/env.d.ts.map +1 -1
  20. package/dist/_lib/env.js +77 -8
  21. package/dist/_lib/env.js.map +1 -1
  22. package/dist/_lib/error-message.d.ts +7 -0
  23. package/dist/_lib/error-message.d.ts.map +1 -0
  24. package/dist/_lib/error-message.js +21 -0
  25. package/dist/_lib/error-message.js.map +1 -0
  26. package/dist/_lib/order-deadline.d.ts +58 -0
  27. package/dist/_lib/order-deadline.d.ts.map +1 -0
  28. package/dist/_lib/order-deadline.js +112 -0
  29. package/dist/_lib/order-deadline.js.map +1 -0
  30. package/dist/_lib/payment-guard.d.ts +59 -0
  31. package/dist/_lib/payment-guard.d.ts.map +1 -0
  32. package/dist/_lib/payment-guard.js +188 -0
  33. package/dist/_lib/payment-guard.js.map +1 -0
  34. package/dist/_lib/payment-lock.d.ts +27 -0
  35. package/dist/_lib/payment-lock.d.ts.map +1 -0
  36. package/dist/_lib/payment-lock.js +199 -0
  37. package/dist/_lib/payment-lock.js.map +1 -0
  38. package/dist/_lib/payment-record.d.ts +70 -0
  39. package/dist/_lib/payment-record.d.ts.map +1 -0
  40. package/dist/_lib/payment-record.js +78 -0
  41. package/dist/_lib/payment-record.js.map +1 -0
  42. package/dist/_lib/runtime-env.d.ts.map +1 -1
  43. package/dist/_lib/runtime-env.js +8 -0
  44. package/dist/_lib/runtime-env.js.map +1 -1
  45. package/dist/_lib/subscription-client.d.ts +136 -5
  46. package/dist/_lib/subscription-client.d.ts.map +1 -1
  47. package/dist/_lib/subscription-client.js +38 -41
  48. package/dist/_lib/subscription-client.js.map +1 -1
  49. package/dist/_lib/xrp-payment.d.ts +33 -0
  50. package/dist/_lib/xrp-payment.d.ts.map +1 -0
  51. package/dist/_lib/xrp-payment.js +99 -0
  52. package/dist/_lib/xrp-payment.js.map +1 -0
  53. package/dist/_lib/xrpl-login-signer.d.ts +54 -0
  54. package/dist/_lib/xrpl-login-signer.d.ts.map +1 -0
  55. package/dist/_lib/xrpl-login-signer.js +102 -0
  56. package/dist/_lib/xrpl-login-signer.js.map +1 -0
  57. package/dist/commands/app-lifecycle.d.ts.map +1 -1
  58. package/dist/commands/app-lifecycle.js +8 -2
  59. package/dist/commands/app-lifecycle.js.map +1 -1
  60. package/dist/commands/deploy.d.ts.map +1 -1
  61. package/dist/commands/deploy.js +8 -0
  62. package/dist/commands/deploy.js.map +1 -1
  63. package/dist/commands/faucet.d.ts +1 -1
  64. package/dist/commands/faucet.d.ts.map +1 -1
  65. package/dist/commands/faucet.js +2 -7
  66. package/dist/commands/faucet.js.map +1 -1
  67. package/dist/commands/personhood.d.ts +2 -2
  68. package/dist/commands/personhood.d.ts.map +1 -1
  69. package/dist/commands/personhood.js +11 -14
  70. package/dist/commands/personhood.js.map +1 -1
  71. package/dist/commands/redeploy.d.ts.map +1 -1
  72. package/dist/commands/redeploy.js +6 -0
  73. package/dist/commands/redeploy.js.map +1 -1
  74. package/dist/commands/subscribe.d.ts +68 -7
  75. package/dist/commands/subscribe.d.ts.map +1 -1
  76. package/dist/commands/subscribe.js +793 -91
  77. package/dist/commands/subscribe.js.map +1 -1
  78. package/dist/commands/topup.d.ts +19 -7
  79. package/dist/commands/topup.d.ts.map +1 -1
  80. package/dist/commands/topup.js +142 -15
  81. package/dist/commands/topup.js.map +1 -1
  82. package/dist/commands/transactions.d.ts +28 -31
  83. package/dist/commands/transactions.d.ts.map +1 -1
  84. package/dist/commands/transactions.js +36 -41
  85. package/dist/commands/transactions.js.map +1 -1
  86. package/dist/commands/upgrade.d.ts.map +1 -1
  87. package/dist/commands/upgrade.js +22 -3
  88. package/dist/commands/upgrade.js.map +1 -1
  89. package/dist/commands/verify.d.ts +19 -2
  90. package/dist/commands/verify.d.ts.map +1 -1
  91. package/dist/commands/verify.js +158 -23
  92. package/dist/commands/verify.js.map +1 -1
  93. package/dist/index.js +0 -4
  94. package/dist/index.js.map +1 -1
  95. package/package.json +2 -2
  96. package/dist/commands/governance.d.ts +0 -42
  97. package/dist/commands/governance.d.ts.map +0 -1
  98. package/dist/commands/governance.js +0 -155
  99. package/dist/commands/governance.js.map +0 -1
  100. package/dist/commands/hist-balance.d.ts +0 -52
  101. package/dist/commands/hist-balance.d.ts.map +0 -1
  102. package/dist/commands/hist-balance.js +0 -134
  103. package/dist/commands/hist-balance.js.map +0 -1
package/README.md CHANGED
@@ -11,6 +11,7 @@ npm install -g @hsuite/smart-engines-cli
11
11
  ```
12
12
  hsuite init # XRPL wallet + faucet + .env.local
13
13
  hsuite subscribe --env <file> # paid smart-app subscription on cluster (tier builder|growth|scale|enterprise)
14
+ hsuite subscribe --pay-with xrp # pay the subscription in XRP (quoted at the HST/XRP market; needs XRP payments on)
14
15
 
15
16
  # deployment lifecycle (manifest-driven):
16
17
  hsuite deploy --manifest <f> # THE canonical path — fresh deploy AND redeploy
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Real-seed fixtures for the signing-identity specs (#3667).
3
+ *
4
+ * `xrpl@4.6.0`'s `Wallet.fromSeed(seed)` forces ed25519 whatever algorithm the seed carries, so a
5
+ * spec that only ever signs with an ed25519 seed cannot tell a correct signer from the broken one.
6
+ * Every path under test is therefore driven twice: with a real secp256k1 seed AND a real ed25519 one.
7
+ */
8
+ export type SeedAlgorithm = 'ecdsa-secp256k1' | 'ed25519';
9
+ export declare const SEED_ALGORITHMS: readonly SeedAlgorithm[];
10
+ export type SeedIdentity = {
11
+ algorithm: SeedAlgorithm;
12
+ seed: string;
13
+ /** The key `ripple-keypairs.deriveKeypair(seed)` yields: the seed's OWN algorithm. */
14
+ publicKey: string;
15
+ /** The account that key is the master key of. */
16
+ address: string;
17
+ };
18
+ /** A fresh real seed of the given algorithm and the account it controls. */
19
+ export declare function makeSeedIdentity(algorithm: SeedAlgorithm): SeedIdentity;
20
+ /**
21
+ * Assert a signed tx_blob is signed by the key behind `identity.address`: the tx names that account,
22
+ * its SigningPubKey is the seed's own key (and derives to that account), and the signature verifies.
23
+ * Returns the decoded transaction for further assertions.
24
+ */
25
+ export declare function expectSignedBy(blob: string, identity: SeedIdentity): Record<string, unknown>;
26
+ //# sourceMappingURL=xrpl-signing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xrpl-signing.d.ts","sourceRoot":"","sources":["../../../src/__tests__/helpers/xrpl-signing.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAAG,SAAS,CAAC;AAE1D,eAAO,MAAM,eAAe,EAAE,SAAS,aAAa,EAAmC,CAAC;AAExF,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,EAAE,aAAa,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,sFAAsF;IACtF,SAAS,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,4EAA4E;AAC5E,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,aAAa,GAAG,YAAY,CAMvE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAW5F"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ /**
3
+ * Real-seed fixtures for the signing-identity specs (#3667).
4
+ *
5
+ * `xrpl@4.6.0`'s `Wallet.fromSeed(seed)` forces ed25519 whatever algorithm the seed carries, so a
6
+ * spec that only ever signs with an ed25519 seed cannot tell a correct signer from the broken one.
7
+ * Every path under test is therefore driven twice: with a real secp256k1 seed AND a real ed25519 one.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.SEED_ALGORITHMS = void 0;
11
+ exports.makeSeedIdentity = makeSeedIdentity;
12
+ exports.expectSignedBy = expectSignedBy;
13
+ exports.SEED_ALGORITHMS = ['ecdsa-secp256k1', 'ed25519'];
14
+ /** A fresh real seed of the given algorithm and the account it controls. */
15
+ function makeSeedIdentity(algorithm) {
16
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
17
+ const { generateSeed, deriveKeypair, deriveAddress } = require('ripple-keypairs');
18
+ const seed = generateSeed({ algorithm });
19
+ const { publicKey } = deriveKeypair(seed);
20
+ return { algorithm, seed, publicKey, address: deriveAddress(publicKey) };
21
+ }
22
+ /**
23
+ * Assert a signed tx_blob is signed by the key behind `identity.address`: the tx names that account,
24
+ * its SigningPubKey is the seed's own key (and derives to that account), and the signature verifies.
25
+ * Returns the decoded transaction for further assertions.
26
+ */
27
+ function expectSignedBy(blob, identity) {
28
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
29
+ const { decode, verifySignature } = require('xrpl');
30
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
31
+ const { deriveAddress } = require('ripple-keypairs');
32
+ const tx = decode(blob);
33
+ expect(tx.Account).toBe(identity.address);
34
+ expect(tx.SigningPubKey).toBe(identity.publicKey);
35
+ expect(deriveAddress(tx.SigningPubKey)).toBe(identity.address);
36
+ expect(verifySignature(blob)).toBe(true);
37
+ return tx;
38
+ }
39
+ //# sourceMappingURL=xrpl-signing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xrpl-signing.js","sourceRoot":"","sources":["../../../src/__tests__/helpers/xrpl-signing.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAgBH,4CAMC;AAOD,wCAWC;AApCY,QAAA,eAAe,GAA6B,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC;AAWxF,4EAA4E;AAC5E,SAAgB,gBAAgB,CAAC,SAAwB;IACvD,8DAA8D;IAC9D,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAClF,MAAM,IAAI,GAAW,YAAY,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;IACjD,MAAM,EAAE,SAAS,EAAE,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IAC1C,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC;AAC3E,CAAC;AAED;;;;GAIG;AACH,SAAgB,cAAc,CAAC,IAAY,EAAE,QAAsB;IACjE,8DAA8D;IAC9D,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACpD,8DAA8D;IAC9D,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACrD,MAAM,EAAE,GAAG,MAAM,CAAC,IAAI,CAA4B,CAAC;IACnD,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC1C,MAAM,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAClD,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC,aAAuB,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACzE,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzC,OAAO,EAAE,CAAC;AACZ,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Report the per-cluster Harbor provisioning outcome (issue #1257
3
+ * requirement 4) from `init` / `pushCredentials` / `reissuePushCredentials`'s
4
+ * `registry.{completedClusters,failedClusters}`.
5
+ *
6
+ * Pure formatting only — no network, no process exit — so `deploy.ts` /
7
+ * `redeploy.ts` can both call it right after fetching push credentials, and
8
+ * it's independently unit-testable.
9
+ */
10
+ export type ClusterProvisioningRegistry = {
11
+ completedClusters?: Array<{
12
+ clusterId: string;
13
+ pushHost: string;
14
+ }>;
15
+ failedClusters?: Array<{
16
+ clusterId: string;
17
+ error: string;
18
+ code: string;
19
+ }>;
20
+ };
21
+ /**
22
+ * Format lines describing the completed/failed cluster partition. Returns
23
+ * `[]` when there is nothing to report (no failures AND no completed-cluster
24
+ * attribution — e.g. a local/dev single-cluster registry). A completed list
25
+ * with zero failures still gets a line naming the clusters, per requirement
26
+ * 4 ("prints which cluster it pushed to").
27
+ */
28
+ export declare function formatClusterProvisioningReport(registry: ClusterProvisioningRegistry): string[];
29
+ //# sourceMappingURL=cluster-provisioning-report.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cluster-provisioning-report.d.ts","sourceRoot":"","sources":["../../src/_lib/cluster-provisioning-report.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,MAAM,2BAA2B,GAAG;IACxC,iBAAiB,CAAC,EAAE,KAAK,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnE,cAAc,CAAC,EAAE,KAAK,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC5E,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,2BAA2B,GAAG,MAAM,EAAE,CAmB/F"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ /**
3
+ * Report the per-cluster Harbor provisioning outcome (issue #1257
4
+ * requirement 4) from `init` / `pushCredentials` / `reissuePushCredentials`'s
5
+ * `registry.{completedClusters,failedClusters}`.
6
+ *
7
+ * Pure formatting only — no network, no process exit — so `deploy.ts` /
8
+ * `redeploy.ts` can both call it right after fetching push credentials, and
9
+ * it's independently unit-testable.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.formatClusterProvisioningReport = formatClusterProvisioningReport;
13
+ /**
14
+ * Format lines describing the completed/failed cluster partition. Returns
15
+ * `[]` when there is nothing to report (no failures AND no completed-cluster
16
+ * attribution — e.g. a local/dev single-cluster registry). A completed list
17
+ * with zero failures still gets a line naming the clusters, per requirement
18
+ * 4 ("prints which cluster it pushed to").
19
+ */
20
+ function formatClusterProvisioningReport(registry) {
21
+ const completed = registry.completedClusters ?? [];
22
+ const failed = registry.failedClusters ?? [];
23
+ const lines = [];
24
+ if (completed.length > 0) {
25
+ lines.push(` harbor: provisioned on ${completed.map((c) => c.clusterId).join(', ')} ` +
26
+ `(${completed.map((c) => c.pushHost).join(', ')})`);
27
+ }
28
+ if (failed.length > 0) {
29
+ lines.push(` harbor: WARNING — provisioning FAILED on ${failed
30
+ .map((f) => `${f.clusterId} (${f.code}: ${f.error})`)
31
+ .join(', ')} — that cluster will not serve this app's image until it converges`);
32
+ }
33
+ return lines;
34
+ }
35
+ //# sourceMappingURL=cluster-provisioning-report.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cluster-provisioning-report.js","sourceRoot":"","sources":["../../src/_lib/cluster-provisioning-report.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AAcH,0EAmBC;AA1BD;;;;;;GAMG;AACH,SAAgB,+BAA+B,CAAC,QAAqC;IACnF,MAAM,SAAS,GAAG,QAAQ,CAAC,iBAAiB,IAAI,EAAE,CAAC;IACnD,MAAM,MAAM,GAAG,QAAQ,CAAC,cAAc,IAAI,EAAE,CAAC;IAC7C,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzB,KAAK,CAAC,IAAI,CACR,4BAA4B,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;YACzE,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACrD,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,KAAK,CAAC,IAAI,CACR,8CAA8C,MAAM;aACjD,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,SAAS,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,GAAG,CAAC;aACpD,IAAI,CAAC,IAAI,CAAC,oEAAoE,CAClF,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,43 @@
1
+ /** The env key that records a `createApp` whose outcome is not known yet. */
2
+ export declare const PENDING_CREATE_KEY = "SUBSCRIPTION_PENDING_CREATE";
3
+ /**
4
+ * Slack added to the signed intent's `exp`. A responder judges expiry on ITS clock and accepts an
5
+ * `iat` up to a minute ahead of it (`ENTITY_CREATE_INTENT_MAX_FUTURE_SKEW_MS`), and it checks
6
+ * expiry when it ADMITS an intent — the validator's edge needs at least 90 s left
7
+ * (`ENTITY_CREATE_INTENT_EDGE_MIN_REMAINING_MS`) — not when the ceremony it started finishes
8
+ * (a rule publication of up to ~65 s, a share round of ~45 s, deposit-account funding of
9
+ * 60-90 s). `exp` + 3 minutes covers that tail plus the replication of the new subscription.
10
+ */
11
+ export declare const PENDING_CREATE_GRACE_MS: number;
12
+ export type PendingCreate = {
13
+ appId: string;
14
+ until: number;
15
+ };
16
+ export declare function formatPendingCreate(pending: PendingCreate): string;
17
+ /**
18
+ * `<entityId>@<epoch ms>` → the record, or `undefined` for anything else. Strict on purpose: the
19
+ * id is used as a URL path parameter and printed into a command, and the deadline decides whether
20
+ * a second entity may be created, so neither is read by `Number()`'s lenient rules (`0x10`,
21
+ * `1e3`, padding) and a deadline no signed intent could have produced is refused.
22
+ */
23
+ export declare function parsePendingCreate(raw: string, now?: number): PendingCreate | undefined;
24
+ /**
25
+ * When the create that carried `intentMessage` should no longer be able to complete anywhere: the
26
+ * signed intent's own `exp` (every responder refuses an expired intent), or — if the message
27
+ * cannot be read — a full intent lifetime from `now`, plus {@link PENDING_CREATE_GRACE_MS}.
28
+ */
29
+ export declare function pendingCreateDeadline(intentMessage: string, now?: number): number;
30
+ /**
31
+ * The HTTP status an error carries, from either shape the transport raises: the SDK's
32
+ * `SdkHttpError` (`statusCode`) or the CLI test seam's `"<METHOD> <path> → <status>: …"` message.
33
+ */
34
+ export declare function httpStatusOf(err: unknown): number | undefined;
35
+ export declare function createWasRefused(err: unknown): boolean;
36
+ /**
37
+ * Did the request never leave this machine? The SDK reports a network failure as
38
+ * `SdkHttpError(status 0)` carrying the underlying `fetch` error, whose `cause.code` names the
39
+ * connect-phase failure. Only those codes count: ECONNRESET, a socket timeout or an aborted
40
+ * request may have been sent.
41
+ */
42
+ export declare function createNeverSent(err: unknown): boolean;
43
+ //# sourceMappingURL=create-outcome.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-outcome.d.ts","sourceRoot":"","sources":["../../src/_lib/create-outcome.ts"],"names":[],"mappings":"AAcA,6EAA6E;AAC7E,eAAO,MAAM,kBAAkB,gCAAgC,CAAC;AAEhE;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,QAAgB,CAAC;AAWrD,MAAM,MAAM,aAAa,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7D,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAElE;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,GAAE,MAAmB,GAAG,aAAa,GAAG,SAAS,CAQnG;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,GAAE,MAAmB,GAAG,MAAM,CAS7F;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAK7D;AAWD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAGtD;AAUD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAKrD"}
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PENDING_CREATE_GRACE_MS = exports.PENDING_CREATE_KEY = void 0;
4
+ exports.formatPendingCreate = formatPendingCreate;
5
+ exports.parsePendingCreate = parsePendingCreate;
6
+ exports.pendingCreateDeadline = pendingCreateDeadline;
7
+ exports.httpStatusOf = httpStatusOf;
8
+ exports.createWasRefused = createWasRefused;
9
+ exports.createNeverSent = createNeverSent;
10
+ /**
11
+ * What a `createApp` that did not return an entity tells `hsuite subscribe` (#3766).
12
+ *
13
+ * Creating a smart-app entity is a long synchronous ceremony (a DKG run plus deposit-account
14
+ * funding) and the client gives up after 180 s, so a request can end WITHOUT a verdict — a
15
+ * timeout, a dropped connection, a gateway 5xx after the work was done — while the platform goes
16
+ * on to create the entity. The CLI therefore records every create as PENDING before it is sent
17
+ * (`SUBSCRIPTION_PENDING_CREATE=<entityId>@<epoch ms>` in the env file) and reconciles it on the
18
+ * next run. This module holds the pure parts: the record's format, the deadline, and the
19
+ * classification of an error as "the platform refused" / "the request never left" (nothing was
20
+ * created) versus "no verdict" (it may have been).
21
+ */
22
+ const smart_engines_sdk_1 = require("@hsuite/smart-engines-sdk");
23
+ /** The env key that records a `createApp` whose outcome is not known yet. */
24
+ exports.PENDING_CREATE_KEY = 'SUBSCRIPTION_PENDING_CREATE';
25
+ /**
26
+ * Slack added to the signed intent's `exp`. A responder judges expiry on ITS clock and accepts an
27
+ * `iat` up to a minute ahead of it (`ENTITY_CREATE_INTENT_MAX_FUTURE_SKEW_MS`), and it checks
28
+ * expiry when it ADMITS an intent — the validator's edge needs at least 90 s left
29
+ * (`ENTITY_CREATE_INTENT_EDGE_MIN_REMAINING_MS`) — not when the ceremony it started finishes
30
+ * (a rule publication of up to ~65 s, a share round of ~45 s, deposit-account funding of
31
+ * 60-90 s). `exp` + 3 minutes covers that tail plus the replication of the new subscription.
32
+ */
33
+ exports.PENDING_CREATE_GRACE_MS = 3 * 60 * 1000;
34
+ /** How far ahead of now a stored deadline may lie: one intent lifetime, the grace, and clock slack. */
35
+ const MAX_DEADLINE_AHEAD_MS = smart_engines_sdk_1.ENTITY_CREATE_INTENT_TTL_MS + exports.PENDING_CREATE_GRACE_MS + 5 * 60 * 1000;
36
+ /** What the CLI creates: `<entityType>-<first 128 bits of H(owner, nonce)>` (`deriveIntentEntityId`). */
37
+ const ENTITY_ID = /^smart-app-[0-9a-f]{32}$/;
38
+ /** An epoch in milliseconds between 2001 and 2286: exactly 13 digits, no sign, no exponent, no hex. */
39
+ const EPOCH_MS = /^\d{13}$/;
40
+ function formatPendingCreate(pending) {
41
+ return `${pending.appId}@${pending.until}`;
42
+ }
43
+ /**
44
+ * `<entityId>@<epoch ms>` → the record, or `undefined` for anything else. Strict on purpose: the
45
+ * id is used as a URL path parameter and printed into a command, and the deadline decides whether
46
+ * a second entity may be created, so neither is read by `Number()`'s lenient rules (`0x10`,
47
+ * `1e3`, padding) and a deadline no signed intent could have produced is refused.
48
+ */
49
+ function parsePendingCreate(raw, now = Date.now()) {
50
+ const parts = raw.split('@');
51
+ if (parts.length !== 2)
52
+ return undefined;
53
+ const [appId, untilText] = parts;
54
+ if (!ENTITY_ID.test(appId) || !EPOCH_MS.test(untilText))
55
+ return undefined;
56
+ const until = Number(untilText);
57
+ if (until > now + MAX_DEADLINE_AHEAD_MS)
58
+ return undefined;
59
+ return { appId, until };
60
+ }
61
+ /**
62
+ * When the create that carried `intentMessage` should no longer be able to complete anywhere: the
63
+ * signed intent's own `exp` (every responder refuses an expired intent), or — if the message
64
+ * cannot be read — a full intent lifetime from `now`, plus {@link PENDING_CREATE_GRACE_MS}.
65
+ */
66
+ function pendingCreateDeadline(intentMessage, now = Date.now()) {
67
+ let exp;
68
+ try {
69
+ const parsed = JSON.parse(intentMessage);
70
+ if (typeof parsed.exp === 'number' && Number.isFinite(parsed.exp))
71
+ exp = parsed.exp;
72
+ }
73
+ catch {
74
+ // unreadable: fall back below
75
+ }
76
+ return (exp ?? now + smart_engines_sdk_1.ENTITY_CREATE_INTENT_TTL_MS) + exports.PENDING_CREATE_GRACE_MS;
77
+ }
78
+ /**
79
+ * The HTTP status an error carries, from either shape the transport raises: the SDK's
80
+ * `SdkHttpError` (`statusCode`) or the CLI test seam's `"<METHOD> <path> → <status>: …"` message.
81
+ */
82
+ function httpStatusOf(err) {
83
+ const statusCode = err?.statusCode;
84
+ if (typeof statusCode === 'number')
85
+ return statusCode;
86
+ const match = /→\s*(\d{3})\b/.exec(err instanceof Error ? err.message : '');
87
+ return match ? Number(match[1]) : undefined;
88
+ }
89
+ /**
90
+ * The statuses that prove the platform REFUSED a create before it did any work: it rejected the
91
+ * request itself (malformed / unauthenticated / not allowed / too large / wrong media type /
92
+ * semantically invalid). Deliberately NOT every 4xx: after the ceremony the validator answers 409
93
+ * ("already exists", "failed to create the subscription") for an entity that EXISTS, and 408 /
94
+ * 429 say nothing about the work.
95
+ */
96
+ const CREATE_REFUSAL_STATUSES = new Set([400, 401, 403, 413, 415, 422]);
97
+ function createWasRefused(err) {
98
+ const status = httpStatusOf(err);
99
+ return status !== undefined && CREATE_REFUSAL_STATUSES.has(status);
100
+ }
101
+ /** Connect-phase failures: no connection was established, so no request was sent. */
102
+ const NEVER_CONNECTED_CODES = new Set([
103
+ 'ECONNREFUSED',
104
+ 'ENOTFOUND',
105
+ 'EAI_AGAIN',
106
+ 'UND_ERR_CONNECT_TIMEOUT',
107
+ ]);
108
+ /**
109
+ * Did the request never leave this machine? The SDK reports a network failure as
110
+ * `SdkHttpError(status 0)` carrying the underlying `fetch` error, whose `cause.code` names the
111
+ * connect-phase failure. Only those codes count: ECONNRESET, a socket timeout or an aborted
112
+ * request may have been sent.
113
+ */
114
+ function createNeverSent(err) {
115
+ if (httpStatusOf(err) !== 0)
116
+ return false;
117
+ const details = err?.details;
118
+ const code = details?.cause?.code ?? details?.code;
119
+ return typeof code === 'string' && NEVER_CONNECTED_CODES.has(code);
120
+ }
121
+ //# sourceMappingURL=create-outcome.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-outcome.js","sourceRoot":"","sources":["../../src/_lib/create-outcome.ts"],"names":[],"mappings":";;;AAsCA,kDAEC;AAQD,gDAQC;AAOD,sDASC;AAMD,oCAKC;AAWD,4CAGC;AAgBD,0CAKC;AAtHD;;;;;;;;;;;GAWG;AACH,iEAAwE;AAExE,6EAA6E;AAChE,QAAA,kBAAkB,GAAG,6BAA6B,CAAC;AAEhE;;;;;;;GAOG;AACU,QAAA,uBAAuB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAErD,uGAAuG;AACvG,MAAM,qBAAqB,GAAG,+CAA2B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,IAAI,OAAO,EAAE,IAAI,CAAC;IACnD,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACrE,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Exact comparison of two decimal amount strings — for on-ledger balances.
3
+ *
4
+ * XRPL reports an IOU balance as a decimal STRING, with fractions as a matter of course
5
+ * (the 0.25% HST transfer fee alone leaves them) and exponent notation for small values
6
+ * (`"1e-7"`). `Number()` loses precision above 2^53 and `BigInt()` throws on a fraction, so
7
+ * neither is safe to decide "does this account already hold what the quote asks?" with. The
8
+ * validator's `membership/decimal-units.ts` solves the same problem for its deposit check; this
9
+ * is the CLI's own copy, because the CLI deliberately has no runtime dependency on
10
+ * `@hsuite/smart-engines-multi-chain-core`.
11
+ *
12
+ * A ledger answer is untrusted input: both the length of the string and the size of its
13
+ * exponent are bounded, so `"1e999999"` is refused instead of becoming a `10n ** 999999n`.
14
+ */
15
+ /**
16
+ * Compare two decimal amount strings exactly.
17
+ *
18
+ * @returns `-1` / `0` / `1` as `a` is below / equal to / above `b`, or `undefined` when either
19
+ * is not a plain decimal number (empty, garbled, or outside the bounds above) — the caller must
20
+ * treat that as "cannot tell", never as a number.
21
+ */
22
+ export declare function compareDecimals(a: unknown, b: unknown): -1 | 0 | 1 | undefined;
23
+ //# sourceMappingURL=decimal-compare.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decimal-compare.d.ts","sourceRoot":"","sources":["../../src/_lib/decimal-compare.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAiCH;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,SAAS,CAY9E"}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ /**
3
+ * Exact comparison of two decimal amount strings — for on-ledger balances.
4
+ *
5
+ * XRPL reports an IOU balance as a decimal STRING, with fractions as a matter of course
6
+ * (the 0.25% HST transfer fee alone leaves them) and exponent notation for small values
7
+ * (`"1e-7"`). `Number()` loses precision above 2^53 and `BigInt()` throws on a fraction, so
8
+ * neither is safe to decide "does this account already hold what the quote asks?" with. The
9
+ * validator's `membership/decimal-units.ts` solves the same problem for its deposit check; this
10
+ * is the CLI's own copy, because the CLI deliberately has no runtime dependency on
11
+ * `@hsuite/smart-engines-multi-chain-core`.
12
+ *
13
+ * A ledger answer is untrusted input: both the length of the string and the size of its
14
+ * exponent are bounded, so `"1e999999"` is refused instead of becoming a `10n ** 999999n`.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.compareDecimals = compareDecimals;
18
+ /** `-?digits[.digits][e±digits]` — at least one digit before or after the point. */
19
+ const DECIMAL = /^(-?)(\d*)(?:\.(\d*))?(?:[eE]([+-]?\d+))?$/;
20
+ /** Longest string accepted. An XRPL IOU value has at most 16 significant digits plus an exponent. */
21
+ const MAX_LENGTH = 64;
22
+ /** Largest |exponent| accepted — XRPL IOU values stay within roughly 1e-96 … 1e96. */
23
+ const MAX_EXPONENT = 100;
24
+ function parse(raw) {
25
+ // The strings come off the wire (`depositInstructions.amount`, a ledger `balance`): a number or
26
+ // a null from a misbehaving server must read as "cannot tell", not throw out of `trim()`.
27
+ if (typeof raw !== 'string')
28
+ return undefined;
29
+ const text = raw.trim();
30
+ if (text.length === 0 || text.length > MAX_LENGTH)
31
+ return undefined;
32
+ const match = DECIMAL.exec(text);
33
+ if (!match)
34
+ return undefined;
35
+ const [, sign, whole = '', fraction = '', exponentText] = match;
36
+ if (whole === '' && fraction === '')
37
+ return undefined;
38
+ const exponent = exponentText === undefined ? 0 : Number(exponentText);
39
+ if (!Number.isSafeInteger(exponent) || Math.abs(exponent) > MAX_EXPONENT)
40
+ return undefined;
41
+ return {
42
+ negative: sign === '-',
43
+ digits: BigInt(`${whole}${fraction}`),
44
+ // value = digits × 10^(exponent − fraction digits)
45
+ exponent: exponent - fraction.length,
46
+ };
47
+ }
48
+ /**
49
+ * Compare two decimal amount strings exactly.
50
+ *
51
+ * @returns `-1` / `0` / `1` as `a` is below / equal to / above `b`, or `undefined` when either
52
+ * is not a plain decimal number (empty, garbled, or outside the bounds above) — the caller must
53
+ * treat that as "cannot tell", never as a number.
54
+ */
55
+ function compareDecimals(a, b) {
56
+ const left = parse(a);
57
+ const right = parse(b);
58
+ if (!left || !right)
59
+ return undefined;
60
+ const floor = Math.min(left.exponent, right.exponent);
61
+ const scale = (p) => {
62
+ const magnitude = p.digits * 10n ** BigInt(p.exponent - floor);
63
+ return p.negative ? -magnitude : magnitude;
64
+ };
65
+ const x = scale(left);
66
+ const y = scale(right);
67
+ return x < y ? -1 : x > y ? 1 : 0;
68
+ }
69
+ //# sourceMappingURL=decimal-compare.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decimal-compare.js","sourceRoot":"","sources":["../../src/_lib/decimal-compare.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;AAwCH,0CAYC;AAlDD,oFAAoF;AACpF,MAAM,OAAO,GAAG,4CAA4C,CAAC;AAE7D,qGAAqG;AACrG,MAAM,UAAU,GAAG,EAAE,CAAC;AAEtB,sFAAsF;AACtF,MAAM,YAAY,GAAG,GAAG,CAAC;AAIzB,SAAS,KAAK,CAAC,GAAY;IACzB,gGAAgG;IAChG,0FAA0F;IAC1F,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAC9C,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IACxB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,UAAU;QAAE,OAAO,SAAS,CAAC;IACpE,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IAC7B,MAA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AAC;IAC7C,CAAC,CAAC;IACF,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;IACtB,MAAM,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IACvB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACpC,CAAC"}
@@ -1,6 +1,12 @@
1
1
  export type EnvMap = Map<string, string>;
2
2
  export declare function readEnv(path: string): EnvMap;
3
3
  export declare function upsertEnv(path: string, updates: Record<string, string>): void;
4
+ /**
5
+ * Delete every line that sets one of `keys`; everything else — comments, ordering, the final
6
+ * newline — is kept verbatim. A no-op (the file is not rewritten) when the file is missing or
7
+ * none of the keys is set.
8
+ */
9
+ export declare function removeEnvKeys(path: string, keys: readonly string[]): void;
4
10
  export type AuthSigner = {
5
11
  chain: 'xrpl';
6
12
  walletAddress: string;
@@ -1 +1 @@
1
- {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/_lib/env.ts"],"names":[],"mappings":"AAcA,MAAM,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEzC,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAgB5C;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAuB7E;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;CACrC,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAyB1D"}
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/_lib/env.ts"],"names":[],"mappings":"AA0BA,MAAM,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEzC,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAgB5C;AA4CD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAuB7E;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAYzE;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;CACrC,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CA4B1D"}
package/dist/_lib/env.js CHANGED
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.readEnv = readEnv;
4
4
  exports.upsertEnv = upsertEnv;
5
+ exports.removeEnvKeys = removeEnvKeys;
5
6
  exports.buildSignerFromEnv = buildSignerFromEnv;
6
7
  /**
7
8
  * Tiny .env parser/writer + XRPL signer factory.
@@ -14,8 +15,8 @@ exports.buildSignerFromEnv = buildSignerFromEnv;
14
15
  * still available for downstream consumers that want to authenticate via
15
16
  * other chains, but the CLI's prescriptive boilerplate writes XRPL only.
16
17
  */
18
+ const crypto_1 = require("crypto");
17
19
  const fs_1 = require("fs");
18
- const xrpl_1 = require("xrpl");
19
20
  function readEnv(path) {
20
21
  if (!(0, fs_1.existsSync)(path))
21
22
  throw new Error(`env file not found: ${path}`);
@@ -36,6 +37,50 @@ function readEnv(path) {
36
37
  }
37
38
  return out;
38
39
  }
40
+ /**
41
+ * Replace the contents of `path` without ever leaving it truncated.
42
+ *
43
+ * The env file holds `XRPL_SEED`, and `writeFileSync` truncates the file BEFORE it writes: a full
44
+ * disk or a kill in that window leaves the developer's wallet seed gone. This writes a temp file
45
+ * in the same directory, fsyncs it, then renames it over the target (an atomic replace), so a
46
+ * reader — and a crash — only ever sees the old file or the new one. A symlinked env file is
47
+ * updated through the link (the link is kept, not replaced by a regular file), and an existing
48
+ * file keeps its permission bits.
49
+ */
50
+ function writeFileAtomic(path, contents) {
51
+ const exists = (0, fs_1.existsSync)(path);
52
+ const target = exists ? (0, fs_1.realpathSync)(path) : path;
53
+ const mode = exists ? (0, fs_1.statSync)(target).mode & 0o777 : undefined;
54
+ const temp = `${target}.${process.pid}.${(0, crypto_1.randomBytes)(4).toString('hex')}.tmp`;
55
+ const fd = (0, fs_1.openSync)(temp, 'wx', 0o666);
56
+ try {
57
+ if (mode !== undefined)
58
+ (0, fs_1.fchmodSync)(fd, mode);
59
+ (0, fs_1.writeSync)(fd, contents);
60
+ (0, fs_1.fsyncSync)(fd);
61
+ }
62
+ catch (err) {
63
+ (0, fs_1.closeSync)(fd);
64
+ discard(temp);
65
+ throw err;
66
+ }
67
+ (0, fs_1.closeSync)(fd);
68
+ try {
69
+ (0, fs_1.renameSync)(temp, target);
70
+ }
71
+ catch (err) {
72
+ discard(temp);
73
+ throw err;
74
+ }
75
+ }
76
+ function discard(path) {
77
+ try {
78
+ (0, fs_1.unlinkSync)(path);
79
+ }
80
+ catch {
81
+ // already gone
82
+ }
83
+ }
39
84
  function upsertEnv(path, updates) {
40
85
  const lines = (0, fs_1.existsSync)(path) ? (0, fs_1.readFileSync)(path, 'utf8').split('\n') : [];
41
86
  const seen = new Set();
@@ -60,7 +105,28 @@ function upsertEnv(path, updates) {
60
105
  let out = next.join('\n');
61
106
  if (!out.endsWith('\n'))
62
107
  out += '\n';
63
- (0, fs_1.writeFileSync)(path, out);
108
+ writeFileAtomic(path, out);
109
+ }
110
+ /**
111
+ * Delete every line that sets one of `keys`; everything else — comments, ordering, the final
112
+ * newline — is kept verbatim. A no-op (the file is not rewritten) when the file is missing or
113
+ * none of the keys is set.
114
+ */
115
+ function removeEnvKeys(path, keys) {
116
+ if (!(0, fs_1.existsSync)(path))
117
+ return;
118
+ const drop = new Set(keys);
119
+ const lines = (0, fs_1.readFileSync)(path, 'utf8').split('\n');
120
+ const kept = lines.filter((raw) => {
121
+ const line = raw.trim();
122
+ const eq = line.indexOf('=');
123
+ if (!line || line.startsWith('#') || eq <= 0)
124
+ return true;
125
+ return !drop.has(line.slice(0, eq).trim());
126
+ });
127
+ if (kept.length === lines.length)
128
+ return;
129
+ writeFileAtomic(path, kept.join('\n'));
64
130
  }
65
131
  function buildSignerFromEnv(env) {
66
132
  const seed = env.get('XRPL_SEED');
@@ -68,21 +134,24 @@ function buildSignerFromEnv(env) {
68
134
  if (!seed || !address) {
69
135
  throw new Error('XRPL_SEED + XRPL_ADDRESS required. Run `hsuite init` to generate a fresh wallet.');
70
136
  }
71
- const wallet = xrpl_1.Wallet.fromSeed(seed);
137
+ // The seed's OWN key (#3667): `deriveKeypair(seed)` respects the algorithm the seed carries.
138
+ // `xrpl.Wallet.fromSeed(seed)` forces ed25519, so a secp256k1 seed logged in with a key that
139
+ // does not belong to XRPL_ADDRESS. Same derivation as `buildXrplLoginSigner`.
140
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
141
+ const { deriveKeypair, sign } = require('ripple-keypairs');
142
+ const { publicKey, privateKey } = deriveKeypair(seed);
72
143
  return {
73
144
  chain: 'xrpl',
74
145
  walletAddress: address,
75
- publicKey: wallet.publicKey,
146
+ publicKey,
76
147
  signFn: (message) => {
77
148
  // XRPL Web3 challenge-response: cluster's Web3AuthService verifies via
78
149
  // ripple-keypairs.verify(messageHex.toUpperCase(), signature, publicKey)
79
150
  // — see libs/security-core/src/auth/web3-auth.service.ts:240.
80
151
  // Match that exactly: hex-encode the UTF-8 challenge, uppercase, then
81
- // sign with wallet.privateKey via ripple-keypairs.sign.
82
- // eslint-disable-next-line @typescript-eslint/no-var-requires
83
- const { sign } = require('ripple-keypairs');
152
+ // sign with the derived private key via ripple-keypairs.sign.
84
153
  const messageHex = Buffer.from(message, 'utf-8').toString('hex').toUpperCase();
85
- return sign(messageHex, wallet.privateKey);
154
+ return sign(messageHex, privateKey);
86
155
  },
87
156
  };
88
157
  }
@@ -1 +1 @@
1
- {"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/_lib/env.ts"],"names":[],"mappings":";;AAgBA,0BAgBC;AAED,8BAuBC;AASD,gDAyBC;AA3FD;;;;;;;;;;GAUG;AACH,2BAA6D;AAC7D,+BAA8B;AAI9B,SAAgB,OAAO,CAAC,IAAY;IAClC,IAAI,CAAC,IAAA,eAAU,EAAC,IAAI,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,IAAI,EAAE,CAAC,CAAC;IACtE,MAAM,GAAG,GAAG,IAAI,GAAG,EAAkB,CAAC;IACtC,KAAK,MAAM,GAAG,IAAI,IAAA,iBAAY,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACzD,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;QACxB,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,SAAS;QAC5C,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,EAAE,GAAG,CAAC;YAAE,SAAS;QACrB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACrC,IAAI,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACpC,IAAI,CAAC,GAAG,CAAC,UA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AAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IACH,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;QAAE,OAAO;IACzC,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACzC,CAAC;AASD,SAAgB,kBAAkB,CAAC,GAAW;IAC5C,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAClC,MAAM,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACxC,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACb,kFAAkF,CACnF,CAAC;IACJ,CAAC;IACD,6FAA6F;IAC7F,6FAA6F;IAC7F,8EAA8E;IAC9E,8DAA8D;IAC9D,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC3D,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IACtD,OAAO;QACL,KAAK,EAAE,MAAM;QACb,aAAa,EAAE,OAAO;QACtB,SAAS;QACT,MAAM,EAAE,CAAC,OAAe,EAAE,EAAE;YAC1B,uEAAuE;YACvE,yEAAyE;YACzE,8DAA8D;YAC9D,sEAAsE;YACtE,8DAA8D;YAC9D,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;YAC/E,OAAO,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QACtC,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * A printable reason for whatever was thrown. An `Error` gives its message (its
3
+ * name when the message is empty); a thrown string is itself; anything else is
4
+ * JSON — never "undefined" and never "[object Object]".
5
+ */
6
+ export declare function errorMessage(err: unknown): string;
7
+ //# sourceMappingURL=error-message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-message.d.ts","sourceRoot":"","sources":["../../src/_lib/error-message.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAQjD"}