@dxos/plugin-client 0.9.0 → 0.9.1-staging.ee54ba693a
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/lib/neutral/{AccountContainer-FZ3IC6H4.mjs → AccountContainer-7SF53UON.mjs} +17 -13
- package/dist/lib/neutral/AccountContainer-7SF53UON.mjs.map +7 -0
- package/dist/lib/neutral/ClientPlugin.node.mjs +477 -370
- package/dist/lib/neutral/ClientPlugin.node.mjs.map +4 -4
- package/dist/lib/neutral/{DevicesContainer-6MWNUC3I.mjs → DevicesContainer-PRWIN36N.mjs} +36 -27
- package/dist/lib/neutral/DevicesContainer-PRWIN36N.mjs.map +7 -0
- package/dist/lib/neutral/{InvitationsContainer-ME722VKS.mjs → InvitationsContainer-BI5RAWET.mjs} +43 -32
- package/dist/lib/neutral/InvitationsContainer-BI5RAWET.mjs.map +7 -0
- package/dist/lib/neutral/{JoinDialog-2NXAKPLP.mjs → JoinDialog-4BWV4CYB.mjs} +2 -2
- package/dist/lib/neutral/JoinDialog-4BWV4CYB.mjs.map +7 -0
- package/dist/lib/neutral/{ProfileContainer-VPX3FPWG.mjs → ProfileContainer-YEAYOTX5.mjs} +22 -21
- package/dist/lib/neutral/ProfileContainer-YEAYOTX5.mjs.map +7 -0
- package/dist/lib/neutral/{RecoveryCodeDialog-EWHB6U5T.mjs → RecoveryCodeDialog-7EPNKCLB.mjs} +2 -2
- package/dist/lib/neutral/RecoveryCodeDialog-7EPNKCLB.mjs.map +7 -0
- package/dist/lib/neutral/{RecoveryCredentialsContainer-IPBGDMIA.mjs → RecoveryCredentialsContainer-6BZ2IWX7.mjs} +24 -15
- package/dist/lib/neutral/RecoveryCredentialsContainer-6BZ2IWX7.mjs.map +7 -0
- package/dist/lib/neutral/UsageContainer-2DWCVVE4.mjs +241 -0
- package/dist/lib/neutral/UsageContainer-2DWCVVE4.mjs.map +7 -0
- package/dist/lib/neutral/account-cache-YVQKLNV2.mjs +16 -0
- package/dist/lib/neutral/account-cache-YVQKLNV2.mjs.map +7 -0
- package/dist/lib/neutral/{app-graph-builder-A74W7C36.mjs → app-graph-builder-RVXTD6OE.mjs} +30 -16
- package/dist/lib/neutral/app-graph-builder-RVXTD6OE.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +6 -6
- package/dist/lib/neutral/capabilities/node.mjs +3 -3
- package/dist/lib/neutral/chunk-6G4KZLBG.mjs +28 -0
- package/dist/lib/neutral/chunk-6G4KZLBG.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-D6HPCLTS.mjs → chunk-7DEIKHB7.mjs} +16 -2
- package/dist/lib/neutral/chunk-7DEIKHB7.mjs.map +7 -0
- package/dist/lib/neutral/chunk-A7WDDIWY.mjs +162 -0
- package/dist/lib/neutral/chunk-A7WDDIWY.mjs.map +7 -0
- package/dist/lib/neutral/chunk-GSKMAS3S.mjs +13 -0
- package/dist/lib/neutral/chunk-GSKMAS3S.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-JEF2FQGB.mjs → chunk-JY35S2CN.mjs} +2 -2
- package/dist/lib/neutral/{chunk-JEF2FQGB.mjs.map → chunk-JY35S2CN.mjs.map} +1 -1
- package/dist/lib/neutral/chunk-ZFABGG2E.mjs +8 -0
- package/dist/lib/neutral/{chunk-NTVDGDQ3.mjs.map → chunk-ZFABGG2E.mjs.map} +2 -2
- package/dist/lib/neutral/containers/index.mjs +10 -8
- package/dist/lib/neutral/containers/index.mjs.map +3 -3
- package/dist/lib/neutral/{create-agent-6HLW4D3A.mjs → create-agent-6UKJMZS5.mjs} +3 -3
- package/dist/lib/neutral/{create-identity-JIWAR5GW.mjs → create-identity-ULCRB3YH.mjs} +3 -3
- package/dist/lib/neutral/{create-passkey-FOXEMXGF.mjs → create-passkey-I7VDS3AC.mjs} +7 -7
- package/dist/lib/neutral/create-passkey-I7VDS3AC.mjs.map +7 -0
- package/dist/lib/neutral/{create-recovery-code-ZWDKLPH4.mjs → create-recovery-code-DH2B6EGP.mjs} +4 -4
- package/dist/lib/neutral/index.mjs +6 -4
- package/dist/lib/neutral/{join-identity-QEQFAE2S.mjs → join-identity-PJCHDNLH.mjs} +3 -3
- package/dist/lib/neutral/{layer-specs-CQLXQBQJ.mjs → layer-specs-YI7BVWKZ.mjs} +6 -8
- package/dist/lib/neutral/layer-specs-YI7BVWKZ.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/meta.mjs +1 -1
- package/dist/lib/neutral/{navigation-handler-LU26CDFR.mjs → navigation-handler-MQ6MZXLX.mjs} +3 -3
- package/dist/lib/neutral/open-usage-OJVTPGOY.mjs +27 -0
- package/dist/lib/neutral/open-usage-OJVTPGOY.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +2 -2
- package/dist/lib/neutral/plugin.mjs +3 -3
- package/dist/lib/neutral/{react-context-B5LXMHVM.mjs → react-context-V74T6JOJ.mjs} +2 -2
- package/dist/lib/neutral/{react-context-B5LXMHVM.mjs.map → react-context-V74T6JOJ.mjs.map} +3 -3
- package/dist/lib/neutral/{react-surface-DEKGWTCD.mjs → react-surface-HPXRA65U.mjs} +8 -3
- package/dist/lib/neutral/react-surface-HPXRA65U.mjs.map +7 -0
- package/dist/lib/neutral/{recover-identity-JNFKLCUD.mjs → recover-identity-B7YM2BR4.mjs} +3 -3
- package/dist/lib/neutral/{redeem-passkey-4SBAI4AG.mjs → redeem-passkey-TYP4XLHO.mjs} +10 -10
- package/dist/lib/neutral/redeem-passkey-TYP4XLHO.mjs.map +7 -0
- package/dist/lib/neutral/{redeem-token-POBD6TMN.mjs → redeem-token-2J33R3PV.mjs} +3 -3
- package/dist/lib/neutral/{reset-storage-LQKUV5RA.mjs → reset-storage-K47HZTGP.mjs} +3 -3
- package/dist/lib/neutral/{share-identity-KNQ2XNXV.mjs → share-identity-TOROBLWL.mjs} +6 -6
- package/dist/lib/neutral/share-identity-TOROBLWL.mjs.map +7 -0
- package/dist/lib/neutral/testing/index.mjs +2 -2
- package/dist/lib/neutral/testing/index.mjs.map +3 -3
- package/dist/lib/neutral/translations.mjs +24 -1
- package/dist/lib/neutral/translations.mjs.map +3 -3
- package/dist/lib/neutral/types/index.mjs +3 -1
- package/dist/types/dx.config.d.ts +28 -0
- package/dist/types/dx.config.d.ts.map +1 -0
- package/dist/types/src/capabilities/account-cache.d.ts +1 -31
- package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -2
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/client.d.ts +1 -2
- package/dist/types/src/capabilities/client.d.ts.map +1 -1
- package/dist/types/src/capabilities/hub-http-client.d.ts +1 -2
- package/dist/types/src/capabilities/hub-http-client.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +9 -43
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/layer-specs.d.ts +1 -2
- package/dist/types/src/capabilities/layer-specs.d.ts.map +1 -1
- package/dist/types/src/capabilities/migrations.d.ts +1 -1
- package/dist/types/src/capabilities/navigation-handler/index.d.ts +1 -1
- package/dist/types/src/capabilities/navigation-handler/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/navigation-handler/navigation-handler.d.ts +1 -2
- package/dist/types/src/capabilities/navigation-handler/navigation-handler.d.ts.map +1 -1
- package/dist/types/src/capabilities/node.d.ts +6 -6
- package/dist/types/src/capabilities/node.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-context.d.ts +1 -6
- package/dist/types/src/capabilities/react-context.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +2 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/schema-defs.d.ts +1 -1
- package/dist/types/src/commands/account/index.d.ts +3 -0
- package/dist/types/src/commands/account/index.d.ts.map +1 -0
- package/dist/types/src/commands/account/login/index.d.ts +2 -0
- package/dist/types/src/commands/account/login/index.d.ts.map +1 -0
- package/dist/types/src/commands/account/login/login.d.ts +12 -0
- package/dist/types/src/commands/account/login/login.d.ts.map +1 -0
- package/dist/types/src/commands/account/logout/index.d.ts +2 -0
- package/dist/types/src/commands/account/logout/index.d.ts.map +1 -0
- package/dist/types/src/commands/account/logout/logout.d.ts +9 -0
- package/dist/types/src/commands/account/logout/logout.d.ts.map +1 -0
- package/dist/types/src/commands/halo/join/join.d.ts +1 -1
- package/dist/types/src/commands/halo/join/join.d.ts.map +1 -1
- package/dist/types/src/commands/halo/util.d.ts +4 -0
- package/dist/types/src/commands/halo/util.d.ts.map +1 -1
- package/dist/types/src/commands/index.d.ts +1 -0
- package/dist/types/src/commands/index.d.ts.map +1 -1
- package/dist/types/src/constants.d.ts.map +1 -1
- package/dist/types/src/containers/AccountContainer/AccountContainer.d.ts.map +1 -1
- package/dist/types/src/containers/AccountContainer/AccountContainer.stories.d.ts +14 -0
- package/dist/types/src/containers/AccountContainer/AccountContainer.stories.d.ts.map +1 -0
- package/dist/types/src/containers/DevicesContainer/DevicesContainer.d.ts.map +1 -1
- package/dist/types/src/containers/InvitationsContainer/InvitationsContainer.d.ts.map +1 -1
- package/dist/types/src/containers/InvitationsContainer/InvitationsContainer.stories.d.ts +14 -0
- package/dist/types/src/containers/InvitationsContainer/InvitationsContainer.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ProfileContainer/ProfileContainer.d.ts.map +1 -1
- package/dist/types/src/containers/RecoveryCredentialsContainer/RecoveryCredentialsContainer.d.ts.map +1 -1
- package/dist/types/src/containers/UsageContainer/UsageContainer.d.ts +7 -0
- package/dist/types/src/containers/UsageContainer/UsageContainer.d.ts.map +1 -0
- package/dist/types/src/containers/UsageContainer/UsageView.d.ts +28 -0
- package/dist/types/src/containers/UsageContainer/UsageView.d.ts.map +1 -0
- package/dist/types/src/containers/UsageContainer/UsageView.stories.d.ts +21 -0
- package/dist/types/src/containers/UsageContainer/UsageView.stories.d.ts.map +1 -0
- package/dist/types/src/containers/UsageContainer/index.d.ts +2 -0
- package/dist/types/src/containers/UsageContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +1 -0
- package/dist/types/src/containers/index.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +2 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/{state/use-hub-http.d.ts → hooks/useHubClient.d.ts} +1 -1
- package/dist/types/src/hooks/useHubClient.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +32 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/create-passkey.d.ts.map +1 -1
- package/dist/types/src/operations/definitions.d.ts +1 -0
- package/dist/types/src/operations/definitions.d.ts.map +1 -1
- package/dist/types/src/operations/index.d.ts.map +1 -1
- package/dist/types/src/operations/open-usage.d.ts +5 -0
- package/dist/types/src/operations/open-usage.d.ts.map +1 -0
- package/dist/types/src/testing/initializeIdentity.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/{state → types}/account-cache.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts.map +1 -1
- package/dist/types/src/types/events.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +1 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +1 -0
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dx.config.ts +19 -0
- package/package.json +47 -44
- package/src/ClientPlugin.node.ts +2 -2
- package/src/ClientPlugin.test.ts +1 -1
- package/src/capabilities/account-cache.ts +1 -3
- package/src/capabilities/app-graph-builder.ts +81 -71
- package/src/capabilities/layer-specs.ts +4 -6
- package/src/capabilities/react-context.tsx +1 -1
- package/src/capabilities/react-surface.tsx +6 -0
- package/src/commands/account/index.ts +13 -0
- package/src/commands/account/login/index.ts +5 -0
- package/src/commands/account/login/login.ts +147 -0
- package/src/commands/account/logout/index.ts +5 -0
- package/src/commands/account/logout/logout.ts +49 -0
- package/src/commands/halo/create/create.ts +2 -2
- package/src/commands/halo/index.ts +6 -6
- package/src/commands/halo/join/join.ts +2 -13
- package/src/commands/halo/util.ts +24 -0
- package/src/commands/index.ts +1 -0
- package/src/constants.ts +3 -3
- package/src/containers/AccountContainer/AccountContainer.stories.tsx +46 -0
- package/src/containers/AccountContainer/AccountContainer.tsx +67 -63
- package/src/containers/DevicesContainer/DevicesContainer.tsx +72 -54
- package/src/containers/InvitationsContainer/InvitationsContainer.stories.tsx +46 -0
- package/src/containers/InvitationsContainer/InvitationsContainer.tsx +65 -62
- package/src/containers/JoinDialog/JoinDialog.tsx +1 -1
- package/src/containers/ProfileContainer/ProfileContainer.tsx +38 -28
- package/src/containers/RecoveryCodeDialog/RecoveryCodeDialog.tsx +1 -1
- package/src/containers/RecoveryCredentialsContainer/RecoveryCredentialsContainer.tsx +52 -43
- package/src/containers/UsageContainer/UsageContainer.tsx +48 -0
- package/src/containers/UsageContainer/UsageView.stories.tsx +127 -0
- package/src/containers/UsageContainer/UsageView.tsx +270 -0
- package/src/containers/UsageContainer/index.ts +5 -0
- package/src/containers/index.ts +1 -0
- package/src/hooks/index.ts +5 -0
- package/src/meta.ts +3 -12
- package/src/operations/create-passkey.ts +6 -4
- package/src/operations/definitions.ts +12 -1
- package/src/operations/index.ts +1 -0
- package/src/operations/open-usage.ts +24 -0
- package/src/operations/redeem-passkey.ts +7 -7
- package/src/operations/share-identity.ts +3 -3
- package/src/testing/initializeIdentity.ts +5 -2
- package/src/translations.ts +25 -1
- package/src/types/capabilities.ts +8 -6
- package/src/types/events.ts +5 -5
- package/src/types/index.ts +1 -0
- package/src/types/schema.ts +23 -16
- package/dist/lib/neutral/AccountContainer-FZ3IC6H4.mjs.map +0 -7
- package/dist/lib/neutral/DevicesContainer-6MWNUC3I.mjs.map +0 -7
- package/dist/lib/neutral/InvitationsContainer-ME722VKS.mjs.map +0 -7
- package/dist/lib/neutral/JoinDialog-2NXAKPLP.mjs.map +0 -7
- package/dist/lib/neutral/ProfileContainer-VPX3FPWG.mjs.map +0 -7
- package/dist/lib/neutral/RecoveryCodeDialog-EWHB6U5T.mjs.map +0 -7
- package/dist/lib/neutral/RecoveryCredentialsContainer-IPBGDMIA.mjs.map +0 -7
- package/dist/lib/neutral/account-cache-4EKGEUJI.mjs +0 -43
- package/dist/lib/neutral/account-cache-4EKGEUJI.mjs.map +0 -7
- package/dist/lib/neutral/app-graph-builder-A74W7C36.mjs.map +0 -7
- package/dist/lib/neutral/chunk-D6HPCLTS.mjs.map +0 -7
- package/dist/lib/neutral/chunk-JOCCVODY.mjs +0 -21
- package/dist/lib/neutral/chunk-JOCCVODY.mjs.map +0 -7
- package/dist/lib/neutral/chunk-NTVDGDQ3.mjs +0 -8
- package/dist/lib/neutral/chunk-TUK3ELUU.mjs +0 -135
- package/dist/lib/neutral/chunk-TUK3ELUU.mjs.map +0 -7
- package/dist/lib/neutral/chunk-WWCVZG3K.mjs +0 -13
- package/dist/lib/neutral/chunk-WWCVZG3K.mjs.map +0 -7
- package/dist/lib/neutral/create-passkey-FOXEMXGF.mjs.map +0 -7
- package/dist/lib/neutral/layer-specs-CQLXQBQJ.mjs.map +0 -7
- package/dist/lib/neutral/react-surface-DEKGWTCD.mjs.map +0 -7
- package/dist/lib/neutral/redeem-passkey-4SBAI4AG.mjs.map +0 -7
- package/dist/lib/neutral/share-identity-KNQ2XNXV.mjs.map +0 -7
- package/dist/types/src/state/use-hub-http.d.ts.map +0 -1
- /package/dist/lib/neutral/{create-agent-6HLW4D3A.mjs.map → create-agent-6UKJMZS5.mjs.map} +0 -0
- /package/dist/lib/neutral/{create-identity-JIWAR5GW.mjs.map → create-identity-ULCRB3YH.mjs.map} +0 -0
- /package/dist/lib/neutral/{create-recovery-code-ZWDKLPH4.mjs.map → create-recovery-code-DH2B6EGP.mjs.map} +0 -0
- /package/dist/lib/neutral/{join-identity-QEQFAE2S.mjs.map → join-identity-PJCHDNLH.mjs.map} +0 -0
- /package/dist/lib/neutral/{navigation-handler-LU26CDFR.mjs.map → navigation-handler-MQ6MZXLX.mjs.map} +0 -0
- /package/dist/lib/neutral/{recover-identity-JNFKLCUD.mjs.map → recover-identity-B7YM2BR4.mjs.map} +0 -0
- /package/dist/lib/neutral/{redeem-token-POBD6TMN.mjs.map → redeem-token-2J33R3PV.mjs.map} +0 -0
- /package/dist/lib/neutral/{reset-storage-LQKUV5RA.mjs.map → reset-storage-K47HZTGP.mjs.map} +0 -0
- /package/dist/types/src/{state → types}/account-cache.d.ts +0 -0
- /package/src/{state/use-hub-http.ts → hooks/useHubClient.ts} +0 -0
- /package/src/{state → types}/account-cache.ts +0 -0
|
@@ -1,54 +1,259 @@
|
|
|
1
1
|
import "./chunk-J5LGTIGS.mjs";
|
|
2
2
|
|
|
3
3
|
// src/ClientPlugin.node.ts
|
|
4
|
-
import { ActivationEvents, Capability, Plugin
|
|
4
|
+
import { ActivationEvents, Capability, Plugin } from "@dxos/app-framework";
|
|
5
5
|
import { AppActivationEvents, AppPlugin } from "@dxos/app-toolkit";
|
|
6
6
|
import { Client, LayerSpecs, Migrations, OperationHandler, SchemaDefs } from "#capabilities";
|
|
7
7
|
import { meta } from "#meta";
|
|
8
8
|
import { ClientEvents } from "#types";
|
|
9
9
|
|
|
10
|
-
// src/commands/
|
|
11
|
-
import * as
|
|
10
|
+
// src/commands/account/index.ts
|
|
11
|
+
import * as Command3 from "@effect/cli/Command";
|
|
12
12
|
|
|
13
|
-
// src/commands/
|
|
13
|
+
// src/commands/account/login/login.ts
|
|
14
|
+
import * as Args from "@effect/cli/Args";
|
|
14
15
|
import * as Command from "@effect/cli/Command";
|
|
16
|
+
import * as Options from "@effect/cli/Options";
|
|
17
|
+
import * as Prompt from "@effect/cli/Prompt";
|
|
15
18
|
import * as Console from "effect/Console";
|
|
19
|
+
import * as Effect2 from "effect/Effect";
|
|
20
|
+
import * as Match from "effect/Match";
|
|
21
|
+
import * as Option from "effect/Option";
|
|
22
|
+
import { CommandConfig, performRecoveryOAuthFlow, print } from "@dxos/cli-util";
|
|
23
|
+
import { ClientService } from "@dxos/client";
|
|
24
|
+
import { Invitation as Invitation2, InvitationEncoder } from "@dxos/client/invitations";
|
|
25
|
+
import { Context as DxContext } from "@dxos/context";
|
|
26
|
+
import { HubHttpClient } from "@dxos/edge-client";
|
|
27
|
+
import { invariant } from "@dxos/invariant";
|
|
28
|
+
import { ATPROTO_OAUTH_SCOPES, OAuthProvider } from "@dxos/protocols";
|
|
29
|
+
|
|
30
|
+
// src/commands/halo/util.ts
|
|
31
|
+
import * as Duration from "effect/Duration";
|
|
16
32
|
import * as Effect from "effect/Effect";
|
|
33
|
+
import { FormBuilder } from "@dxos/cli-util";
|
|
34
|
+
import { Invitation } from "@dxos/client/invitations";
|
|
35
|
+
var printIdentity = (identity2) => FormBuilder.make({
|
|
36
|
+
title: "Identity"
|
|
37
|
+
}).pipe(FormBuilder.set("identityDid", identity2.identityDid), FormBuilder.set("displayName", identity2.profile?.displayName ?? "<none>"), FormBuilder.build);
|
|
38
|
+
var TERMINAL_FAILURE_STATES = /* @__PURE__ */ new Set([
|
|
39
|
+
Invitation.State.CANCELLED,
|
|
40
|
+
Invitation.State.TIMEOUT,
|
|
41
|
+
Invitation.State.ERROR,
|
|
42
|
+
Invitation.State.EXPIRED
|
|
43
|
+
]);
|
|
44
|
+
var waitForState = (invitation, state) => Effect.async((resume) => {
|
|
45
|
+
const subscription = invitation.subscribe((inv) => {
|
|
46
|
+
if (inv.state === state) {
|
|
47
|
+
resume(Effect.void);
|
|
48
|
+
} else if (TERMINAL_FAILURE_STATES.has(inv.state)) {
|
|
49
|
+
resume(Effect.fail(new Error(`Invitation failed with state: ${Invitation.State[inv.state]}`)));
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return Effect.sync(() => subscription.unsubscribe());
|
|
53
|
+
}).pipe(Effect.timeout(Duration.minutes(3)));
|
|
54
|
+
|
|
55
|
+
// src/commands/account/login/login.ts
|
|
56
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-client/src/commands/account/login/login.ts";
|
|
57
|
+
var LOGIN_METHODS = [
|
|
58
|
+
"email",
|
|
59
|
+
"atproto",
|
|
60
|
+
"device-invitation",
|
|
61
|
+
"recovery-code"
|
|
62
|
+
];
|
|
63
|
+
var METHOD_CHOICES = [
|
|
64
|
+
{
|
|
65
|
+
title: "Email",
|
|
66
|
+
value: "email"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
title: "AT Protocol",
|
|
70
|
+
value: "atproto"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
title: "Device invitation",
|
|
74
|
+
value: "device-invitation"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
title: "Recovery code",
|
|
78
|
+
value: "recovery-code"
|
|
79
|
+
}
|
|
80
|
+
];
|
|
81
|
+
var INPUT_PROMPT = {
|
|
82
|
+
"email": "Email address",
|
|
83
|
+
"atproto": "atproto handle or DID (e.g. alice.bsky.social)",
|
|
84
|
+
"device-invitation": "Invitation code or URL",
|
|
85
|
+
"recovery-code": "Recovery code (seed phrase)"
|
|
86
|
+
};
|
|
87
|
+
var login = Command.make("login", {
|
|
88
|
+
method: Options.choice("method", LOGIN_METHODS).pipe(Options.withDescription("Login method (email | atproto | device-invitation | recovery-code). Prompted if omitted."), Options.optional),
|
|
89
|
+
input: Args.text({
|
|
90
|
+
name: "input"
|
|
91
|
+
}).pipe(Args.withDescription("Method input: email address / atproto handle / invitation code / recovery code."), Args.optional)
|
|
92
|
+
}, Effect2.fn(function* ({ method, input }) {
|
|
93
|
+
const { json } = yield* CommandConfig;
|
|
94
|
+
const client = yield* ClientService;
|
|
95
|
+
invariant(!client.halo.identity.get(), "Already logged in. Run `dx account logout` first.", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 59, S: this, A: ["!client.halo.identity.get()", "'Already logged in. Run `dx account logout` first.'"] });
|
|
96
|
+
const resolvedMethod = Option.isSome(method) ? method.value : yield* Prompt.select({
|
|
97
|
+
message: "Choose a login method:",
|
|
98
|
+
choices: METHOD_CHOICES
|
|
99
|
+
}).pipe(Prompt.run);
|
|
100
|
+
const resolvedInput = Option.isSome(input) ? input.value : yield* Prompt.text({
|
|
101
|
+
message: `${INPUT_PROMPT[resolvedMethod]}:`
|
|
102
|
+
}).pipe(Prompt.run);
|
|
103
|
+
const identity2 = yield* Match.value(resolvedMethod).pipe(Match.when("atproto", () => loginWithAtproto(client, resolvedInput)), Match.when("email", () => loginWithEmail(client, resolvedInput)), Match.when("recovery-code", () => loginWithRecoveryCode(client, resolvedInput)), Match.when("device-invitation", () => loginWithDeviceInvitation(client, resolvedInput)), Match.exhaustive);
|
|
104
|
+
if (json) {
|
|
105
|
+
yield* Console.log(JSON.stringify({
|
|
106
|
+
identityDid: identity2.did,
|
|
107
|
+
displayName: identity2.profile?.displayName
|
|
108
|
+
}, null, 2));
|
|
109
|
+
} else {
|
|
110
|
+
yield* Console.log("Logged in successfully");
|
|
111
|
+
yield* Console.log(print(printIdentity({
|
|
112
|
+
identityDid: identity2.did,
|
|
113
|
+
profile: identity2.profile
|
|
114
|
+
})));
|
|
115
|
+
}
|
|
116
|
+
})).pipe(Command.withDescription("Log in to an existing DXOS identity (same methods as Composer)."));
|
|
117
|
+
var loginWithAtproto = (client, handle) => Effect2.gen(function* () {
|
|
118
|
+
const edgeBaseUrl = client.config.values.runtime?.services?.edge?.url;
|
|
119
|
+
invariant(edgeBaseUrl, "Edge services not configured (runtime.services.edge.url).", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 86, S: this, A: ["edgeBaseUrl", "'Edge services not configured (runtime.services.edge.url).'"] });
|
|
120
|
+
const { recoveryProof } = yield* performRecoveryOAuthFlow({
|
|
121
|
+
edgeBaseUrl,
|
|
122
|
+
provider: OAuthProvider.ATPROTO,
|
|
123
|
+
scopes: ATPROTO_OAUTH_SCOPES,
|
|
124
|
+
loginHint: handle
|
|
125
|
+
});
|
|
126
|
+
return yield* Effect2.tryPromise(() => client.halo.recoverIdentity({
|
|
127
|
+
recoveryProof
|
|
128
|
+
}));
|
|
129
|
+
});
|
|
130
|
+
var loginWithRecoveryCode = (client, recoveryCode) => Effect2.tryPromise(() => client.halo.recoverIdentity({
|
|
131
|
+
recoveryCode
|
|
132
|
+
}));
|
|
133
|
+
var loginWithEmail = (client, email) => Effect2.gen(function* () {
|
|
134
|
+
const hubUrl = client.config.values?.runtime?.app?.env?.DX_HUB_URL;
|
|
135
|
+
invariant(hubUrl, "Hub URL not configured (runtime.app.env.DX_HUB_URL).", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 105, S: this, A: ["hubUrl", "'Hub URL not configured (runtime.app.env.DX_HUB_URL).'"] });
|
|
136
|
+
const hub = new HubHttpClient(hubUrl);
|
|
137
|
+
const { token: inlineToken } = yield* Effect2.tryPromise(() => hub.login(DxContext.default(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 107 }), {
|
|
138
|
+
email
|
|
139
|
+
}));
|
|
140
|
+
let token = inlineToken;
|
|
141
|
+
if (!token) {
|
|
142
|
+
yield* Console.log(`A login link was sent to ${email}. Paste the token from the email below.`);
|
|
143
|
+
token = yield* Prompt.text({
|
|
144
|
+
message: "Login token"
|
|
145
|
+
}).pipe(Prompt.run);
|
|
146
|
+
}
|
|
147
|
+
return yield* Effect2.tryPromise(() => client.halo.recoverIdentity({
|
|
148
|
+
token
|
|
149
|
+
}));
|
|
150
|
+
});
|
|
151
|
+
var loginWithDeviceInvitation = (client, encoded) => Effect2.gen(function* () {
|
|
152
|
+
let code = encoded;
|
|
153
|
+
if (code.startsWith("http") || code.startsWith("socket")) {
|
|
154
|
+
code = new URL(code).searchParams.get("deviceInvitationCode") ?? code;
|
|
155
|
+
}
|
|
156
|
+
const invitation = client.halo.join(InvitationEncoder.decode(code));
|
|
157
|
+
yield* waitForState(invitation, Invitation2.State.READY_FOR_AUTHENTICATION);
|
|
158
|
+
const authCode = yield* Prompt.text({
|
|
159
|
+
message: "Enter the authentication code"
|
|
160
|
+
}).pipe(Prompt.run);
|
|
161
|
+
yield* Effect2.tryPromise(() => invitation.authenticate(authCode));
|
|
162
|
+
yield* waitForState(invitation, Invitation2.State.SUCCESS);
|
|
163
|
+
const identity2 = client.halo.identity.get();
|
|
164
|
+
invariant(identity2, "Device invitation completed but no identity is present.", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 138, S: this, A: ["identity", "'Device invitation completed but no identity is present.'"] });
|
|
165
|
+
return identity2;
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
// src/commands/account/logout/logout.ts
|
|
169
|
+
import * as Command2 from "@effect/cli/Command";
|
|
170
|
+
import * as Options2 from "@effect/cli/Options";
|
|
171
|
+
import * as Prompt2 from "@effect/cli/Prompt";
|
|
172
|
+
import * as FileSystem from "@effect/platform/FileSystem";
|
|
173
|
+
import * as Console2 from "effect/Console";
|
|
174
|
+
import * as Effect3 from "effect/Effect";
|
|
175
|
+
import { CommandConfig as CommandConfig2 } from "@dxos/cli-util";
|
|
176
|
+
import { DX_DATA, getProfilePath } from "@dxos/client-protocol";
|
|
177
|
+
import { ConfigService } from "@dxos/config";
|
|
178
|
+
var logout = Command2.make("logout", {
|
|
179
|
+
force: Options2.boolean("force", {
|
|
180
|
+
ifPresent: true
|
|
181
|
+
}).pipe(Options2.withDescription("Skip confirmation prompt."))
|
|
182
|
+
}, Effect3.fnUntraced(function* ({ force }) {
|
|
183
|
+
const fs = yield* FileSystem.FileSystem;
|
|
184
|
+
const config2 = yield* ConfigService;
|
|
185
|
+
const { json, profile: profile2 } = yield* CommandConfig2;
|
|
186
|
+
const path = config2.values.runtime?.client?.storage?.dataRoot ?? getProfilePath(DX_DATA, profile2);
|
|
187
|
+
if (!force) {
|
|
188
|
+
const confirmed = yield* Prompt2.confirm({
|
|
189
|
+
message: `Log out of profile (${profile2})? This removes the local identity and data; spaces re-sync on next login.`,
|
|
190
|
+
initial: false
|
|
191
|
+
}).pipe(Prompt2.run);
|
|
192
|
+
if (!confirmed) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
yield* fs.remove(path, {
|
|
197
|
+
recursive: true
|
|
198
|
+
}).pipe(Effect3.catchIf((e) => e._tag === "SystemError" && e.reason === "NotFound", () => Effect3.void));
|
|
199
|
+
if (json) {
|
|
200
|
+
yield* Console2.log(JSON.stringify({
|
|
201
|
+
profile: profile2,
|
|
202
|
+
loggedOut: true
|
|
203
|
+
}, null, 2));
|
|
204
|
+
} else {
|
|
205
|
+
yield* Console2.log(`Logged out of profile (${profile2}).`);
|
|
206
|
+
}
|
|
207
|
+
})).pipe(Command2.withDescription("Log out of the current profile (clears the local identity and data)."));
|
|
208
|
+
|
|
209
|
+
// src/commands/account/index.ts
|
|
210
|
+
var account = Command3.make("account").pipe(Command3.withDescription("Log in and out of a DXOS identity."), Command3.withSubcommands([
|
|
211
|
+
login,
|
|
212
|
+
logout
|
|
213
|
+
]));
|
|
214
|
+
|
|
215
|
+
// src/commands/config/index.ts
|
|
216
|
+
import * as Command5 from "@effect/cli/Command";
|
|
217
|
+
|
|
218
|
+
// src/commands/config/view.ts
|
|
219
|
+
import * as Command4 from "@effect/cli/Command";
|
|
220
|
+
import * as Console3 from "effect/Console";
|
|
221
|
+
import * as Effect4 from "effect/Effect";
|
|
17
222
|
import * as Yaml from "yaml";
|
|
18
|
-
import { CommandConfig } from "@dxos/cli-util";
|
|
19
|
-
import { ConfigService } from "@dxos/client";
|
|
223
|
+
import { CommandConfig as CommandConfig3 } from "@dxos/cli-util";
|
|
224
|
+
import { ConfigService as ConfigService2 } from "@dxos/client";
|
|
20
225
|
import { DX_CONFIG, getProfileConfigPath } from "@dxos/client-protocol";
|
|
21
|
-
var view =
|
|
22
|
-
const config2 = yield*
|
|
23
|
-
const { json, profile: profile2 } = yield*
|
|
226
|
+
var view = Command4.make("view", {}, Effect4.fnUntraced(function* () {
|
|
227
|
+
const config2 = yield* ConfigService2;
|
|
228
|
+
const { json, profile: profile2 } = yield* CommandConfig3;
|
|
24
229
|
const configPath = getProfileConfigPath(DX_CONFIG, profile2);
|
|
25
230
|
if (json) {
|
|
26
|
-
yield*
|
|
231
|
+
yield* Console3.log(JSON.stringify(config2.values, null, 2));
|
|
27
232
|
} else {
|
|
28
|
-
yield*
|
|
29
|
-
yield*
|
|
233
|
+
yield* Console3.log(`Path: ${configPath}`);
|
|
234
|
+
yield* Console3.log(Yaml.stringify(config2.values));
|
|
30
235
|
}
|
|
31
236
|
}));
|
|
32
237
|
|
|
33
238
|
// src/commands/config/index.ts
|
|
34
|
-
var config =
|
|
239
|
+
var config = Command5.make("config").pipe(Command5.withDescription("Config commands."), Command5.withSubcommands([
|
|
35
240
|
view
|
|
36
241
|
]));
|
|
37
242
|
|
|
38
243
|
// src/commands/device/index.ts
|
|
39
|
-
import * as
|
|
244
|
+
import * as Command9 from "@effect/cli/Command";
|
|
40
245
|
|
|
41
246
|
// src/commands/device/info/info.ts
|
|
42
|
-
import * as
|
|
43
|
-
import * as
|
|
44
|
-
import * as
|
|
45
|
-
import { CommandConfig as
|
|
46
|
-
import { print } from "@dxos/cli-util";
|
|
47
|
-
import { ClientService } from "@dxos/client";
|
|
247
|
+
import * as Command6 from "@effect/cli/Command";
|
|
248
|
+
import * as Console4 from "effect/Console";
|
|
249
|
+
import * as Effect5 from "effect/Effect";
|
|
250
|
+
import { CommandConfig as CommandConfig4 } from "@dxos/cli-util";
|
|
251
|
+
import { print as print2 } from "@dxos/cli-util";
|
|
252
|
+
import { ClientService as ClientService2 } from "@dxos/client";
|
|
48
253
|
import { DeviceType as DeviceType2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
49
254
|
|
|
50
255
|
// src/commands/device/util.ts
|
|
51
|
-
import { FormBuilder } from "@dxos/cli-util";
|
|
256
|
+
import { FormBuilder as FormBuilder2 } from "@dxos/cli-util";
|
|
52
257
|
import { Device, DeviceKind, DeviceType } from "@dxos/client/halo";
|
|
53
258
|
var maybeTruncateKey = (key, truncate = false) => truncate ? key.truncate() : key.toHex();
|
|
54
259
|
var getDeviceTitle = (device2) => {
|
|
@@ -73,30 +278,30 @@ var mapDevices = (devices, truncateKeys = false) => {
|
|
|
73
278
|
presence: device2?.kind === DeviceKind.CURRENT ? "THIS DEVICE" : Device.PresenceState[device2.presence]
|
|
74
279
|
}));
|
|
75
280
|
};
|
|
76
|
-
var printDevice = (device2) =>
|
|
281
|
+
var printDevice = (device2) => FormBuilder2.make({
|
|
77
282
|
title: getDeviceTitle(device2)
|
|
78
|
-
}).pipe(
|
|
283
|
+
}).pipe(FormBuilder2.set("deviceKey", device2.deviceKey.truncate()), FormBuilder2.set("label", device2.profile?.label ?? "<none>"), FormBuilder2.set("type", device2.profile?.type ? DeviceType[device2.profile?.type] : "UNKNOWN"), FormBuilder2.set("kind", DeviceKind[device2.kind]), FormBuilder2.set("presence", device2?.kind === DeviceKind.CURRENT ? "THIS DEVICE" : Device.PresenceState[device2.presence]), FormBuilder2.set("platform", device2.profile?.platform ?? "<none>"), FormBuilder2.set("platformVersion", device2.profile?.platformVersion ?? "<none>"), FormBuilder2.set("architecture", device2.profile?.architecture ?? "<none>"), FormBuilder2.set("os", device2.profile?.os ?? "<none>"), FormBuilder2.set("osVersion", device2.profile?.osVersion ?? "<none>"), FormBuilder2.build);
|
|
79
284
|
var printDevices = (devices) => {
|
|
80
285
|
return devices.map(printDevice);
|
|
81
286
|
};
|
|
82
287
|
|
|
83
288
|
// src/commands/device/info/info.ts
|
|
84
|
-
var handler =
|
|
85
|
-
const { json } = yield*
|
|
86
|
-
const client = yield*
|
|
289
|
+
var handler = Effect5.fn(function* () {
|
|
290
|
+
const { json } = yield* CommandConfig4;
|
|
291
|
+
const client = yield* ClientService2;
|
|
87
292
|
const device2 = client.halo.device;
|
|
88
293
|
if (!device2) {
|
|
89
294
|
if (json) {
|
|
90
|
-
yield*
|
|
295
|
+
yield* Console4.log(JSON.stringify({
|
|
91
296
|
error: "No device found"
|
|
92
297
|
}, null, 2));
|
|
93
298
|
} else {
|
|
94
|
-
yield*
|
|
299
|
+
yield* Console4.log("No device found.");
|
|
95
300
|
}
|
|
96
301
|
return;
|
|
97
302
|
}
|
|
98
303
|
if (json) {
|
|
99
|
-
yield*
|
|
304
|
+
yield* Console4.log(JSON.stringify({
|
|
100
305
|
deviceKey: device2.deviceKey.toHex(),
|
|
101
306
|
profile: {
|
|
102
307
|
...device2.profile,
|
|
@@ -104,50 +309,50 @@ var handler = Effect2.fn(function* () {
|
|
|
104
309
|
}
|
|
105
310
|
}, null, 2));
|
|
106
311
|
} else {
|
|
107
|
-
yield*
|
|
312
|
+
yield* Console4.log(print2(printDevice(device2)));
|
|
108
313
|
}
|
|
109
314
|
});
|
|
110
|
-
var info =
|
|
315
|
+
var info = Command6.make("info", {}, handler).pipe(Command6.withDescription("Show device info."));
|
|
111
316
|
|
|
112
317
|
// src/commands/device/list/list.ts
|
|
113
|
-
import * as
|
|
114
|
-
import * as
|
|
115
|
-
import * as
|
|
116
|
-
import { CommandConfig as
|
|
318
|
+
import * as Command7 from "@effect/cli/Command";
|
|
319
|
+
import * as Console5 from "effect/Console";
|
|
320
|
+
import * as Effect6 from "effect/Effect";
|
|
321
|
+
import { CommandConfig as CommandConfig5 } from "@dxos/cli-util";
|
|
117
322
|
import { printList } from "@dxos/cli-util";
|
|
118
|
-
import { ClientService as
|
|
119
|
-
var handler2 =
|
|
120
|
-
const { json } = yield*
|
|
121
|
-
const client = yield*
|
|
323
|
+
import { ClientService as ClientService3 } from "@dxos/client";
|
|
324
|
+
var handler2 = Effect6.fn(function* () {
|
|
325
|
+
const { json } = yield* CommandConfig5;
|
|
326
|
+
const client = yield* ClientService3;
|
|
122
327
|
const devices = client.halo.devices.get();
|
|
123
328
|
if (json) {
|
|
124
|
-
yield*
|
|
329
|
+
yield* Console5.log(JSON.stringify(mapDevices(devices), null, 2));
|
|
125
330
|
} else {
|
|
126
331
|
const formatted = printDevices(devices);
|
|
127
|
-
yield*
|
|
332
|
+
yield* Console5.log(printList(formatted));
|
|
128
333
|
}
|
|
129
334
|
});
|
|
130
|
-
var list =
|
|
335
|
+
var list = Command7.make("list", {}, handler2).pipe(Command7.withDescription("List devices."));
|
|
131
336
|
|
|
132
337
|
// src/commands/device/update/update.ts
|
|
133
|
-
import * as
|
|
134
|
-
import * as
|
|
135
|
-
import * as
|
|
136
|
-
import * as
|
|
137
|
-
import { CommandConfig as
|
|
138
|
-
import { print as
|
|
139
|
-
import { ClientService as
|
|
140
|
-
var handler3 =
|
|
141
|
-
const { json } = yield*
|
|
142
|
-
const client = yield*
|
|
338
|
+
import * as Command8 from "@effect/cli/Command";
|
|
339
|
+
import * as Options3 from "@effect/cli/Options";
|
|
340
|
+
import * as Console6 from "effect/Console";
|
|
341
|
+
import * as Effect7 from "effect/Effect";
|
|
342
|
+
import { CommandConfig as CommandConfig6 } from "@dxos/cli-util";
|
|
343
|
+
import { print as print3 } from "@dxos/cli-util";
|
|
344
|
+
import { ClientService as ClientService4 } from "@dxos/client";
|
|
345
|
+
var handler3 = Effect7.fn(function* ({ label }) {
|
|
346
|
+
const { json } = yield* CommandConfig6;
|
|
347
|
+
const client = yield* ClientService4;
|
|
143
348
|
const device2 = client.halo.device;
|
|
144
349
|
if (!device2) {
|
|
145
350
|
if (json) {
|
|
146
|
-
yield*
|
|
351
|
+
yield* Console6.log(JSON.stringify({
|
|
147
352
|
error: "No device found"
|
|
148
353
|
}, null, 2));
|
|
149
354
|
} else {
|
|
150
|
-
yield*
|
|
355
|
+
yield* Console6.log("No device found.");
|
|
151
356
|
}
|
|
152
357
|
return;
|
|
153
358
|
}
|
|
@@ -158,234 +363,171 @@ var handler3 = Effect4.fn(function* ({ label }) {
|
|
|
158
363
|
const devicesService = client.services.services.DevicesService;
|
|
159
364
|
if (!devicesService) {
|
|
160
365
|
if (json) {
|
|
161
|
-
yield*
|
|
366
|
+
yield* Console6.log(JSON.stringify({
|
|
162
367
|
error: "DevicesService not found"
|
|
163
368
|
}, null, 2));
|
|
164
369
|
} else {
|
|
165
|
-
yield*
|
|
370
|
+
yield* Console6.log("DevicesService not found.");
|
|
166
371
|
}
|
|
167
372
|
return;
|
|
168
373
|
}
|
|
169
|
-
const updatedDevice = yield*
|
|
374
|
+
const updatedDevice = yield* Effect7.tryPromise(() => devicesService.updateDevice(updatedProfile));
|
|
170
375
|
if (json) {
|
|
171
|
-
yield*
|
|
376
|
+
yield* Console6.log(JSON.stringify({
|
|
172
377
|
deviceKey: updatedDevice.deviceKey.toHex(),
|
|
173
378
|
profile: updatedDevice.profile
|
|
174
379
|
}, null, 2));
|
|
175
380
|
} else {
|
|
176
|
-
yield*
|
|
381
|
+
yield* Console6.log(print3(printDevice(updatedDevice)));
|
|
177
382
|
}
|
|
178
383
|
});
|
|
179
|
-
var update =
|
|
180
|
-
label:
|
|
181
|
-
}, handler3).pipe(
|
|
384
|
+
var update = Command8.make("update", {
|
|
385
|
+
label: Options3.text("label").pipe(Options3.withDescription("The device label."))
|
|
386
|
+
}, handler3).pipe(Command8.withDescription("Update device label."));
|
|
182
387
|
|
|
183
388
|
// src/commands/device/index.ts
|
|
184
|
-
var device =
|
|
389
|
+
var device = Command9.make("device").pipe(Command9.withDescription("Manage HALO devices."), Command9.withSubcommands([
|
|
185
390
|
info,
|
|
186
391
|
list,
|
|
187
392
|
update
|
|
188
393
|
]));
|
|
189
394
|
|
|
190
395
|
// src/commands/edge/index.ts
|
|
191
|
-
import * as
|
|
396
|
+
import * as Command11 from "@effect/cli/Command";
|
|
192
397
|
|
|
193
398
|
// src/commands/edge/status.ts
|
|
194
|
-
import * as
|
|
195
|
-
import * as
|
|
196
|
-
import * as
|
|
197
|
-
import * as
|
|
198
|
-
import { CommandConfig as
|
|
199
|
-
import { ClientService as
|
|
399
|
+
import * as Command10 from "@effect/cli/Command";
|
|
400
|
+
import * as Console7 from "effect/Console";
|
|
401
|
+
import * as Effect8 from "effect/Effect";
|
|
402
|
+
import * as Option2 from "effect/Option";
|
|
403
|
+
import { CommandConfig as CommandConfig7 } from "@dxos/cli-util";
|
|
404
|
+
import { ClientService as ClientService5 } from "@dxos/client";
|
|
200
405
|
import { createEdgeIdentity } from "@dxos/client/edge";
|
|
201
406
|
import { Context } from "@dxos/context";
|
|
202
|
-
var
|
|
203
|
-
var getStatus = () =>
|
|
204
|
-
const client = yield*
|
|
407
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-client/src/commands/edge/status.ts";
|
|
408
|
+
var getStatus = () => Effect8.gen(function* () {
|
|
409
|
+
const client = yield* ClientService5;
|
|
205
410
|
const identity2 = createEdgeIdentity(client);
|
|
206
411
|
client.edge.http.setIdentity(identity2);
|
|
207
|
-
const status2 = yield*
|
|
208
|
-
if (yield*
|
|
209
|
-
yield*
|
|
412
|
+
const status2 = yield* Effect8.tryPromise(() => client.edge.http.getStatus(Context.default(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 16 })));
|
|
413
|
+
if (yield* CommandConfig7.isJson) {
|
|
414
|
+
yield* Console7.log(JSON.stringify(status2, null, 2));
|
|
210
415
|
} else if (status2.problems.length > 0) {
|
|
211
416
|
for (const problem of status2.problems) {
|
|
212
|
-
yield*
|
|
417
|
+
yield* Console7.error(problem);
|
|
213
418
|
}
|
|
214
419
|
} else {
|
|
215
|
-
yield*
|
|
420
|
+
yield* Console7.log("No problems found.");
|
|
216
421
|
}
|
|
217
422
|
}).pipe(
|
|
218
423
|
// TODO(wittjosiah): Tagged error.
|
|
219
|
-
|
|
424
|
+
Effect8.catchSome((error2) => {
|
|
220
425
|
if (error2 instanceof Error && error2.message === "Identity not available") {
|
|
221
|
-
return
|
|
426
|
+
return Option2.some(Console7.error(error2.message));
|
|
222
427
|
} else {
|
|
223
|
-
return
|
|
428
|
+
return Option2.none();
|
|
224
429
|
}
|
|
225
430
|
})
|
|
226
431
|
);
|
|
227
|
-
var status =
|
|
432
|
+
var status = Command10.make("status", {}, getStatus).pipe(Command10.withDescription("Get the EDGE status for the current identity."));
|
|
228
433
|
|
|
229
434
|
// src/commands/edge/index.ts
|
|
230
|
-
var edge =
|
|
435
|
+
var edge = Command11.make("edge").pipe(Command11.withDescription("EDGE commands."), Command11.withSubcommands([
|
|
231
436
|
status
|
|
232
437
|
]));
|
|
233
438
|
|
|
234
439
|
// src/commands/halo/index.ts
|
|
235
|
-
import * as
|
|
236
|
-
|
|
237
|
-
// src/commands/halo/create/create.ts
|
|
238
|
-
import * as Command9 from "@effect/cli/Command";
|
|
239
|
-
import * as Options2 from "@effect/cli/Options";
|
|
240
|
-
import * as Console6 from "effect/Console";
|
|
241
|
-
import * as Effect6 from "effect/Effect";
|
|
242
|
-
import * as Option2 from "effect/Option";
|
|
243
|
-
import { Capabilities, Plugin } from "@dxos/app-framework";
|
|
244
|
-
import { PERSONAL_SPACE_TAG } from "@dxos/app-toolkit";
|
|
245
|
-
import { CommandConfig as CommandConfig6, flushAndSync, spaceLayer } from "@dxos/cli-util";
|
|
246
|
-
import { print as print3 } from "@dxos/cli-util";
|
|
247
|
-
import { ClientService as ClientService5 } from "@dxos/client";
|
|
248
|
-
import { invariant } from "@dxos/invariant";
|
|
249
|
-
import { EdgeReplicationSetting } from "@dxos/protocols/proto/dxos/echo/metadata";
|
|
250
|
-
import { MembershipPolicy } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
251
|
-
import { ClientOperation } from "#operations";
|
|
252
|
-
|
|
253
|
-
// src/commands/halo/util.ts
|
|
254
|
-
import { FormBuilder as FormBuilder2 } from "@dxos/cli-util";
|
|
255
|
-
var printIdentity = (identity2) => FormBuilder2.make({
|
|
256
|
-
title: "Identity"
|
|
257
|
-
}).pipe(FormBuilder2.set("identityDid", identity2.identityDid), FormBuilder2.set("displayName", identity2.profile?.displayName ?? "<none>"), FormBuilder2.build);
|
|
258
|
-
|
|
259
|
-
// src/commands/halo/create/create.ts
|
|
260
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-client/src/commands/halo/create/create.ts";
|
|
261
|
-
var handler4 = Effect6.fn(function* ({ agent, displayName }) {
|
|
262
|
-
const { json } = yield* CommandConfig6;
|
|
263
|
-
const client = yield* ClientService5;
|
|
264
|
-
invariant(!client.halo.identity.get(), "Identity already exists", { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 23, S: this, A: ["!client.halo.identity.get()", "'Identity already exists'"] });
|
|
265
|
-
const manager = yield* Plugin.Service;
|
|
266
|
-
const { invoke } = manager.capabilities.get(Capabilities.OperationInvoker);
|
|
267
|
-
const identity2 = yield* invoke(ClientOperation.CreateIdentity, {
|
|
268
|
-
displayName: Option2.getOrUndefined(displayName)
|
|
269
|
-
});
|
|
270
|
-
if (agent) {
|
|
271
|
-
yield* invoke(ClientOperation.CreateAgent);
|
|
272
|
-
}
|
|
273
|
-
const space = yield* Effect6.promise(() => client.spaces.create({}, {
|
|
274
|
-
tags: [
|
|
275
|
-
PERSONAL_SPACE_TAG
|
|
276
|
-
],
|
|
277
|
-
membershipPolicy: MembershipPolicy.LOCKED
|
|
278
|
-
}));
|
|
279
|
-
yield* Effect6.promise(() => space.waitUntilReady());
|
|
280
|
-
yield* Effect6.promise(() => space.internal.setEdgeReplicationPreference(EdgeReplicationSetting.ENABLED));
|
|
281
|
-
yield* flushAndSync({
|
|
282
|
-
indexes: true
|
|
283
|
-
}).pipe(Effect6.provide(spaceLayer(Option2.some(space.id))));
|
|
284
|
-
if (json) {
|
|
285
|
-
yield* Console6.log(JSON.stringify({
|
|
286
|
-
identityDid: identity2.identityDid,
|
|
287
|
-
displayName: identity2.profile?.displayName
|
|
288
|
-
}, null, 2));
|
|
289
|
-
} else {
|
|
290
|
-
yield* Console6.log(print3(printIdentity(identity2)));
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
var create = Command9.make("create", {
|
|
294
|
-
agent: Options2.boolean("noAgent", {
|
|
295
|
-
ifPresent: false
|
|
296
|
-
}).pipe(Options2.withDescription("Do not create an EDGE agent for the identity.")),
|
|
297
|
-
displayName: Options2.text("displayName").pipe(Options2.withDescription("The display name of the identity."), Options2.optional)
|
|
298
|
-
}, handler4).pipe(Command9.withDescription("Create a new identity."));
|
|
440
|
+
import * as Command19 from "@effect/cli/Command";
|
|
299
441
|
|
|
300
442
|
// src/commands/halo/credential/index.ts
|
|
301
|
-
import * as
|
|
443
|
+
import * as Command14 from "@effect/cli/Command";
|
|
302
444
|
|
|
303
445
|
// src/commands/halo/credential/add/add.ts
|
|
304
|
-
import * as
|
|
305
|
-
import * as
|
|
306
|
-
import * as
|
|
307
|
-
import * as
|
|
308
|
-
import * as
|
|
446
|
+
import * as Args2 from "@effect/cli/Args";
|
|
447
|
+
import * as Command12 from "@effect/cli/Command";
|
|
448
|
+
import * as Prompt3 from "@effect/cli/Prompt";
|
|
449
|
+
import * as Console8 from "effect/Console";
|
|
450
|
+
import * as Effect9 from "effect/Effect";
|
|
309
451
|
import * as Option3 from "effect/Option";
|
|
310
|
-
import { CommandConfig as
|
|
452
|
+
import { CommandConfig as CommandConfig8 } from "@dxos/cli-util";
|
|
311
453
|
import { ClientService as ClientService6 } from "@dxos/client";
|
|
312
454
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
313
455
|
import { schema } from "@dxos/protocols/proto";
|
|
314
456
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-client/src/commands/halo/credential/add/add.ts";
|
|
315
|
-
var
|
|
316
|
-
const { json } = yield*
|
|
457
|
+
var handler4 = Effect9.fn(function* ({ credential: credential2 }) {
|
|
458
|
+
const { json } = yield* CommandConfig8;
|
|
317
459
|
const client = yield* ClientService6;
|
|
318
460
|
let credentialHex = Option3.getOrUndefined(credential2);
|
|
319
461
|
if (!credentialHex) {
|
|
320
|
-
credentialHex = yield*
|
|
462
|
+
credentialHex = yield* Prompt3.text({
|
|
321
463
|
message: "Enter credential (hex string)"
|
|
322
|
-
}).pipe(
|
|
464
|
+
}).pipe(Prompt3.run);
|
|
323
465
|
}
|
|
324
466
|
invariant2(credentialHex, "Invalid credential.", { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 23, S: this, A: ["credentialHex", "'Invalid credential.'"] });
|
|
325
467
|
const identity2 = client.halo.identity;
|
|
326
468
|
if (!identity2) {
|
|
327
469
|
if (json) {
|
|
328
|
-
yield*
|
|
470
|
+
yield* Console8.log(JSON.stringify({
|
|
329
471
|
error: "Profile not initialized"
|
|
330
472
|
}, null, 2));
|
|
331
473
|
} else {
|
|
332
|
-
yield*
|
|
474
|
+
yield* Console8.log("Profile not initialized.");
|
|
333
475
|
}
|
|
334
476
|
return;
|
|
335
477
|
}
|
|
336
|
-
yield*
|
|
478
|
+
yield* Effect9.gen(function* () {
|
|
337
479
|
const codec = schema.getCodecForType("dxos.halo.credentials.Credential");
|
|
338
|
-
const credentialBytes = yield*
|
|
480
|
+
const credentialBytes = yield* Effect9.try({
|
|
339
481
|
try: () => Buffer.from(credentialHex, "hex"),
|
|
340
482
|
catch: (error2) => new Error(`Failed to parse hex string: ${error2}`)
|
|
341
483
|
});
|
|
342
484
|
const verifyError = codec.protoType.verify(credentialBytes);
|
|
343
485
|
if (verifyError) {
|
|
344
|
-
yield*
|
|
486
|
+
yield* Effect9.fail(new Error(verifyError));
|
|
345
487
|
}
|
|
346
|
-
const credentialObj = yield*
|
|
488
|
+
const credentialObj = yield* Effect9.try({
|
|
347
489
|
try: () => codec.decode(credentialBytes),
|
|
348
490
|
catch: (error2) => new Error(`Failed to decode credential: ${error2}`)
|
|
349
491
|
});
|
|
350
|
-
yield*
|
|
492
|
+
yield* Effect9.tryPromise({
|
|
351
493
|
try: () => client.halo.writeCredentials([
|
|
352
494
|
credentialObj
|
|
353
495
|
]),
|
|
354
496
|
catch: (error2) => new Error(`Failed to write credential: ${error2}`)
|
|
355
497
|
});
|
|
356
498
|
if (json) {
|
|
357
|
-
yield*
|
|
499
|
+
yield* Console8.log(JSON.stringify({
|
|
358
500
|
success: true
|
|
359
501
|
}, null, 2));
|
|
360
502
|
} else {
|
|
361
|
-
yield*
|
|
503
|
+
yield* Console8.log("Credential added successfully.");
|
|
362
504
|
}
|
|
363
|
-
}).pipe(
|
|
505
|
+
}).pipe(Effect9.catchAll((error2) => Effect9.gen(function* () {
|
|
364
506
|
if (json) {
|
|
365
|
-
yield*
|
|
507
|
+
yield* Console8.log(JSON.stringify({
|
|
366
508
|
error: "Invalid credential",
|
|
367
509
|
message: error2 instanceof Error ? error2.message : String(error2)
|
|
368
510
|
}, null, 2));
|
|
369
511
|
} else {
|
|
370
|
-
yield*
|
|
512
|
+
yield* Console8.log("Invalid credential.");
|
|
371
513
|
}
|
|
372
|
-
yield*
|
|
514
|
+
yield* Effect9.fail(error2);
|
|
373
515
|
})));
|
|
374
516
|
});
|
|
375
|
-
var add =
|
|
376
|
-
credential:
|
|
517
|
+
var add = Command12.make("add", {
|
|
518
|
+
credential: Args2.text({
|
|
377
519
|
name: "credential"
|
|
378
|
-
}).pipe(
|
|
379
|
-
},
|
|
520
|
+
}).pipe(Args2.withDescription("Credential as hex string."), Args2.optional)
|
|
521
|
+
}, handler4).pipe(Command12.withDescription("Import credential into HALO."));
|
|
380
522
|
|
|
381
523
|
// src/commands/halo/credential/list/list.ts
|
|
382
|
-
import * as
|
|
383
|
-
import * as
|
|
384
|
-
import * as
|
|
385
|
-
import * as
|
|
386
|
-
import * as
|
|
524
|
+
import * as Command13 from "@effect/cli/Command";
|
|
525
|
+
import * as Options4 from "@effect/cli/Options";
|
|
526
|
+
import * as Console9 from "effect/Console";
|
|
527
|
+
import * as Duration2 from "effect/Duration";
|
|
528
|
+
import * as Effect10 from "effect/Effect";
|
|
387
529
|
import * as Option4 from "effect/Option";
|
|
388
|
-
import { CommandConfig as
|
|
530
|
+
import { CommandConfig as CommandConfig9, Common, FormBuilder as FormBuilder3, getSpace, printList as printList2 } from "@dxos/cli-util";
|
|
389
531
|
import { ClientService as ClientService7 } from "@dxos/client";
|
|
390
532
|
var mapCredentials = (credentials) => {
|
|
391
533
|
return credentials.map((credential2) => ({
|
|
@@ -402,109 +544,109 @@ var printCredential = (credential2) => {
|
|
|
402
544
|
title: type
|
|
403
545
|
}).pipe(FormBuilder3.option("id", Option4.fromNullable(credential2.id?.truncate())), FormBuilder3.option("issuer", Option4.fromNullable(credential2.issuer?.truncate())), FormBuilder3.option("subject", Option4.fromNullable(credential2.subject?.id?.truncate())), FormBuilder3.build);
|
|
404
546
|
};
|
|
405
|
-
var
|
|
406
|
-
const { json } = yield*
|
|
547
|
+
var handler5 = Effect10.fn(function* ({ type, spaceId, timeout: timeout3, delay }) {
|
|
548
|
+
const { json } = yield* CommandConfig9;
|
|
407
549
|
const client = yield* ClientService7;
|
|
408
550
|
let credentials;
|
|
409
551
|
if (Option4.isSome(spaceId)) {
|
|
410
552
|
const space = yield* getSpace(spaceId.value);
|
|
411
|
-
credentials = yield*
|
|
553
|
+
credentials = yield* Effect10.tryPromise(() => space.internal.getCredentials());
|
|
412
554
|
} else {
|
|
413
555
|
const identity2 = client.halo.identity;
|
|
414
556
|
if (!identity2) {
|
|
415
557
|
if (json) {
|
|
416
|
-
yield*
|
|
558
|
+
yield* Console9.log(JSON.stringify({
|
|
417
559
|
error: "Profile not initialized"
|
|
418
560
|
}, null, 2));
|
|
419
561
|
} else {
|
|
420
|
-
yield*
|
|
562
|
+
yield* Console9.log("Profile not initialized.");
|
|
421
563
|
}
|
|
422
564
|
return;
|
|
423
565
|
}
|
|
424
|
-
const latch = yield*
|
|
566
|
+
const latch = yield* Effect10.makeLatch();
|
|
425
567
|
const subscription = client.halo.credentials.subscribe((creds) => {
|
|
426
568
|
if (creds.length > 0) {
|
|
427
|
-
|
|
569
|
+
Effect10.runSync(latch.open);
|
|
428
570
|
}
|
|
429
571
|
});
|
|
430
|
-
yield* latch.await.pipe(
|
|
572
|
+
yield* latch.await.pipe(Effect10.timeout(Duration2.millis(timeout3)), Effect10.catchAll(() => Effect10.void), Effect10.ensuring(Effect10.sync(() => {
|
|
431
573
|
subscription.unsubscribe();
|
|
432
574
|
})));
|
|
433
|
-
yield*
|
|
575
|
+
yield* Effect10.sleep(Duration2.millis(delay));
|
|
434
576
|
credentials = client.halo.queryCredentials({
|
|
435
577
|
type: Option4.getOrUndefined(type)
|
|
436
578
|
});
|
|
437
579
|
}
|
|
438
580
|
if (json) {
|
|
439
|
-
yield*
|
|
581
|
+
yield* Console9.log(JSON.stringify(mapCredentials(credentials), null, 2));
|
|
440
582
|
} else {
|
|
441
583
|
const formatted = credentials.map(printCredential);
|
|
442
|
-
yield*
|
|
584
|
+
yield* Console9.log(printList2(formatted));
|
|
443
585
|
}
|
|
444
586
|
});
|
|
445
|
-
var list2 =
|
|
446
|
-
type:
|
|
447
|
-
spaceId: Common.spaceId.pipe(
|
|
448
|
-
timeout:
|
|
449
|
-
delay:
|
|
450
|
-
},
|
|
587
|
+
var list2 = Command13.make("list", {
|
|
588
|
+
type: Options4.text("type").pipe(Options4.withDescription("Filter by credential type."), Options4.optional),
|
|
589
|
+
spaceId: Common.spaceId.pipe(Options4.withDescription("Space ID to show credentials from."), Options4.optional),
|
|
590
|
+
timeout: Options4.integer("timeout").pipe(Options4.withDescription("Time in milliseconds to wait for at least one credential before listing."), Options4.withDefault(500)),
|
|
591
|
+
delay: Options4.integer("delay").pipe(Options4.withDescription("Delay in milliseconds before listing."), Options4.withDefault(250))
|
|
592
|
+
}, handler5).pipe(Command13.withDescription("List HALO credentials."));
|
|
451
593
|
|
|
452
594
|
// src/commands/halo/credential/index.ts
|
|
453
|
-
var credential =
|
|
595
|
+
var credential = Command14.make("credential").pipe(Command14.withDescription("Manage HALO credentials."), Command14.withSubcommands([
|
|
454
596
|
add,
|
|
455
597
|
list2
|
|
456
598
|
]));
|
|
457
599
|
|
|
458
600
|
// src/commands/halo/identity/identity.ts
|
|
459
|
-
import * as
|
|
460
|
-
import * as
|
|
461
|
-
import * as
|
|
462
|
-
import { CommandConfig as
|
|
601
|
+
import * as Command15 from "@effect/cli/Command";
|
|
602
|
+
import * as Console10 from "effect/Console";
|
|
603
|
+
import * as Effect11 from "effect/Effect";
|
|
604
|
+
import { CommandConfig as CommandConfig10 } from "@dxos/cli-util";
|
|
463
605
|
import { print as print4 } from "@dxos/cli-util";
|
|
464
606
|
import { ClientService as ClientService8 } from "@dxos/client";
|
|
465
|
-
var
|
|
466
|
-
const { json } = yield*
|
|
607
|
+
var handler6 = Effect11.fn(function* () {
|
|
608
|
+
const { json } = yield* CommandConfig10;
|
|
467
609
|
const client = yield* ClientService8;
|
|
468
610
|
const identity2 = client.halo.identity.get();
|
|
469
611
|
if (!identity2) {
|
|
470
612
|
if (json) {
|
|
471
|
-
yield*
|
|
613
|
+
yield* Console10.log(JSON.stringify({
|
|
472
614
|
error: "Identity not initialized"
|
|
473
615
|
}, null, 2));
|
|
474
616
|
} else {
|
|
475
|
-
yield*
|
|
617
|
+
yield* Console10.log("Identity not initialized.");
|
|
476
618
|
}
|
|
477
619
|
} else {
|
|
478
620
|
if (json) {
|
|
479
|
-
yield*
|
|
621
|
+
yield* Console10.log(JSON.stringify({
|
|
480
622
|
identityDid: identity2.did,
|
|
481
623
|
displayName: identity2.profile?.displayName
|
|
482
624
|
}, null, 2));
|
|
483
625
|
} else {
|
|
484
|
-
yield*
|
|
626
|
+
yield* Console10.log(print4(printIdentity({
|
|
485
627
|
identityDid: identity2.did,
|
|
486
628
|
profile: identity2.profile
|
|
487
629
|
})));
|
|
488
630
|
}
|
|
489
631
|
}
|
|
490
632
|
});
|
|
491
|
-
var identity =
|
|
633
|
+
var identity = Command15.make("identity", {}, handler6).pipe(Command15.withDescription("Get the current identity."));
|
|
492
634
|
|
|
493
635
|
// src/commands/halo/keys/keys.ts
|
|
494
|
-
import * as
|
|
495
|
-
import * as
|
|
496
|
-
import * as
|
|
636
|
+
import * as Command16 from "@effect/cli/Command";
|
|
637
|
+
import * as Console11 from "effect/Console";
|
|
638
|
+
import * as Effect12 from "effect/Effect";
|
|
497
639
|
import * as Option5 from "effect/Option";
|
|
498
|
-
import { CommandConfig as
|
|
640
|
+
import { CommandConfig as CommandConfig11 } from "@dxos/cli-util";
|
|
499
641
|
import { FormBuilder as FormBuilder4, print as print5 } from "@dxos/cli-util";
|
|
500
642
|
import { ClientService as ClientService9 } from "@dxos/client";
|
|
501
|
-
var
|
|
502
|
-
const { json } = yield*
|
|
643
|
+
var handler7 = Effect12.fn(function* () {
|
|
644
|
+
const { json } = yield* CommandConfig11;
|
|
503
645
|
const client = yield* ClientService9;
|
|
504
646
|
const identity2 = client.halo.identity.get();
|
|
505
647
|
const device2 = client.halo.device;
|
|
506
648
|
if (json) {
|
|
507
|
-
yield*
|
|
649
|
+
yield* Console11.log(JSON.stringify({
|
|
508
650
|
identityKey: identity2?.identityKey.toHex(),
|
|
509
651
|
deviceKey: device2?.deviceKey.toHex()
|
|
510
652
|
}, null, 2));
|
|
@@ -512,54 +654,20 @@ var handler8 = Effect10.fn(function* () {
|
|
|
512
654
|
const builder = FormBuilder4.make({
|
|
513
655
|
title: "HALO Keys"
|
|
514
656
|
}).pipe(FormBuilder4.option("identityKey", Option5.fromNullable(identity2?.identityKey.truncate())), FormBuilder4.option("deviceKey", Option5.fromNullable(device2?.deviceKey.truncate())));
|
|
515
|
-
yield*
|
|
657
|
+
yield* Console11.log(print5(FormBuilder4.build(builder)));
|
|
516
658
|
}
|
|
517
659
|
});
|
|
518
|
-
var keys =
|
|
519
|
-
|
|
520
|
-
// src/commands/halo/recover/recover.ts
|
|
521
|
-
import * as Args2 from "@effect/cli/Args";
|
|
522
|
-
import * as Command15 from "@effect/cli/Command";
|
|
523
|
-
import * as Console11 from "effect/Console";
|
|
524
|
-
import * as Effect11 from "effect/Effect";
|
|
525
|
-
import { CommandConfig as CommandConfig11, print as print6 } from "@dxos/cli-util";
|
|
526
|
-
import { ClientService as ClientService10 } from "@dxos/client";
|
|
527
|
-
import { invariant as invariant3 } from "@dxos/invariant";
|
|
528
|
-
var __dxlog_file4 = "/__w/dxos/dxos/packages/plugins/plugin-client/src/commands/halo/recover/recover.ts";
|
|
529
|
-
var recover = Command15.make("recover", {
|
|
530
|
-
recoveryCode: Args2.text({
|
|
531
|
-
name: "recoveryCode"
|
|
532
|
-
}).pipe(Args2.withDescription("The recovery code seed phrase."))
|
|
533
|
-
}, Effect11.fn(function* ({ recoveryCode }) {
|
|
534
|
-
const { json } = yield* CommandConfig11;
|
|
535
|
-
const client = yield* ClientService10;
|
|
536
|
-
invariant3(!client.halo.identity.get(), "Identity already exists", { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 20, S: this, A: ["!client.halo.identity.get()", "'Identity already exists'"] });
|
|
537
|
-
const identity2 = yield* Effect11.tryPromise(() => client.halo.recoverIdentity({
|
|
538
|
-
recoveryCode
|
|
539
|
-
}));
|
|
540
|
-
if (json) {
|
|
541
|
-
yield* Console11.log(JSON.stringify({
|
|
542
|
-
identityDid: identity2.did,
|
|
543
|
-
displayName: identity2.profile?.displayName
|
|
544
|
-
}, null, 2));
|
|
545
|
-
} else {
|
|
546
|
-
yield* Console11.log("Identity recovered successfully");
|
|
547
|
-
yield* Console11.log(print6(printIdentity({
|
|
548
|
-
identityDid: identity2.did,
|
|
549
|
-
profile: identity2.profile
|
|
550
|
-
})));
|
|
551
|
-
}
|
|
552
|
-
})).pipe(Command15.withDescription("Recover an existing identity using a recovery code."));
|
|
660
|
+
var keys = Command16.make("keys", {}, handler7).pipe(Command16.withDescription("Show HALO keys."));
|
|
553
661
|
|
|
554
662
|
// src/commands/halo/seed/seed.ts
|
|
555
|
-
import * as
|
|
663
|
+
import * as Command17 from "@effect/cli/Command";
|
|
556
664
|
import * as Console12 from "effect/Console";
|
|
557
|
-
import * as
|
|
665
|
+
import * as Effect13 from "effect/Effect";
|
|
558
666
|
import { CommandConfig as CommandConfig12 } from "@dxos/cli-util";
|
|
559
|
-
import { ClientService as
|
|
560
|
-
var
|
|
667
|
+
import { ClientService as ClientService10 } from "@dxos/client";
|
|
668
|
+
var handler8 = Effect13.fn(function* () {
|
|
561
669
|
const { json } = yield* CommandConfig12;
|
|
562
|
-
const client = yield*
|
|
670
|
+
const client = yield* ClientService10;
|
|
563
671
|
const identityService = client.services.services.IdentityService;
|
|
564
672
|
if (!identityService) {
|
|
565
673
|
if (json) {
|
|
@@ -571,7 +679,7 @@ var handler9 = Effect12.fn(function* () {
|
|
|
571
679
|
}
|
|
572
680
|
return;
|
|
573
681
|
}
|
|
574
|
-
const result = yield*
|
|
682
|
+
const result = yield* Effect13.tryPromise(() => identityService.createRecoveryCredential({}));
|
|
575
683
|
if (json) {
|
|
576
684
|
yield* Console12.log(JSON.stringify({
|
|
577
685
|
recoveryCode: result.recoveryCode
|
|
@@ -580,19 +688,19 @@ var handler9 = Effect12.fn(function* () {
|
|
|
580
688
|
yield* Console12.log(result.recoveryCode);
|
|
581
689
|
}
|
|
582
690
|
});
|
|
583
|
-
var seed =
|
|
691
|
+
var seed = Command17.make("seed", {}, handler8).pipe(Command17.withDescription("Generate a seedphrase that can be used for identity recovery."));
|
|
584
692
|
|
|
585
693
|
// src/commands/halo/update/update.ts
|
|
586
|
-
import * as
|
|
587
|
-
import * as
|
|
694
|
+
import * as Command18 from "@effect/cli/Command";
|
|
695
|
+
import * as Options5 from "@effect/cli/Options";
|
|
588
696
|
import * as Console13 from "effect/Console";
|
|
589
|
-
import * as
|
|
697
|
+
import * as Effect14 from "effect/Effect";
|
|
590
698
|
import { CommandConfig as CommandConfig13 } from "@dxos/cli-util";
|
|
591
|
-
import { print as
|
|
592
|
-
import { ClientService as
|
|
593
|
-
var
|
|
699
|
+
import { print as print6 } from "@dxos/cli-util";
|
|
700
|
+
import { ClientService as ClientService11 } from "@dxos/client";
|
|
701
|
+
var handler9 = Effect14.fn(function* ({ displayName }) {
|
|
594
702
|
const { json } = yield* CommandConfig13;
|
|
595
|
-
const client = yield*
|
|
703
|
+
const client = yield* ClientService11;
|
|
596
704
|
const identity2 = client.halo.identity.get();
|
|
597
705
|
if (!identity2) {
|
|
598
706
|
if (json) {
|
|
@@ -615,7 +723,7 @@ var handler10 = Effect13.fn(function* ({ displayName }) {
|
|
|
615
723
|
}
|
|
616
724
|
return;
|
|
617
725
|
}
|
|
618
|
-
const updatedIdentity = yield*
|
|
726
|
+
const updatedIdentity = yield* Effect14.tryPromise(() => identityService.updateProfile({
|
|
619
727
|
displayName
|
|
620
728
|
}));
|
|
621
729
|
if (json) {
|
|
@@ -624,40 +732,38 @@ var handler10 = Effect13.fn(function* ({ displayName }) {
|
|
|
624
732
|
displayName: updatedIdentity.profile?.displayName
|
|
625
733
|
}, null, 2));
|
|
626
734
|
} else {
|
|
627
|
-
yield* Console13.log(
|
|
735
|
+
yield* Console13.log(print6(printIdentity({
|
|
628
736
|
identityDid: updatedIdentity.did,
|
|
629
737
|
profile: updatedIdentity.profile
|
|
630
738
|
})));
|
|
631
739
|
}
|
|
632
740
|
});
|
|
633
|
-
var update2 =
|
|
634
|
-
displayName:
|
|
635
|
-
},
|
|
741
|
+
var update2 = Command18.make("update", {
|
|
742
|
+
displayName: Options5.text("displayName").pipe(Options5.withDescription("The display name of the identity."))
|
|
743
|
+
}, handler9).pipe(Command18.withDescription("Update identity profile."));
|
|
636
744
|
|
|
637
745
|
// src/commands/halo/index.ts
|
|
638
|
-
var halo =
|
|
639
|
-
create,
|
|
746
|
+
var halo = Command19.make("halo").pipe(Command19.withDescription("Manage HALO identity."), Command19.withSubcommands([
|
|
640
747
|
credential,
|
|
641
748
|
identity,
|
|
642
749
|
keys,
|
|
643
|
-
recover,
|
|
644
750
|
seed,
|
|
645
751
|
update2
|
|
646
752
|
]));
|
|
647
753
|
|
|
648
754
|
// src/commands/profile/index.ts
|
|
649
|
-
import * as
|
|
755
|
+
import * as Command26 from "@effect/cli/Command";
|
|
650
756
|
|
|
651
757
|
// src/commands/profile/create.ts
|
|
652
|
-
import * as
|
|
653
|
-
import * as
|
|
654
|
-
import * as
|
|
758
|
+
import * as Command20 from "@effect/cli/Command";
|
|
759
|
+
import * as Options6 from "@effect/cli/Options";
|
|
760
|
+
import * as FileSystem3 from "@effect/platform/FileSystem";
|
|
655
761
|
import * as Path from "@effect/platform/Path";
|
|
656
762
|
import * as Console14 from "effect/Console";
|
|
657
|
-
import * as
|
|
763
|
+
import * as Effect15 from "effect/Effect";
|
|
658
764
|
import * as Option6 from "effect/Option";
|
|
659
765
|
import * as Record from "effect/Record";
|
|
660
|
-
import { CommandConfig as CommandConfig14, print as
|
|
766
|
+
import { CommandConfig as CommandConfig14, print as print7 } from "@dxos/cli-util";
|
|
661
767
|
import { DX_CONFIG as DX_CONFIG2, getProfileConfigPath as getProfileConfigPath2 } from "@dxos/client-protocol";
|
|
662
768
|
import { trim } from "@dxos/util";
|
|
663
769
|
|
|
@@ -722,12 +828,12 @@ var TEMPLATES = {
|
|
|
722
828
|
url: http://localhost:8787
|
|
723
829
|
`
|
|
724
830
|
};
|
|
725
|
-
var
|
|
726
|
-
template:
|
|
727
|
-
name:
|
|
728
|
-
},
|
|
831
|
+
var create = Command20.make("create", {
|
|
832
|
+
template: Options6.choice("template", Record.keys(TEMPLATES)).pipe(Options6.withDescription("Template to use"), Options6.withDefault("default")),
|
|
833
|
+
name: Options6.text("name").pipe(Options6.withDescription("Profile name"), Options6.optional)
|
|
834
|
+
}, Effect15.fnUntraced(function* ({ template, name }) {
|
|
729
835
|
const { json } = yield* CommandConfig14;
|
|
730
|
-
const fs = yield*
|
|
836
|
+
const fs = yield* FileSystem3.FileSystem;
|
|
731
837
|
const path = yield* Path.Path;
|
|
732
838
|
const profileName = name.pipe(Option6.getOrElse(() => template));
|
|
733
839
|
const configPath = getProfileConfigPath2(DX_CONFIG2, profileName);
|
|
@@ -744,67 +850,67 @@ var create2 = Command19.make("create", {
|
|
|
744
850
|
path: configPath
|
|
745
851
|
}, null, 2));
|
|
746
852
|
} else {
|
|
747
|
-
yield* Console14.log(
|
|
853
|
+
yield* Console14.log(print7(printProfileCreated(profileName, configPath)));
|
|
748
854
|
}
|
|
749
855
|
}));
|
|
750
856
|
|
|
751
857
|
// src/commands/profile/delete.ts
|
|
752
|
-
import * as
|
|
753
|
-
import * as
|
|
754
|
-
import * as
|
|
858
|
+
import * as Command21 from "@effect/cli/Command";
|
|
859
|
+
import * as Options7 from "@effect/cli/Options";
|
|
860
|
+
import * as FileSystem5 from "@effect/platform/FileSystem";
|
|
755
861
|
import * as Console15 from "effect/Console";
|
|
756
|
-
import * as
|
|
862
|
+
import * as Effect16 from "effect/Effect";
|
|
757
863
|
import * as Option7 from "effect/Option";
|
|
758
|
-
import { CommandConfig as CommandConfig15, print as
|
|
864
|
+
import { CommandConfig as CommandConfig15, print as print8 } from "@dxos/cli-util";
|
|
759
865
|
import { DX_CONFIG as DX_CONFIG3, getProfileConfigPath as getProfileConfigPath3 } from "@dxos/client-protocol";
|
|
760
|
-
var del =
|
|
761
|
-
name:
|
|
762
|
-
},
|
|
866
|
+
var del = Command21.make("delete", {
|
|
867
|
+
name: Options7.text("name").pipe(Options7.withDescription("Profile name"), Options7.optional)
|
|
868
|
+
}, Effect16.fnUntraced(function* ({ name }) {
|
|
763
869
|
const { json } = yield* CommandConfig15;
|
|
764
|
-
const fs = yield*
|
|
870
|
+
const fs = yield* FileSystem5.FileSystem;
|
|
765
871
|
const profileName = name.pipe(Option7.getOrElse(() => "default"));
|
|
766
872
|
const configPath = getProfileConfigPath3(DX_CONFIG3, profileName);
|
|
767
873
|
const pluginsPath = `${DX_CONFIG3}/plugins/${profileName}.yml`;
|
|
768
|
-
yield* fs.remove(configPath).pipe(
|
|
769
|
-
yield* fs.remove(pluginsPath).pipe(
|
|
874
|
+
yield* fs.remove(configPath).pipe(Effect16.ignore);
|
|
875
|
+
yield* fs.remove(pluginsPath).pipe(Effect16.ignore);
|
|
770
876
|
if (json) {
|
|
771
877
|
yield* Console15.log(JSON.stringify({
|
|
772
878
|
name: profileName,
|
|
773
879
|
deleted: true
|
|
774
880
|
}, null, 2));
|
|
775
881
|
} else {
|
|
776
|
-
yield* Console15.log(
|
|
882
|
+
yield* Console15.log(print8(printProfileDeleted(profileName)));
|
|
777
883
|
}
|
|
778
884
|
}));
|
|
779
885
|
|
|
780
886
|
// src/commands/profile/import.ts
|
|
781
|
-
import * as
|
|
782
|
-
import * as
|
|
783
|
-
import * as
|
|
784
|
-
import * as
|
|
887
|
+
import * as Command22 from "@effect/cli/Command";
|
|
888
|
+
import * as Options8 from "@effect/cli/Options";
|
|
889
|
+
import * as Prompt4 from "@effect/cli/Prompt";
|
|
890
|
+
import * as FileSystem7 from "@effect/platform/FileSystem";
|
|
785
891
|
import * as Path3 from "@effect/platform/Path";
|
|
786
892
|
import * as Console16 from "effect/Console";
|
|
787
|
-
import * as
|
|
893
|
+
import * as Effect17 from "effect/Effect";
|
|
788
894
|
import * as Option8 from "effect/Option";
|
|
789
895
|
import { CommandConfig as CommandConfig16 } from "@dxos/cli-util";
|
|
790
|
-
import { ConfigService as
|
|
896
|
+
import { ConfigService as ConfigService3 } from "@dxos/config";
|
|
791
897
|
import { log as log17 } from "@dxos/log";
|
|
792
|
-
var
|
|
793
|
-
var
|
|
898
|
+
var __dxlog_file4 = "/__w/dxos/dxos/packages/plugins/plugin-client/src/commands/profile/import.ts";
|
|
899
|
+
var handler10 = Effect17.fn(function* ({ file, dataDir, force }) {
|
|
794
900
|
const dataDirValue = Option8.getOrUndefined(dataDir);
|
|
795
901
|
const { json, profile: profile2 } = yield* CommandConfig16;
|
|
796
|
-
const fs = yield*
|
|
902
|
+
const fs = yield* FileSystem7.FileSystem;
|
|
797
903
|
const path = yield* Path3.Path;
|
|
798
|
-
const config2 = yield*
|
|
799
|
-
const { createLevel, createStorageObjects, importProfileData, decodeProfileArchive } = yield*
|
|
904
|
+
const config2 = yield* ConfigService3;
|
|
905
|
+
const { createLevel, createStorageObjects, importProfileData, decodeProfileArchive } = yield* Effect17.promise(() => import("@dxos/client-services"));
|
|
800
906
|
let storageConfig;
|
|
801
907
|
if (!dataDirValue) {
|
|
802
908
|
if (!force) {
|
|
803
909
|
yield* Console16.log(`Will overwrite profile: ${profile2}`);
|
|
804
|
-
const confirmed = yield*
|
|
910
|
+
const confirmed = yield* Prompt4.confirm({
|
|
805
911
|
message: `Delete all data? (Profile: ${profile2})`,
|
|
806
912
|
initial: false
|
|
807
|
-
}).pipe(
|
|
913
|
+
}).pipe(Prompt4.run);
|
|
808
914
|
if (!confirmed) {
|
|
809
915
|
return;
|
|
810
916
|
}
|
|
@@ -821,7 +927,7 @@ var handler11 = Effect16.fn(function* ({ file, dataDir, force }) {
|
|
|
821
927
|
if (yield* fs.exists(storageConfig.dataRoot)) {
|
|
822
928
|
log17.error("data directory already exists", {
|
|
823
929
|
path: storageConfig.dataRoot
|
|
824
|
-
}, { "~LogMeta": "~LogMeta", F:
|
|
930
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 44, S: this });
|
|
825
931
|
if (json) {
|
|
826
932
|
yield* Console16.log(JSON.stringify({
|
|
827
933
|
error: "Data directory already exists"
|
|
@@ -835,12 +941,12 @@ var handler11 = Effect16.fn(function* ({ file, dataDir, force }) {
|
|
|
835
941
|
const archive = decodeProfileArchive(data);
|
|
836
942
|
yield* Console16.log(`Importing archive with ${archive.storage.length} entries`);
|
|
837
943
|
const { storage } = createStorageObjects(storageConfig);
|
|
838
|
-
const level = yield*
|
|
944
|
+
const level = yield* Effect17.tryPromise({
|
|
839
945
|
try: () => createLevel(storageConfig),
|
|
840
946
|
catch: (error2) => new Error(`Failed to create level: ${error2}`)
|
|
841
947
|
});
|
|
842
948
|
yield* Console16.log("Beginning profile import...");
|
|
843
|
-
yield*
|
|
949
|
+
yield* Effect17.tryPromise({
|
|
844
950
|
try: () => importProfileData({
|
|
845
951
|
storage,
|
|
846
952
|
level
|
|
@@ -856,27 +962,27 @@ var handler11 = Effect16.fn(function* ({ file, dataDir, force }) {
|
|
|
856
962
|
}, null, 2));
|
|
857
963
|
}
|
|
858
964
|
});
|
|
859
|
-
var importCommand =
|
|
860
|
-
file:
|
|
861
|
-
dataDir:
|
|
862
|
-
force:
|
|
965
|
+
var importCommand = Command22.make("import", {
|
|
966
|
+
file: Options8.text("file").pipe(Options8.withDescription("Archive filename."), Options8.withAlias("f")),
|
|
967
|
+
dataDir: Options8.text("data-dir").pipe(Options8.withDescription("Storage directory."), Options8.optional),
|
|
968
|
+
force: Options8.boolean("force", {
|
|
863
969
|
ifPresent: true
|
|
864
|
-
}).pipe(
|
|
865
|
-
},
|
|
970
|
+
}).pipe(Options8.withDescription("Skip confirmation prompt."))
|
|
971
|
+
}, handler10).pipe(Command22.withDescription("Import profile."));
|
|
866
972
|
|
|
867
973
|
// src/commands/profile/inspect.ts
|
|
868
|
-
import * as
|
|
869
|
-
import * as
|
|
870
|
-
import * as
|
|
974
|
+
import * as Command23 from "@effect/cli/Command";
|
|
975
|
+
import * as Options9 from "@effect/cli/Options";
|
|
976
|
+
import * as FileSystem9 from "@effect/platform/FileSystem";
|
|
871
977
|
import * as Console17 from "effect/Console";
|
|
872
|
-
import * as
|
|
873
|
-
import { CommandConfig as CommandConfig17, FormBuilder as FormBuilder6, print as
|
|
978
|
+
import * as Effect18 from "effect/Effect";
|
|
979
|
+
import { CommandConfig as CommandConfig17, FormBuilder as FormBuilder6, print as print9 } from "@dxos/cli-util";
|
|
874
980
|
import { ProfileArchiveEntryType } from "@dxos/protocols";
|
|
875
981
|
import { arrayToBuffer } from "@dxos/util";
|
|
876
|
-
var
|
|
982
|
+
var handler11 = Effect18.fn(function* ({ file, storage }) {
|
|
877
983
|
const { json } = yield* CommandConfig17;
|
|
878
|
-
const fs = yield*
|
|
879
|
-
const { decodeProfileArchive } = yield*
|
|
984
|
+
const fs = yield* FileSystem9.FileSystem;
|
|
985
|
+
const { decodeProfileArchive } = yield* Effect18.promise(() => import("@dxos/client-services"));
|
|
880
986
|
const data = yield* fs.readFile(file);
|
|
881
987
|
const archive = decodeProfileArchive(data);
|
|
882
988
|
if (json) {
|
|
@@ -889,8 +995,8 @@ var handler12 = Effect17.fn(function* ({ file, storage }) {
|
|
|
889
995
|
} else {
|
|
890
996
|
const builder = FormBuilder6.make({
|
|
891
997
|
title: "Profile Archive"
|
|
892
|
-
}).pipe(FormBuilder6.when(archive.meta, FormBuilder6.each(Object.entries(archive.meta ?? {}), ([key,
|
|
893
|
-
yield* Console17.log(
|
|
998
|
+
}).pipe(FormBuilder6.when(archive.meta, FormBuilder6.each(Object.entries(archive.meta ?? {}), ([key, value2]) => FormBuilder6.set(key, String(value2)))), FormBuilder6.build);
|
|
999
|
+
yield* Console17.log(print9(builder));
|
|
894
1000
|
if (storage) {
|
|
895
1001
|
yield* Console17.log("\nStorage entries:\n");
|
|
896
1002
|
for (const entry of archive.storage) {
|
|
@@ -900,41 +1006,41 @@ var handler12 = Effect17.fn(function* ({ file, storage }) {
|
|
|
900
1006
|
}
|
|
901
1007
|
}
|
|
902
1008
|
});
|
|
903
|
-
var inspect =
|
|
904
|
-
file:
|
|
905
|
-
storage:
|
|
1009
|
+
var inspect = Command23.make("inspect", {
|
|
1010
|
+
file: Options9.text("file").pipe(Options9.withDescription("Archive filename."), Options9.withAlias("f")),
|
|
1011
|
+
storage: Options9.boolean("storage", {
|
|
906
1012
|
ifPresent: true
|
|
907
|
-
}).pipe(
|
|
908
|
-
},
|
|
1013
|
+
}).pipe(Options9.withDescription("List storage entries."))
|
|
1014
|
+
}, handler11).pipe(Command23.withDescription("Inspect profile archive."));
|
|
909
1015
|
|
|
910
1016
|
// src/commands/profile/list.ts
|
|
911
|
-
import * as
|
|
912
|
-
import * as
|
|
1017
|
+
import * as Command24 from "@effect/cli/Command";
|
|
1018
|
+
import * as FileSystem11 from "@effect/platform/FileSystem";
|
|
913
1019
|
import * as Path5 from "@effect/platform/Path";
|
|
914
1020
|
import * as Console18 from "effect/Console";
|
|
915
|
-
import * as
|
|
1021
|
+
import * as Effect19 from "effect/Effect";
|
|
916
1022
|
import * as Yaml2 from "yaml";
|
|
917
1023
|
import { CommandConfig as CommandConfig18, printList as printList3 } from "@dxos/cli-util";
|
|
918
1024
|
import { Config } from "@dxos/client";
|
|
919
|
-
import { DX_CONFIG as DX_CONFIG4, DX_DATA, getProfilePath } from "@dxos/client-protocol";
|
|
920
|
-
var list3 =
|
|
1025
|
+
import { DX_CONFIG as DX_CONFIG4, DX_DATA as DX_DATA2, getProfilePath as getProfilePath2 } from "@dxos/client-protocol";
|
|
1026
|
+
var list3 = Command24.make("list", {}, Effect19.fnUntraced(function* () {
|
|
921
1027
|
const { profile: currentProfile } = yield* CommandConfig18;
|
|
922
|
-
const fs = yield*
|
|
1028
|
+
const fs = yield* FileSystem11.FileSystem;
|
|
923
1029
|
const path = yield* Path5.Path;
|
|
924
1030
|
const profileDir = path.join(DX_CONFIG4, "profile");
|
|
925
1031
|
const entries = yield* fs.readDirectory(profileDir);
|
|
926
1032
|
const profileFiles = entries.filter((entry) => entry.endsWith(".yml"));
|
|
927
|
-
const profiles = yield*
|
|
1033
|
+
const profiles = yield* Effect19.forEach(profileFiles, (filename) => Effect19.gen(function* () {
|
|
928
1034
|
const name = filename.slice(0, -4);
|
|
929
1035
|
const configPath = path.join(profileDir, filename);
|
|
930
|
-
const configContent = yield* fs.readFileString(configPath).pipe(
|
|
1036
|
+
const configContent = yield* fs.readFileString(configPath).pipe(Effect19.catchTag("SystemError", () => Effect19.succeed("{}")));
|
|
931
1037
|
const configValues = Yaml2.parse(configContent) ?? {};
|
|
932
1038
|
const config2 = new Config(configValues);
|
|
933
1039
|
return {
|
|
934
1040
|
name,
|
|
935
1041
|
isCurrent: name === currentProfile,
|
|
936
1042
|
fullPath: configPath,
|
|
937
|
-
storagePath:
|
|
1043
|
+
storagePath: getProfilePath2(configValues?.runtime?.client?.storage?.dataRoot ?? DX_DATA2, name),
|
|
938
1044
|
edge: config2.values.runtime?.services?.edge?.url
|
|
939
1045
|
};
|
|
940
1046
|
}));
|
|
@@ -948,26 +1054,26 @@ var list3 = Command23.make("list", {}, Effect18.fnUntraced(function* () {
|
|
|
948
1054
|
}));
|
|
949
1055
|
|
|
950
1056
|
// src/commands/profile/reset.ts
|
|
951
|
-
import * as
|
|
952
|
-
import * as
|
|
953
|
-
import * as
|
|
954
|
-
import * as
|
|
1057
|
+
import * as Command25 from "@effect/cli/Command";
|
|
1058
|
+
import * as Options10 from "@effect/cli/Options";
|
|
1059
|
+
import * as Prompt5 from "@effect/cli/Prompt";
|
|
1060
|
+
import * as FileSystem13 from "@effect/platform/FileSystem";
|
|
955
1061
|
import * as Console19 from "effect/Console";
|
|
956
|
-
import * as
|
|
957
|
-
import { CommandConfig as CommandConfig19, print as
|
|
958
|
-
import { DX_DATA as
|
|
959
|
-
import { ConfigService as
|
|
960
|
-
var reset =
|
|
961
|
-
force:
|
|
1062
|
+
import * as Effect20 from "effect/Effect";
|
|
1063
|
+
import { CommandConfig as CommandConfig19, print as print10 } from "@dxos/cli-util";
|
|
1064
|
+
import { DX_DATA as DX_DATA3, getProfilePath as getProfilePath3 } from "@dxos/client-protocol";
|
|
1065
|
+
import { ConfigService as ConfigService4 } from "@dxos/config";
|
|
1066
|
+
var reset = Command25.make("reset", {
|
|
1067
|
+
force: Options10.boolean("force", {
|
|
962
1068
|
ifPresent: true
|
|
963
|
-
}).pipe(
|
|
964
|
-
},
|
|
965
|
-
const fs = yield*
|
|
966
|
-
const config2 = yield*
|
|
1069
|
+
}).pipe(Options10.withDescription("Skip confirmation prompt"))
|
|
1070
|
+
}, Effect20.fnUntraced(function* ({ force }) {
|
|
1071
|
+
const fs = yield* FileSystem13.FileSystem;
|
|
1072
|
+
const config2 = yield* ConfigService4;
|
|
967
1073
|
const { json, profile: profile2 } = yield* CommandConfig19;
|
|
968
|
-
const path = config2.values.runtime?.client?.storage?.dataRoot ??
|
|
1074
|
+
const path = config2.values.runtime?.client?.storage?.dataRoot ?? getProfilePath3(DX_DATA3, profile2);
|
|
969
1075
|
if (!force) {
|
|
970
|
-
const confirmed = yield*
|
|
1076
|
+
const confirmed = yield* Prompt5.confirm({
|
|
971
1077
|
message: `Are you sure you want to reset the profile (${profile2})?`,
|
|
972
1078
|
initial: false
|
|
973
1079
|
});
|
|
@@ -984,13 +1090,13 @@ var reset = Command24.make("reset", {
|
|
|
984
1090
|
reset: true
|
|
985
1091
|
}, null, 2));
|
|
986
1092
|
} else {
|
|
987
|
-
yield* Console19.log(
|
|
1093
|
+
yield* Console19.log(print10(printProfileReset(profile2)));
|
|
988
1094
|
}
|
|
989
1095
|
}));
|
|
990
1096
|
|
|
991
1097
|
// src/commands/profile/index.ts
|
|
992
|
-
var profile =
|
|
993
|
-
|
|
1098
|
+
var profile = Command26.make("profile").pipe(Command26.withDescription("Profile commands."), Command26.withSubcommands([
|
|
1099
|
+
create,
|
|
994
1100
|
del,
|
|
995
1101
|
importCommand,
|
|
996
1102
|
inspect,
|
|
@@ -999,10 +1105,11 @@ var profile = Command25.make("profile").pipe(Command25.withDescription("Profile
|
|
|
999
1105
|
]));
|
|
1000
1106
|
|
|
1001
1107
|
// src/ClientPlugin.node.ts
|
|
1002
|
-
var ClientPlugin =
|
|
1108
|
+
var ClientPlugin = Plugin.define(meta).pipe(
|
|
1003
1109
|
// TODO(wittjosiah): Could some of these commands make use of operations?
|
|
1004
1110
|
AppPlugin.addCommandModule({
|
|
1005
1111
|
commands: [
|
|
1112
|
+
account,
|
|
1006
1113
|
config,
|
|
1007
1114
|
device,
|
|
1008
1115
|
edge,
|
|
@@ -1013,7 +1120,7 @@ var ClientPlugin = Plugin2.define(meta).pipe(
|
|
|
1013
1120
|
AppPlugin.addOperationHandlerModule({
|
|
1014
1121
|
activate: OperationHandler
|
|
1015
1122
|
}),
|
|
1016
|
-
|
|
1123
|
+
Plugin.addModule((options) => ({
|
|
1017
1124
|
id: Capability.getModuleTag(Client),
|
|
1018
1125
|
activatesOn: ActivationEvents.Startup,
|
|
1019
1126
|
firesAfterActivation: [
|
|
@@ -1021,25 +1128,25 @@ var ClientPlugin = Plugin2.define(meta).pipe(
|
|
|
1021
1128
|
],
|
|
1022
1129
|
activate: () => Client(options)
|
|
1023
1130
|
})),
|
|
1024
|
-
|
|
1131
|
+
Plugin.addModule({
|
|
1025
1132
|
activatesOn: ClientEvents.ClientReady,
|
|
1026
1133
|
firesBeforeActivation: [
|
|
1027
1134
|
AppActivationEvents.SetupSchema
|
|
1028
1135
|
],
|
|
1029
1136
|
activate: SchemaDefs
|
|
1030
1137
|
}),
|
|
1031
|
-
|
|
1138
|
+
Plugin.addModule({
|
|
1032
1139
|
activatesOn: ClientEvents.ClientReady,
|
|
1033
1140
|
firesBeforeActivation: [
|
|
1034
1141
|
ClientEvents.SetupMigration
|
|
1035
1142
|
],
|
|
1036
1143
|
activate: Migrations
|
|
1037
1144
|
}),
|
|
1038
|
-
|
|
1145
|
+
Plugin.addModule({
|
|
1039
1146
|
activatesOn: ActivationEvents.SetupProcessManager,
|
|
1040
1147
|
activate: LayerSpecs
|
|
1041
1148
|
}),
|
|
1042
|
-
|
|
1149
|
+
Plugin.make
|
|
1043
1150
|
);
|
|
1044
1151
|
var ClientPlugin_node_default = ClientPlugin;
|
|
1045
1152
|
export {
|