@arcote.tech/arc-cli 0.8.0 → 0.8.1
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/dist/index.js +43 -18
- package/package.json +10 -10
- package/src/commands/platform-deploy.ts +8 -0
- package/src/platform/server.ts +14 -4
package/dist/index.js
CHANGED
|
@@ -10204,11 +10204,18 @@ function notifyTokenChange(scope) {
|
|
|
10204
10204
|
|
|
10205
10205
|
class AuthAdapter {
|
|
10206
10206
|
scopes = new Map;
|
|
10207
|
+
namespace;
|
|
10208
|
+
constructor(options) {
|
|
10209
|
+
this.namespace = options?.storageNamespace || undefined;
|
|
10210
|
+
}
|
|
10211
|
+
storageKey(scope) {
|
|
10212
|
+
return this.namespace ? `${TOKEN_PREFIX}${this.namespace}:${scope}` : TOKEN_PREFIX + scope;
|
|
10213
|
+
}
|
|
10207
10214
|
setToken(token, scope = "default") {
|
|
10208
10215
|
if (!token) {
|
|
10209
10216
|
this.scopes.delete(scope);
|
|
10210
10217
|
if (hasLocalStorage()) {
|
|
10211
|
-
localStorage.removeItem(
|
|
10218
|
+
localStorage.removeItem(this.storageKey(scope));
|
|
10212
10219
|
notifyTokenChange(scope);
|
|
10213
10220
|
}
|
|
10214
10221
|
return;
|
|
@@ -10218,7 +10225,7 @@ class AuthAdapter {
|
|
|
10218
10225
|
if (parts.length !== 3) {
|
|
10219
10226
|
this.scopes.delete(scope);
|
|
10220
10227
|
if (hasLocalStorage())
|
|
10221
|
-
localStorage.removeItem(
|
|
10228
|
+
localStorage.removeItem(this.storageKey(scope));
|
|
10222
10229
|
return;
|
|
10223
10230
|
}
|
|
10224
10231
|
const payload = JSON.parse(atob(parts[1]));
|
|
@@ -10232,13 +10239,13 @@ class AuthAdapter {
|
|
|
10232
10239
|
}
|
|
10233
10240
|
});
|
|
10234
10241
|
if (hasLocalStorage()) {
|
|
10235
|
-
localStorage.setItem(
|
|
10242
|
+
localStorage.setItem(this.storageKey(scope), token);
|
|
10236
10243
|
notifyTokenChange(scope);
|
|
10237
10244
|
}
|
|
10238
10245
|
} catch {
|
|
10239
10246
|
this.scopes.delete(scope);
|
|
10240
10247
|
if (hasLocalStorage())
|
|
10241
|
-
localStorage.removeItem(
|
|
10248
|
+
localStorage.removeItem(this.storageKey(scope));
|
|
10242
10249
|
}
|
|
10243
10250
|
}
|
|
10244
10251
|
setDecoded(decoded, scope = "default") {
|
|
@@ -10247,10 +10254,13 @@ class AuthAdapter {
|
|
|
10247
10254
|
loadPersisted() {
|
|
10248
10255
|
if (!hasLocalStorage())
|
|
10249
10256
|
return;
|
|
10257
|
+
const prefix = this.namespace ? `${TOKEN_PREFIX}${this.namespace}:` : TOKEN_PREFIX;
|
|
10250
10258
|
for (let i = 0;i < localStorage.length; i++) {
|
|
10251
10259
|
const key = localStorage.key(i);
|
|
10252
|
-
if (key?.startsWith(
|
|
10253
|
-
const scope = key.slice(
|
|
10260
|
+
if (key?.startsWith(prefix)) {
|
|
10261
|
+
const scope = key.slice(prefix.length);
|
|
10262
|
+
if (!this.namespace && scope.includes(":"))
|
|
10263
|
+
continue;
|
|
10254
10264
|
const raw = localStorage.getItem(key);
|
|
10255
10265
|
if (raw) {
|
|
10256
10266
|
try {
|
|
@@ -10304,7 +10314,7 @@ class AuthAdapter {
|
|
|
10304
10314
|
clear() {
|
|
10305
10315
|
if (hasLocalStorage()) {
|
|
10306
10316
|
for (const scope of this.scopes.keys()) {
|
|
10307
|
-
localStorage.removeItem(
|
|
10317
|
+
localStorage.removeItem(this.storageKey(scope));
|
|
10308
10318
|
}
|
|
10309
10319
|
}
|
|
10310
10320
|
this.scopes.clear();
|
|
@@ -11393,6 +11403,8 @@ class ArcFunction {
|
|
|
11393
11403
|
if (!tokenInstance) {
|
|
11394
11404
|
return false;
|
|
11395
11405
|
}
|
|
11406
|
+
if (!protection.check)
|
|
11407
|
+
continue;
|
|
11396
11408
|
const result = await protection.check(tokenInstance);
|
|
11397
11409
|
if (result === false) {
|
|
11398
11410
|
return false;
|
|
@@ -17839,11 +17851,18 @@ function notifyTokenChange2(scope) {
|
|
|
17839
17851
|
|
|
17840
17852
|
class AuthAdapter2 {
|
|
17841
17853
|
scopes = new Map;
|
|
17854
|
+
namespace;
|
|
17855
|
+
constructor(options) {
|
|
17856
|
+
this.namespace = options?.storageNamespace || undefined;
|
|
17857
|
+
}
|
|
17858
|
+
storageKey(scope) {
|
|
17859
|
+
return this.namespace ? `${TOKEN_PREFIX2}${this.namespace}:${scope}` : TOKEN_PREFIX2 + scope;
|
|
17860
|
+
}
|
|
17842
17861
|
setToken(token, scope = "default") {
|
|
17843
17862
|
if (!token) {
|
|
17844
17863
|
this.scopes.delete(scope);
|
|
17845
17864
|
if (hasLocalStorage2()) {
|
|
17846
|
-
localStorage.removeItem(
|
|
17865
|
+
localStorage.removeItem(this.storageKey(scope));
|
|
17847
17866
|
notifyTokenChange2(scope);
|
|
17848
17867
|
}
|
|
17849
17868
|
return;
|
|
@@ -17853,7 +17872,7 @@ class AuthAdapter2 {
|
|
|
17853
17872
|
if (parts.length !== 3) {
|
|
17854
17873
|
this.scopes.delete(scope);
|
|
17855
17874
|
if (hasLocalStorage2())
|
|
17856
|
-
localStorage.removeItem(
|
|
17875
|
+
localStorage.removeItem(this.storageKey(scope));
|
|
17857
17876
|
return;
|
|
17858
17877
|
}
|
|
17859
17878
|
const payload = JSON.parse(atob(parts[1]));
|
|
@@ -17867,13 +17886,13 @@ class AuthAdapter2 {
|
|
|
17867
17886
|
}
|
|
17868
17887
|
});
|
|
17869
17888
|
if (hasLocalStorage2()) {
|
|
17870
|
-
localStorage.setItem(
|
|
17889
|
+
localStorage.setItem(this.storageKey(scope), token);
|
|
17871
17890
|
notifyTokenChange2(scope);
|
|
17872
17891
|
}
|
|
17873
17892
|
} catch {
|
|
17874
17893
|
this.scopes.delete(scope);
|
|
17875
17894
|
if (hasLocalStorage2())
|
|
17876
|
-
localStorage.removeItem(
|
|
17895
|
+
localStorage.removeItem(this.storageKey(scope));
|
|
17877
17896
|
}
|
|
17878
17897
|
}
|
|
17879
17898
|
setDecoded(decoded, scope = "default") {
|
|
@@ -17882,10 +17901,13 @@ class AuthAdapter2 {
|
|
|
17882
17901
|
loadPersisted() {
|
|
17883
17902
|
if (!hasLocalStorage2())
|
|
17884
17903
|
return;
|
|
17904
|
+
const prefix = this.namespace ? `${TOKEN_PREFIX2}${this.namespace}:` : TOKEN_PREFIX2;
|
|
17885
17905
|
for (let i = 0;i < localStorage.length; i++) {
|
|
17886
17906
|
const key = localStorage.key(i);
|
|
17887
|
-
if (key?.startsWith(
|
|
17888
|
-
const scope = key.slice(
|
|
17907
|
+
if (key?.startsWith(prefix)) {
|
|
17908
|
+
const scope = key.slice(prefix.length);
|
|
17909
|
+
if (!this.namespace && scope.includes(":"))
|
|
17910
|
+
continue;
|
|
17889
17911
|
const raw = localStorage.getItem(key);
|
|
17890
17912
|
if (raw) {
|
|
17891
17913
|
try {
|
|
@@ -17939,7 +17961,7 @@ class AuthAdapter2 {
|
|
|
17939
17961
|
clear() {
|
|
17940
17962
|
if (hasLocalStorage2()) {
|
|
17941
17963
|
for (const scope of this.scopes.keys()) {
|
|
17942
|
-
localStorage.removeItem(
|
|
17964
|
+
localStorage.removeItem(this.storageKey(scope));
|
|
17943
17965
|
}
|
|
17944
17966
|
}
|
|
17945
17967
|
this.scopes.clear();
|
|
@@ -19028,6 +19050,8 @@ class ArcFunction2 {
|
|
|
19028
19050
|
if (!tokenInstance) {
|
|
19029
19051
|
return false;
|
|
19030
19052
|
}
|
|
19053
|
+
if (!protection.check)
|
|
19054
|
+
continue;
|
|
19031
19055
|
const result = await protection.check(tokenInstance);
|
|
19032
19056
|
if (result === false) {
|
|
19033
19057
|
return false;
|
|
@@ -36633,6 +36657,7 @@ async function platformDeploy(envArg, options = {}) {
|
|
|
36633
36657
|
ensurePersistedSecret(ws.rootDir, name, "ARC_APP_SECRET", () => randomBytes(32).toString("base64url"));
|
|
36634
36658
|
ensurePersistedSecret(ws.rootDir, name, "ARC_PAIRING_TOKEN", () => randomBytes(16).toString("base64url"));
|
|
36635
36659
|
}
|
|
36660
|
+
cfg = loadDeployConfig(ws.rootDir);
|
|
36636
36661
|
}
|
|
36637
36662
|
if (cfg.observability?.enabled) {
|
|
36638
36663
|
const key = cfg.observability.adminPasswordEnv ?? "ARC_OBSERVABILITY_PASSWORD";
|
|
@@ -38379,7 +38404,6 @@ init_i18n();
|
|
|
38379
38404
|
import { timingSafeEqual } from "crypto";
|
|
38380
38405
|
import { existsSync as existsSync19, mkdirSync as mkdirSync15 } from "fs";
|
|
38381
38406
|
import { join as join22 } from "path";
|
|
38382
|
-
import { MAP_SCHEMA_VERSION } from "@arcote.tech/arc-map/types";
|
|
38383
38407
|
async function resolveDbAdapterFactory(dbPath) {
|
|
38384
38408
|
const databaseUrl = process.env.DATABASE_URL;
|
|
38385
38409
|
if (databaseUrl && databaseUrl.length > 0) {
|
|
@@ -38648,6 +38672,7 @@ function parseCorsOrigins(raw) {
|
|
|
38648
38672
|
const list = raw.split(",").map((s) => s.trim()).filter(Boolean);
|
|
38649
38673
|
return list.length > 0 ? list : undefined;
|
|
38650
38674
|
}
|
|
38675
|
+
var DISCOVERY_SCHEMA_VERSION = 1;
|
|
38651
38676
|
function safeEqual(a2, b4) {
|
|
38652
38677
|
const ab = Buffer.from(a2);
|
|
38653
38678
|
const bb = Buffer.from(b4);
|
|
@@ -38670,7 +38695,7 @@ function handleDiscovery(req, ctx, ws, manifest, federation, mapUrl) {
|
|
|
38670
38695
|
const platformUrl = process.env.ARC_PUBLIC_URL || new URL(req.url).origin;
|
|
38671
38696
|
return Response.json({
|
|
38672
38697
|
meta: {
|
|
38673
|
-
schemaVersion:
|
|
38698
|
+
schemaVersion: DISCOVERY_SCHEMA_VERSION,
|
|
38674
38699
|
name: ws.appName,
|
|
38675
38700
|
version: ws.rootPkg?.version ?? undefined
|
|
38676
38701
|
},
|
|
@@ -39085,11 +39110,11 @@ async function startPlatform(opts) {
|
|
|
39085
39110
|
}
|
|
39086
39111
|
async function startMapTool(ws, port, authToken, platformServer, platform3) {
|
|
39087
39112
|
try {
|
|
39088
|
-
const { startMapServer, MAP_SCHEMA_VERSION
|
|
39113
|
+
const { startMapServer, MAP_SCHEMA_VERSION } = await import("@arcote.tech/arc-map");
|
|
39089
39114
|
const { getContext } = await import("@arcote.tech/platform");
|
|
39090
39115
|
const globs = ws.packages.map((p3) => join23(p3.path, "src", "**", "*.{ts,tsx}"));
|
|
39091
39116
|
const packageOf = (absFile) => ws.packages.find((p3) => absFile.startsWith(join23(p3.path, "src")))?.name;
|
|
39092
|
-
const meta = readAppMeta(ws.rootDir,
|
|
39117
|
+
const meta = readAppMeta(ws.rootDir, MAP_SCHEMA_VERSION);
|
|
39093
39118
|
const map = await startMapServer({
|
|
39094
39119
|
getContext: () => getContext(),
|
|
39095
39120
|
scan: { globs, workspaceRoot: ws.rootDir, packageOf },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcote.tech/arc-cli",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "CLI tool for Arc framework",
|
|
5
5
|
"module": "index.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
"build": "bun build --target=bun ./src/index.ts --outdir=dist --external @arcote.tech/arc --external @arcote.tech/arc-ds --external @arcote.tech/arc-react --external @arcote.tech/platform --external @arcote.tech/arc-map --external '@opentelemetry/*' && chmod +x dist/index.js"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@arcote.tech/arc": "^0.8.
|
|
16
|
-
"@arcote.tech/arc-ds": "^0.8.
|
|
17
|
-
"@arcote.tech/arc-react": "^0.8.
|
|
18
|
-
"@arcote.tech/arc-host": "^0.8.
|
|
19
|
-
"@arcote.tech/arc-adapter-db-sqlite": "^0.8.
|
|
20
|
-
"@arcote.tech/arc-adapter-db-postgres": "^0.8.
|
|
21
|
-
"@arcote.tech/arc-otel": "^0.8.
|
|
15
|
+
"@arcote.tech/arc": "^0.8.1",
|
|
16
|
+
"@arcote.tech/arc-ds": "^0.8.1",
|
|
17
|
+
"@arcote.tech/arc-react": "^0.8.1",
|
|
18
|
+
"@arcote.tech/arc-host": "^0.8.1",
|
|
19
|
+
"@arcote.tech/arc-adapter-db-sqlite": "^0.8.1",
|
|
20
|
+
"@arcote.tech/arc-adapter-db-postgres": "^0.8.1",
|
|
21
|
+
"@arcote.tech/arc-otel": "^0.8.1",
|
|
22
22
|
"@opentelemetry/api": "^1.9.0",
|
|
23
23
|
"@opentelemetry/api-logs": "^0.57.0",
|
|
24
24
|
"@opentelemetry/core": "^1.30.0",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"@opentelemetry/sdk-trace-base": "^1.30.0",
|
|
32
32
|
"@opentelemetry/sdk-trace-node": "^1.30.0",
|
|
33
33
|
"@opentelemetry/semantic-conventions": "^1.27.0",
|
|
34
|
-
"@arcote.tech/platform": "^0.8.
|
|
35
|
-
"@arcote.tech/arc-map": "^0.8.
|
|
34
|
+
"@arcote.tech/platform": "^0.8.1",
|
|
35
|
+
"@arcote.tech/arc-map": "^0.8.1",
|
|
36
36
|
"@clack/prompts": "^0.9.0",
|
|
37
37
|
"commander": "^11.1.0",
|
|
38
38
|
"chokidar": "^3.5.3",
|
|
@@ -119,6 +119,14 @@ export async function platformDeploy(
|
|
|
119
119
|
randomBytes(16).toString("base64url"),
|
|
120
120
|
);
|
|
121
121
|
}
|
|
122
|
+
// Przeładowanie jest KONIECZNE: `loadDeployConfig` wczytał sidecar i scalił
|
|
123
|
+
// go do `cfg.envs[].envVars` ZANIM powyższe dopisało do pliku, a compose
|
|
124
|
+
// renderuje `environment` właśnie z `envVars`. Bez tego kontener startuje
|
|
125
|
+
// bez sekretów i pada na fail-fascie — przy czym DRUGI deploy by przeszedł
|
|
126
|
+
// (sidecar ma już klucze), co daje błąd zależny od historii, najgorszy do
|
|
127
|
+
// zdiagnozowania. Inaczej niż hasło Postgresa, które trafia do compose
|
|
128
|
+
// przez `${ARC_PG_PASSWORD_*}` z `/opt/arc/.env`, nie przez `envVars`.
|
|
129
|
+
cfg = loadDeployConfig(ws.rootDir);
|
|
122
130
|
}
|
|
123
131
|
|
|
124
132
|
// Observability stack — one Grafana password per deployment (stack-wide,
|
package/src/platform/server.ts
CHANGED
|
@@ -10,9 +10,6 @@ import {
|
|
|
10
10
|
import { timingSafeEqual } from "crypto";
|
|
11
11
|
import { existsSync, mkdirSync } from "fs";
|
|
12
12
|
import { join } from "path";
|
|
13
|
-
// Subpath `/types` jest bezzależnościowy — import z korzenia arc-map wciągnąłby
|
|
14
|
-
// ts-morph do każdego startu platformy (startup.ts importuje mapę leniwie).
|
|
15
|
-
import { MAP_SCHEMA_VERSION } from "@arcote.tech/arc-map/types";
|
|
16
13
|
import { readTranslationsConfig } from "../i18n";
|
|
17
14
|
import { err, ok, type BuildManifest, type WorkspaceInfo } from "./shared";
|
|
18
15
|
import type { BuildManifestGroup, ModuleAccess } from "@arcote.tech/platform";
|
|
@@ -532,6 +529,19 @@ function parseCorsOrigins(raw: string | undefined): string[] | undefined {
|
|
|
532
529
|
return list.length > 0 ? list : undefined;
|
|
533
530
|
}
|
|
534
531
|
|
|
532
|
+
/**
|
|
533
|
+
* Wersja kontraktu discovery — MUSI odpowiadać `MAP_SCHEMA_VERSION`
|
|
534
|
+
* z `@arcote.tech/arc-map/src/types.ts`.
|
|
535
|
+
*
|
|
536
|
+
* Świadomie ZDUPLIKOWANA, nie zaimportowana: `arc-map` to narzędzie DEV, którego
|
|
537
|
+
* w obrazie produkcyjnym NIE MA (`bun install --production` pomija devDeps, a
|
|
538
|
+
* CLI trzyma go jako `--external`). Import — nawet z bezzależnościowego subpatha
|
|
539
|
+
* — zostawał w `host.js` i wywalał kontener w pętli restartów:
|
|
540
|
+
* `Cannot find module '@arcote.tech/arc-map/types'`. Bezzależnościowość PLIKU
|
|
541
|
+
* nie pomaga, gdy brakuje całego PAKIETU.
|
|
542
|
+
*/
|
|
543
|
+
const DISCOVERY_SCHEMA_VERSION = 1;
|
|
544
|
+
|
|
535
545
|
/** Porównanie sekretów w czasie stałym (bez wycieku długości prefiksu). */
|
|
536
546
|
function safeEqual(a: string, b: string): boolean {
|
|
537
547
|
const ab = Buffer.from(a);
|
|
@@ -581,7 +591,7 @@ function handleDiscovery(
|
|
|
581
591
|
return Response.json(
|
|
582
592
|
{
|
|
583
593
|
meta: {
|
|
584
|
-
schemaVersion:
|
|
594
|
+
schemaVersion: DISCOVERY_SCHEMA_VERSION,
|
|
585
595
|
name: ws.appName,
|
|
586
596
|
version: (ws.rootPkg?.version as string | undefined) ?? undefined,
|
|
587
597
|
},
|