@tinycloud/cli 1.2.2-beta.2 → 1.2.2-beta.4
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/legacy-entry.js +89 -51
- package/dist/legacy-entry.js.map +1 -1
- package/package.json +1 -1
package/dist/legacy-entry.js
CHANGED
|
@@ -16288,7 +16288,7 @@ function eddsa(Point, cHash, eddsaOpts = {}) {
|
|
|
16288
16288
|
});
|
|
16289
16289
|
const { prehash } = eddsaOpts;
|
|
16290
16290
|
const { BASE, Fp: Fp2, Fn: Fn2 } = Point;
|
|
16291
|
-
const
|
|
16291
|
+
const randomBytes9 = eddsaOpts.randomBytes || randomBytes;
|
|
16292
16292
|
const adjustScalarBytes2 = eddsaOpts.adjustScalarBytes || ((bytes) => bytes);
|
|
16293
16293
|
const domain = eddsaOpts.domain || ((data, ctx, phflag) => {
|
|
16294
16294
|
_abool2(phflag, "phflag");
|
|
@@ -16370,7 +16370,7 @@ function eddsa(Point, cHash, eddsaOpts = {}) {
|
|
|
16370
16370
|
signature: 2 * _size,
|
|
16371
16371
|
seed: _size
|
|
16372
16372
|
};
|
|
16373
|
-
function randomSecretKey(seed =
|
|
16373
|
+
function randomSecretKey(seed = randomBytes9(lengths.seed)) {
|
|
16374
16374
|
return _abytes2(seed, lengths.seed, "seed");
|
|
16375
16375
|
}
|
|
16376
16376
|
function keygen(seed) {
|
|
@@ -20282,6 +20282,7 @@ init_types();
|
|
|
20282
20282
|
init_constants();
|
|
20283
20283
|
init_errors();
|
|
20284
20284
|
import { createServer } from "http";
|
|
20285
|
+
import { randomBytes as randomBytes3 } from "crypto";
|
|
20285
20286
|
import { createInterface } from "readline";
|
|
20286
20287
|
var PRIVATE_JWK_FIELDS = /* @__PURE__ */ new Set([
|
|
20287
20288
|
"d",
|
|
@@ -20293,6 +20294,7 @@ var PRIVATE_JWK_FIELDS = /* @__PURE__ */ new Set([
|
|
|
20293
20294
|
"oth",
|
|
20294
20295
|
"k"
|
|
20295
20296
|
]);
|
|
20297
|
+
var MAX_CALLBACK_BODY_BYTES = 1024 * 1024;
|
|
20296
20298
|
function publicJwkForDelegation(jwk) {
|
|
20297
20299
|
const publicJwk = {};
|
|
20298
20300
|
for (const [key, value] of Object.entries(jwk)) {
|
|
@@ -20443,6 +20445,7 @@ async function callbackFlow(did, options = {}) {
|
|
|
20443
20445
|
settled = true;
|
|
20444
20446
|
clearTimeout(timeout);
|
|
20445
20447
|
server.close();
|
|
20448
|
+
server.closeAllConnections();
|
|
20446
20449
|
if (rl) {
|
|
20447
20450
|
rl.close();
|
|
20448
20451
|
}
|
|
@@ -20452,37 +20455,50 @@ async function callbackFlow(did, options = {}) {
|
|
|
20452
20455
|
reject(result.error);
|
|
20453
20456
|
}
|
|
20454
20457
|
}
|
|
20455
|
-
const
|
|
20456
|
-
|
|
20457
|
-
|
|
20458
|
+
const callbackPath = `/callback/${randomBytes3(16).toString("base64url")}`;
|
|
20459
|
+
const openKeyOrigin = new URL(options.openkeyHost ?? DEFAULT_OPENKEY_HOST).origin;
|
|
20460
|
+
const cors = { "Access-Control-Allow-Origin": openKeyOrigin, "Vary": "Origin" };
|
|
20461
|
+
const server = createServer({ connectionsCheckingInterval: 1e3 }, (req, res) => {
|
|
20462
|
+
if (req.headers.origin !== openKeyOrigin) {
|
|
20463
|
+
res.writeHead(403);
|
|
20464
|
+
res.end();
|
|
20465
|
+
return;
|
|
20466
|
+
}
|
|
20467
|
+
if (req.method === "POST" && req.url === callbackPath) {
|
|
20468
|
+
const chunks = [];
|
|
20469
|
+
let size = 0;
|
|
20458
20470
|
req.on("data", (chunk) => {
|
|
20459
|
-
|
|
20471
|
+
size += chunk.length;
|
|
20472
|
+
if (size > MAX_CALLBACK_BODY_BYTES) {
|
|
20473
|
+
res.writeHead(413, cors);
|
|
20474
|
+
res.end();
|
|
20475
|
+
req.destroy();
|
|
20476
|
+
return;
|
|
20477
|
+
}
|
|
20478
|
+
chunks.push(chunk);
|
|
20460
20479
|
});
|
|
20461
20480
|
req.on("end", () => {
|
|
20481
|
+
let data;
|
|
20462
20482
|
try {
|
|
20463
|
-
|
|
20464
|
-
|
|
20465
|
-
|
|
20466
|
-
res.writeHead(400, { "Content-Type": "application/json" });
|
|
20467
|
-
res.end(JSON.stringify({ error: invalid2 }));
|
|
20468
|
-
settle({ error: new Error(`Invalid delegation payload: ${invalid2}`) });
|
|
20469
|
-
return;
|
|
20470
|
-
}
|
|
20471
|
-
res.writeHead(200, {
|
|
20472
|
-
"Content-Type": "application/json",
|
|
20473
|
-
"Access-Control-Allow-Origin": "*"
|
|
20474
|
-
});
|
|
20475
|
-
res.end(JSON.stringify({ success: true }));
|
|
20476
|
-
settle({ data });
|
|
20477
|
-
} catch (err2) {
|
|
20478
|
-
res.writeHead(400, { "Content-Type": "application/json" });
|
|
20483
|
+
data = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
20484
|
+
} catch {
|
|
20485
|
+
res.writeHead(400, { ...cors, "Content-Type": "application/json" });
|
|
20479
20486
|
res.end(JSON.stringify({ error: "Invalid JSON" }));
|
|
20480
|
-
|
|
20487
|
+
return;
|
|
20488
|
+
}
|
|
20489
|
+
const invalid2 = validateDelegationCallbackPayload(data);
|
|
20490
|
+
if (invalid2) {
|
|
20491
|
+
res.writeHead(400, { ...cors, "Content-Type": "application/json" });
|
|
20492
|
+
res.end(JSON.stringify({ error: invalid2 }));
|
|
20493
|
+
return;
|
|
20481
20494
|
}
|
|
20495
|
+
res.writeHead(200, { ...cors, "Content-Type": "application/json" });
|
|
20496
|
+
res.end(JSON.stringify({ success: true }));
|
|
20497
|
+
settle({ data });
|
|
20482
20498
|
});
|
|
20483
|
-
} else if (req.method === "OPTIONS") {
|
|
20499
|
+
} else if (req.method === "OPTIONS" && req.url === callbackPath) {
|
|
20484
20500
|
res.writeHead(204, {
|
|
20485
|
-
|
|
20501
|
+
...cors,
|
|
20486
20502
|
"Access-Control-Allow-Methods": "POST, OPTIONS",
|
|
20487
20503
|
"Access-Control-Allow-Headers": "Content-Type"
|
|
20488
20504
|
});
|
|
@@ -20492,6 +20508,8 @@ async function callbackFlow(did, options = {}) {
|
|
|
20492
20508
|
res.end();
|
|
20493
20509
|
}
|
|
20494
20510
|
});
|
|
20511
|
+
server.headersTimeout = 1e4;
|
|
20512
|
+
server.requestTimeout = 1e4;
|
|
20495
20513
|
server.listen(0, "127.0.0.1", async () => {
|
|
20496
20514
|
const addr = server.address();
|
|
20497
20515
|
if (!addr || typeof addr === "string") {
|
|
@@ -20499,7 +20517,7 @@ async function callbackFlow(did, options = {}) {
|
|
|
20499
20517
|
return;
|
|
20500
20518
|
}
|
|
20501
20519
|
const port = addr.port;
|
|
20502
|
-
const callbackUrl = `http://127.0.0.1:${port}
|
|
20520
|
+
const callbackUrl = `http://127.0.0.1:${port}${callbackPath}`;
|
|
20503
20521
|
const authUrl = buildAuthUrl(did, { ...options, callback: callbackUrl });
|
|
20504
20522
|
const openBrowser = shouldOpenBrowser(options);
|
|
20505
20523
|
const hasTerminal = Boolean(process.stdin.isTTY || process.stderr.isTTY);
|
|
@@ -20589,14 +20607,14 @@ import {
|
|
|
20589
20607
|
createECDH,
|
|
20590
20608
|
createHash,
|
|
20591
20609
|
createHmac,
|
|
20592
|
-
randomBytes as
|
|
20610
|
+
randomBytes as randomBytes5
|
|
20593
20611
|
} from "crypto";
|
|
20594
20612
|
|
|
20595
20613
|
// src/auth/local-key.ts
|
|
20596
20614
|
init_replication_config();
|
|
20597
20615
|
import { TCWSessionManager, importKey, initPanicHook } from "@tinycloud/node-sdk-wasm";
|
|
20598
20616
|
import { PrivateKeySigner } from "@tinycloud/node-sdk";
|
|
20599
|
-
import { randomBytes as
|
|
20617
|
+
import { randomBytes as randomBytes4 } from "crypto";
|
|
20600
20618
|
var wasmInitialized = false;
|
|
20601
20619
|
function ensureWasm() {
|
|
20602
20620
|
if (!wasmInitialized) {
|
|
@@ -20621,7 +20639,7 @@ function keyToDID(jwk) {
|
|
|
20621
20639
|
return mgr.getDID(keyId);
|
|
20622
20640
|
}
|
|
20623
20641
|
function generateEthereumPrivateKey() {
|
|
20624
|
-
const keyBytes =
|
|
20642
|
+
const keyBytes = randomBytes4(32);
|
|
20625
20643
|
return "0x" + keyBytes.toString("hex");
|
|
20626
20644
|
}
|
|
20627
20645
|
async function deriveAddress(privateKey) {
|
|
@@ -21005,7 +21023,7 @@ init_constants();
|
|
|
21005
21023
|
init_profiles();
|
|
21006
21024
|
init_errors();
|
|
21007
21025
|
init_space();
|
|
21008
|
-
import { isLocalOwnerProfile as isLocalOwnerProfile3 } from "@tinycloud/operations/profile";
|
|
21026
|
+
import { isLocalOwnerProfile as isLocalOwnerProfile3, ownerSessionLacksProof as ownerSessionLacksProof3 } from "@tinycloud/operations/profile";
|
|
21009
21027
|
import { ProfileLockTimeoutError as ProfileLockTimeoutError2 } from "@tinycloud/operations/state";
|
|
21010
21028
|
function assertNotLocalOwner(profileName2, profile, flow) {
|
|
21011
21029
|
if (profile === null || !isLocalOwnerProfile3(profile)) return;
|
|
@@ -21052,6 +21070,7 @@ function assertSessionReplaceable(profileName2, snapshot, ownerDid, scope, newEx
|
|
|
21052
21070
|
}
|
|
21053
21071
|
const { session } = snapshot;
|
|
21054
21072
|
if (session === null) return;
|
|
21073
|
+
if (ownerSessionLacksProof3(session, snapshot.profile)) return;
|
|
21055
21074
|
const expiresAt = sessionExpiresAt(session);
|
|
21056
21075
|
if (expiresAt !== null && Date.parse(expiresAt) <= Date.now()) return;
|
|
21057
21076
|
const held = Array.isArray(session.permissions) ? session.permissions.filter((permission) => ownerDid === void 0 || typeof session.spaceId !== "string" || !isLegacyNestedDecrypt(permission, scope, ownerDid, session.spaceId)) : void 0;
|
|
@@ -21140,6 +21159,11 @@ function warnIfNotPrimaryKey(ownerDid, primary) {
|
|
|
21140
21159
|
if (primary !== false || ownerDid === void 0) return;
|
|
21141
21160
|
process.stderr.write(nonPrimaryKeyWarning(ownerDid));
|
|
21142
21161
|
}
|
|
21162
|
+
function announceFirstOwner(profileName2, expectedOwner, ownerDid) {
|
|
21163
|
+
if (expectedOwner !== void 0 || ownerDid === void 0) return;
|
|
21164
|
+
process.stderr.write(`Profile "${profileName2}" now belongs to ${ownerDid}. If that isn't your OpenKey account, stop using this profile and create a new one with tc init.
|
|
21165
|
+
`);
|
|
21166
|
+
}
|
|
21143
21167
|
function ownerLoginPermissions(owner) {
|
|
21144
21168
|
const space = ownerSpaceId("default", owner);
|
|
21145
21169
|
return [
|
|
@@ -21385,8 +21409,8 @@ async function acquireDeviceDelegation(input) {
|
|
|
21385
21409
|
const nodeOrigin = canonicalOrigin(input.nodeOrigin, "TinyCloud node origin");
|
|
21386
21410
|
const shareOrigin = canonicalOrigin(input.shareOrigin, "Share origin");
|
|
21387
21411
|
const fetchFn = input.fetchFn ?? globalThis.fetch;
|
|
21388
|
-
const deviceSecret =
|
|
21389
|
-
const codeVerifier =
|
|
21412
|
+
const deviceSecret = randomBytes5(32).toString("base64url");
|
|
21413
|
+
const codeVerifier = randomBytes5(32).toString("base64url");
|
|
21390
21414
|
const relayKey = createECDH("prime256v1");
|
|
21391
21415
|
relayKey.generateKeys();
|
|
21392
21416
|
const relayPublicJwk = relayPublicJwkOf(relayKey);
|
|
@@ -21545,6 +21569,7 @@ async function loginWithDeviceAuthorization(input) {
|
|
|
21545
21569
|
approved: { scope: result.session.permissions, ownerDid: result.ownerDid, replaceSession: input.replaceSession === true }
|
|
21546
21570
|
});
|
|
21547
21571
|
warnIfNotPrimaryKey(result.ownerDid, result.primary);
|
|
21572
|
+
announceFirstOwner(input.profileName, expectedOwner, result.ownerDid);
|
|
21548
21573
|
return { profile, result };
|
|
21549
21574
|
}
|
|
21550
21575
|
|
|
@@ -23436,10 +23461,10 @@ async function handleOpenKeyAuth(profileName2, host, options = {}) {
|
|
|
23436
23461
|
profile: profileName2,
|
|
23437
23462
|
did: profile.did,
|
|
23438
23463
|
spaceId: delegationData.spaceId,
|
|
23464
|
+
ownerDid: profile.ownerDid ?? null,
|
|
23439
23465
|
authMethod: "openkey",
|
|
23440
23466
|
...options.permissions ? {
|
|
23441
23467
|
scoped: true,
|
|
23442
|
-
ownerDid: profile.ownerDid,
|
|
23443
23468
|
host,
|
|
23444
23469
|
permissions: delegationData.permissions,
|
|
23445
23470
|
declined,
|
|
@@ -23559,6 +23584,7 @@ async function refreshOpenKeySession(profileName2, host, options = {}) {
|
|
|
23559
23584
|
...permissions && verifiedOwner ? { approved: { scope: sanitizedSession.permissions, ownerDid: verifiedOwner, replaceSession: options.replaceSession === true } } : {}
|
|
23560
23585
|
});
|
|
23561
23586
|
warnIfNotPrimaryKey(verifiedOwner, ownerKeyPrimary);
|
|
23587
|
+
announceFirstOwner(profileName2, expectedOwner, verifiedOwner);
|
|
23562
23588
|
return { profile: updatedProfile, delegationData: sanitizedSession, declined, legacyNested };
|
|
23563
23589
|
}
|
|
23564
23590
|
|
|
@@ -23858,6 +23884,8 @@ init_constants();
|
|
|
23858
23884
|
init_formatter();
|
|
23859
23885
|
init_theme();
|
|
23860
23886
|
init_errors();
|
|
23887
|
+
init_session_expired();
|
|
23888
|
+
init_types();
|
|
23861
23889
|
function registerDoctorCommand(program) {
|
|
23862
23890
|
program.command("doctor").description("Run diagnostic checks").action(async (_options, cmd) => {
|
|
23863
23891
|
try {
|
|
@@ -23903,8 +23931,14 @@ function registerDoctorCommand(program) {
|
|
|
23903
23931
|
if (profileOk && profileName2) {
|
|
23904
23932
|
try {
|
|
23905
23933
|
const session = await ProfileManager.getSession(profileName2);
|
|
23906
|
-
|
|
23907
|
-
|
|
23934
|
+
const { state: state2, expiresAt } = storedSessionState(session);
|
|
23935
|
+
sessionOk = sessionStateIsUsable(state2);
|
|
23936
|
+
if (state2 === "expired") {
|
|
23937
|
+
const posture = resolveProfilePosture(await ProfileManager.getProfile(profileName2));
|
|
23938
|
+
sessionDetail = `expired ${expiresAt} \u2014 ${signInAgainHint(profileName2, posture)}`;
|
|
23939
|
+
} else {
|
|
23940
|
+
sessionDetail = sessionOk ? "active" : "no session \u2014 run tc auth login";
|
|
23941
|
+
}
|
|
23908
23942
|
} catch {
|
|
23909
23943
|
sessionDetail = "error reading session";
|
|
23910
23944
|
}
|
|
@@ -23917,7 +23951,7 @@ function registerDoctorCommand(program) {
|
|
|
23917
23951
|
try {
|
|
23918
23952
|
const host = profileOk && profileName2 ? (await ProfileManager.getProfile(profileName2)).host : globalOpts.host || DEFAULT_HOST;
|
|
23919
23953
|
const start = Date.now();
|
|
23920
|
-
const response = await fetch(`${host}/
|
|
23954
|
+
const response = await fetch(`${host}/healthz`);
|
|
23921
23955
|
const latency = Date.now() - start;
|
|
23922
23956
|
nodeReachable = response.ok;
|
|
23923
23957
|
nodeDetail = nodeReachable ? `${host} (${latency}ms)` : `${host} returned ${response.status}`;
|
|
@@ -23936,7 +23970,7 @@ function registerDoctorCommand(program) {
|
|
|
23936
23970
|
spaceDetail = "error checking space";
|
|
23937
23971
|
}
|
|
23938
23972
|
} else {
|
|
23939
|
-
spaceDetail = "skipped (no session)";
|
|
23973
|
+
spaceDetail = "skipped (no active session)";
|
|
23940
23974
|
}
|
|
23941
23975
|
checks.push({ name: "Space", ok: spaceOk, detail: spaceDetail });
|
|
23942
23976
|
const result = {
|
|
@@ -24922,7 +24956,7 @@ function parseOperatorType(raw) {
|
|
|
24922
24956
|
// src/commands/replica.ts
|
|
24923
24957
|
init_sdk();
|
|
24924
24958
|
init_replication_registry();
|
|
24925
|
-
import { randomBytes as
|
|
24959
|
+
import { randomBytes as randomBytes6 } from "crypto";
|
|
24926
24960
|
import { constants as fsConstants2 } from "fs";
|
|
24927
24961
|
import { open as open4, readdir as readdir5, rename as rename3, stat as stat3, unlink as unlink2, readFile as readFile9, lstat as lstat4 } from "fs/promises";
|
|
24928
24962
|
import { basename as basename3, dirname as dirname5, join as join10, resolve as resolve2 } from "path";
|
|
@@ -25021,6 +25055,7 @@ import {
|
|
|
25021
25055
|
readSession as readSession2,
|
|
25022
25056
|
withProfileLock as withProfileLock5
|
|
25023
25057
|
} from "@tinycloud/operations/state";
|
|
25058
|
+
import { ownerSessionLacksProof as ownerSessionLacksProof4 } from "@tinycloud/operations/profile";
|
|
25024
25059
|
init_profiles();
|
|
25025
25060
|
init_constants();
|
|
25026
25061
|
init_errors();
|
|
@@ -25145,7 +25180,10 @@ async function createReplica(profile, config) {
|
|
|
25145
25180
|
async function storedGrants(profile) {
|
|
25146
25181
|
const authorizations = [];
|
|
25147
25182
|
const session = await readSession2(profile).catch(() => null);
|
|
25148
|
-
|
|
25183
|
+
const config = await ProfileManager.getProfile(profile).catch(() => null);
|
|
25184
|
+
if (typeof session?.delegationHeader?.Authorization === "string" && !ownerSessionLacksProof4(session, config)) {
|
|
25185
|
+
authorizations.push(session.delegationHeader.Authorization);
|
|
25186
|
+
}
|
|
25149
25187
|
const records = await readAdditionalDelegations2(profile).catch(
|
|
25150
25188
|
() => []
|
|
25151
25189
|
);
|
|
@@ -25269,7 +25307,7 @@ function describeStatus(status) {
|
|
|
25269
25307
|
}
|
|
25270
25308
|
async function writeFileAtomic(path, bytes) {
|
|
25271
25309
|
const target = resolve2(path);
|
|
25272
|
-
const temp = join10(dirname5(target), `.${basename3(target)}.${
|
|
25310
|
+
const temp = join10(dirname5(target), `.${basename3(target)}.${randomBytes6(6).toString("hex")}.tmp`);
|
|
25273
25311
|
const handle = await open4(temp, fsConstants2.O_CREAT | fsConstants2.O_EXCL | fsConstants2.O_WRONLY, 384);
|
|
25274
25312
|
try {
|
|
25275
25313
|
await handle.writeFile(bytes);
|
|
@@ -25456,7 +25494,7 @@ or coverage incomplete; 5 grant expired, revoked or not yet valid; 6 network;
|
|
|
25456
25494
|
chooseGrant(grants, deviceDid, space, prefix);
|
|
25457
25495
|
store = await createReplica(profile, {
|
|
25458
25496
|
name,
|
|
25459
|
-
replicaId:
|
|
25497
|
+
replicaId: randomBytes6(16).toString("hex"),
|
|
25460
25498
|
host,
|
|
25461
25499
|
space,
|
|
25462
25500
|
prefix,
|
|
@@ -25619,7 +25657,7 @@ import { join as join11 } from "path";
|
|
|
25619
25657
|
import { homedir, hostname, userInfo } from "os";
|
|
25620
25658
|
import { appSecretScope } from "@tinycloud/sdk-core";
|
|
25621
25659
|
import { invokeOperation as invokeOperation2 } from "@tinycloud/operations";
|
|
25622
|
-
import { isLocalOwnerProfile as isLocalOwnerProfile4 } from "@tinycloud/operations/profile";
|
|
25660
|
+
import { isLocalOwnerProfile as isLocalOwnerProfile4, ownerSessionLacksProof as ownerSessionLacksProof5 } from "@tinycloud/operations/profile";
|
|
25623
25661
|
import {
|
|
25624
25662
|
buildSecretManagerUrl,
|
|
25625
25663
|
buildSecretRequestUrl as buildSecretRequestUrl2,
|
|
@@ -26154,11 +26192,11 @@ async function ensureSecretsNode(ctx, options, openKeyAcquisition, selectedProfi
|
|
|
26154
26192
|
const profile = selectedProfile ?? await ProfileManager.getProfile(ctx.profile).catch(() => null);
|
|
26155
26193
|
if (profile?.authMethod === "openkey" && canRequestOwnerPermissions(profile)) {
|
|
26156
26194
|
const session = await ProfileManager.getSession(ctx.profile);
|
|
26157
|
-
if (!session || isStoredSessionExpired(session)) {
|
|
26195
|
+
if (!session || isStoredSessionExpired(session) || ownerSessionLacksProof5(session, profile)) {
|
|
26158
26196
|
if (!process.stdin.isTTY && !process.stderr.isTTY) {
|
|
26159
26197
|
throw new CLIError(
|
|
26160
26198
|
"AUTH_REQUIRED",
|
|
26161
|
-
`Profile "${ctx.profile}" has ${session ? "an expired" : "no"} OpenKey session; headless secret access cannot open a browser login.`,
|
|
26199
|
+
`Profile "${ctx.profile}" has ${session ? "an expired or unverified" : "no"} OpenKey session; headless secret access cannot open a browser login.`,
|
|
26162
26200
|
ExitCode.AUTH_REQUIRED,
|
|
26163
26201
|
{ hint: scopedSecretLoginHint(ctx.profile) }
|
|
26164
26202
|
);
|
|
@@ -26266,7 +26304,7 @@ async function canonicalSecretGet(params, collect) {
|
|
|
26266
26304
|
throw sessionExpiredError(params.ctx.profile, posture);
|
|
26267
26305
|
}
|
|
26268
26306
|
if (profile2.authMethod === "openkey" && canRequestOwnerPermissions(profile2)) {
|
|
26269
|
-
if (!session || isStoredSessionExpired(session)) {
|
|
26307
|
+
if (!session || isStoredSessionExpired(session) || ownerSessionLacksProof5(session, profile2)) {
|
|
26270
26308
|
ownerNode = await ensureSecretsNode(params.ctx, params.options, params.openKeyAcquisition, profile2);
|
|
26271
26309
|
}
|
|
26272
26310
|
}
|
|
@@ -35546,7 +35584,7 @@ function receiveJson(result, path) {
|
|
|
35546
35584
|
// src/share/io.ts
|
|
35547
35585
|
import { constants } from "fs";
|
|
35548
35586
|
import { lstat as lstat5, mkdir as mkdir4, mkdtemp, open as open7, readFile as readFile11, realpath as realpath2, stat as stat4, link as link2, rename as rename4, rm as rm6, unlink as unlink3 } from "fs/promises";
|
|
35549
|
-
import { randomBytes as
|
|
35587
|
+
import { randomBytes as randomBytes7 } from "crypto";
|
|
35550
35588
|
import { basename as basename4, join as join12, resolve as resolve3, sep as sep2 } from "path";
|
|
35551
35589
|
init_errors();
|
|
35552
35590
|
var MAX_SHARE_STDIN_BYTES = 100 * 1024 * 1024;
|
|
@@ -35633,7 +35671,7 @@ async function writeShareOutput(directory, filename, bytes, force) {
|
|
|
35633
35671
|
const stagingDirectory = await mkdtemp(join12(stableDirectory, ".tinycloud-share-stage-"));
|
|
35634
35672
|
const stagingInfo = await lstat5(stagingDirectory);
|
|
35635
35673
|
if (!stagingInfo.isDirectory() || (stagingInfo.mode & 511) !== 448) throw new Error("OUTPUT_EXISTS");
|
|
35636
|
-
const stagingPath = join12(stagingDirectory, `.tinycloud-share-${
|
|
35674
|
+
const stagingPath = join12(stagingDirectory, `.tinycloud-share-${randomBytes7(16).toString("hex")}.tmp`);
|
|
35637
35675
|
let temporaryPath;
|
|
35638
35676
|
let handle;
|
|
35639
35677
|
try {
|
|
@@ -36091,7 +36129,7 @@ init_constants();
|
|
|
36091
36129
|
init_sdk();
|
|
36092
36130
|
init_host();
|
|
36093
36131
|
init_theme();
|
|
36094
|
-
import { randomBytes as
|
|
36132
|
+
import { randomBytes as randomBytes8 } from "crypto";
|
|
36095
36133
|
import { mkdir as mkdir5, writeFile as writeFile4 } from "fs/promises";
|
|
36096
36134
|
import { dirname as dirname6 } from "path";
|
|
36097
36135
|
function didWithoutFragment2(did) {
|
|
@@ -36172,7 +36210,7 @@ it directly with \`tc space host <name>\` (no request needed).
|
|
|
36172
36210
|
const artifact = {
|
|
36173
36211
|
kind: "tinycloud.host.request",
|
|
36174
36212
|
version: 1,
|
|
36175
|
-
requestId: `hostreq_${Date.now().toString(36)}_${
|
|
36213
|
+
requestId: `hostreq_${Date.now().toString(36)}_${randomBytes8(4).toString("hex")}`,
|
|
36176
36214
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
36177
36215
|
spaceName,
|
|
36178
36216
|
spaceId,
|
|
@@ -36514,7 +36552,7 @@ init_permissions();
|
|
|
36514
36552
|
import {
|
|
36515
36553
|
NodeWasmBindings as NodeWasmBindings2
|
|
36516
36554
|
} from "@tinycloud/node-sdk";
|
|
36517
|
-
import { ownerSessionLacksProof as
|
|
36555
|
+
import { ownerSessionLacksProof as ownerSessionLacksProof6 } from "@tinycloud/operations/profile";
|
|
36518
36556
|
var wasmBindings = null;
|
|
36519
36557
|
function registerStatusCommand(program) {
|
|
36520
36558
|
program.command("status").description("Show local TinyCloud profile, session, delegation, and permission state").action(async (_options, cmd) => {
|
|
@@ -36581,7 +36619,7 @@ async function inspectProfile(params) {
|
|
|
36581
36619
|
]);
|
|
36582
36620
|
const hasPrivateKey = typeof profile?.privateKey === "string" && profile.privateKey.length > 0;
|
|
36583
36621
|
const localKeyAuthenticated = profile?.authMethod === "local" && hasPrivateKey;
|
|
36584
|
-
const sessionAuthenticated = session !== null && sessionExpired !== true && !
|
|
36622
|
+
const sessionAuthenticated = session !== null && sessionExpired !== true && !ownerSessionLacksProof6(session, profile);
|
|
36585
36623
|
const authenticated = localKeyAuthenticated || sessionAuthenticated;
|
|
36586
36624
|
const status = resolveStatus({
|
|
36587
36625
|
exists: profile !== null,
|