@tinycloud/cli 0.7.0-beta.20 → 0.7.0-beta.21
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 +8 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -42730,10 +42730,10 @@ function serviceFromActions(actions) {
|
|
|
42730
42730
|
|
|
42731
42731
|
// src/lib/sdk.ts
|
|
42732
42732
|
async function createSDKInstance(ctx, options) {
|
|
42733
|
-
const profile = await ProfileManager.getProfile(ctx.profile);
|
|
42733
|
+
const profile = options?.privateKey ? await ProfileManager.getProfile(ctx.profile).catch(() => null) : await ProfileManager.getProfile(ctx.profile);
|
|
42734
42734
|
const session = await ProfileManager.getSession(ctx.profile);
|
|
42735
42735
|
const key2 = await ProfileManager.getKey(ctx.profile);
|
|
42736
|
-
const effectivePrivateKey = options?.privateKey ?? profile
|
|
42736
|
+
const effectivePrivateKey = options?.privateKey ?? profile?.privateKey;
|
|
42737
42737
|
if (!key2 && !effectivePrivateKey) {
|
|
42738
42738
|
throw new CLIError(
|
|
42739
42739
|
"AUTH_REQUIRED",
|
|
@@ -42741,7 +42741,7 @@ async function createSDKInstance(ctx, options) {
|
|
|
42741
42741
|
ExitCode.AUTH_REQUIRED
|
|
42742
42742
|
);
|
|
42743
42743
|
}
|
|
42744
|
-
if (profile
|
|
42744
|
+
if (profile?.authMethod === "local" && effectivePrivateKey) {
|
|
42745
42745
|
const node2 = new TinyCloudNode({
|
|
42746
42746
|
host: ctx.host,
|
|
42747
42747
|
privateKey: effectivePrivateKey
|
|
@@ -42752,7 +42752,7 @@ async function createSDKInstance(ctx, options) {
|
|
|
42752
42752
|
delegationCid: session.delegationCid,
|
|
42753
42753
|
spaceId: session.spaceId,
|
|
42754
42754
|
jwk: session.jwk ?? key2,
|
|
42755
|
-
verificationMethod: session.verificationMethod ?? profile
|
|
42755
|
+
verificationMethod: session.verificationMethod ?? profile?.sessionDid ?? profile?.did,
|
|
42756
42756
|
address: session.address,
|
|
42757
42757
|
chainId: session.chainId,
|
|
42758
42758
|
siwe: session.siwe,
|
|
@@ -42776,7 +42776,7 @@ async function createSDKInstance(ctx, options) {
|
|
|
42776
42776
|
delegationCid: session.delegationCid,
|
|
42777
42777
|
spaceId: session.spaceId,
|
|
42778
42778
|
jwk: session.jwk ?? key2,
|
|
42779
|
-
verificationMethod: session.verificationMethod ?? profile
|
|
42779
|
+
verificationMethod: session.verificationMethod ?? profile?.did,
|
|
42780
42780
|
address: session.address,
|
|
42781
42781
|
chainId: session.chainId,
|
|
42782
42782
|
siwe: session.siwe,
|
|
@@ -42787,6 +42787,9 @@ async function createSDKInstance(ctx, options) {
|
|
|
42787
42787
|
return node;
|
|
42788
42788
|
}
|
|
42789
42789
|
async function ensureAuthenticated(ctx, options) {
|
|
42790
|
+
if (options?.privateKey) {
|
|
42791
|
+
return createSDKInstance(ctx, options);
|
|
42792
|
+
}
|
|
42790
42793
|
const profile = await ProfileManager.getProfile(ctx.profile).catch(() => null);
|
|
42791
42794
|
if (profile?.authMethod === "local" && profile.privateKey) {
|
|
42792
42795
|
return createSDKInstance(ctx, { privateKey: profile.privateKey });
|