@synopackageland/cli 0.49.0 → 0.50.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/CHANGELOG.md +17 -0
- package/README.md +10 -0
- package/dist/ctl/ai-tools.d.ts +9 -1
- package/dist/ctl/ai-tools.js +4 -4
- package/dist/ctl/cli.d.ts +8 -1
- package/dist/ctl/cli.js +40 -5
- package/dist/ctl/descriptor.d.ts +15 -2
- package/dist/ctl/descriptor.js +9 -4
- package/dist/ctl/flows.js +2 -0
- package/dist/ctl/input.d.ts +5 -3
- package/dist/ctl/input.js +3 -3
- package/dist/ctl/native-auth-command.d.ts +9 -0
- package/dist/ctl/native-auth-command.js +98 -0
- package/dist/ctl/native-executor.d.ts +16 -0
- package/dist/ctl/native-executor.js +187 -0
- package/dist/ctl/native-file-types.d.ts +16 -0
- package/dist/ctl/native-file-types.js +57 -0
- package/dist/ctl/native-files.d.ts +13 -0
- package/dist/ctl/native-files.js +115 -0
- package/dist/ctl/native-metadata.d.ts +10 -0
- package/dist/ctl/native-metadata.js +50 -0
- package/dist/ctl/native-paths.d.ts +4 -0
- package/dist/ctl/native-paths.js +54 -0
- package/dist/ctl/native-protocol.d.ts +21 -0
- package/dist/ctl/native-protocol.js +150 -0
- package/dist/ctl/native-registry.d.ts +8 -0
- package/dist/ctl/native-registry.js +182 -0
- package/dist/ctl/native-schemas.d.ts +7 -0
- package/dist/ctl/native-schemas.js +25 -0
- package/dist/ctl/native-store.d.ts +61 -0
- package/dist/ctl/native-store.js +348 -0
- package/dist/ctl/native-transfers.d.ts +13 -0
- package/dist/ctl/native-transfers.js +331 -0
- package/dist/ctl/native-transport.d.ts +30 -0
- package/dist/ctl/native-transport.js +148 -0
- package/dist/ctl/native-types.d.ts +15 -0
- package/dist/ctl/native-types.js +1 -0
- package/dist/ctl/registry.d.ts +5 -4
- package/dist/ctl/registry.js +12 -1
- package/dist/ctl/service.d.ts +32 -1
- package/dist/ctl/service.js +122 -1
- package/dist/error-registry.js +15 -0
- package/dist/generated/native-http.d.ts +189 -0
- package/dist/generated/native-http.js +1 -0
- package/dist/nas/store.d.ts +3 -1
- package/dist/nas/store.js +6 -3
- package/dist/nas/transport.d.ts +1 -0
- package/dist/native-http-schema/descriptor.schema.json +242 -0
- package/dist/native-http-schema/inventory.schema.json +121 -0
- package/dist/native-http-schema/registry.schema.json +872 -0
- package/dist/native-http-schema/source.json +1 -0
- package/dist/runtime/sdk-source.d.ts +1 -1
- package/dist/runtime/sdk-source.js +1 -1
- package/dist/standalone/api-description.d.ts +2 -5
- package/dist/standalone/build.js +5 -1
- package/dist/standalone/compose-errors.js +5 -0
- package/dist/standalone/inspect-spk.js +2 -17
- package/dist/standalone/lifecycle.js +9 -2
- package/dist/standalone/manifest.d.ts +1 -0
- package/dist/standalone/manifest.js +22 -5
- package/dist/standalone/mobile.js +4 -4
- package/dist/standalone/native-http-inspect.d.ts +9 -0
- package/dist/standalone/native-http-inspect.js +43 -0
- package/dist/standalone/native-http.d.ts +31 -0
- package/dist/standalone/native-http.js +120 -0
- package/dist/standalone/operation-registry.d.ts +2 -7
- package/dist/standalone/operation-registry.js +3 -0
- package/dist/standalone/spk.d.ts +1 -0
- package/dist/standalone/spk.js +15 -1
- package/package.json +3 -3
- package/schema/dsm-api-contract.json +8 -7
- package/skills/SKILL.md +2 -2
- package/skills/reference/compose.md +21 -0
- package/skills/reference/ctl.md +198 -0
- package/skills/reference/daemon-mode.md +1 -1
- package/skills/reference/mobile.md +7 -3
- package/skills/reference/upstream-fork.md +5 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"module":"github.com/synopackageland/syno-pkg-land-sdk","version":"development","local":true}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { goPrivateCovers } from './go-env.js';
|
|
2
2
|
import { type ExecutorManifest } from './sdk-executor-manifest.js';
|
|
3
3
|
/** Pinned SDK for CLI-owned controllers and Compose planning; App pins take precedence. */
|
|
4
|
-
export declare const DEFAULT_SDK_VERSION = "0.
|
|
4
|
+
export declare const DEFAULT_SDK_VERSION = "0.52.0";
|
|
5
5
|
export declare const SDK_PACKAGE = "@synopackageland/sdk";
|
|
6
6
|
export declare const SDK_MODULE = "github.com/synopackageland/syno-pkg-land-sdk";
|
|
7
7
|
export declare const EXECUTOR_MODULE = "github.com/synopackageland/syno-pkg-land-sdk/executor";
|
|
@@ -5,7 +5,7 @@ import { tmpdir } from 'node:os';
|
|
|
5
5
|
import { join } from 'node:path';
|
|
6
6
|
import { readExecutorManifest, predatesExecutorManifest } from './sdk-executor-manifest.js';
|
|
7
7
|
/** Pinned SDK for CLI-owned controllers and Compose planning; App pins take precedence. */
|
|
8
|
-
export const DEFAULT_SDK_VERSION = '0.
|
|
8
|
+
export const DEFAULT_SDK_VERSION = '0.52.0';
|
|
9
9
|
export const SDK_PACKAGE = '@synopackageland/sdk';
|
|
10
10
|
export const SDK_MODULE = 'github.com/synopackageland/syno-pkg-land-sdk';
|
|
11
11
|
export const EXECUTOR_MODULE = `${SDK_MODULE}/executor`;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import type { Descriptor } from '../ctl/descriptor.js';
|
|
2
1
|
import { type StandaloneManifest } from './manifest.js';
|
|
3
2
|
import type { CommandRunner } from './build.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
registry: Record<string, string>;
|
|
7
|
-
} | undefined>;
|
|
3
|
+
import type { NativeArtifacts } from './native-http.js';
|
|
4
|
+
export declare function buildApiDescription(m: StandaloneManifest, bridgeMethods: string[] | undefined, run: CommandRunner): Promise<NativeArtifacts | undefined>;
|
|
8
5
|
export declare function describeApiRoutes(m: StandaloneManifest, bridgeMethods: string[] | undefined, run: CommandRunner): Promise<{
|
|
9
6
|
method: string;
|
|
10
7
|
permission: string;
|
package/dist/standalone/build.js
CHANGED
|
@@ -4,6 +4,7 @@ import { buildAppBackup } from './hyper-backup.js';
|
|
|
4
4
|
import { auditGoRoutes, httpRoutesDigest } from './route-audit.js';
|
|
5
5
|
import { PORTAL_REQUIRES_EXECUTOR } from "../portal/alias.js";
|
|
6
6
|
import { buildApiDescription } from "./api-description.js";
|
|
7
|
+
import { buildNativeMetadataCgi } from './native-http.js';
|
|
7
8
|
import { goChildEnv } from "../runtime/go-env.js";
|
|
8
9
|
import { spawn } from "node:child_process";
|
|
9
10
|
import { goModulePath, privateSdkHint, SDK_MODULE, sdkSource, } from "../runtime/sdk-source.js";
|
|
@@ -154,7 +155,9 @@ export async function buildStandalone(options) {
|
|
|
154
155
|
const executor = await buildExecutor(manifest, arch, archWork, run);
|
|
155
156
|
executor?.warnings.forEach((warning) => warnings.add(warning));
|
|
156
157
|
const builtManifest = executor ? { ...manifest, executor } : manifest;
|
|
157
|
-
const { cgi: cgiPath, worker: backgroundWorker, app, } =
|
|
158
|
+
const { cgi: cgiPath, worker: backgroundWorker, app, } = builtManifest.ctl?.enabled && builtManifest.ctl.transport === 'native-http'
|
|
159
|
+
? { cgi: await buildNativeMetadataCgi(builtManifest, arch, archWork, run, apiDescription) }
|
|
160
|
+
: await backendFor(builtManifest, arch, archWork, run, bridge);
|
|
158
161
|
const outputPath = join(stage, `${manifest.package}-${manifest.spkVersion}-${arch}.spk`);
|
|
159
162
|
const daemonControl = await buildDaemonControl(manifest, arch, archWork, run);
|
|
160
163
|
const identityGateway = await buildIdentityGateway(manifest, arch, archWork, run);
|
|
@@ -183,6 +186,7 @@ export async function buildStandalone(options) {
|
|
|
183
186
|
portalText,
|
|
184
187
|
apiDescription,
|
|
185
188
|
apiRegistry: apiArtifact?.registry,
|
|
189
|
+
httpInventory: apiArtifact?.inventory,
|
|
186
190
|
});
|
|
187
191
|
return outputPath;
|
|
188
192
|
}));
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/** SDK planner errors accepted at this versioned tool boundary. */
|
|
2
2
|
export const COMPOSE_ERRORS = {
|
|
3
|
+
COMPOSE_STOP_UNCONFIRMED: {
|
|
4
|
+
code: "COMPOSE_STOP_UNCONFIRMED",
|
|
5
|
+
description: "The App's local stop operation failed.",
|
|
6
|
+
suggestion: "Inspect the failed App hook or local service cleanup, resolve that failure and retry Stop. Missing Container Manager profiles after Stop are normal; do not recreate or modify them.",
|
|
7
|
+
},
|
|
3
8
|
COMPOSE_HOST_UDP_INVALID: {
|
|
4
9
|
code: "COMPOSE_HOST_UDP_INVALID",
|
|
5
10
|
description: "The host UDP listener declaration is invalid.",
|
|
@@ -10,7 +10,7 @@ import { nativePortal } from "./portal.js";
|
|
|
10
10
|
import { nativeGatewaySupported, renderNativeGatewayConfig, renderNativeGatewayDiagnostic, renderNativeGatewayPrepare, NATIVE_GATEWAY_CONFIG, gatewayEntryPath } from './native-gateway.js';
|
|
11
11
|
import { inspectPortalInfo } from "../portal/info.js";
|
|
12
12
|
import { isDeepStrictEqual } from "node:util";
|
|
13
|
-
import {
|
|
13
|
+
import { inspectCtlArtifacts } from './native-http-inspect.js';
|
|
14
14
|
import { dsmLauncherType } from "../contract/app-launch.js";
|
|
15
15
|
import { isWebLaunchMode, resolvedWebLaunch, trustedAppEntryPath, usesAuthGateway, } from "../contract/web-launch.js";
|
|
16
16
|
import { loadContract } from "../contract/load.js";
|
|
@@ -182,6 +182,7 @@ export async function inspectSpk(spkPath, expectedKind) {
|
|
|
182
182
|
return root;
|
|
183
183
|
}, payload, metadata.hyperBackup, /^package="([^"]*)"$/m.exec(readOptional(join(dir, "INFO")) ?? "")?.[1] ?? "", familyOfArchToken(/^arch="([^"]*)"$/m.exec(readOptional(join(dir, "INFO")) ?? "")?.[1]?.split(/\s+/)[0] ?? "") ?? "x86_64", findings);
|
|
184
184
|
const integrations = metadata.integrations ?? [];
|
|
185
|
+
await inspectCtlArtifacts(dir, paths, metadata.ctl, metadata.entry, findings);
|
|
185
186
|
if (metadata.compose !== undefined) {
|
|
186
187
|
const result = await inspectUnifiedCompose(dir, payload, { ...metadata, installSettings }, findings);
|
|
187
188
|
if (dependencies) {
|
|
@@ -249,22 +250,6 @@ export async function inspectSpk(spkPath, expectedKind) {
|
|
|
249
250
|
checkUninstall(dir, findings);
|
|
250
251
|
if (kind === "container")
|
|
251
252
|
await checkContainerExposure(dir, join(dir, "package.tgz"), findings);
|
|
252
|
-
if (metadata.ctl || paths.has("synopkgland-api.json")) {
|
|
253
|
-
if (!metadata.ctl ||
|
|
254
|
-
!paths.has("synopkgland-api.json") ||
|
|
255
|
-
[...paths].some((path) => path.startsWith("ui/") && path.endsWith("synopkgland-api.json")))
|
|
256
|
-
findings.push("CTL_DESCRIPTOR_LAYOUT_INVALID API description must be private and match its build record.");
|
|
257
|
-
else {
|
|
258
|
-
const apiDir = join(dir, "api-description-inspection");
|
|
259
|
-
mkdirSync(apiDir);
|
|
260
|
-
await tar.x({
|
|
261
|
-
file: join(dir, "package.tgz"),
|
|
262
|
-
cwd: apiDir,
|
|
263
|
-
filter: (path) => path.replace(/^\.\//, "") === "synopkgland-api.json",
|
|
264
|
-
});
|
|
265
|
-
findings.push(...inspectApiDescription(readFileSync(join(apiDir, "synopkgland-api.json"), "utf8"), { id: info.package, version: info.version }, metadata.ctl.hash, metadata.ctl.registry));
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
253
|
const bridge = compiledKind && kind !== "native-go"
|
|
269
254
|
? await checkBridgeApp(dir, metadata.backend, info, payload, findings, metadata.entry)
|
|
270
255
|
: undefined;
|
|
@@ -63,13 +63,20 @@ function renderStandaloneScriptInternal(name, manifest) {
|
|
|
63
63
|
compose: undefined,
|
|
64
64
|
daemon: manifest.identityGateway ? composeDaemon(manifest) : undefined,
|
|
65
65
|
};
|
|
66
|
-
|
|
66
|
+
let body = name === "preinst"
|
|
67
67
|
? renderComposeInstall(manifest.package).replace("#!/bin/sh\n", () => "#!/bin/sh\n" + renderSharedFolderPreparation(manifest.sharedFolder))
|
|
68
68
|
: renderStandaloneScriptInternal(name, { ...native, appScripts: undefined });
|
|
69
|
+
if (name === "start-stop-status" && !manifest.identityGateway) {
|
|
70
|
+
// Report real local teardown failures. Container Manager may remove
|
|
71
|
+
// profiles on STOP and recreate them in its START worker; neither
|
|
72
|
+
// action may require those profiles to exist.
|
|
73
|
+
body = `#!/bin/sh\nsynopkgland_compose_lifecycle() (\n${body.slice("#!/bin/sh\n".length)})\nsynopkgland_compose_result=0\nsynopkgland_compose_lifecycle "$@" || synopkgland_compose_result=$?\nif [ "$1" = stop ] && [ "$synopkgland_compose_result" != 0 ]; then\n echo "[COMPOSE_STOP_UNCONFIRMED] Local service teardown failed; inspect App hooks and local services, then retry Stop" >&2\nfi\nexit "$synopkgland_compose_result"\n`;
|
|
74
|
+
}
|
|
69
75
|
const control = `"/var/packages/${manifest.package}/target/daemon/control"`;
|
|
70
76
|
const paths = `"\${SYNOPKG_PKGDEST:-/var/packages/${manifest.package}/target}" "\${SYNOPKG_PKGVAR:-/var/packages/${manifest.package}/var}"`;
|
|
71
77
|
const preflight = name === "start-stop-status"
|
|
72
|
-
? `
|
|
78
|
+
? (!manifest.identityGateway ? `if [ "$1" = restart ]; then\n "$0" stop || exit $?\n exec "$0" start\nfi\n` : "") +
|
|
79
|
+
`case "$1" in prestart|start|restart)\n "\${SYNOPKG_PKGDEST:-/var/packages/${manifest.package}/target}/compose/control" preflight || exit $? ;;\nesac\n` +
|
|
73
80
|
(!manifest.identityGateway ? `case "$1" in prestart|prestop) exit 0 ;; esac\n` : "")
|
|
74
81
|
: "";
|
|
75
82
|
const remember = name === "postinst" &&
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { validateNativeManifest } from './native-http.js';
|
|
1
2
|
import { readMobile, mobileIconPath } from './mobile.js';
|
|
2
3
|
import { daemonNoFileSdkProblem, daemonNoFileIdentityProblem, DAEMON_NOFILE_MIN_DSM, DAEMON_NOFILE_UNSUPPORTED, DAEMON_NOFILE_ACTIVATION_PROBLEM } from './daemon-nofile.js';
|
|
3
4
|
import { readAllowedSecretFiles } from "../secret-files.js";
|
|
@@ -226,7 +227,7 @@ function readManifest(raw, c) {
|
|
|
226
227
|
: undefined;
|
|
227
228
|
if (binaryProblem)
|
|
228
229
|
c.fail("STANDALONE_ROOT_PROGRAMS_INVALID", binaryProblem);
|
|
229
|
-
const backend = raw.compose !== undefined && raw.backend === undefined
|
|
230
|
+
const backend = (raw.compose !== undefined || isRecord(raw.ctl) && raw.ctl.transport === 'native-http') && raw.backend === undefined
|
|
230
231
|
? { kind: "binary", files: {} }
|
|
231
232
|
: arches && readBackend(raw.backend, arches, c);
|
|
232
233
|
if (backend && backend.kind !== "binary" && rootOps) {
|
|
@@ -248,7 +249,7 @@ function readManifest(raw, c) {
|
|
|
248
249
|
}
|
|
249
250
|
let permissions;
|
|
250
251
|
let integrations;
|
|
251
|
-
if (backend && backend.kind !== "binary") {
|
|
252
|
+
if (backend && backend.kind !== "binary" && !(isRecord(raw.ctl) && raw.ctl.transport === 'native-http')) {
|
|
252
253
|
try {
|
|
253
254
|
const source = isRecord(raw.ctl) && typeof raw.ctl.registry === 'string' ? readRegistry(registryFile(c.root, raw.ctl.registry)) : undefined;
|
|
254
255
|
permissions = readApiPermissions(backend, capabilities, source?.operations);
|
|
@@ -283,7 +284,7 @@ function readManifest(raw, c) {
|
|
|
283
284
|
c.fail(problem.code, problem.message);
|
|
284
285
|
}
|
|
285
286
|
const gatewayRaw = isRecord(raw.identity_gateway) ? raw.identity_gateway : {};
|
|
286
|
-
if (raw.compose !== undefined && isRecord(raw.ctl) && raw.ctl.enabled === true)
|
|
287
|
+
if (raw.compose !== undefined && isRecord(raw.ctl) && raw.ctl.enabled === true && raw.ctl.transport !== 'native-http')
|
|
287
288
|
c.fail("CTL_UNSUPPORTED_BACKEND", "Compose does not support automatic ctl descriptions; disable ctl.");
|
|
288
289
|
if (isRecord(raw.compose) && isRecord(raw.compose.web) && !isRecord(raw.compose.web.health))
|
|
289
290
|
c.fail("COMPOSE_HEALTH_REQUIRED", "Select compose.web.health.path and expected 2xx status for the actual App. Readiness does not follow redirects; check is static and does not probe HTTP.");
|
|
@@ -420,7 +421,7 @@ function readManifest(raw, c) {
|
|
|
420
421
|
}
|
|
421
422
|
const entry = raw.entry === undefined
|
|
422
423
|
? undefined
|
|
423
|
-
: raw.compose !== undefined &&
|
|
424
|
+
: (raw.compose !== undefined || isRecord(raw.ctl) && raw.ctl.transport === 'native-http') &&
|
|
424
425
|
(raw.entry === "admin-only" || raw.entry === "app-privilege")
|
|
425
426
|
? raw.entry
|
|
426
427
|
: readEntry(raw.entry, backend, permissions?.policy, c);
|
|
@@ -589,6 +590,8 @@ function readManifest(raw, c) {
|
|
|
589
590
|
if (typeof raw.ctl.registry !== 'string' || raw.ctl.commands !== undefined)
|
|
590
591
|
throw Error('Use ctl.registry without ctl.commands.');
|
|
591
592
|
const registry = readRegistry(registryFile(c.root, raw.ctl.registry));
|
|
593
|
+
if (raw.ctl.transport !== undefined && raw.ctl.transport !== 'native-http' || (registry.version === 3) !== (raw.ctl.transport === 'native-http') || raw.ctl.transport === 'native-http' && (raw.ctl.external !== undefined || !identityGateway?.ingress || capabilities.identity))
|
|
594
|
+
throw Error('Native HTTP requires a v3 registry, protected same-origin ingress and no ctl.external or standalone identity.');
|
|
592
595
|
raw.ctl.commands = Object.fromEntries(Object.entries(registry.operations).filter(([, op]) => op.ai !== 'hidden'));
|
|
593
596
|
}
|
|
594
597
|
catch (error) {
|
|
@@ -596,6 +599,10 @@ function readManifest(raw, c) {
|
|
|
596
599
|
return undefined;
|
|
597
600
|
}
|
|
598
601
|
}
|
|
602
|
+
if (isRecord(raw.ctl) && raw.ctl.transport !== undefined && (raw.ctl.transport !== 'native-http' || typeof raw.ctl.registry !== 'string')) {
|
|
603
|
+
c.fail('CTL_DECLARATION_INVALID', 'Explicit native-http transport requires a v3 operation registry.');
|
|
604
|
+
return undefined;
|
|
605
|
+
}
|
|
599
606
|
if (isRecord(raw.ctl) && raw.ctl.external !== undefined) {
|
|
600
607
|
const external = raw.ctl.external;
|
|
601
608
|
if (!isRecord(external) || Object.keys(external).length < 1 || Object.keys(external).length > 16 ||
|
|
@@ -606,7 +613,7 @@ function readManifest(raw, c) {
|
|
|
606
613
|
return undefined;
|
|
607
614
|
}
|
|
608
615
|
}
|
|
609
|
-
|
|
616
|
+
const manifest = {
|
|
610
617
|
...(raw.ctl ? { ctl: raw.ctl } : {}),
|
|
611
618
|
...(allowSecretFiles ? { allowSecretFiles } : {}),
|
|
612
619
|
root: c.root,
|
|
@@ -655,6 +662,16 @@ function readManifest(raw, c) {
|
|
|
655
662
|
...(loginStyle ? { loginStyle } : {}),
|
|
656
663
|
...(appScripts ? { appScripts } : {}),
|
|
657
664
|
};
|
|
665
|
+
if (manifest.ctl?.transport === 'native-http') {
|
|
666
|
+
try {
|
|
667
|
+
validateNativeManifest(manifest);
|
|
668
|
+
}
|
|
669
|
+
catch (error) {
|
|
670
|
+
c.fail('CTL_NATIVE_REGISTRY_INVALID', error.message);
|
|
671
|
+
return undefined;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
return manifest;
|
|
658
675
|
}
|
|
659
676
|
function checkBridgeMethods(backend, permissions, c) {
|
|
660
677
|
for (const problem of bridgeMethodProblems(backend.methods, permissions, `${relative(c.root, backend.dir)}/permissions.json`))
|
|
@@ -89,10 +89,10 @@ export async function renderMobileAssets(manifest, uiDigest, moduleVersion) {
|
|
|
89
89
|
hash.update(path).update(bytes);
|
|
90
90
|
const version = hash.digest('hex');
|
|
91
91
|
if (mobile.entry === 'app') {
|
|
92
|
-
const
|
|
92
|
+
const appBundle = `${moduleVersion ? `./${moduleVersion}/${MODULE_UI_ENTRY}` : './app.js'}?v=${version}`;
|
|
93
93
|
const options = {
|
|
94
94
|
packageId: manifest.package, build: version, displayName: name.en,
|
|
95
|
-
appIcon: `./icons/mobile-192.png?v=${version}`,
|
|
95
|
+
appIcon: `./icons/mobile-192.png?v=${version}`, appBundle,
|
|
96
96
|
...(manifest.portal ? { portal: { defaultAlias: manifest.portal.alias } } : {}),
|
|
97
97
|
requestTimeout,
|
|
98
98
|
...(manifest.i18n?.catalogs ? { messages: manifest.i18n.catalogs } : {}),
|
|
@@ -100,8 +100,8 @@ export async function renderMobileAssets(manifest, uiDigest, moduleVersion) {
|
|
|
100
100
|
// Classic bundles rely on document.currentScript.dataset.package; keep
|
|
101
101
|
// their script carrier rather than evaluating them as an ES module.
|
|
102
102
|
const loadApp = moduleVersion
|
|
103
|
-
? `import(${json(
|
|
104
|
-
: `new Promise((resolve,reject)=>{const script=document.createElement('script');script.src=new URL(${json(
|
|
103
|
+
? `import(${json(appBundle)})`
|
|
104
|
+
: `new Promise((resolve,reject)=>{const script=document.createElement('script');script.src=new URL(${json(appBundle)},import.meta.url).href;script.dataset.package=${json(manifest.package)};script.onload=()=>resolve(window.DsmPackageApps?.[${json(manifest.package)}]);script.onerror=reject;document.head.appendChild(script)})`;
|
|
105
105
|
const source = `import {bootEntryPage} from ${json(entryModule(manifest))};\nbootEntryPage({...${json(options)},root:document.querySelector('.dsmapp-root'),mount:async(root,ctx)=>{const app=await ${loadApp};if(typeof app?.mount!=='function')throw new Error('The UI must export mount(root, ctx)');return app.mount(root,ctx)}});`;
|
|
106
106
|
const bundled = await build({ stdin: { contents: source, resolveDir: manifest.root, sourcefile: 'synopkgland-entry.generated.js' }, bundle: true, write: false, format: 'esm', platform: 'browser', target: 'es2022', minify: true, plugins: [{ name: 'app-import', setup(api) { api.onResolve({ filter: /[?]v=/ }, args => ({ path: args.path, external: true })); } }], legalComments: 'inline' });
|
|
107
107
|
files.set('entry.js', Buffer.from(bundled.outputFiles[0].text));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface CtlBuildRecord {
|
|
2
|
+
hash: string;
|
|
3
|
+
registry?: Record<string, string>;
|
|
4
|
+
transport?: string;
|
|
5
|
+
inventorySha256?: string;
|
|
6
|
+
sdk?: string;
|
|
7
|
+
}
|
|
8
|
+
/** Runs before Compose's early inspect return as well as on native packages. */
|
|
9
|
+
export declare function inspectCtlArtifacts(dir: string, paths: Set<string>, record: CtlBuildRecord | undefined, entry: string | undefined, findings: string[]): Promise<void>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { readFileSync, mkdirSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import * as tar from 'tar';
|
|
4
|
+
import { validateNativeArtifacts, digest, HTTP_INVENTORY_FILE } from '../ctl/native-metadata.js';
|
|
5
|
+
import { gatewayEntryPolicyDigest } from './identity-gateway.js';
|
|
6
|
+
import { CGI_PAYLOAD_PATH } from './dsm-window.js';
|
|
7
|
+
import { inspectApiDescription } from './api-description-inspect.js';
|
|
8
|
+
import { strictJson } from '../ctl/json.js';
|
|
9
|
+
/** Runs before Compose's early inspect return as well as on native packages. */
|
|
10
|
+
export async function inspectCtlArtifacts(dir, paths, record, entry, findings) {
|
|
11
|
+
if (!record && !paths.has('synopkgland-api.json') && !paths.has(HTTP_INVENTORY_FILE))
|
|
12
|
+
return;
|
|
13
|
+
if (!record || !paths.has('synopkgland-api.json') || [...paths].some(path => path.startsWith('ui/') && (path.endsWith('synopkgland-api.json') || path.endsWith(HTTP_INVENTORY_FILE)))) {
|
|
14
|
+
findings.push('CTL_DESCRIPTOR_LAYOUT_INVALID metadata must be private and match its build record.');
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const root = join(dir, 'api-description-inspection');
|
|
18
|
+
mkdirSync(root, { recursive: true });
|
|
19
|
+
const wanted = new Set(['synopkgland-api.json', HTTP_INVENTORY_FILE, 'sso/gateway.json', CGI_PAYLOAD_PATH]);
|
|
20
|
+
await tar.x({ file: join(dir, 'package.tgz'), cwd: root, filter: path => wanted.has(path.replace(/^\.\//, '')) });
|
|
21
|
+
const raw = readFileSync(join(root, 'synopkgland-api.json'), 'utf8'), info = readFileSync(join(dir, 'INFO'), 'utf8'), id = /^package="([^"]+)"$/m.exec(info)?.[1] ?? '', version = /^version="([^"]+)"$/m.exec(info)?.[1] ?? '';
|
|
22
|
+
try {
|
|
23
|
+
const description = strictJson(raw);
|
|
24
|
+
if (description.version !== 3) {
|
|
25
|
+
if (record.transport || paths.has(HTTP_INVENTORY_FILE))
|
|
26
|
+
throw Error();
|
|
27
|
+
findings.push(...inspectApiDescription(raw, { id, version }, record.hash, record.registry));
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (record.transport !== 'native-http' || !record.sdk || !paths.has(HTTP_INVENTORY_FILE) || !paths.has('sso/gateway.json') || !paths.has(CGI_PAYLOAD_PATH))
|
|
31
|
+
throw Error();
|
|
32
|
+
const { descriptor: d, inventory: i } = validateNativeArtifacts(description, strictJson(readFileSync(join(root, HTTP_INVENTORY_FILE))));
|
|
33
|
+
const p = d.payload;
|
|
34
|
+
const gateway = strictJson(readFileSync(join(root, 'sso/gateway.json')));
|
|
35
|
+
const permissions = Object.fromEntries(Object.entries(i.bindings).map(([name, b]) => [name, b.permission]));
|
|
36
|
+
const cgi = readFileSync(join(root, CGI_PAYLOAD_PATH));
|
|
37
|
+
if (p.package.id !== id || p.package.version !== version || p.entry !== (entry ?? 'policy') || d.sha256 !== record.hash || p.inventorySha256 !== record.inventorySha256 || digest(permissions) !== digest(record.registry) || p.entryPolicyDigest !== gatewayEntryPolicyDigest(gateway) || p.execution.basePath !== gateway.ingress_path || digest(i.upstreamAuthPaths) !== digest(gateway.upstream_auth_paths) || !cgi.includes(Buffer.from(d.sha256)) || !cgi.includes(Buffer.from('api/nativehttp.NewDescriptionHandler')))
|
|
38
|
+
throw Error();
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
findings.push('CTL_NATIVE_METADATA_MISMATCH descriptor, HTTP inventory, gateway policy, CGI pin or final INFO differs.');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type NativeArchFamily } from '../build-spk/dsm-arch.js';
|
|
2
|
+
import type { NativeInventory } from '../ctl/native-types.js';
|
|
3
|
+
import type { Descriptor } from '../ctl/descriptor.js';
|
|
4
|
+
import type { StandaloneManifest } from './manifest.js';
|
|
5
|
+
import type { CommandRunner } from './build.js';
|
|
6
|
+
export interface NativeArtifacts {
|
|
7
|
+
description: Descriptor;
|
|
8
|
+
registry: Record<string, string>;
|
|
9
|
+
inventory?: NativeInventory;
|
|
10
|
+
}
|
|
11
|
+
export declare function nativeSdk(m: StandaloneManifest): import("../runtime/sdk-source.js").SdkSource;
|
|
12
|
+
export declare function nativeBuildConfig(m: StandaloneManifest): {
|
|
13
|
+
package: {
|
|
14
|
+
id: string;
|
|
15
|
+
version: string;
|
|
16
|
+
displayName: string;
|
|
17
|
+
};
|
|
18
|
+
aliases: string[];
|
|
19
|
+
provenance: {
|
|
20
|
+
developedBy: string;
|
|
21
|
+
generator: string;
|
|
22
|
+
};
|
|
23
|
+
backend: string;
|
|
24
|
+
transport: string;
|
|
25
|
+
gateway: any;
|
|
26
|
+
};
|
|
27
|
+
export declare function validateNativeManifest(m: StandaloneManifest): void;
|
|
28
|
+
export declare function generateNativeOperations(m: StandaloneManifest, run: CommandRunner, check?: boolean): Promise<NativeArtifacts>;
|
|
29
|
+
/** Fixed SDK metadata-only CGI; no App business routes are linked. */
|
|
30
|
+
export declare function metadataCgiSource(pkg: string, entry: string, sha256: string): string;
|
|
31
|
+
export declare function buildNativeMetadataCgi(m: StandaloneManifest, arch: NativeArchFamily, work: string, run: CommandRunner, description: Descriptor): Promise<string>;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { readFileSync, mkdtempSync, writeFileSync, rmSync, existsSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { sdkSource, SDK_MODULE } from '../runtime/sdk-source.js';
|
|
5
|
+
import { goChildEnv } from '../runtime/go-env.js';
|
|
6
|
+
import { goBuildEnv } from '../build-spk/dsm-arch.js';
|
|
7
|
+
import { identityGatewayConfig, gatewayEntryPolicyDigest } from './identity-gateway.js';
|
|
8
|
+
import { validateNativeArtifacts, HTTP_INVENTORY_FILE, digest } from '../ctl/native-metadata.js';
|
|
9
|
+
import { validateNativeRegistry } from '../ctl/native-registry.js';
|
|
10
|
+
import { registryFile, readRegistry, writeGenerated, registryReference, registryTools } from '../ctl/registry.js';
|
|
11
|
+
export function nativeSdk(m) {
|
|
12
|
+
if (!m.identityGateway?.sdk || !m.identityGateway.ingress)
|
|
13
|
+
throw Error('CTL_NATIVE_SDK_REQUIRED: native HTTP requires protected same-origin gateway ingress.');
|
|
14
|
+
const sdk = sdkSource(m.identityGateway.sdk);
|
|
15
|
+
for (const name of ['registry', 'descriptor', 'inventory']) {
|
|
16
|
+
const path = join(sdk.goDir, 'api/nativehttp/schema', name + '.schema.json');
|
|
17
|
+
if (!existsSync(path) || digest(JSON.parse(readFileSync(path, 'utf8'))) !== digest(JSON.parse(readFileSync(new URL(`../../dist/native-http-schema/${name}.schema.json`, import.meta.url), 'utf8'))))
|
|
18
|
+
throw Error('CTL_NATIVE_SDK_REQUIRED: use SDK after 0.51.1, containing native HTTP v3, matching this CLI.');
|
|
19
|
+
}
|
|
20
|
+
return sdk;
|
|
21
|
+
}
|
|
22
|
+
export function nativeBuildConfig(m) { return { package: { id: m.package, version: m.spkVersion, displayName: m.displayname }, aliases: m.ctl?.aliases ?? [m.package.toLowerCase()], provenance: { developedBy: m.ctl?.developedBy ?? 'unknown', generator: 'synopkgland-cli' }, backend: m.compose ? 'compose' : 'native', transport: 'native-http', gateway: JSON.parse(identityGatewayConfig(m)) }; }
|
|
23
|
+
export function validateNativeManifest(m) {
|
|
24
|
+
if (Object.keys(m.capabilities).some(name => name !== 'composeMounts') || !['binary', 'go'].includes(m.backend.kind))
|
|
25
|
+
throw Error('CTL_NATIVE_BACKEND_CONFLICT: metadata-only native HTTP cannot replace SDK business capabilities or bridge runtimes; keep their RPC transport.');
|
|
26
|
+
if (m.uninstall?.purge.exec === 'ui/cgi/api.cgi')
|
|
27
|
+
throw Error('CTL_NATIVE_BACKEND_CONFLICT: use a separate package uninstall executable with metadata-only native HTTP.');
|
|
28
|
+
nativeSdk(m);
|
|
29
|
+
const registry = readRegistry(registryFile(m.root, m.ctl.registry));
|
|
30
|
+
if (registry.version !== 3)
|
|
31
|
+
throw Error('CTL_NATIVE_REGISTRY_INVALID: native-http requires v3.');
|
|
32
|
+
const config = nativeBuildConfig(m), g = config.gateway;
|
|
33
|
+
if (g.access === 'public' || g.upstream_access === 'public' || g.entry === 'policy')
|
|
34
|
+
throw Error('CTL_NATIVE_REGISTRY_INVALID: native HTTP cannot bypass DSM entry.');
|
|
35
|
+
validateNativeRegistry(registry, { basePath: g.ingress_path, upstreamAuthPaths: g.upstream_auth_paths ?? [], entry: m.entry ?? 'policy' });
|
|
36
|
+
}
|
|
37
|
+
export async function generateNativeOperations(m, run, check = false) {
|
|
38
|
+
validateNativeManifest(m);
|
|
39
|
+
const sdk = nativeSdk(m), config = nativeBuildConfig(m), work = mkdtempSync(join(tmpdir(), 'synopkgland-native-metadata-'));
|
|
40
|
+
try {
|
|
41
|
+
const file = join(work, 'config.json');
|
|
42
|
+
writeFileSync(file, JSON.stringify(config));
|
|
43
|
+
const response = await run('go', ['run', './api/nativehttp/cmd/export', '-registry', registryFile(m.root, m.ctl.registry), '-config', file], { cwd: sdk.goDir, env: goChildEnv({ ...process.env, GOOS: undefined, GOARCH: undefined, GOARM: undefined, CGO_ENABLED: '0' }), capture: true });
|
|
44
|
+
if (response.status !== 0)
|
|
45
|
+
throw Error('CTL_NATIVE_EXPORT_FAILED: SDK native HTTP metadata export failed.');
|
|
46
|
+
let artifacts;
|
|
47
|
+
try {
|
|
48
|
+
const raw = JSON.parse(response.stdout ?? '');
|
|
49
|
+
artifacts = validateNativeArtifacts(raw.descriptor, raw.inventory);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
throw Error('CTL_NATIVE_EXPORT_FAILED: invalid SDK metadata export.');
|
|
53
|
+
}
|
|
54
|
+
if (artifacts.descriptor.payload.entryPolicyDigest !== gatewayEntryPolicyDigest(config.gateway) || digest(artifacts.descriptor.payload.package) !== digest(config.package))
|
|
55
|
+
throw Error('CTL_NATIVE_EXPORT_FAILED: resolved metadata mismatch.');
|
|
56
|
+
const registry = readRegistry(registryFile(m.root, m.ctl.registry));
|
|
57
|
+
if (digest(registry) !== artifacts.descriptor.payload.registrySha256)
|
|
58
|
+
throw Error('CTL_NATIVE_REGISTRY_CHANGED: registry changed during metadata export.');
|
|
59
|
+
const write = (name, value) => writeGenerated(join(m.root, 'generated', name), JSON.stringify(value, null, 2) + '\n', check);
|
|
60
|
+
write('synopkgland-api.json', artifacts.descriptor);
|
|
61
|
+
write(HTTP_INVENTORY_FILE, artifacts.inventory);
|
|
62
|
+
write('ctl.json', { commands: artifacts.descriptor.payload.commands });
|
|
63
|
+
write('tools.json', { tools: registryTools(registry) });
|
|
64
|
+
write('routes.json', artifacts.inventory.bindings);
|
|
65
|
+
writeGenerated(join(m.root, 'generated', 'operations.md'), registryReference(registry), check);
|
|
66
|
+
return { description: artifacts.descriptor, inventory: artifacts.inventory, registry: Object.fromEntries(Object.entries(artifacts.inventory.bindings).map(([name, b]) => [name, b.permission])) };
|
|
67
|
+
}
|
|
68
|
+
finally {
|
|
69
|
+
rmSync(work, { recursive: true, force: true });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/** Fixed SDK metadata-only CGI; no App business routes are linked. */
|
|
73
|
+
export function metadataCgiSource(pkg, entry, sha256) {
|
|
74
|
+
return `package main
|
|
75
|
+
import (
|
|
76
|
+
"encoding/json"
|
|
77
|
+
"fmt"
|
|
78
|
+
"net/http/cgi"
|
|
79
|
+
"os"
|
|
80
|
+
"path/filepath"
|
|
81
|
+
"${SDK_MODULE}/api/nativehttp"
|
|
82
|
+
"${SDK_MODULE}/dsm"
|
|
83
|
+
)
|
|
84
|
+
func main() {
|
|
85
|
+
root := "/var/packages/${pkg}/target"
|
|
86
|
+
// Bind the packaged descriptor to the CGI build before constructing its handler.
|
|
87
|
+
raw, err := os.ReadFile(filepath.Join(root,"synopkgland-api.json"))
|
|
88
|
+
if err != nil { os.Exit(1) }
|
|
89
|
+
if err := check(raw); err != nil { os.Exit(1) }
|
|
90
|
+
auth, err := dsm.NewEntryGate(dsm.NewAuthenticator(),${JSON.stringify(entry)},${JSON.stringify(pkg)},"/var/packages/${pkg}/var")
|
|
91
|
+
if err != nil { os.Exit(1) }
|
|
92
|
+
handler, err := nativehttp.NewDescriptionHandler(auth,filepath.Join(root,"synopkgland-api.json"),filepath.Join(root,"${HTTP_INVENTORY_FILE}"))
|
|
93
|
+
if err != nil { os.Exit(1) }
|
|
94
|
+
if err = cgi.Serve(handler); err != nil { os.Exit(1) }
|
|
95
|
+
}
|
|
96
|
+
` + `\n// The SDK's JCS hash is the build pin; raw formatting is deliberately irrelevant.
|
|
97
|
+
func check(raw []byte) error {
|
|
98
|
+
return checkDescription(raw,${JSON.stringify(sha256)})
|
|
99
|
+
}
|
|
100
|
+
`;
|
|
101
|
+
}
|
|
102
|
+
export async function buildNativeMetadataCgi(m, arch, work, run, description) {
|
|
103
|
+
const sdk = nativeSdk(m), source = join(work, 'native-metadata.go'), out = join(work, `native-metadata-${arch}.cgi`);
|
|
104
|
+
writeFileSync(source, metadataCgiSource(m.package, m.entry ?? '', description.sha256) + `\n` + checkSource);
|
|
105
|
+
// Build in the pinned SDK module; source is CLI-owned and uses only exported SDK APIs.
|
|
106
|
+
const result = await run('go', ['build', '-trimpath', '-buildvcs=false', '-ldflags', `-s -w -buildid= -X ${SDK_MODULE}/api.expectedEntryMode=${m.entry ?? ''}`, '-o', out, source], { cwd: sdk.goDir, env: goChildEnv({ ...process.env, ...goBuildEnv(arch) }) });
|
|
107
|
+
if (result.status !== 0 || !existsSync(out))
|
|
108
|
+
throw Error('CTL_NATIVE_CGI_BUILD_FAILED: SDK metadata CGI compilation failed.');
|
|
109
|
+
return out;
|
|
110
|
+
}
|
|
111
|
+
const checkSource = `
|
|
112
|
+
func checkDescription(raw []byte, expected string) error {
|
|
113
|
+
var d map[string]json.RawMessage
|
|
114
|
+
if err := json.Unmarshal(raw,&d); err != nil { return err }
|
|
115
|
+
delete(d,"sha256")
|
|
116
|
+
unsigned, err := json.Marshal(d); if err != nil { return err }
|
|
117
|
+
actual, err := nativehttp.Digest(unsigned); if err != nil { return err }
|
|
118
|
+
if actual != expected { return fmt.Errorf("packaged metadata changed") }; return nil
|
|
119
|
+
}
|
|
120
|
+
`;
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { type Descriptor } from '../ctl/descriptor.js';
|
|
2
2
|
import { type StandaloneManifest } from './manifest.js';
|
|
3
3
|
import type { CommandRunner } from './build.js';
|
|
4
|
+
import { type NativeArtifacts } from './native-http.js';
|
|
4
5
|
export declare function operationRegistry(m: StandaloneManifest): import("../ctl/registry.js").OperationRegistry;
|
|
5
6
|
export declare function registryDescriptor(m: StandaloneManifest, registry?: import("../ctl/registry.js").OperationRegistry): Descriptor;
|
|
6
7
|
/** Generation writes metadata only. The exporter constructs routes without running handlers. */
|
|
7
|
-
export declare function generateOperations(m: StandaloneManifest, run: CommandRunner, check?: boolean, bridgeMethods?: string[]): Promise<
|
|
8
|
-
description: Descriptor;
|
|
9
|
-
registry: {
|
|
10
|
-
'identity.session'?: string | undefined;
|
|
11
|
-
'identity.logout'?: string | undefined;
|
|
12
|
-
};
|
|
13
|
-
}>;
|
|
8
|
+
export declare function generateOperations(m: StandaloneManifest, run: CommandRunner, check?: boolean, bridgeMethods?: string[]): Promise<NativeArtifacts>;
|
|
@@ -6,6 +6,7 @@ import { makeDescriptor, validateDescriptor, flowMethods } from '../ctl/descript
|
|
|
6
6
|
import { readApiPermissions, API_PERMISSIONS_FILE } from './api-permissions.js';
|
|
7
7
|
import { sdkBackend } from './manifest.js';
|
|
8
8
|
import { describeApiRoutes } from './api-description.js';
|
|
9
|
+
import { generateNativeOperations } from './native-http.js';
|
|
9
10
|
export function operationRegistry(m) {
|
|
10
11
|
if (!m.ctl?.registry)
|
|
11
12
|
throw Error('CTL_REGISTRY_REQUIRED: declare ctl.registry with a synopkgland.api v2 spec.');
|
|
@@ -30,6 +31,8 @@ export function registryDescriptor(m, registry = operationRegistry(m)) {
|
|
|
30
31
|
}
|
|
31
32
|
/** Generation writes metadata only. The exporter constructs routes without running handlers. */
|
|
32
33
|
export async function generateOperations(m, run, check = false, bridgeMethods) {
|
|
34
|
+
if (m.ctl?.transport === 'native-http')
|
|
35
|
+
return generateNativeOperations(m, run, check);
|
|
33
36
|
const source = operationRegistry(m);
|
|
34
37
|
const registry = structuredClone(source);
|
|
35
38
|
if (m.backend.kind === 'binary' || m.compose)
|
package/dist/standalone/spk.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export interface AssembleOptions {
|
|
|
30
30
|
portalText?: PortalCatalogs;
|
|
31
31
|
apiRegistry?: Record<string, string>;
|
|
32
32
|
apiDescription?: import("../ctl/descriptor.js").Descriptor;
|
|
33
|
+
httpInventory?: import('../ctl/native-types.js').NativeInventory;
|
|
33
34
|
}
|
|
34
35
|
/**
|
|
35
36
|
* Packs an unsigned Standalone Package SPK. DSM runs installation/lifecycle
|
package/dist/standalone/spk.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { validateNativeArtifacts, digest } from '../ctl/native-metadata.js';
|
|
2
|
+
import { gatewayEntryPolicyDigest } from './identity-gateway.js';
|
|
1
3
|
import { renderMobileAssets } from './mobile.js';
|
|
2
4
|
import { requireDaemonNoFileActivation } from "./daemon-nofile.js";
|
|
3
5
|
import { gatewayIngressOwnershipSupported } from './gateway-ingress.js';
|
|
@@ -74,6 +76,16 @@ export class StandaloneBuildError extends Error {
|
|
|
74
76
|
*/
|
|
75
77
|
export async function assembleStandaloneSpk(options) {
|
|
76
78
|
const { manifest } = options;
|
|
79
|
+
if (manifest.ctl?.enabled && manifest.ctl.transport === 'native-http') {
|
|
80
|
+
if (!options.apiDescription || !options.httpInventory || !options.cgiPath)
|
|
81
|
+
throw new StandaloneBuildError('CTL_NATIVE_METADATA_REQUIRED', 'Native HTTP requires its descriptor, inventory and metadata CGI.');
|
|
82
|
+
const { descriptor, inventory } = validateNativeArtifacts(options.apiDescription, options.httpInventory);
|
|
83
|
+
const gateway = JSON.parse(identityGatewayConfig(manifest));
|
|
84
|
+
if (descriptor.payload.entryPolicyDigest !== gatewayEntryPolicyDigest(gateway) || descriptor.payload.package.id !== manifest.package || descriptor.payload.package.version !== manifest.spkVersion || inventory.basePath !== gateway.ingress_path || digest(inventory.upstreamAuthPaths) !== digest(gateway.upstream_auth_paths))
|
|
85
|
+
throw new StandaloneBuildError('CTL_NATIVE_METADATA_MISMATCH', 'Native metadata differs from the resolved package gateway.');
|
|
86
|
+
}
|
|
87
|
+
else if (options.apiDescription?.version === 3 || options.httpInventory)
|
|
88
|
+
throw new StandaloneBuildError('CTL_NATIVE_METADATA_MISMATCH', 'Native metadata requires explicit native-http transport.');
|
|
77
89
|
requireDaemonNoFileActivation(manifest.daemon?.nofile);
|
|
78
90
|
const staging = mkdtempSync(join(tmpdir(), "syno-standalone-spk-"));
|
|
79
91
|
try {
|
|
@@ -115,6 +127,8 @@ export async function assembleStandaloneSpk(options) {
|
|
|
115
127
|
writeUiTexts(uiRoot, appTitle(manifest), manifest.console);
|
|
116
128
|
if (options.apiDescription)
|
|
117
129
|
writeFile(join(staging, "package", "synopkgland-api.json"), JSON.stringify(options.apiDescription) + "\n");
|
|
130
|
+
if (options.httpInventory)
|
|
131
|
+
writeFile(join(staging, 'package', 'synopkgland-http-inventory.json'), JSON.stringify(options.httpInventory) + '\n');
|
|
118
132
|
const cgiTarget = join(staging, "package", CGI_PAYLOAD_PATH);
|
|
119
133
|
mkdirSync(dirname(cgiTarget), { recursive: true });
|
|
120
134
|
if (options.cgiPath) {
|
|
@@ -273,7 +287,7 @@ export async function assembleStandaloneSpk(options) {
|
|
|
273
287
|
...(manifest.integrations ? { integrations: manifest.integrations } : {}),
|
|
274
288
|
...(manifest.lifecycleTimeouts ? { lifecycleTimeouts: manifest.lifecycleTimeouts } : {}),
|
|
275
289
|
...("timeoutSeconds" in manifest.backend && manifest.backend.timeoutSeconds ? { operationSeconds: manifest.backend.timeoutSeconds } : {}),
|
|
276
|
-
...(options.apiDescription ? { ctl: { hash: options.apiDescription.sha256, registry: options.apiRegistry } } : {}),
|
|
290
|
+
...(options.apiDescription ? { ctl: { hash: options.apiDescription.sha256, registry: options.apiRegistry, ...(options.httpInventory ? { transport: 'native-http', inventorySha256: options.apiDescription.payload.inventorySha256, sdk: manifest.identityGateway.sdk } : {}) } } : {}),
|
|
277
291
|
backend: manifest.backend.kind,
|
|
278
292
|
...(gatewayAdmissionPolicy(manifest.identityGateway, manifest.entry) ? { provider_only_oidc: gatewayAdmissionPolicy(manifest.identityGateway, manifest.entry) } : {}),
|
|
279
293
|
...(manifest.identityGateway && gatewayExternalAccess(manifest.identityGateway)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synopackageland/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.50.0",
|
|
4
4
|
"description": "Syno Package Land Developer Kit CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
],
|
|
26
26
|
"scripts": {
|
|
27
27
|
"check:docs": "node --test scripts/check-doc-versions.test.mjs && node scripts/check-doc-versions.mjs",
|
|
28
|
-
"build": "rm -rf dist && tsc",
|
|
28
|
+
"build": "rm -rf dist && node scripts/prepare-native-http.mjs && tsc",
|
|
29
29
|
"test": "npm run build && node --import tsx --import ./test/helpers/strict-dsm-setup.ts --test --test-concurrency=${SYNOPKGLAND_GATE_JOBS:-3} test/*.test.ts test/ctl/*.test.ts",
|
|
30
30
|
"test:glossary": "node --test scripts/test/glossary-drift.test.mjs",
|
|
31
31
|
"test:scripts": "node --test scripts/test/gate.test.mjs scripts/test/release.test.mjs scripts/test/pack-docker.test.mjs scripts/test/npm-pack.test.mjs scripts/test/executor-bump.test.mjs scripts/test/smoke-exports.test.mjs scripts/test/parallel.test.mjs scripts/test/scaffold-matrix.test.mjs scripts/test/frontend-deps.test.mjs scripts/test/docker-gate.test.mjs scripts/test/gate-plan.test.mjs scripts/test/gates.test.mjs && python3 scripts/test/npm-publish.py",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@napi-rs/keyring": "^2.1.1",
|
|
42
|
-
"@synopackageland/templates": "~0.41.
|
|
42
|
+
"@synopackageland/templates": "~0.41.1",
|
|
43
43
|
"ajv": "^8.17.1",
|
|
44
44
|
"commander": "^13.1.0",
|
|
45
45
|
"esbuild": "^0.28.2",
|