@dxos/plugin-client 0.7.4 → 0.7.5-main.937ce75
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/browser/chunk-52IJQ35F.mjs +78 -0
- package/dist/lib/browser/chunk-52IJQ35F.mjs.map +7 -0
- package/dist/lib/browser/chunk-X4QUPYC6.mjs +12 -0
- package/dist/lib/browser/chunk-X4QUPYC6.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +163 -221
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +1 -5
- package/dist/lib/browser/types.mjs +10 -0
- package/dist/lib/browser/types.mjs.map +7 -0
- package/dist/lib/node/chunk-NFO3ADQC.cjs +98 -0
- package/dist/lib/node/chunk-NFO3ADQC.cjs.map +7 -0
- package/dist/lib/node/chunk-RUA5KXVW.cjs +35 -0
- package/dist/lib/node/chunk-RUA5KXVW.cjs.map +7 -0
- package/dist/lib/node/index.cjs +165 -224
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.cjs +4 -8
- package/dist/lib/node/meta.cjs.map +2 -2
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types.cjs +32 -0
- package/dist/lib/node/types.cjs.map +7 -0
- package/dist/lib/node-esm/chunk-GMGRQ5Q7.mjs +14 -0
- package/dist/lib/node-esm/chunk-GMGRQ5Q7.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-TI4GNGMM.mjs +79 -0
- package/dist/lib/node-esm/chunk-TI4GNGMM.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +163 -221
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/meta.mjs +1 -5
- package/dist/lib/node-esm/types.mjs +11 -0
- package/dist/lib/node-esm/types.mjs.map +7 -0
- package/dist/types/src/ClientPlugin.d.ts +2 -35
- package/dist/types/src/ClientPlugin.d.ts.map +1 -1
- package/dist/types/src/components/IdentityDialog.d.ts +1 -0
- package/dist/types/src/components/IdentityDialog.d.ts.map +1 -1
- package/dist/types/src/components/JoinDialog.d.ts +1 -0
- package/dist/types/src/components/JoinDialog.d.ts.map +1 -1
- package/dist/types/src/components/RecoveryCodeDialog.d.ts +1 -0
- package/dist/types/src/components/RecoveryCodeDialog.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +0 -10
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +110 -0
- package/dist/types/src/types.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +22 -13
- package/src/ClientPlugin.tsx +111 -200
- package/src/components/IdentityDialog.tsx +13 -11
- package/src/components/JoinDialog.tsx +13 -19
- package/src/components/RecoveryCodeDialog.tsx +3 -1
- package/src/meta.ts +0 -14
- package/src/types.ts +115 -0
- package/dist/lib/browser/chunk-FGUXUNOK.mjs +0 -26
- package/dist/lib/browser/chunk-FGUXUNOK.mjs.map +0 -7
- package/dist/lib/node/chunk-XYLDQWFV.cjs +0 -51
- package/dist/lib/node/chunk-XYLDQWFV.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-C6X363FK.mjs +0 -28
- package/dist/lib/node-esm/chunk-C6X363FK.mjs.map +0 -7
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CLIENT_PLUGIN
|
|
3
|
+
} from "./chunk-X4QUPYC6.mjs";
|
|
4
|
+
|
|
5
|
+
// packages/plugins/plugin-client/src/types.ts
|
|
6
|
+
import { S } from "@dxos/echo-schema";
|
|
7
|
+
import { Client, PublicKey } from "@dxos/react-client";
|
|
8
|
+
var IdentitySchema = S.Struct({
|
|
9
|
+
identityKey: S.instanceOf(PublicKey),
|
|
10
|
+
spaceKey: S.optional(S.instanceOf(PublicKey)),
|
|
11
|
+
profile: S.optional(S.Struct({
|
|
12
|
+
displayName: S.optional(S.String),
|
|
13
|
+
avatarCid: S.optional(S.String),
|
|
14
|
+
data: S.optional(S.Record({
|
|
15
|
+
key: S.String,
|
|
16
|
+
value: S.Any
|
|
17
|
+
}))
|
|
18
|
+
}))
|
|
19
|
+
});
|
|
20
|
+
var CLIENT_ACTION = `${CLIENT_PLUGIN}/action`;
|
|
21
|
+
var ClientAction;
|
|
22
|
+
(function(ClientAction2) {
|
|
23
|
+
class CreateIdentity extends S.TaggedClass()(`${CLIENT_ACTION}/create-identity`, {
|
|
24
|
+
input: S.Struct({
|
|
25
|
+
displayName: S.optional(S.String)
|
|
26
|
+
}),
|
|
27
|
+
output: IdentitySchema
|
|
28
|
+
}) {
|
|
29
|
+
}
|
|
30
|
+
ClientAction2.CreateIdentity = CreateIdentity;
|
|
31
|
+
class JoinIdentity extends S.TaggedClass()(`${CLIENT_ACTION}/join-identity`, {
|
|
32
|
+
input: S.Struct({
|
|
33
|
+
invitationCode: S.String
|
|
34
|
+
}),
|
|
35
|
+
output: S.Void
|
|
36
|
+
}) {
|
|
37
|
+
}
|
|
38
|
+
ClientAction2.JoinIdentity = JoinIdentity;
|
|
39
|
+
class ShareIdentity extends S.TaggedClass()(`${CLIENT_ACTION}/share-identity`, {
|
|
40
|
+
input: S.Void,
|
|
41
|
+
output: S.Void
|
|
42
|
+
}) {
|
|
43
|
+
}
|
|
44
|
+
ClientAction2.ShareIdentity = ShareIdentity;
|
|
45
|
+
class RecoverIdentity extends S.TaggedClass()(`${CLIENT_ACTION}/recover-identity`, {
|
|
46
|
+
input: S.Void,
|
|
47
|
+
output: S.Void
|
|
48
|
+
}) {
|
|
49
|
+
}
|
|
50
|
+
ClientAction2.RecoverIdentity = RecoverIdentity;
|
|
51
|
+
class ResetStorage extends S.TaggedClass()(`${CLIENT_ACTION}/reset-storage`, {
|
|
52
|
+
input: S.Struct({
|
|
53
|
+
target: S.optional(S.String)
|
|
54
|
+
}),
|
|
55
|
+
output: S.Void
|
|
56
|
+
}) {
|
|
57
|
+
}
|
|
58
|
+
ClientAction2.ResetStorage = ResetStorage;
|
|
59
|
+
class CreateAgent extends S.TaggedClass()(`${CLIENT_ACTION}/create-agent`, {
|
|
60
|
+
input: S.Void,
|
|
61
|
+
output: S.Void
|
|
62
|
+
}) {
|
|
63
|
+
}
|
|
64
|
+
ClientAction2.CreateAgent = CreateAgent;
|
|
65
|
+
class CreateRecoveryCode extends S.TaggedClass()(`${CLIENT_ACTION}/create-recovery-code`, {
|
|
66
|
+
input: S.Void,
|
|
67
|
+
output: S.Void
|
|
68
|
+
}) {
|
|
69
|
+
}
|
|
70
|
+
ClientAction2.CreateRecoveryCode = CreateRecoveryCode;
|
|
71
|
+
})(ClientAction || (ClientAction = {}));
|
|
72
|
+
var parseClientPlugin = (plugin) => (plugin?.provides).client instanceof Client ? plugin : void 0;
|
|
73
|
+
|
|
74
|
+
export {
|
|
75
|
+
ClientAction,
|
|
76
|
+
parseClientPlugin
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=chunk-52IJQ35F.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/types.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport {\n type GraphBuilderProvides,\n type IntentResolverProvides,\n type Plugin,\n type SurfaceProvides,\n type TranslationsProvides,\n} from '@dxos/app-framework';\nimport { S } from '@dxos/echo-schema';\nimport { Client, PublicKey, type ClientOptions } from '@dxos/react-client';\n\nimport { CLIENT_PLUGIN } from './meta';\n\n// TODO(wittjosiah): Factor out. Generate?\nconst IdentitySchema = S.Struct({\n identityKey: S.instanceOf(PublicKey),\n spaceKey: S.optional(S.instanceOf(PublicKey)),\n profile: S.optional(\n S.Struct({\n displayName: S.optional(S.String),\n avatarCid: S.optional(S.String),\n data: S.optional(S.Record({ key: S.String, value: S.Any })),\n }),\n ),\n});\n\nconst CLIENT_ACTION = `${CLIENT_PLUGIN}/action`;\nexport namespace ClientAction {\n export class CreateIdentity extends S.TaggedClass<CreateIdentity>()(`${CLIENT_ACTION}/create-identity`, {\n input: S.Struct({\n displayName: S.optional(S.String),\n }),\n output: IdentitySchema,\n }) {}\n\n export class JoinIdentity extends S.TaggedClass<JoinIdentity>()(`${CLIENT_ACTION}/join-identity`, {\n input: S.Struct({\n invitationCode: S.String,\n }),\n output: S.Void,\n }) {}\n\n export class ShareIdentity extends S.TaggedClass<ShareIdentity>()(`${CLIENT_ACTION}/share-identity`, {\n input: S.Void,\n output: S.Void,\n }) {}\n\n export class RecoverIdentity extends S.TaggedClass<RecoverIdentity>()(`${CLIENT_ACTION}/recover-identity`, {\n input: S.Void,\n output: S.Void,\n }) {}\n\n export class ResetStorage extends S.TaggedClass<ResetStorage>()(`${CLIENT_ACTION}/reset-storage`, {\n input: S.Struct({\n target: S.optional(S.String),\n }),\n output: S.Void,\n }) {}\n\n export class CreateAgent extends S.TaggedClass<CreateAgent>()(`${CLIENT_ACTION}/create-agent`, {\n input: S.Void,\n output: S.Void,\n }) {}\n\n export class CreateRecoveryCode extends S.TaggedClass<CreateRecoveryCode>()(`${CLIENT_ACTION}/create-recovery-code`, {\n input: S.Void,\n output: S.Void,\n }) {}\n}\n\nexport type ClientPluginOptions = ClientOptions & {\n /**\n * Used to track app-specific state in spaces.\n */\n appKey: string;\n\n /**\n * Base URL for the invitation link.\n */\n invitationUrl?: string;\n\n /**\n * Query parameter for the invitation code.\n */\n invitationParam?: string;\n\n /**\n * Run after the client has been initialized.\n */\n onClientInitialized?: (client: Client) => Promise<void>;\n\n /**\n * Run after the identity has been successfully initialized.\n * Run with client during plugin ready phase.\n */\n onReady?: (client: Client, plugins: Plugin[]) => Promise<void>;\n\n /**\n * Called when the client is reset.\n */\n onReset?: (params: { target?: string }) => Promise<void>;\n};\n\nexport type ClientPluginProvides = IntentResolverProvides &\n GraphBuilderProvides &\n SurfaceProvides &\n TranslationsProvides & {\n client: Client;\n };\n\nexport const parseClientPlugin = (plugin?: Plugin) =>\n (plugin?.provides as any).client instanceof Client ? (plugin as Plugin<ClientPluginProvides>) : undefined;\n"],
|
|
5
|
+
"mappings": ";;;;;AAWA,SAASA,SAAS;AAClB,SAASC,QAAQC,iBAAqC;AAKtD,IAAMC,iBAAiBC,EAAEC,OAAO;EAC9BC,aAAaF,EAAEG,WAAWC,SAAAA;EAC1BC,UAAUL,EAAEM,SAASN,EAAEG,WAAWC,SAAAA,CAAAA;EAClCG,SAASP,EAAEM,SACTN,EAAEC,OAAO;IACPO,aAAaR,EAAEM,SAASN,EAAES,MAAM;IAChCC,WAAWV,EAAEM,SAASN,EAAES,MAAM;IAC9BE,MAAMX,EAAEM,SAASN,EAAEY,OAAO;MAAEC,KAAKb,EAAES;MAAQK,OAAOd,EAAEe;IAAI,CAAA,CAAA;EAC1D,CAAA,CAAA;AAEJ,CAAA;AAEA,IAAMC,gBAAgB,GAAGC,aAAAA;;UACRC,eAAAA;EACR,MAAMC,uBAAuBnB,EAAEoB,YAAW,EAAmB,GAAGJ,aAAAA,oBAAiC;IACtGK,OAAOrB,EAAEC,OAAO;MACdO,aAAaR,EAAEM,SAASN,EAAES,MAAM;IAClC,CAAA;IACAa,QAAQvB;EACV,CAAA,EAAA;EAAI;gBALSoB,iBAAAA;EAON,MAAMI,qBAAqBvB,EAAEoB,YAAW,EAAiB,GAAGJ,aAAAA,kBAA+B;IAChGK,OAAOrB,EAAEC,OAAO;MACduB,gBAAgBxB,EAAES;IACpB,CAAA;IACAa,QAAQtB,EAAEyB;EACZ,CAAA,EAAA;EAAI;gBALSF,eAAAA;EAON,MAAMG,sBAAsB1B,EAAEoB,YAAW,EAAkB,GAAGJ,aAAAA,mBAAgC;IACnGK,OAAOrB,EAAEyB;IACTH,QAAQtB,EAAEyB;EACZ,CAAA,EAAA;EAAI;gBAHSC,gBAAAA;EAKN,MAAMC,wBAAwB3B,EAAEoB,YAAW,EAAoB,GAAGJ,aAAAA,qBAAkC;IACzGK,OAAOrB,EAAEyB;IACTH,QAAQtB,EAAEyB;EACZ,CAAA,EAAA;EAAI;gBAHSE,kBAAAA;EAKN,MAAMC,qBAAqB5B,EAAEoB,YAAW,EAAiB,GAAGJ,aAAAA,kBAA+B;IAChGK,OAAOrB,EAAEC,OAAO;MACd4B,QAAQ7B,EAAEM,SAASN,EAAES,MAAM;IAC7B,CAAA;IACAa,QAAQtB,EAAEyB;EACZ,CAAA,EAAA;EAAI;gBALSG,eAAAA;EAON,MAAME,oBAAoB9B,EAAEoB,YAAW,EAAgB,GAAGJ,aAAAA,iBAA8B;IAC7FK,OAAOrB,EAAEyB;IACTH,QAAQtB,EAAEyB;EACZ,CAAA,EAAA;EAAI;gBAHSK,cAAAA;EAKN,MAAMC,2BAA2B/B,EAAEoB,YAAW,EAAuB,GAAGJ,aAAAA,yBAAsC;IACnHK,OAAOrB,EAAEyB;IACTH,QAAQtB,EAAEyB;EACZ,CAAA,EAAA;EAAI;gBAHSM,qBAAAA;AAIf,GAzCiBb,iBAAAA,eAAAA,CAAAA,EAAAA;AAmFV,IAAMc,oBAAoB,CAACC,YAC/BA,QAAQC,UAAiBC,kBAAkBC,SAAUH,SAA0CI;",
|
|
6
|
+
"names": ["S", "Client", "PublicKey", "IdentitySchema", "S", "Struct", "identityKey", "instanceOf", "PublicKey", "spaceKey", "optional", "profile", "displayName", "String", "avatarCid", "data", "Record", "key", "value", "Any", "CLIENT_ACTION", "CLIENT_PLUGIN", "ClientAction", "CreateIdentity", "TaggedClass", "input", "output", "JoinIdentity", "invitationCode", "Void", "ShareIdentity", "RecoverIdentity", "ResetStorage", "target", "CreateAgent", "CreateRecoveryCode", "parseClientPlugin", "plugin", "provides", "client", "Client", "undefined"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// packages/plugins/plugin-client/src/meta.ts
|
|
2
|
+
var CLIENT_PLUGIN = "dxos.org/plugin/client";
|
|
3
|
+
var meta_default = {
|
|
4
|
+
id: CLIENT_PLUGIN,
|
|
5
|
+
name: "Client"
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
CLIENT_PLUGIN,
|
|
10
|
+
meta_default
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=chunk-X4QUPYC6.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/meta.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const CLIENT_PLUGIN = 'dxos.org/plugin/client';\n\nexport default {\n id: CLIENT_PLUGIN,\n name: 'Client',\n} satisfies PluginMeta;\n"],
|
|
5
|
+
"mappings": ";AAMO,IAAMA,gBAAgB;AAE7B,IAAA,eAAe;EACbC,IAAID;EACJE,MAAM;AACR;",
|
|
6
|
+
"names": ["CLIENT_PLUGIN", "id", "name"]
|
|
7
|
+
}
|
|
@@ -1,64 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ClientAction
|
|
3
|
+
} from "./chunk-52IJQ35F.mjs";
|
|
1
4
|
import {
|
|
2
5
|
CLIENT_PLUGIN,
|
|
3
|
-
ClientAction,
|
|
4
|
-
OBSERVABILITY_ACTION,
|
|
5
6
|
meta_default
|
|
6
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-X4QUPYC6.mjs";
|
|
7
8
|
|
|
8
9
|
// packages/plugins/plugin-client/src/ClientPlugin.tsx
|
|
9
10
|
import React4 from "react";
|
|
10
|
-
import { LayoutAction as LayoutAction3, parseIntentPlugin, resolvePlugin } from "@dxos/app-framework";
|
|
11
|
+
import { LayoutAction as LayoutAction3, parseIntentPlugin, resolvePlugin, createSurface, createIntent as createIntent3, createResolver } from "@dxos/app-framework";
|
|
11
12
|
import { Config, Defaults, Envs, Local, Storage } from "@dxos/config";
|
|
12
13
|
import { registerSignalsRuntime } from "@dxos/echo-signals/react";
|
|
13
14
|
import { invariant } from "@dxos/invariant";
|
|
14
15
|
import { createExtension } from "@dxos/plugin-graph";
|
|
16
|
+
import { ObservabilityAction as ObservabilityAction2 } from "@dxos/plugin-observability/types";
|
|
15
17
|
import { Client, ClientProvider } from "@dxos/react-client";
|
|
16
18
|
|
|
17
19
|
// packages/plugins/plugin-client/src/components/IdentityDialog.tsx
|
|
18
20
|
import React, { useCallback } from "react";
|
|
19
|
-
import { LayoutAction, useIntentDispatcher } from "@dxos/app-framework";
|
|
21
|
+
import { createIntent, LayoutAction, useIntentDispatcher } from "@dxos/app-framework";
|
|
20
22
|
import { useClient } from "@dxos/react-client";
|
|
21
23
|
import { Clipboard, Dialog } from "@dxos/react-ui";
|
|
22
24
|
import { IdentityPanel } from "@dxos/shell/react";
|
|
25
|
+
var IDENTITY_DIALOG = `${CLIENT_PLUGIN}/IdentityDialog`;
|
|
23
26
|
var IdentityDialog = (props) => {
|
|
24
|
-
const dispatch = useIntentDispatcher();
|
|
27
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
25
28
|
const client = useClient();
|
|
26
|
-
const handleDone = useCallback(() => dispatch({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
state: false
|
|
31
|
-
}
|
|
32
|
-
}), [
|
|
29
|
+
const handleDone = useCallback(() => dispatch(createIntent(LayoutAction.SetLayout, {
|
|
30
|
+
element: "dialog",
|
|
31
|
+
state: false
|
|
32
|
+
})), [
|
|
33
33
|
dispatch
|
|
34
34
|
]);
|
|
35
35
|
const handleResetStorage = useCallback(async () => {
|
|
36
36
|
await client.reset();
|
|
37
|
-
await dispatch(
|
|
38
|
-
action: ClientAction.RESET_STORAGE
|
|
39
|
-
});
|
|
37
|
+
await dispatch(createIntent(ClientAction.ResetStorage));
|
|
40
38
|
}, [
|
|
41
39
|
dispatch
|
|
42
40
|
]);
|
|
43
41
|
const handleRecover = useCallback(async () => {
|
|
44
42
|
await client.reset();
|
|
45
|
-
await dispatch({
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
target: "recoverIdentity"
|
|
49
|
-
}
|
|
50
|
-
});
|
|
43
|
+
await dispatch(createIntent(ClientAction.ResetStorage, {
|
|
44
|
+
target: "recoverIdentity"
|
|
45
|
+
}));
|
|
51
46
|
}, [
|
|
52
47
|
dispatch
|
|
53
48
|
]);
|
|
54
49
|
const handleJoinNewIdentity = useCallback(async () => {
|
|
55
50
|
await client.reset();
|
|
56
|
-
await dispatch({
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
target: "deviceInvitation"
|
|
60
|
-
}
|
|
61
|
-
});
|
|
51
|
+
await dispatch(createIntent(ClientAction.ResetStorage, {
|
|
52
|
+
target: "deviceInvitation"
|
|
53
|
+
}));
|
|
62
54
|
}, [
|
|
63
55
|
dispatch
|
|
64
56
|
]);
|
|
@@ -76,33 +68,26 @@ var IdentityDialog = (props) => {
|
|
|
76
68
|
|
|
77
69
|
// packages/plugins/plugin-client/src/components/JoinDialog.tsx
|
|
78
70
|
import React2, { useCallback as useCallback2 } from "react";
|
|
79
|
-
import { LayoutAction as LayoutAction2, useIntentDispatcher as useIntentDispatcher2 } from "@dxos/app-framework";
|
|
71
|
+
import { createIntent as createIntent2, LayoutAction as LayoutAction2, useIntentDispatcher as useIntentDispatcher2 } from "@dxos/app-framework";
|
|
72
|
+
import { ObservabilityAction } from "@dxos/plugin-observability/types";
|
|
80
73
|
import { Dialog as Dialog2 } from "@dxos/react-ui";
|
|
81
74
|
import { JoinPanel } from "@dxos/shell/react";
|
|
75
|
+
var JOIN_DIALOG = `${CLIENT_PLUGIN}/JoinDialog`;
|
|
82
76
|
var JoinDialog = (props) => {
|
|
83
|
-
const dispatch = useIntentDispatcher2();
|
|
84
|
-
const handleCancelResetStorage = useCallback2(() => dispatch(
|
|
85
|
-
plugin: CLIENT_PLUGIN,
|
|
86
|
-
action: ClientAction.SHARE_IDENTITY
|
|
87
|
-
}), [
|
|
77
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher2();
|
|
78
|
+
const handleCancelResetStorage = useCallback2(() => dispatch(createIntent2(ClientAction.ShareIdentity)), [
|
|
88
79
|
dispatch
|
|
89
80
|
]);
|
|
90
81
|
const handleDone = useCallback2(async (result) => {
|
|
91
82
|
if (result?.identityKey) {
|
|
92
83
|
await Promise.all([
|
|
93
|
-
dispatch({
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
})
|
|
100
|
-
dispatch({
|
|
101
|
-
action: OBSERVABILITY_ACTION,
|
|
102
|
-
data: {
|
|
103
|
-
name: props.initialDisposition === "recover-identity" ? "identity.recover" : "identity.join"
|
|
104
|
-
}
|
|
105
|
-
})
|
|
84
|
+
dispatch(createIntent2(LayoutAction2.SetLayout, {
|
|
85
|
+
element: "dialog",
|
|
86
|
+
state: false
|
|
87
|
+
})),
|
|
88
|
+
dispatch(createIntent2(ObservabilityAction.SendEvent, {
|
|
89
|
+
name: props.initialDisposition === "recover-identity" ? "identity.recover" : "identity.join"
|
|
90
|
+
}))
|
|
106
91
|
]);
|
|
107
92
|
}
|
|
108
93
|
}, [
|
|
@@ -125,15 +110,14 @@ var JoinDialog = (props) => {
|
|
|
125
110
|
// packages/plugins/plugin-client/src/components/RecoveryCodeDialog.tsx
|
|
126
111
|
import React3, { useCallback as useCallback3, useState } from "react";
|
|
127
112
|
import { AlertDialog, Button, Clipboard as Clipboard2, Input, useTranslation } from "@dxos/react-ui";
|
|
113
|
+
var RECOVER_CODE_DIALOG = `${CLIENT_PLUGIN}/RecoveryCodeDialog`;
|
|
128
114
|
var RecoveryCodeDialog = ({ code }) => {
|
|
129
115
|
const { t } = useTranslation(CLIENT_PLUGIN);
|
|
130
116
|
const [confirmation, setConfirmation] = useState(false);
|
|
131
117
|
const handleConfirmation = useCallback3((checked) => setConfirmation(checked), []);
|
|
132
118
|
return /* @__PURE__ */ React3.createElement(AlertDialog.Content, {
|
|
133
119
|
classNames: "bs-content min-bs-[15rem] max-bs-full md:max-is-[40rem] overflow-hidden"
|
|
134
|
-
}, /* @__PURE__ */ React3.createElement(AlertDialog.Title, {
|
|
135
|
-
classNames: ""
|
|
136
|
-
}, t("recovery code dialog title")), /* @__PURE__ */ React3.createElement("p", {
|
|
120
|
+
}, /* @__PURE__ */ React3.createElement(AlertDialog.Title, null, t("recovery code dialog title")), /* @__PURE__ */ React3.createElement("p", {
|
|
137
121
|
className: "py-4"
|
|
138
122
|
}, t("recovery code dialog description")), /* @__PURE__ */ React3.createElement(Clipboard2.Provider, null, /* @__PURE__ */ React3.createElement(Code, {
|
|
139
123
|
code
|
|
@@ -193,7 +177,6 @@ var translations_default = [
|
|
|
193
177
|
|
|
194
178
|
// packages/plugins/plugin-client/src/ClientPlugin.tsx
|
|
195
179
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-client/src/ClientPlugin.tsx";
|
|
196
|
-
var parseClientPlugin = (plugin) => (plugin?.provides).client instanceof Client ? plugin : void 0;
|
|
197
180
|
var ClientPlugin = ({ appKey, invitationUrl = window.location.origin, invitationParam = "deviceInvitationCode", onClientInitialized, onReady, onReset, ...options }) => {
|
|
198
181
|
registerSignalsRuntime();
|
|
199
182
|
let client;
|
|
@@ -231,7 +214,7 @@ var ClientPlugin = ({ appKey, invitationUrl = window.location.origin, invitation
|
|
|
231
214
|
}, children)
|
|
232
215
|
};
|
|
233
216
|
},
|
|
234
|
-
ready: async (plugins) => {
|
|
217
|
+
ready: async ({ plugins }) => {
|
|
235
218
|
if (error) {
|
|
236
219
|
throw error;
|
|
237
220
|
}
|
|
@@ -243,27 +226,33 @@ var ClientPlugin = ({ appKey, invitationUrl = window.location.origin, invitation
|
|
|
243
226
|
provides: {
|
|
244
227
|
translations: translations_default,
|
|
245
228
|
surface: {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
229
|
+
definitions: () => [
|
|
230
|
+
createSurface({
|
|
231
|
+
id: IDENTITY_DIALOG,
|
|
232
|
+
role: "dialog",
|
|
233
|
+
filter: (data) => data.component === IDENTITY_DIALOG,
|
|
234
|
+
component: ({ data }) => /* @__PURE__ */ React4.createElement(IdentityDialog, {
|
|
235
|
+
...data.subject,
|
|
236
|
+
createInvitationUrl: createDeviceInvitationUrl
|
|
237
|
+
})
|
|
238
|
+
}),
|
|
239
|
+
createSurface({
|
|
240
|
+
id: JOIN_DIALOG,
|
|
241
|
+
role: "dialog",
|
|
242
|
+
filter: (data) => data.component === JOIN_DIALOG,
|
|
243
|
+
component: ({ data }) => /* @__PURE__ */ React4.createElement(JoinDialog, data.subject)
|
|
244
|
+
}),
|
|
245
|
+
createSurface({
|
|
246
|
+
id: RECOVER_CODE_DIALOG,
|
|
247
|
+
role: "dialog",
|
|
248
|
+
filter: (data) => data.component === RECOVER_CODE_DIALOG,
|
|
249
|
+
component: ({ data }) => /* @__PURE__ */ React4.createElement(RecoveryCodeDialog, data.subject)
|
|
250
|
+
})
|
|
251
|
+
]
|
|
263
252
|
},
|
|
264
253
|
graph: {
|
|
265
254
|
builder: (plugins) => {
|
|
266
|
-
const
|
|
255
|
+
const dispatch = resolvePlugin(plugins, parseIntentPlugin)?.provides.intent.dispatchPromise;
|
|
267
256
|
const id = `${CLIENT_PLUGIN}/open-shell`;
|
|
268
257
|
return createExtension({
|
|
269
258
|
id: CLIENT_PLUGIN,
|
|
@@ -272,12 +261,7 @@ var ClientPlugin = ({ appKey, invitationUrl = window.location.origin, invitation
|
|
|
272
261
|
{
|
|
273
262
|
id,
|
|
274
263
|
data: async () => {
|
|
275
|
-
await
|
|
276
|
-
{
|
|
277
|
-
plugin: CLIENT_PLUGIN,
|
|
278
|
-
action: ClientAction.SHARE_IDENTITY
|
|
279
|
-
}
|
|
280
|
-
]);
|
|
264
|
+
await dispatch?.(createIntent3(ClientAction.ShareIdentity));
|
|
281
265
|
},
|
|
282
266
|
properties: {
|
|
283
267
|
label: [
|
|
@@ -301,149 +285,108 @@ var ClientPlugin = ({ appKey, invitationUrl = window.location.origin, invitation
|
|
|
301
285
|
}
|
|
302
286
|
},
|
|
303
287
|
intent: {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
await client.services.services.EdgeAgentService.createAgent(null, {
|
|
407
|
-
timeout: 1e4
|
|
408
|
-
});
|
|
409
|
-
return {
|
|
410
|
-
data: true
|
|
411
|
-
};
|
|
412
|
-
}
|
|
413
|
-
case ClientAction.CREATE_RECOVERY_CODE: {
|
|
414
|
-
invariant(client.services.services.IdentityService, "IdentityService not available", {
|
|
415
|
-
F: __dxlog_file,
|
|
416
|
-
L: 289,
|
|
417
|
-
S: void 0,
|
|
418
|
-
A: [
|
|
419
|
-
"client.services.services.IdentityService",
|
|
420
|
-
"'IdentityService not available'"
|
|
421
|
-
]
|
|
422
|
-
});
|
|
423
|
-
const { seedphrase } = await client.services.services.IdentityService.createRecoveryPhrase();
|
|
424
|
-
return {
|
|
425
|
-
data: true,
|
|
426
|
-
intents: [
|
|
427
|
-
[
|
|
428
|
-
{
|
|
429
|
-
action: LayoutAction3.SET_LAYOUT,
|
|
430
|
-
data: {
|
|
431
|
-
element: "dialog",
|
|
432
|
-
dialogBlockAlign: "start",
|
|
433
|
-
dialogType: "alert",
|
|
434
|
-
state: true,
|
|
435
|
-
component: "dxos.org/plugin/client/RecoveryCodeDialog",
|
|
436
|
-
subject: {
|
|
437
|
-
code: seedphrase
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
]
|
|
442
|
-
]
|
|
443
|
-
};
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
}
|
|
288
|
+
resolvers: () => [
|
|
289
|
+
createResolver(ClientAction.CreateIdentity, async () => {
|
|
290
|
+
const data = await client.halo.createIdentity();
|
|
291
|
+
return {
|
|
292
|
+
data,
|
|
293
|
+
intents: [
|
|
294
|
+
createIntent3(ObservabilityAction2.SendEvent, {
|
|
295
|
+
name: "identity.create"
|
|
296
|
+
})
|
|
297
|
+
]
|
|
298
|
+
};
|
|
299
|
+
}),
|
|
300
|
+
createResolver(ClientAction.JoinIdentity, async (data) => {
|
|
301
|
+
return {
|
|
302
|
+
intents: [
|
|
303
|
+
createIntent3(LayoutAction3.SetLayout, {
|
|
304
|
+
element: "dialog",
|
|
305
|
+
component: JOIN_DIALOG,
|
|
306
|
+
dialogBlockAlign: "start",
|
|
307
|
+
subject: {
|
|
308
|
+
initialInvitationCode: data.invitationCode,
|
|
309
|
+
initialDisposition: "accept-halo-invitation"
|
|
310
|
+
}
|
|
311
|
+
})
|
|
312
|
+
]
|
|
313
|
+
};
|
|
314
|
+
}),
|
|
315
|
+
createResolver(ClientAction.ShareIdentity, async () => {
|
|
316
|
+
return {
|
|
317
|
+
intents: [
|
|
318
|
+
createIntent3(LayoutAction3.SetLayout, {
|
|
319
|
+
element: "dialog",
|
|
320
|
+
component: IDENTITY_DIALOG,
|
|
321
|
+
dialogBlockAlign: "start"
|
|
322
|
+
}),
|
|
323
|
+
createIntent3(ObservabilityAction2.SendEvent, {
|
|
324
|
+
name: "identity.share"
|
|
325
|
+
})
|
|
326
|
+
]
|
|
327
|
+
};
|
|
328
|
+
}),
|
|
329
|
+
createResolver(ClientAction.RecoverIdentity, async () => {
|
|
330
|
+
return {
|
|
331
|
+
intents: [
|
|
332
|
+
createIntent3(LayoutAction3.SetLayout, {
|
|
333
|
+
element: "dialog",
|
|
334
|
+
component: JOIN_DIALOG,
|
|
335
|
+
dialogBlockAlign: "start",
|
|
336
|
+
subject: {
|
|
337
|
+
initialDisposition: "recover-identity"
|
|
338
|
+
}
|
|
339
|
+
})
|
|
340
|
+
]
|
|
341
|
+
};
|
|
342
|
+
}),
|
|
343
|
+
createResolver(ClientAction.ResetStorage, async (data) => {
|
|
344
|
+
await onReset?.({
|
|
345
|
+
target: data.target
|
|
346
|
+
});
|
|
347
|
+
return {};
|
|
348
|
+
}),
|
|
349
|
+
createResolver(ClientAction.CreateAgent, async () => {
|
|
350
|
+
invariant(client.services.services.EdgeAgentService, "Missing EdgeAgentService", {
|
|
351
|
+
F: __dxlog_file,
|
|
352
|
+
L: 203,
|
|
353
|
+
S: void 0,
|
|
354
|
+
A: [
|
|
355
|
+
"client.services.services.EdgeAgentService",
|
|
356
|
+
"'Missing EdgeAgentService'"
|
|
357
|
+
]
|
|
358
|
+
});
|
|
359
|
+
await client.services.services.EdgeAgentService.createAgent(null, {
|
|
360
|
+
timeout: 1e4
|
|
361
|
+
});
|
|
362
|
+
}),
|
|
363
|
+
createResolver(ClientAction.CreateRecoveryCode, async () => {
|
|
364
|
+
invariant(client.services.services.IdentityService, "IdentityService not available", {
|
|
365
|
+
F: __dxlog_file,
|
|
366
|
+
L: 207,
|
|
367
|
+
S: void 0,
|
|
368
|
+
A: [
|
|
369
|
+
"client.services.services.IdentityService",
|
|
370
|
+
"'IdentityService not available'"
|
|
371
|
+
]
|
|
372
|
+
});
|
|
373
|
+
const { seedphrase } = await client.services.services.IdentityService.createRecoveryPhrase();
|
|
374
|
+
return {
|
|
375
|
+
intents: [
|
|
376
|
+
createIntent3(LayoutAction3.SetLayout, {
|
|
377
|
+
element: "dialog",
|
|
378
|
+
dialogBlockAlign: "start",
|
|
379
|
+
dialogType: "alert",
|
|
380
|
+
state: true,
|
|
381
|
+
component: RECOVER_CODE_DIALOG,
|
|
382
|
+
subject: {
|
|
383
|
+
code: seedphrase
|
|
384
|
+
}
|
|
385
|
+
})
|
|
386
|
+
]
|
|
387
|
+
};
|
|
388
|
+
})
|
|
389
|
+
]
|
|
447
390
|
}
|
|
448
391
|
}
|
|
449
392
|
};
|
|
@@ -453,7 +396,6 @@ var ClientPlugin = ({ appKey, invitationUrl = window.location.origin, invitation
|
|
|
453
396
|
var src_default = ClientPlugin;
|
|
454
397
|
export {
|
|
455
398
|
ClientPlugin,
|
|
456
|
-
src_default as default
|
|
457
|
-
parseClientPlugin
|
|
399
|
+
src_default as default
|
|
458
400
|
};
|
|
459
401
|
//# sourceMappingURL=index.mjs.map
|