@tinycloud/cli 0.7.7-beta.0 → 0.7.7-beta.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 +28 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31642,8 +31642,19 @@ var CLIError = class extends Error {
|
|
|
31642
31642
|
}
|
|
31643
31643
|
};
|
|
31644
31644
|
function wrapError(error) {
|
|
31645
|
-
if (error instanceof CLIError) return error;
|
|
31646
31645
|
const message = error instanceof Error ? error.message : String(error);
|
|
31646
|
+
if (message.includes("Missing private key parameter in JWK")) {
|
|
31647
|
+
const profileName = activeProfileName ?? process.env.TC_PROFILE ?? DEFAULT_PROFILE;
|
|
31648
|
+
return new CLIError(
|
|
31649
|
+
"AUTH_REQUIRED",
|
|
31650
|
+
`Profile "${profileName}" cannot restore its session because its private key material is missing.`,
|
|
31651
|
+
ExitCode.AUTH_REQUIRED,
|
|
31652
|
+
{
|
|
31653
|
+
hint: `Sign in again with: tc --profile ${profileName} auth login --method openkey`
|
|
31654
|
+
}
|
|
31655
|
+
);
|
|
31656
|
+
}
|
|
31657
|
+
if (error instanceof CLIError) return error;
|
|
31647
31658
|
if (message.includes("Not signed in") || message.includes("AUTH_EXPIRED") || message.includes("Session expired")) {
|
|
31648
31659
|
return new CLIError("AUTH_REQUIRED", message, ExitCode.AUTH_REQUIRED);
|
|
31649
31660
|
}
|
|
@@ -43364,6 +43375,20 @@ function selectSignerJwk(sessionJwk, key2) {
|
|
|
43364
43375
|
}
|
|
43365
43376
|
return key2 ?? void 0;
|
|
43366
43377
|
}
|
|
43378
|
+
function signerJwkForProfile(profileName, sessionJwk, key2) {
|
|
43379
|
+
const jwk = selectSignerJwk(sessionJwk, key2);
|
|
43380
|
+
if (jwkHasPrivateParameter(jwk)) {
|
|
43381
|
+
return jwk;
|
|
43382
|
+
}
|
|
43383
|
+
throw new CLIError(
|
|
43384
|
+
"AUTH_REQUIRED",
|
|
43385
|
+
`Profile "${profileName}" cannot restore its session because its private key material is missing.`,
|
|
43386
|
+
ExitCode.AUTH_REQUIRED,
|
|
43387
|
+
{
|
|
43388
|
+
hint: `Sign in again with: tc --profile ${profileName} auth login --method openkey`
|
|
43389
|
+
}
|
|
43390
|
+
);
|
|
43391
|
+
}
|
|
43367
43392
|
async function createSDKInstance(ctx, options) {
|
|
43368
43393
|
const profile = options?.privateKey ? await ProfileManager.getProfile(ctx.profile).catch(() => null) : await ProfileManager.getProfile(ctx.profile);
|
|
43369
43394
|
const session = await ProfileManager.getSession(ctx.profile);
|
|
@@ -43386,7 +43411,7 @@ async function createSDKInstance(ctx, options) {
|
|
|
43386
43411
|
delegationHeader: session.delegationHeader,
|
|
43387
43412
|
delegationCid: session.delegationCid,
|
|
43388
43413
|
spaceId: session.spaceId,
|
|
43389
|
-
jwk:
|
|
43414
|
+
jwk: signerJwkForProfile(ctx.profile, session.jwk, key2),
|
|
43390
43415
|
verificationMethod: session.verificationMethod ?? profile?.sessionDid ?? profile?.did,
|
|
43391
43416
|
address: session.address,
|
|
43392
43417
|
chainId: session.chainId,
|
|
@@ -43410,7 +43435,7 @@ async function createSDKInstance(ctx, options) {
|
|
|
43410
43435
|
delegationHeader: session.delegationHeader,
|
|
43411
43436
|
delegationCid: session.delegationCid,
|
|
43412
43437
|
spaceId: session.spaceId,
|
|
43413
|
-
jwk:
|
|
43438
|
+
jwk: signerJwkForProfile(ctx.profile, session.jwk, key2),
|
|
43414
43439
|
verificationMethod: session.verificationMethod ?? profile?.did,
|
|
43415
43440
|
address: session.address,
|
|
43416
43441
|
chainId: session.chainId,
|