@hsuite/smart-engines-cli 1.7.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -7
- package/dist/__tests__/helpers/fixtures-image-hygiene.d.ts +18 -0
- package/dist/__tests__/helpers/fixtures-image-hygiene.d.ts.map +1 -0
- package/dist/__tests__/helpers/fixtures-image-hygiene.js +42 -0
- package/dist/__tests__/helpers/fixtures-image-hygiene.js.map +1 -0
- package/dist/_lib/baas.d.ts +12 -17
- package/dist/_lib/baas.d.ts.map +1 -1
- package/dist/_lib/baas.js +13 -1
- package/dist/_lib/baas.js.map +1 -1
- package/dist/_lib/cluster-provisioning-report.d.ts +29 -0
- package/dist/_lib/cluster-provisioning-report.d.ts.map +1 -0
- package/dist/_lib/cluster-provisioning-report.js +35 -0
- package/dist/_lib/cluster-provisioning-report.js.map +1 -0
- package/dist/_lib/create-outcome.d.ts +43 -0
- package/dist/_lib/create-outcome.d.ts.map +1 -0
- package/dist/_lib/create-outcome.js +121 -0
- package/dist/_lib/create-outcome.js.map +1 -0
- package/dist/_lib/decimal-compare.d.ts +23 -0
- package/dist/_lib/decimal-compare.d.ts.map +1 -0
- package/dist/_lib/decimal-compare.js +69 -0
- package/dist/_lib/decimal-compare.js.map +1 -0
- package/dist/_lib/env.d.ts +6 -0
- package/dist/_lib/env.d.ts.map +1 -1
- package/dist/_lib/env.js +68 -1
- package/dist/_lib/env.js.map +1 -1
- package/dist/_lib/framework.js +2 -2
- package/dist/_lib/image-hygiene.d.ts +36 -0
- package/dist/_lib/image-hygiene.d.ts.map +1 -0
- package/dist/_lib/image-hygiene.js +233 -0
- package/dist/_lib/image-hygiene.js.map +1 -0
- package/dist/_lib/order-deadline.d.ts +35 -0
- package/dist/_lib/order-deadline.d.ts.map +1 -0
- package/dist/_lib/order-deadline.js +78 -0
- package/dist/_lib/order-deadline.js.map +1 -0
- package/dist/_lib/run-fn.d.ts +34 -0
- package/dist/_lib/run-fn.d.ts.map +1 -0
- package/dist/_lib/run-fn.js +15 -0
- package/dist/_lib/run-fn.js.map +1 -0
- package/dist/_lib/runtime-env.d.ts.map +1 -1
- package/dist/_lib/runtime-env.js +3 -0
- package/dist/_lib/runtime-env.js.map +1 -1
- package/dist/_lib/subscription-client.d.ts +123 -1
- package/dist/_lib/subscription-client.d.ts.map +1 -1
- package/dist/_lib/subscription-client.js +51 -41
- package/dist/_lib/subscription-client.js.map +1 -1
- package/dist/_lib/transport.d.ts +62 -0
- package/dist/_lib/transport.d.ts.map +1 -0
- package/dist/_lib/transport.js +120 -0
- package/dist/_lib/transport.js.map +1 -0
- package/dist/_lib/xrpl-login-signer.d.ts +39 -0
- package/dist/_lib/xrpl-login-signer.d.ts.map +1 -0
- package/dist/_lib/xrpl-login-signer.js +78 -0
- package/dist/_lib/xrpl-login-signer.js.map +1 -0
- package/dist/commands/app-lifecycle.d.ts.map +1 -1
- package/dist/commands/app-lifecycle.js +8 -2
- package/dist/commands/app-lifecycle.js.map +1 -1
- package/dist/commands/customer-scope.d.ts +48 -0
- package/dist/commands/customer-scope.d.ts.map +1 -0
- package/dist/commands/customer-scope.js +89 -0
- package/dist/commands/customer-scope.js.map +1 -0
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +11 -2
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/personhood.d.ts +2 -2
- package/dist/commands/personhood.d.ts.map +1 -1
- package/dist/commands/personhood.js +12 -10
- package/dist/commands/personhood.js.map +1 -1
- package/dist/commands/redeploy.d.ts.map +1 -1
- package/dist/commands/redeploy.js +9 -2
- package/dist/commands/redeploy.js.map +1 -1
- package/dist/commands/subscribe.d.ts +52 -5
- package/dist/commands/subscribe.d.ts.map +1 -1
- package/dist/commands/subscribe.js +656 -70
- package/dist/commands/subscribe.js.map +1 -1
- package/dist/commands/topup.d.ts.map +1 -1
- package/dist/commands/topup.js +16 -1
- package/dist/commands/topup.js.map +1 -1
- package/dist/commands/transactions.d.ts +28 -31
- package/dist/commands/transactions.d.ts.map +1 -1
- package/dist/commands/transactions.js +36 -40
- package/dist/commands/transactions.js.map +1 -1
- package/dist/commands/upgrade.d.ts.map +1 -1
- package/dist/commands/upgrade.js +9 -1
- package/dist/commands/upgrade.js.map +1 -1
- package/dist/commands/verify.d.ts +23 -3
- package/dist/commands/verify.d.ts.map +1 -1
- package/dist/commands/verify.js +178 -34
- package/dist/commands/verify.js.map +1 -1
- package/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/commands/governance.d.ts +0 -42
- package/dist/commands/governance.d.ts.map +0 -1
- package/dist/commands/governance.js +0 -144
- package/dist/commands/governance.js.map +0 -1
- package/dist/commands/hist-balance.d.ts +0 -52
- package/dist/commands/hist-balance.d.ts.map +0 -1
- package/dist/commands/hist-balance.js +0 -134
- package/dist/commands/hist-balance.js.map +0 -1
package/README.md
CHANGED
|
@@ -99,6 +99,42 @@ After this, your smart-app boots in cluster-mode automatically.
|
|
|
99
99
|
|
|
100
100
|
---
|
|
101
101
|
|
|
102
|
+
## Plaintext transport: HTTPS by default, one explicit opt-in
|
|
103
|
+
|
|
104
|
+
The CLI mints and carries credentials (`hsuite init`, `hsuite subscribe`), so it
|
|
105
|
+
does not talk plaintext `http://` to a public host. Every command that takes a
|
|
106
|
+
`--server` / `--gateway` — or reaches the validator through
|
|
107
|
+
`_lib/subscription-client.ts` — routes through ONE resolver
|
|
108
|
+
(`src/_lib/transport.ts`); no call site derives the flag from the URL scheme.
|
|
109
|
+
|
|
110
|
+
| Target | Behaviour |
|
|
111
|
+
|---|---|
|
|
112
|
+
| `https://…` | Accepted |
|
|
113
|
+
| `http://localhost`, `http://127.0.0.1`, `http://[::1]` | Accepted — the local-dev flow needs no flag |
|
|
114
|
+
| `http://<cluster-service>.svc[.cluster.local]` | Deferred to the SDK transport policy (which admits it) |
|
|
115
|
+
| any other `http://…` | **Refused** before the client is built |
|
|
116
|
+
|
|
117
|
+
A refusal names the opt-in:
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
✗ refusing to send credentials over plaintext http:// to gateway.example.com: the
|
|
121
|
+
smart-engines transport policy admits plain http:// only toward an in-cluster
|
|
122
|
+
service name (*.svc, *.cluster.local). Use https://, or re-run with --insecure
|
|
123
|
+
(or HSUITE_ALLOW_INSECURE=1) to allow it — local development only.
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
The opt-in is one mechanism, either spelling:
|
|
127
|
+
|
|
128
|
+
```sh
|
|
129
|
+
hsuite --insecure deploy --manifest ./app.json # global flag, before or after the subcommand
|
|
130
|
+
HSUITE_ALLOW_INSECURE=1 hsuite deploy --manifest ./app.json
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
It is global (`--insecure` is registered once on the root program, not per
|
|
134
|
+
command) and applies to every command in the same invocation. The flag sets
|
|
135
|
+
`HSUITE_ALLOW_INSECURE=1`; only the exact value `1` counts. Use it only against
|
|
136
|
+
a host you operate yourself.
|
|
137
|
+
|
|
102
138
|
## Deployment commands
|
|
103
139
|
|
|
104
140
|
Eight commands take a smart-app from a manifest to a running, manageable
|
|
@@ -111,10 +147,11 @@ deployment on the cluster. They all share base flags:
|
|
|
111
147
|
| `--app-id <id>` | `DEPLOYED_APP_ID` → `SUBSCRIPTION_APP_ID` | App to act on |
|
|
112
148
|
|
|
113
149
|
Every command constructs exactly **one** `BaasClient`
|
|
114
|
-
(`{ hostUrl, appId, pathPrefix: '/host', allowInsecure, timeout }
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
150
|
+
(`{ hostUrl, appId, pathPrefix: '/host', allowInsecure, timeout }`, where
|
|
151
|
+
`allowInsecure` comes from the shared resolver above — `undefined` unless the
|
|
152
|
+
target is loopback or opted in) and authenticates it with the env XRPL signer —
|
|
153
|
+
connecting straight to the public round-robin gateway (no cluster-discovery
|
|
154
|
+
factory, whose per-cluster hostnames aren't reachable from a dev machine).
|
|
118
155
|
|
|
119
156
|
### The manifest (one canonical shape)
|
|
120
157
|
|
|
@@ -166,8 +203,8 @@ same set the smart-app's env schema reads (`XRPL_*`, `SUBSCRIPTION_APP_ID`,
|
|
|
166
203
|
deploy-time / CLI-only knobs (e.g. `SUBSCRIPTION_NFT_SERIAL`, `VALIDATOR_API_KEY`)
|
|
167
204
|
are **not** forwarded. The list lives in
|
|
168
205
|
`packages/hsuite-cli/src/_lib/runtime-env.ts` (`RUNTIME_ENV_KEYS`), mirroring the
|
|
169
|
-
smart-app schema (`
|
|
170
|
-
|
|
206
|
+
smart-app schema (`smart-app/src/config/env-validation.ts` in the
|
|
207
|
+
`HSuiteNetwork/showcase-smart-app` repo).
|
|
171
208
|
|
|
172
209
|
**Precedence:** the forwarded `.env.local` values are the base;
|
|
173
210
|
**`manifest.backend.env` is overlaid last and WINS** for any key it sets. Use
|
|
@@ -264,6 +301,17 @@ The `strategy` field on the manifest/deploy request is **advisory**: a
|
|
|
264
301
|
`recreate` request is coerced to `RollingUpdate` for multi-replica apps (with a
|
|
265
302
|
warning).
|
|
266
303
|
|
|
304
|
+
### Image-hygiene gate (HSUITEPT-5)
|
|
305
|
+
|
|
306
|
+
Right after `docker build` — and before any tag / login / push, also with
|
|
307
|
+
`--skip-build` — `hsuite deploy` scans the built image's compiled output
|
|
308
|
+
(`dist/`, `build/`, `lib/` under the image `WorkingDir`) and **aborts** if it
|
|
309
|
+
ships `.map`, `.d.ts` or `.tsbuildinfo` files: a pentest pulled a customer image
|
|
310
|
+
whose `dist/` read like source. Not skippable. Build the backend with
|
|
311
|
+
`sourceMap` / `declaration` off and `removeComments` on (a production tsconfig),
|
|
312
|
+
or keep those files out of the image (`.dockerignore`). `node_modules/` is never
|
|
313
|
+
scanned.
|
|
314
|
+
|
|
267
315
|
### `hsuite deploy` — THE canonical deploy path
|
|
268
316
|
|
|
269
317
|
`hsuite deploy --manifest <file>` is the **single, canonical path** to deploy a
|
|
@@ -404,7 +452,8 @@ hsuite subscribe --env .env.local --tier builder
|
|
|
404
452
|
## Companion packages
|
|
405
453
|
|
|
406
454
|
- **[`@hsuite/smart-engines-sdk`](https://www.npmjs.com/package/@hsuite/smart-engines-sdk)** — the underlying SDK that `hsuite` wraps. Use it directly when you need finer-grained control over auth, BaaS calls, or chain operations.
|
|
407
|
-
- **[
|
|
455
|
+
- **[showcase-smart-app](https://github.com/HSuiteNetwork/showcase-smart-app)** — a reference NestJS backend + Ionic dApp that demonstrate the full integration.
|
|
456
|
+
- **[boilerplate-smart-app](https://github.com/HSuiteNetwork/boilerplate-smart-app)** — the fork-and-go starting point for a new smart-app.
|
|
408
457
|
|
|
409
458
|
---
|
|
410
459
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canned answers for the image-hygiene gate legs every `buildAndPush` runs
|
|
3
|
+
* (HSUITEPT-5): `docker inspect` → WorkingDir, `docker create` → container id,
|
|
4
|
+
* `docker cp` → the current {@link hygieneTar}, `docker rm` → nothing.
|
|
5
|
+
*
|
|
6
|
+
* Fold into any fake `execFileSync` / `runFn` as its fallthrough
|
|
7
|
+
* (`return hygieneLeg(file, args)`), so the gate sees a CLEAN image by default
|
|
8
|
+
* and the suite under test keeps asserting only its own legs. Plant an
|
|
9
|
+
* offending file with `hygieneTar = tarWith('dist/main.js.map')`.
|
|
10
|
+
*/
|
|
11
|
+
export declare const HYGIENE_CID: string;
|
|
12
|
+
/** Empty archive = clean image. Reassign per test; reset in `beforeEach` where it matters. */
|
|
13
|
+
export declare let hygieneTar: Buffer;
|
|
14
|
+
export declare function setHygieneTar(tar: Buffer): void;
|
|
15
|
+
export declare function hygieneLeg(file: string, args: string[]): unknown;
|
|
16
|
+
/** One-entry ustar archive (enough to plant an offending file). */
|
|
17
|
+
export declare function tarWith(name: string): Buffer;
|
|
18
|
+
//# sourceMappingURL=fixtures-image-hygiene.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixtures-image-hygiene.d.ts","sourceRoot":"","sources":["../../../src/__tests__/helpers/fixtures-image-hygiene.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,QAAiB,CAAC;AAE1C,8FAA8F;AAC9F,eAAO,IAAI,UAAU,EAAE,MAA2B,CAAC;AAEnD,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE/C;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAMhE;AAED,mEAAmE;AACnE,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM5C"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hygieneTar = exports.HYGIENE_CID = void 0;
|
|
4
|
+
exports.setHygieneTar = setHygieneTar;
|
|
5
|
+
exports.hygieneLeg = hygieneLeg;
|
|
6
|
+
exports.tarWith = tarWith;
|
|
7
|
+
/**
|
|
8
|
+
* Canned answers for the image-hygiene gate legs every `buildAndPush` runs
|
|
9
|
+
* (HSUITEPT-5): `docker inspect` → WorkingDir, `docker create` → container id,
|
|
10
|
+
* `docker cp` → the current {@link hygieneTar}, `docker rm` → nothing.
|
|
11
|
+
*
|
|
12
|
+
* Fold into any fake `execFileSync` / `runFn` as its fallthrough
|
|
13
|
+
* (`return hygieneLeg(file, args)`), so the gate sees a CLEAN image by default
|
|
14
|
+
* and the suite under test keeps asserting only its own legs. Plant an
|
|
15
|
+
* offending file with `hygieneTar = tarWith('dist/main.js.map')`.
|
|
16
|
+
*/
|
|
17
|
+
exports.HYGIENE_CID = 'c'.repeat(64);
|
|
18
|
+
/** Empty archive = clean image. Reassign per test; reset in `beforeEach` where it matters. */
|
|
19
|
+
exports.hygieneTar = Buffer.alloc(1024);
|
|
20
|
+
function setHygieneTar(tar) {
|
|
21
|
+
exports.hygieneTar = tar;
|
|
22
|
+
}
|
|
23
|
+
function hygieneLeg(file, args) {
|
|
24
|
+
if (file !== 'docker')
|
|
25
|
+
return undefined;
|
|
26
|
+
if (args[0] === 'inspect')
|
|
27
|
+
return '/app\n';
|
|
28
|
+
if (args[0] === 'create')
|
|
29
|
+
return `${exports.HYGIENE_CID}\n`;
|
|
30
|
+
if (args[0] === 'cp')
|
|
31
|
+
return exports.hygieneTar;
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
/** One-entry ustar archive (enough to plant an offending file). */
|
|
35
|
+
function tarWith(name) {
|
|
36
|
+
const header = Buffer.alloc(512);
|
|
37
|
+
header.write(name, 0, 100, 'utf8');
|
|
38
|
+
header.write('00000000000\0', 124, 12, 'ascii');
|
|
39
|
+
header.write('0', 156, 1, 'ascii');
|
|
40
|
+
return Buffer.concat([header, Buffer.alloc(1024)]);
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=fixtures-image-hygiene.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixtures-image-hygiene.js","sourceRoot":"","sources":["../../../src/__tests__/helpers/fixtures-image-hygiene.ts"],"names":[],"mappings":";;;AAeA,sCAEC;AAED,gCAMC;AAGD,0BAMC;AAlCD;;;;;;;;;GASG;AACU,QAAA,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAE1C,8FAA8F;AACnF,QAAA,UAAU,GAAW,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAEnD,SAAgB,aAAa,CAAC,GAAW;IACvC,kBAAU,GAAG,GAAG,CAAC;AACnB,CAAC;AAED,SAAgB,UAAU,CAAC,IAAY,EAAE,IAAc;IACrD,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IACxC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC;IAC3C,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ;QAAE,OAAO,GAAG,mBAAW,IAAI,CAAC;IACpD,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI;QAAE,OAAO,kBAAU,CAAC;IACxC,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,mEAAmE;AACnE,SAAgB,OAAO,CAAC,IAAY;IAClC,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;IACnC,MAAM,CAAC,KAAK,CAAC,eAAe,EAAE,GAAG,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;IAChD,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;IACnC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC"}
|
package/dist/_lib/baas.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BaasClient } from '@hsuite/smart-engines-sdk';
|
|
2
2
|
import type { EnvMap } from './env';
|
|
3
|
+
import type { RunFn } from './run-fn';
|
|
3
4
|
/** Default per-app deploy timeout — `init` runs the smart-app entity DKG ceremony. */
|
|
4
5
|
export declare const DEFAULT_DEPLOY_TIMEOUT_MS = 240000;
|
|
5
6
|
/**
|
|
@@ -18,23 +19,11 @@ export type RegistryCreds = {
|
|
|
18
19
|
repository: string;
|
|
19
20
|
};
|
|
20
21
|
/**
|
|
21
|
-
*
|
|
22
|
-
* `
|
|
23
|
-
*
|
|
24
|
-
* The return value MATTERS for stdout-capturing invocations (the `docker push`
|
|
25
|
-
* and `docker inspect` legs in {@link buildAndPush}): `execFileSync` returns the
|
|
26
|
-
* child's stdout, and with `encoding: 'utf8'` that is a `string`. We parse the
|
|
27
|
-
* push summary / `RepoDigests` out of it to recover the pushed manifest digest.
|
|
28
|
-
* Legs run with inherited stdio (build/tag/login) return nothing meaningful.
|
|
29
|
-
* Unit tests supply a fake that returns canned push/inspect stdout.
|
|
22
|
+
* The shell-out seam. Declared in `./run-fn` so `image-hygiene.ts` can take it
|
|
23
|
+
* without importing this module back (dependency-cruiser `no-circular`), and
|
|
24
|
+
* re-exported here because every existing caller imports it from `baas`.
|
|
30
25
|
*/
|
|
31
|
-
export type RunFn
|
|
32
|
-
input?: string;
|
|
33
|
-
stdio?: unknown;
|
|
34
|
-
env?: NodeJS.ProcessEnv;
|
|
35
|
-
cwd?: string;
|
|
36
|
-
encoding?: BufferEncoding;
|
|
37
|
-
}) => unknown;
|
|
26
|
+
export type { RunFn } from './run-fn';
|
|
38
27
|
export type ConnectAndAuthOpts = {
|
|
39
28
|
/** Public gateway/host URL. */
|
|
40
29
|
gateway: string;
|
|
@@ -51,7 +40,7 @@ export type ConnectAndAuthOpts = {
|
|
|
51
40
|
clientFactory?: (config: {
|
|
52
41
|
hostUrl: string;
|
|
53
42
|
appId: string;
|
|
54
|
-
allowInsecure: boolean;
|
|
43
|
+
allowInsecure: boolean | undefined;
|
|
55
44
|
pathPrefix: string;
|
|
56
45
|
timeout: number;
|
|
57
46
|
}) => BaasClient;
|
|
@@ -88,6 +77,8 @@ export type BuildAndPushOpts = {
|
|
|
88
77
|
platform?: string;
|
|
89
78
|
/** Test seam — defaults to `execFileSync`. */
|
|
90
79
|
runFn?: RunFn;
|
|
80
|
+
/** Progress sink for the image-hygiene gate (defaults to silent). */
|
|
81
|
+
log?: (message: string) => void;
|
|
91
82
|
/** Push retry attempts (round-robin robot-auth can need a couple). Default 6. */
|
|
92
83
|
pushAttempts?: number;
|
|
93
84
|
/**
|
|
@@ -125,6 +116,10 @@ export declare function imageTarget(registry: RegistryCreds, tag: string): strin
|
|
|
125
116
|
* - optional `<build>` (shell command) in `context`
|
|
126
117
|
* - `docker build --platform linux/amd64 --provenance=false --sbom=false
|
|
127
118
|
* -t hsuite-local/<name>:<tag> -f <dockerfile> <context>`
|
|
119
|
+
* - image-hygiene gate ({@link assertImageHygiene}, HSUITEPT-5): the built
|
|
120
|
+
* image's compiled output must ship no source maps / declarations — runs
|
|
121
|
+
* even with `--skip-build` (the image is about to be deployed either way)
|
|
122
|
+
* and ABORTS before any tag / login / push
|
|
128
123
|
* - `docker tag <local> <server>/<repo>:<tag>`
|
|
129
124
|
* - `docker login <server> -u <username> --password-stdin` ← username a
|
|
130
125
|
* DISCRETE argv element; password on stdin
|
package/dist/_lib/baas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baas.d.ts","sourceRoot":"","sources":["../../src/_lib/baas.ts"],"names":[],"mappings":"AA+CA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"baas.d.ts","sourceRoot":"","sources":["../../src/_lib/baas.ts"],"names":[],"mappings":"AA+CA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGpC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAItC,sFAAsF;AACtF,eAAO,MAAM,yBAAyB,SAAU,CAAC;AAEjD;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,gBAAgB,CAAC;AAEpD,+EAA+E;AAC/E,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;GAIG;AACH,YAAY,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEtC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,+BAA+B;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,iDAAiD;IAC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EF;;GAEG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAExE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAmI3D;AAwDD,MAAM,MAAM,eAAe,GAAG;IAC5B,sDAAsD;IACtD,GAAG,EAAE,MAAM,CAAC;IACZ,2BAA2B;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,8CAA8C;IAC9C,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAIzD"}
|
package/dist/_lib/baas.js
CHANGED
|
@@ -55,6 +55,8 @@ const child_process_1 = require("child_process");
|
|
|
55
55
|
const smart_engines_sdk_1 = require("@hsuite/smart-engines-sdk");
|
|
56
56
|
const env_1 = require("./env");
|
|
57
57
|
const docker_1 = require("./docker");
|
|
58
|
+
const image_hygiene_1 = require("./image-hygiene");
|
|
59
|
+
const transport_1 = require("./transport");
|
|
58
60
|
/** Default per-app deploy timeout — `init` runs the smart-app entity DKG ceremony. */
|
|
59
61
|
exports.DEFAULT_DEPLOY_TIMEOUT_MS = 240_000;
|
|
60
62
|
/**
|
|
@@ -75,7 +77,7 @@ async function connectAndAuth(opts) {
|
|
|
75
77
|
const config = {
|
|
76
78
|
hostUrl: opts.gateway,
|
|
77
79
|
appId: opts.appId ?? 'pending',
|
|
78
|
-
allowInsecure: opts.gateway
|
|
80
|
+
allowInsecure: (0, transport_1.resolveAllowInsecure)(opts.gateway),
|
|
79
81
|
pathPrefix: '/host',
|
|
80
82
|
timeout: opts.timeout ?? exports.DEFAULT_DEPLOY_TIMEOUT_MS,
|
|
81
83
|
};
|
|
@@ -104,6 +106,10 @@ function imageTarget(registry, tag) {
|
|
|
104
106
|
* - optional `<build>` (shell command) in `context`
|
|
105
107
|
* - `docker build --platform linux/amd64 --provenance=false --sbom=false
|
|
106
108
|
* -t hsuite-local/<name>:<tag> -f <dockerfile> <context>`
|
|
109
|
+
* - image-hygiene gate ({@link assertImageHygiene}, HSUITEPT-5): the built
|
|
110
|
+
* image's compiled output must ship no source maps / declarations — runs
|
|
111
|
+
* even with `--skip-build` (the image is about to be deployed either way)
|
|
112
|
+
* and ABORTS before any tag / login / push
|
|
107
113
|
* - `docker tag <local> <server>/<repo>:<tag>`
|
|
108
114
|
* - `docker login <server> -u <username> --password-stdin` ← username a
|
|
109
115
|
* DISCRETE argv element; password on stdin
|
|
@@ -187,6 +193,12 @@ function buildAndPush(opts) {
|
|
|
187
193
|
env: dockerEnv,
|
|
188
194
|
});
|
|
189
195
|
}
|
|
196
|
+
// HSUITEPT-5: never push (or deploy an already-pushed) image whose compiled
|
|
197
|
+
// output reads like source. Throws `ImageHygieneError` with the offending
|
|
198
|
+
// entries; nothing below runs. Not skippable — this is the platform-owned
|
|
199
|
+
// choke point for customer image hygiene, and app-side build config is
|
|
200
|
+
// never relied on.
|
|
201
|
+
(0, image_hygiene_1.assertImageHygiene)({ image: localTag, run, env: dockerEnv, log: opts.log });
|
|
190
202
|
// #1679: aim the whole docker sequence at ONE origin when the caller resolved
|
|
191
203
|
// a pin. `opts.registry` itself is left alone — see `pushHost`'s docblock for
|
|
192
204
|
// why collapsing it breaks the downstream fan-out.
|
package/dist/_lib/baas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baas.js","sourceRoot":"","sources":["../../src/_lib/baas.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"baas.js","sourceRoot":"","sources":["../../src/_lib/baas.ts"],"names":[],"mappings":";;;AA6GA,wCAiBC;AAyDD,kCAEC;AAwCD,oCAmIC;AAyED,kCAIC;AAjbD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,iDA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DAA0D,CAC7D,CAAC;IACJ,CAAC;IACD,OAAO,cAAc,CAAC;AACxB,CAAC;AAWD;;;;;;;GAOG;AACH,SAAgB,WAAW,CAAC,IAAqB;IAC/C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,IAAK,4BAAiC,CAAC;IAC7D,GAAG,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IACzE,OAAO,IAAI,CAAC,GAAG,CAAC;AAClB,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,GAAG,+BAAuB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAEpG,yGAAyG;AACzG,MAAM,SAAS,GAAG,0BAA0B,CAAC;AAE7C,uGAAuG;AACvG,MAAM,QAAQ,GAAG,UAAU,CAAC;AAI5B,SAAgB,mBAAmB,CAAC,OAAsB;IACxD,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;AAC7C,CAAC;AAED;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,GAAW,EAAE,MAAc,IAAI,CAAC,GAAG,EAAE;IACtE,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACzC,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC;IACjC,IAAI,CAAC,SAAS,CAAC,IAAI,CAA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CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAE7F,SAAgB,gBAAgB,CAAC,GAAY;IAC3C,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IACjC,OAAO,MAAM,KAAK,SAAS,IAAI,uBAAuB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AACrE,CAAC;AAED,qFAAqF;AACrF,MAAM,qBAAqB,GAAwB,IAAI,GAAG,CAAC;IACzD,cAAc;IACd,WAAW;IACX,WAAW;IACX,yBAAyB;CAC1B,CAAC,CAAC;AAEH;;;;;GAKG;AACH,SAAgB,eAAe,CAAC,GAAY;IAC1C,IAAI,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC1C,MAAM,OAAO,GAAI,GAA2E,EAAE,OAAO,CAAC;IACtG,MAAM,IAAI,GAAG,OAAO,EAAE,KAAK,EAAE,IAAI,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"}
|