@dxos/client-protocol 0.1.58-main.75cbd70 → 0.1.58-main.7822bed
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/index.mjs +45 -20
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +34 -6
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/types/src/echo.d.ts +35 -8
- package/dist/types/src/echo.d.ts.map +1 -1
- package/dist/types/src/halo.d.ts +4 -4
- package/dist/types/src/halo.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/invitations/invitations.d.ts +7 -7
- package/dist/types/src/invitations/invitations.d.ts.map +1 -1
- package/dist/types/src/proto/gen/schema.d.ts +15 -0
- package/dist/types/src/proto/gen/schema.d.ts.map +1 -0
- package/dist/types/src/proto/index.d.ts +2 -0
- package/dist/types/src/proto/index.d.ts.map +1 -0
- package/dist/types/src/shell.d.ts +1 -1
- package/dist/types/src/shell.d.ts.map +1 -1
- package/dist/types/src/space.d.ts +4 -3
- package/dist/types/src/space.d.ts.map +1 -1
- package/package.json +20 -14
- package/src/echo.ts +44 -10
- package/src/halo.ts +4 -4
- package/src/index.ts +1 -0
- package/src/invitations/invitations.ts +7 -7
- package/src/proto/gen/schema.ts +34 -0
- package/src/proto/index.ts +5 -0
- package/src/proto/schema.proto +16 -0
- package/src/shell.ts +1 -1
- package/src/space.ts +5 -3
|
@@ -19,6 +19,9 @@ var ENV_DX_CONFIG = "DX_CONFIG";
|
|
|
19
19
|
var ENV_DX_PROFILE = "DX_PROFILE";
|
|
20
20
|
var ENV_DX_PROFILE_DEFAULT = "default";
|
|
21
21
|
|
|
22
|
+
// packages/sdk/client-protocol/src/echo.ts
|
|
23
|
+
var defaultKey = "__DEFAULT__";
|
|
24
|
+
|
|
22
25
|
// packages/sdk/client-protocol/src/invitations/encoder.ts
|
|
23
26
|
import base from "base-x";
|
|
24
27
|
import { schema } from "@dxos/protocols";
|
|
@@ -48,7 +51,7 @@ import { Invitation } from "@dxos/protocols/proto/dxos/client/services";
|
|
|
48
51
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-protocol/src/invitations/invitations.ts";
|
|
49
52
|
var AUTHENTICATION_CODE_LENGTH = 6;
|
|
50
53
|
var INVITATION_TIMEOUT = 3 * 6e4;
|
|
51
|
-
var
|
|
54
|
+
var CancellableInvitation = class extends MulticastObservable {
|
|
52
55
|
constructor({ subscriber, initialInvitation, onCancel }) {
|
|
53
56
|
super(subscriber, initialInvitation);
|
|
54
57
|
this._onCancel = onCancel;
|
|
@@ -57,7 +60,7 @@ var CancellableInvitationObservable = class extends MulticastObservable {
|
|
|
57
60
|
return this._onCancel();
|
|
58
61
|
}
|
|
59
62
|
};
|
|
60
|
-
var
|
|
63
|
+
var AuthenticatingInvitation = class extends CancellableInvitation {
|
|
61
64
|
constructor({ subscriber, initialInvitation, onCancel, onAuthenticate }) {
|
|
62
65
|
super({
|
|
63
66
|
subscriber,
|
|
@@ -91,35 +94,54 @@ var wrapObservable = async (observable) => {
|
|
|
91
94
|
});
|
|
92
95
|
};
|
|
93
96
|
|
|
97
|
+
// packages/sdk/client-protocol/src/proto/gen/schema.ts
|
|
98
|
+
import * as dxos_echo_schema from "@dxos/echo-schema";
|
|
99
|
+
var schemaJson = '{"nested":{"dxos":{"nested":{"sdk":{"nested":{"client":{"nested":{"Properties":{"options":{"(object)":true},"fields":{"name":{"type":"string","id":1}}}}}}}}}}}';
|
|
100
|
+
var schema2 = dxos_echo_schema.EchoSchema.fromJson(schemaJson);
|
|
101
|
+
var Properties = class _Properties extends dxos_echo_schema.TypedObject {
|
|
102
|
+
static {
|
|
103
|
+
this.type = schema2.getType("dxos.sdk.client.Properties");
|
|
104
|
+
}
|
|
105
|
+
static filter(opts) {
|
|
106
|
+
return _Properties.type.createFilter(opts);
|
|
107
|
+
}
|
|
108
|
+
constructor(initValues, opts) {
|
|
109
|
+
super({
|
|
110
|
+
...initValues
|
|
111
|
+
}, _Properties.type, opts);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
schema2.registerPrototype(Properties);
|
|
115
|
+
|
|
94
116
|
// packages/sdk/client-protocol/src/service-definitions.ts
|
|
95
|
-
import { schema as
|
|
117
|
+
import { schema as schema3 } from "@dxos/protocols";
|
|
96
118
|
import { createServiceBundle } from "@dxos/rpc";
|
|
97
119
|
var clientServiceBundle = createServiceBundle({
|
|
98
|
-
SystemService:
|
|
99
|
-
NetworkService:
|
|
100
|
-
LoggingService:
|
|
101
|
-
IdentityService:
|
|
102
|
-
InvitationsService:
|
|
103
|
-
DevicesService:
|
|
104
|
-
SpacesService:
|
|
105
|
-
DataService:
|
|
120
|
+
SystemService: schema3.getService("dxos.client.services.SystemService"),
|
|
121
|
+
NetworkService: schema3.getService("dxos.client.services.NetworkService"),
|
|
122
|
+
LoggingService: schema3.getService("dxos.client.services.LoggingService"),
|
|
123
|
+
IdentityService: schema3.getService("dxos.client.services.IdentityService"),
|
|
124
|
+
InvitationsService: schema3.getService("dxos.client.services.InvitationsService"),
|
|
125
|
+
DevicesService: schema3.getService("dxos.client.services.DevicesService"),
|
|
126
|
+
SpacesService: schema3.getService("dxos.client.services.SpacesService"),
|
|
127
|
+
DataService: schema3.getService("dxos.echo.service.DataService"),
|
|
106
128
|
// Agent-only.
|
|
107
|
-
FunctionRegistryService:
|
|
129
|
+
FunctionRegistryService: schema3.getService("dxos.agent.functions.FunctionRegistryService"),
|
|
108
130
|
// TODO(burdon): Deprecated.
|
|
109
|
-
DevtoolsHost:
|
|
110
|
-
TracingService:
|
|
131
|
+
DevtoolsHost: schema3.getService("dxos.devtools.host.DevtoolsHost"),
|
|
132
|
+
TracingService: schema3.getService("dxos.tracing.TracingService")
|
|
111
133
|
});
|
|
112
134
|
var iframeServiceBundle = {
|
|
113
|
-
BridgeService:
|
|
135
|
+
BridgeService: schema3.getService("dxos.mesh.bridge.BridgeService")
|
|
114
136
|
};
|
|
115
137
|
var workerServiceBundle = {
|
|
116
|
-
WorkerService:
|
|
138
|
+
WorkerService: schema3.getService("dxos.iframe.WorkerService")
|
|
117
139
|
};
|
|
118
140
|
var appServiceBundle = {
|
|
119
|
-
AppService:
|
|
141
|
+
AppService: schema3.getService("dxos.iframe.AppService")
|
|
120
142
|
};
|
|
121
143
|
var shellServiceBundle = {
|
|
122
|
-
ShellService:
|
|
144
|
+
ShellService: schema3.getService("dxos.iframe.ShellService")
|
|
123
145
|
};
|
|
124
146
|
|
|
125
147
|
// packages/sdk/client-protocol/src/timeouts.ts
|
|
@@ -133,9 +155,9 @@ var LOAD_CONTROL_FEEDS_TIMEOUT = 3e3;
|
|
|
133
155
|
export {
|
|
134
156
|
AUTHENTICATION_CODE_LENGTH,
|
|
135
157
|
AUTH_TIMEOUT,
|
|
136
|
-
|
|
158
|
+
AuthenticatingInvitation,
|
|
137
159
|
CREATE_SPACE_TIMEOUT,
|
|
138
|
-
|
|
160
|
+
CancellableInvitation,
|
|
139
161
|
DEFAULT_CLIENT_CHANNEL,
|
|
140
162
|
DEFAULT_INTERNAL_CHANNEL,
|
|
141
163
|
DEFAULT_SHELL_CHANNEL,
|
|
@@ -155,13 +177,16 @@ export {
|
|
|
155
177
|
LOAD_CONTROL_FEEDS_TIMEOUT,
|
|
156
178
|
LOAD_PROPERTIES_TIMEOUT,
|
|
157
179
|
PROXY_CONNECTION_TIMEOUT,
|
|
180
|
+
Properties,
|
|
158
181
|
RESOURCE_LOCK_TIMEOUT,
|
|
159
182
|
STATUS_TIMEOUT,
|
|
160
183
|
appServiceBundle,
|
|
161
184
|
clientServiceBundle,
|
|
162
185
|
defaultConfig,
|
|
186
|
+
defaultKey,
|
|
163
187
|
getProfilePath,
|
|
164
188
|
iframeServiceBundle,
|
|
189
|
+
schema2 as schema,
|
|
165
190
|
shellServiceBundle,
|
|
166
191
|
workerServiceBundle,
|
|
167
192
|
wrapObservable
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/config.ts", "../../../src/invitations/encoder.ts", "../../../src/invitations/invitations.ts", "../../../src/service-definitions.ts", "../../../src/timeouts.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport { ConfigProto } from '@dxos/config';\n\nexport const DEFAULT_INTERNAL_CHANNEL = 'dxos:vault';\nexport const DEFAULT_CLIENT_CHANNEL = 'dxos:app';\nexport const DEFAULT_SHELL_CHANNEL = 'dxos:shell';\n\nexport const DEFAULT_VAULT_ORIGIN = 'https://halo.dxos.org';\nexport const DEFAULT_VAULT_URL = DEFAULT_VAULT_ORIGIN + '/vault.html';\n\nexport const EXPECTED_CONFIG_VERSION = 1;\nexport const defaultConfig: ConfigProto = { version: 1 };\n\n// TODO(burdon): Allow override via env? Generalize since currently NodeJS only.\nconst HOME = typeof process !== 'undefined' ? process?.env?.HOME ?? '' : '';\n\n// Base directories.\n// TODO(burdon): Consider Windows, Linux, OSX.\n// https://wiki.archlinux.org/title/XDG_Base_Directory\n// Each `/dx` directory should contain `/profile/<DX_PROFILE>` subdirectories.\nexport const getProfilePath = (root: string, profile: string, file: string | undefined = undefined) =>\n `${root}/profile/${profile}` + (file ? `/${file}` : '');\n\n// XDG_CONFIG_HOME (Analogous to /etc.)\nexport const DX_CONFIG = `${HOME}/.config/dx`;\n\n// XDG_CACHE_HOME (Analogous to /var/cache).\nexport const DX_CACHE = `${HOME}/.cache/dx`;\n\n// TODO(burdon): Storage should use this by default (make path optional).\n// XDG_DATA_HOME (Analogous to /usr/share).\nexport const DX_DATA = `${HOME}/.local/share/dx`;\n\n// XDG_STATE_HOME (Analogous to /var/lib).\nexport const DX_STATE = `${HOME}/.local/state/dx`;\n\n// XDG_RUNTIME_DIR (Non-essential files, sockets, etc.)\nexport const DX_RUNTIME = '/tmp/dx/run';\n\nexport const ENV_DX_CONFIG = 'DX_CONFIG';\nexport const ENV_DX_PROFILE = 'DX_PROFILE';\nexport const ENV_DX_PROFILE_DEFAULT = 'default';\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport base from 'base-x';\n\nimport { schema } from '@dxos/protocols';\nimport { Invitation } from '@dxos/protocols/proto/dxos/client/services';\n\n// Encode with URL-safe alpha-numeric characters.\nconst base62 = base('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');\n\nconst codec = schema.getCodecForType('dxos.client.services.Invitation');\n\n/**\n * Encodes and decodes an invitation proto into/from alphanumeric chars.\n */\nexport class InvitationEncoder {\n static decode(text: string): Invitation {\n return codec.decode(base62.decode(text));\n }\n\n static encode(invitation: Invitation): string {\n return base62.encode(\n codec.encode({\n invitationId: invitation.invitationId,\n type: invitation.type,\n kind: invitation.kind,\n authMethod: invitation.authMethod,\n swarmKey: invitation.swarmKey,\n state: invitation.state,\n timeout: invitation.timeout,\n }),\n );\n }\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { MulticastObservable, Observable, Subscriber } from '@dxos/async';\nimport { invariant } from '@dxos/invariant';\nimport { Invitation } from '@dxos/protocols/proto/dxos/client/services';\n\nexport const AUTHENTICATION_CODE_LENGTH = 6;\n\nexport const INVITATION_TIMEOUT = 3 * 60_000; // 3 mins.\n\nexport interface Invitations {\n created: MulticastObservable<CancellableInvitationObservable[]>;\n accepted: MulticastObservable<AuthenticatingInvitationObservable[]>;\n createInvitation(options?: Partial<Invitation>): CancellableInvitationObservable;\n acceptInvitation(invitation: Invitation): AuthenticatingInvitationObservable;\n}\n\n/**\n * Base class for all invitation observables and providers.\n */\nexport class CancellableInvitationObservable extends MulticastObservable<Invitation> {\n private readonly _onCancel: () => Promise<void>;\n\n constructor({\n subscriber,\n initialInvitation,\n onCancel,\n }: {\n subscriber: Observable<Invitation> | Subscriber<Invitation>;\n initialInvitation: Invitation;\n onCancel: () => Promise<void>;\n }) {\n super(subscriber, initialInvitation);\n this._onCancel = onCancel;\n }\n\n cancel(): Promise<void> {\n return this._onCancel();\n }\n}\n\n/**\n * Cancelable observer that relays authentication requests.\n */\nexport class AuthenticatingInvitationObservable extends CancellableInvitationObservable {\n private readonly _onAuthenticate: (authCode: string) => Promise<void>;\n\n constructor({\n subscriber,\n initialInvitation,\n onCancel,\n onAuthenticate,\n }: {\n subscriber: Observable<Invitation> | Subscriber<Invitation>;\n initialInvitation: Invitation;\n onCancel: () => Promise<void>;\n onAuthenticate: (authCode: string) => Promise<void>;\n }) {\n super({ subscriber, initialInvitation, onCancel });\n this._onAuthenticate = onAuthenticate;\n }\n\n async authenticate(authCode: string): Promise<void> {\n return this._onAuthenticate(authCode);\n }\n}\n\n/**\n * Testing util to wrap non-authenticating observable with promise.\n * Don't use this in production code.\n * @deprecated\n */\n// TODO(wittjosiah): Move to testing.\nexport const wrapObservable = async (observable: CancellableInvitationObservable): Promise<Invitation> => {\n return new Promise((resolve, reject) => {\n const subscription = observable.subscribe(\n (invitation: Invitation | undefined) => {\n // TODO(burdon): Throw error if auth requested.\n invariant(invitation?.state === Invitation.State.SUCCESS);\n subscription.unsubscribe();\n resolve(invitation);\n },\n (err: Error) => {\n subscription.unsubscribe();\n reject(err);\n },\n );\n });\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { Context } from '@dxos/context';\nimport { schema } from '@dxos/protocols';\nimport { FunctionRegistryService } from '@dxos/protocols/proto/dxos/agent/functions';\nimport {\n DevicesService,\n IdentityService,\n InvitationsService,\n LoggingService,\n NetworkService,\n SpacesService,\n SystemService,\n} from '@dxos/protocols/proto/dxos/client/services';\nimport { DevtoolsHost } from '@dxos/protocols/proto/dxos/devtools/host';\nimport { DataService } from '@dxos/protocols/proto/dxos/echo/service';\nimport type { AppService, ShellService, WorkerService } from '@dxos/protocols/proto/dxos/iframe';\nimport type { BridgeService } from '@dxos/protocols/proto/dxos/mesh/bridge';\nimport { TracingService } from '@dxos/protocols/proto/dxos/tracing';\nimport { createServiceBundle, ServiceBundle } from '@dxos/rpc';\n\n//\n// NOTE: Should contain client/proxy dependencies only.\n//\n\nexport type ClientServices = {\n SystemService: SystemService;\n NetworkService: NetworkService;\n LoggingService: LoggingService;\n\n IdentityService: IdentityService;\n InvitationsService: InvitationsService;\n DevicesService: DevicesService;\n SpacesService: SpacesService;\n DataService: DataService;\n\n FunctionRegistryService: FunctionRegistryService;\n\n // TODO(burdon): Deprecated.\n DevtoolsHost: DevtoolsHost;\n\n TracingService: TracingService;\n};\n\n/**\n * Provide access to client services definitions and service handler.\n */\nexport interface ClientServicesProvider {\n descriptors: ServiceBundle<ClientServices>;\n services: Partial<ClientServices>;\n\n open(ctx: Context): Promise<void>;\n close(ctx: Context): Promise<void>;\n}\n\n/**\n * Services supported by host.\n */\nexport const clientServiceBundle = createServiceBundle<ClientServices>({\n SystemService: schema.getService('dxos.client.services.SystemService'),\n NetworkService: schema.getService('dxos.client.services.NetworkService'),\n LoggingService: schema.getService('dxos.client.services.LoggingService'),\n\n IdentityService: schema.getService('dxos.client.services.IdentityService'),\n InvitationsService: schema.getService('dxos.client.services.InvitationsService'),\n DevicesService: schema.getService('dxos.client.services.DevicesService'),\n SpacesService: schema.getService('dxos.client.services.SpacesService'),\n DataService: schema.getService('dxos.echo.service.DataService'),\n\n // Agent-only.\n FunctionRegistryService: schema.getService('dxos.agent.functions.FunctionRegistryService'),\n\n // TODO(burdon): Deprecated.\n DevtoolsHost: schema.getService('dxos.devtools.host.DevtoolsHost'),\n\n TracingService: schema.getService('dxos.tracing.TracingService'),\n});\n\nexport type IframeServiceBundle = {\n BridgeService: BridgeService;\n};\n\nexport const iframeServiceBundle: ServiceBundle<IframeServiceBundle> = {\n BridgeService: schema.getService('dxos.mesh.bridge.BridgeService'),\n};\n\nexport type WorkerServiceBundle = {\n WorkerService: WorkerService;\n};\n\nexport const workerServiceBundle: ServiceBundle<WorkerServiceBundle> = {\n WorkerService: schema.getService('dxos.iframe.WorkerService'),\n};\n\nexport type AppServiceBundle = {\n AppService: AppService;\n};\n\nexport const appServiceBundle: ServiceBundle<AppServiceBundle> = {\n AppService: schema.getService('dxos.iframe.AppService'),\n};\n\nexport type ShellServiceBundle = {\n ShellService: ShellService;\n};\n\nexport const shellServiceBundle: ServiceBundle<ShellServiceBundle> = {\n ShellService: schema.getService('dxos.iframe.ShellService'),\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\n/**\n * Timeout for making rpc connections from remote proxies.\n */\nexport const PROXY_CONNECTION_TIMEOUT = 30_000;\n\n/**\n * Timeout for the device to be added to the trusted set during auth.\n */\nexport const AUTH_TIMEOUT = 30_000;\n\n/**\n * Timeout for how long the remote client will wait before assuming the connection is lost.\n */\nexport const STATUS_TIMEOUT = 10_000;\n\n/**\n * Timeout for waiting before stealing resource lock.\n */\nexport const RESOURCE_LOCK_TIMEOUT = 3_000;\n\n/**\n * Timeout for space properties to be loaded in the set of tracked items.\n * Accounts for latency between SpaceService reporting the space as READY and DataService streaming the item states.\n */\nexport const LOAD_PROPERTIES_TIMEOUT = 3_000;\n\n/**\n * Timeout for creating new spaces.\n */\nexport const CREATE_SPACE_TIMEOUT = 3_000;\n\n/**\n * Timeout for loading of control feeds.\n */\nexport const LOAD_CONTROL_FEEDS_TIMEOUT = 3_000;\n"],
|
|
5
|
-
"mappings": ";AAMO,IAAMA,2BAA2B;AACjC,IAAMC,yBAAyB;AAC/B,IAAMC,wBAAwB;AAE9B,IAAMC,uBAAuB;AAC7B,IAAMC,oBAAoBD,uBAAuB;AAEjD,IAAME,0BAA0B;AAChC,IAAMC,gBAA6B;EAAEC,SAAS;AAAE;AAGvD,IAAMC,OAAO,OAAOC,YAAY,cAAcA,SAASC,KAAKF,QAAQ,KAAK;AAMlE,IAAMG,iBAAiB,CAACC,MAAcC,SAAiBC,OAA2BC,WACvF,GAAGH,IAAAA,YAAgBC,OAAAA,MAAaC,OAAO,IAAIA,IAAAA,KAAS;AAG/C,IAAME,YAAY,GAAGR,IAAAA;AAGrB,IAAMS,WAAW,GAAGT,IAAAA;AAIpB,IAAMU,UAAU,GAAGV,IAAAA;AAGnB,IAAMW,WAAW,GAAGX,IAAAA;AAGpB,IAAMY,aAAa;AAEnB,IAAMC,gBAAgB;AACtB,IAAMC,iBAAiB;AACvB,IAAMC,yBAAyB;;;
|
|
6
|
-
"names": ["DEFAULT_INTERNAL_CHANNEL", "DEFAULT_CLIENT_CHANNEL", "DEFAULT_SHELL_CHANNEL", "DEFAULT_VAULT_ORIGIN", "DEFAULT_VAULT_URL", "EXPECTED_CONFIG_VERSION", "defaultConfig", "version", "HOME", "process", "env", "getProfilePath", "root", "profile", "file", "undefined", "DX_CONFIG", "DX_CACHE", "DX_DATA", "DX_STATE", "DX_RUNTIME", "ENV_DX_CONFIG", "ENV_DX_PROFILE", "ENV_DX_PROFILE_DEFAULT", "base", "schema", "base62", "base", "codec", "schema", "getCodecForType", "InvitationEncoder", "decode", "text", "encode", "invitation", "invitationId", "type", "kind", "authMethod", "swarmKey", "state", "timeout", "MulticastObservable", "invariant", "Invitation", "AUTHENTICATION_CODE_LENGTH", "INVITATION_TIMEOUT", "
|
|
3
|
+
"sources": ["../../../src/config.ts", "../../../src/echo.ts", "../../../src/invitations/encoder.ts", "../../../src/invitations/invitations.ts", "../../../src/proto/gen/schema.ts", "../../../src/service-definitions.ts", "../../../src/timeouts.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport { ConfigProto } from '@dxos/config';\n\nexport const DEFAULT_INTERNAL_CHANNEL = 'dxos:vault';\nexport const DEFAULT_CLIENT_CHANNEL = 'dxos:app';\nexport const DEFAULT_SHELL_CHANNEL = 'dxos:shell';\n\nexport const DEFAULT_VAULT_ORIGIN = 'https://halo.dxos.org';\nexport const DEFAULT_VAULT_URL = DEFAULT_VAULT_ORIGIN + '/vault.html';\n\nexport const EXPECTED_CONFIG_VERSION = 1;\nexport const defaultConfig: ConfigProto = { version: 1 };\n\n// TODO(burdon): Allow override via env? Generalize since currently NodeJS only.\nconst HOME = typeof process !== 'undefined' ? process?.env?.HOME ?? '' : '';\n\n// Base directories.\n// TODO(burdon): Consider Windows, Linux, OSX.\n// https://wiki.archlinux.org/title/XDG_Base_Directory\n// Each `/dx` directory should contain `/profile/<DX_PROFILE>` subdirectories.\nexport const getProfilePath = (root: string, profile: string, file: string | undefined = undefined) =>\n `${root}/profile/${profile}` + (file ? `/${file}` : '');\n\n// XDG_CONFIG_HOME (Analogous to /etc.)\nexport const DX_CONFIG = `${HOME}/.config/dx`;\n\n// XDG_CACHE_HOME (Analogous to /var/cache).\nexport const DX_CACHE = `${HOME}/.cache/dx`;\n\n// TODO(burdon): Storage should use this by default (make path optional).\n// XDG_DATA_HOME (Analogous to /usr/share).\nexport const DX_DATA = `${HOME}/.local/share/dx`;\n\n// XDG_STATE_HOME (Analogous to /var/lib).\nexport const DX_STATE = `${HOME}/.local/state/dx`;\n\n// XDG_RUNTIME_DIR (Non-essential files, sockets, etc.)\nexport const DX_RUNTIME = '/tmp/dx/run';\n\nexport const ENV_DX_CONFIG = 'DX_CONFIG';\nexport const ENV_DX_PROFILE = 'DX_PROFILE';\nexport const ENV_DX_PROFILE_DEFAULT = 'default';\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport type { MulticastObservable } from '@dxos/async';\nimport type { EchoSchema } from '@dxos/echo-schema';\nimport type { PublicKey } from '@dxos/keys';\nimport type { Invitation } from '@dxos/protocols/proto/dxos/client/services';\n\nimport type { AuthenticatingInvitation } from './invitations';\nimport type { Space } from './space';\n\n// Space properties key for default metadata.\n// TODO(wittjosiah): Remove. Default space should be indicated by data in HALO space.\nexport const defaultKey = '__DEFAULT__';\n\n/**\n * TODO(burdon): Public API (move comments here).\n */\n// TODO(wittjosiah): Rename?\n// https://ts.dev/style/#naming-style\n// ClientApi? ClientProtocol?\nexport interface Echo extends MulticastObservable<Space[]> {\n /**\n * Resolves when the default space is available.\n */\n // TODO(wittjosiah): Remove. Ensure default space is always available.\n get isReady(): MulticastObservable<boolean>;\n\n /**\n * Returns the list of spaces.\n */\n get(): Space[];\n\n /**\n * Returns the space with the given key.\n */\n get(spaceKey: PublicKey): Space | undefined;\n\n /**\n * Returns the default space.\n */\n get default(): Space;\n\n /**\n * Creates a new space.\n */\n create(): Promise<Space>;\n\n /**\n * Creates a space from the given snapshot.\n */\n // clone(snapshot: SpaceSnapshot): Promise<Space>;\n\n /**\n * Joins an existing space using the given invitation.\n */\n join(invitation: Invitation | string): AuthenticatingInvitation;\n\n /**\n * Adds a schema to ECHO.\n */\n addSchema(schema: EchoSchema): void;\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport base from 'base-x';\n\nimport { schema } from '@dxos/protocols';\nimport { Invitation } from '@dxos/protocols/proto/dxos/client/services';\n\n// Encode with URL-safe alpha-numeric characters.\nconst base62 = base('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');\n\nconst codec = schema.getCodecForType('dxos.client.services.Invitation');\n\n/**\n * Encodes and decodes an invitation proto into/from alphanumeric chars.\n */\nexport class InvitationEncoder {\n static decode(text: string): Invitation {\n return codec.decode(base62.decode(text));\n }\n\n static encode(invitation: Invitation): string {\n return base62.encode(\n codec.encode({\n invitationId: invitation.invitationId,\n type: invitation.type,\n kind: invitation.kind,\n authMethod: invitation.authMethod,\n swarmKey: invitation.swarmKey,\n state: invitation.state,\n timeout: invitation.timeout,\n }),\n );\n }\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { MulticastObservable, Observable, Subscriber } from '@dxos/async';\nimport { invariant } from '@dxos/invariant';\nimport { Invitation } from '@dxos/protocols/proto/dxos/client/services';\n\nexport const AUTHENTICATION_CODE_LENGTH = 6;\n\nexport const INVITATION_TIMEOUT = 3 * 60_000; // 3 mins.\n\nexport interface Invitations {\n created: MulticastObservable<CancellableInvitation[]>;\n accepted: MulticastObservable<AuthenticatingInvitation[]>;\n share(options?: Partial<Invitation>): CancellableInvitation;\n join(invitation: Invitation): AuthenticatingInvitation;\n}\n\n/**\n * Base class for all invitation observables and providers.\n */\nexport class CancellableInvitation extends MulticastObservable<Invitation> {\n private readonly _onCancel: () => Promise<void>;\n\n constructor({\n subscriber,\n initialInvitation,\n onCancel,\n }: {\n subscriber: Observable<Invitation> | Subscriber<Invitation>;\n initialInvitation: Invitation;\n onCancel: () => Promise<void>;\n }) {\n super(subscriber, initialInvitation);\n this._onCancel = onCancel;\n }\n\n cancel(): Promise<void> {\n return this._onCancel();\n }\n}\n\n/**\n * Cancelable observer that relays authentication requests.\n */\nexport class AuthenticatingInvitation extends CancellableInvitation {\n private readonly _onAuthenticate: (authCode: string) => Promise<void>;\n\n constructor({\n subscriber,\n initialInvitation,\n onCancel,\n onAuthenticate,\n }: {\n subscriber: Observable<Invitation> | Subscriber<Invitation>;\n initialInvitation: Invitation;\n onCancel: () => Promise<void>;\n onAuthenticate: (authCode: string) => Promise<void>;\n }) {\n super({ subscriber, initialInvitation, onCancel });\n this._onAuthenticate = onAuthenticate;\n }\n\n async authenticate(authCode: string): Promise<void> {\n return this._onAuthenticate(authCode);\n }\n}\n\n/**\n * Testing util to wrap non-authenticating observable with promise.\n * Don't use this in production code.\n * @deprecated\n */\n// TODO(wittjosiah): Move to testing.\nexport const wrapObservable = async (observable: CancellableInvitation): Promise<Invitation> => {\n return new Promise((resolve, reject) => {\n const subscription = observable.subscribe(\n (invitation: Invitation | undefined) => {\n // TODO(burdon): Throw error if auth requested.\n invariant(invitation?.state === Invitation.State.SUCCESS);\n subscription.unsubscribe();\n resolve(invitation);\n },\n (err: Error) => {\n subscription.unsubscribe();\n reject(err);\n },\n );\n });\n};\n", "/**\n * @generated @dxos/echo-typegen src/proto/schema.proto\n **/\n\nimport * as dxos_echo_schema from \"@dxos/echo-schema\";\n\nconst schemaJson =\n '{\"nested\":{\"dxos\":{\"nested\":{\"sdk\":{\"nested\":{\"client\":{\"nested\":{\"Properties\":{\"options\":{\"(object)\":true},\"fields\":{\"name\":{\"type\":\"string\",\"id\":1}}}}}}}}}}}';\n\nexport const schema = dxos_echo_schema.EchoSchema.fromJson(schemaJson);\n\nexport type PropertiesProps = {\n name: string;\n};\n\nexport class Properties extends dxos_echo_schema.TypedObject<PropertiesProps> {\n static readonly type = schema.getType(\"dxos.sdk.client.Properties\");\n\n static filter(\n opts?: Partial<PropertiesProps>\n ): dxos_echo_schema.TypeFilter<Properties> {\n return Properties.type.createFilter(opts);\n }\n\n constructor(\n initValues?: Partial<PropertiesProps>,\n opts?: dxos_echo_schema.TypedObjectOpts\n ) {\n super({ ...initValues }, Properties.type, opts);\n }\n declare name: string;\n}\n\nschema.registerPrototype(Properties);\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { Context } from '@dxos/context';\nimport { schema } from '@dxos/protocols';\nimport { FunctionRegistryService } from '@dxos/protocols/proto/dxos/agent/functions';\nimport {\n DevicesService,\n IdentityService,\n InvitationsService,\n LoggingService,\n NetworkService,\n SpacesService,\n SystemService,\n} from '@dxos/protocols/proto/dxos/client/services';\nimport { DevtoolsHost } from '@dxos/protocols/proto/dxos/devtools/host';\nimport { DataService } from '@dxos/protocols/proto/dxos/echo/service';\nimport type { AppService, ShellService, WorkerService } from '@dxos/protocols/proto/dxos/iframe';\nimport type { BridgeService } from '@dxos/protocols/proto/dxos/mesh/bridge';\nimport { TracingService } from '@dxos/protocols/proto/dxos/tracing';\nimport { createServiceBundle, ServiceBundle } from '@dxos/rpc';\n\n//\n// NOTE: Should contain client/proxy dependencies only.\n//\n\nexport type ClientServices = {\n SystemService: SystemService;\n NetworkService: NetworkService;\n LoggingService: LoggingService;\n\n IdentityService: IdentityService;\n InvitationsService: InvitationsService;\n DevicesService: DevicesService;\n SpacesService: SpacesService;\n DataService: DataService;\n\n FunctionRegistryService: FunctionRegistryService;\n\n // TODO(burdon): Deprecated.\n DevtoolsHost: DevtoolsHost;\n\n TracingService: TracingService;\n};\n\n/**\n * Provide access to client services definitions and service handler.\n */\nexport interface ClientServicesProvider {\n descriptors: ServiceBundle<ClientServices>;\n services: Partial<ClientServices>;\n\n open(ctx: Context): Promise<void>;\n close(ctx: Context): Promise<void>;\n}\n\n/**\n * Services supported by host.\n */\nexport const clientServiceBundle = createServiceBundle<ClientServices>({\n SystemService: schema.getService('dxos.client.services.SystemService'),\n NetworkService: schema.getService('dxos.client.services.NetworkService'),\n LoggingService: schema.getService('dxos.client.services.LoggingService'),\n\n IdentityService: schema.getService('dxos.client.services.IdentityService'),\n InvitationsService: schema.getService('dxos.client.services.InvitationsService'),\n DevicesService: schema.getService('dxos.client.services.DevicesService'),\n SpacesService: schema.getService('dxos.client.services.SpacesService'),\n DataService: schema.getService('dxos.echo.service.DataService'),\n\n // Agent-only.\n FunctionRegistryService: schema.getService('dxos.agent.functions.FunctionRegistryService'),\n\n // TODO(burdon): Deprecated.\n DevtoolsHost: schema.getService('dxos.devtools.host.DevtoolsHost'),\n\n TracingService: schema.getService('dxos.tracing.TracingService'),\n});\n\nexport type IframeServiceBundle = {\n BridgeService: BridgeService;\n};\n\nexport const iframeServiceBundle: ServiceBundle<IframeServiceBundle> = {\n BridgeService: schema.getService('dxos.mesh.bridge.BridgeService'),\n};\n\nexport type WorkerServiceBundle = {\n WorkerService: WorkerService;\n};\n\nexport const workerServiceBundle: ServiceBundle<WorkerServiceBundle> = {\n WorkerService: schema.getService('dxos.iframe.WorkerService'),\n};\n\nexport type AppServiceBundle = {\n AppService: AppService;\n};\n\nexport const appServiceBundle: ServiceBundle<AppServiceBundle> = {\n AppService: schema.getService('dxos.iframe.AppService'),\n};\n\nexport type ShellServiceBundle = {\n ShellService: ShellService;\n};\n\nexport const shellServiceBundle: ServiceBundle<ShellServiceBundle> = {\n ShellService: schema.getService('dxos.iframe.ShellService'),\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\n/**\n * Timeout for making rpc connections from remote proxies.\n */\nexport const PROXY_CONNECTION_TIMEOUT = 30_000;\n\n/**\n * Timeout for the device to be added to the trusted set during auth.\n */\nexport const AUTH_TIMEOUT = 30_000;\n\n/**\n * Timeout for how long the remote client will wait before assuming the connection is lost.\n */\nexport const STATUS_TIMEOUT = 10_000;\n\n/**\n * Timeout for waiting before stealing resource lock.\n */\nexport const RESOURCE_LOCK_TIMEOUT = 3_000;\n\n/**\n * Timeout for space properties to be loaded in the set of tracked items.\n * Accounts for latency between SpaceService reporting the space as READY and DataService streaming the item states.\n */\nexport const LOAD_PROPERTIES_TIMEOUT = 3_000;\n\n/**\n * Timeout for creating new spaces.\n */\nexport const CREATE_SPACE_TIMEOUT = 3_000;\n\n/**\n * Timeout for loading of control feeds.\n */\nexport const LOAD_CONTROL_FEEDS_TIMEOUT = 3_000;\n"],
|
|
5
|
+
"mappings": ";AAMO,IAAMA,2BAA2B;AACjC,IAAMC,yBAAyB;AAC/B,IAAMC,wBAAwB;AAE9B,IAAMC,uBAAuB;AAC7B,IAAMC,oBAAoBD,uBAAuB;AAEjD,IAAME,0BAA0B;AAChC,IAAMC,gBAA6B;EAAEC,SAAS;AAAE;AAGvD,IAAMC,OAAO,OAAOC,YAAY,cAAcA,SAASC,KAAKF,QAAQ,KAAK;AAMlE,IAAMG,iBAAiB,CAACC,MAAcC,SAAiBC,OAA2BC,WACvF,GAAGH,IAAAA,YAAgBC,OAAAA,MAAaC,OAAO,IAAIA,IAAAA,KAAS;AAG/C,IAAME,YAAY,GAAGR,IAAAA;AAGrB,IAAMS,WAAW,GAAGT,IAAAA;AAIpB,IAAMU,UAAU,GAAGV,IAAAA;AAGnB,IAAMW,WAAW,GAAGX,IAAAA;AAGpB,IAAMY,aAAa;AAEnB,IAAMC,gBAAgB;AACtB,IAAMC,iBAAiB;AACvB,IAAMC,yBAAyB;;;AC9B/B,IAAMC,aAAa;;;ACV1B,OAAOC,UAAU;AAEjB,SAASC,cAAc;AAIvB,IAAMC,SAASC,KAAK,gEAAA;AAEpB,IAAMC,QAAQC,OAAOC,gBAAgB,iCAAA;AAK9B,IAAMC,oBAAN,MAAMA;EACX,OAAOC,OAAOC,MAA0B;AACtC,WAAOL,MAAMI,OAAON,OAAOM,OAAOC,IAAAA,CAAAA;EACpC;EAEA,OAAOC,OAAOC,YAAgC;AAC5C,WAAOT,OAAOQ,OACZN,MAAMM,OAAO;MACXE,cAAcD,WAAWC;MACzBC,MAAMF,WAAWE;MACjBC,MAAMH,WAAWG;MACjBC,YAAYJ,WAAWI;MACvBC,UAAUL,WAAWK;MACrBC,OAAON,WAAWM;MAClBC,SAASP,WAAWO;IACtB,CAAA,CAAA;EAEJ;AACF;;;AC/BA,SAASC,2BAAmD;AAC5D,SAASC,iBAAiB;AAC1B,SAASC,kBAAkB;;AAEpB,IAAMC,6BAA6B;AAEnC,IAAMC,qBAAqB,IAAI;AAY/B,IAAMC,wBAAN,cAAoCL,oBAAAA;EAGzCM,YAAY,EACVC,YACAC,mBACAC,SAAQ,GAKP;AACD,UAAMF,YAAYC,iBAAAA;AAClB,SAAKE,YAAYD;EACnB;EAEAE,SAAwB;AACtB,WAAO,KAAKD,UAAS;EACvB;AACF;AAKO,IAAME,2BAAN,cAAuCP,sBAAAA;EAG5CC,YAAY,EACVC,YACAC,mBACAC,UACAI,eAAc,GAMb;AACD,UAAM;MAAEN;MAAYC;MAAmBC;IAAS,CAAA;AAChD,SAAKK,kBAAkBD;EACzB;EAEA,MAAME,aAAaC,UAAiC;AAClD,WAAO,KAAKF,gBAAgBE,QAAAA;EAC9B;AACF;AAQO,IAAMC,iBAAiB,OAAOC,eAAAA;AACnC,SAAO,IAAIC,QAAQ,CAACC,SAASC,WAAAA;AAC3B,UAAMC,eAAeJ,WAAWK,UAC9B,CAACC,eAAAA;AAECvB,gBAAUuB,YAAYC,UAAUvB,WAAWwB,MAAMC,SAAO,QAAA;;;;;;;;;AACxDL,mBAAaM,YAAW;AACxBR,cAAQI,UAAAA;IACV,GACA,CAACK,QAAAA;AACCP,mBAAaM,YAAW;AACxBP,aAAOQ,GAAAA;IACT,CAAA;EAEJ,CAAA;AACF;;;ACtFA,YAAYC,sBAAsB;AAElC,IAAMC,aACJ;AAEK,IAAMC,UAA0BC,4BAAWC,SAASH,UAAAA;AAMpD,IAAMI,aAAN,MAAMA,oBAAoCC,6BAAW;EAC1D;SAAgBC,OAAOL,QAAOM,QAAQ,4BAAA;;EAEtC,OAAOC,OACLC,MACyC;AACzC,WAAOL,YAAWE,KAAKI,aAAaD,IAAAA;EACtC;EAEAE,YACEC,YACAH,MACA;AACA,UAAM;MAAE,GAAGG;IAAW,GAAGR,YAAWE,MAAMG,IAAAA;EAC5C;AAEF;AAEAR,QAAOY,kBAAkBT,UAAAA;;;AC5BzB,SAASU,UAAAA,eAAc;AAgBvB,SAASC,2BAA0C;AAuC5C,IAAMC,sBAAsBC,oBAAoC;EACrEC,eAAeC,QAAOC,WAAW,oCAAA;EACjCC,gBAAgBF,QAAOC,WAAW,qCAAA;EAClCE,gBAAgBH,QAAOC,WAAW,qCAAA;EAElCG,iBAAiBJ,QAAOC,WAAW,sCAAA;EACnCI,oBAAoBL,QAAOC,WAAW,yCAAA;EACtCK,gBAAgBN,QAAOC,WAAW,qCAAA;EAClCM,eAAeP,QAAOC,WAAW,oCAAA;EACjCO,aAAaR,QAAOC,WAAW,+BAAA;;EAG/BQ,yBAAyBT,QAAOC,WAAW,8CAAA;;EAG3CS,cAAcV,QAAOC,WAAW,iCAAA;EAEhCU,gBAAgBX,QAAOC,WAAW,6BAAA;AACpC,CAAA;AAMO,IAAMW,sBAA0D;EACrEC,eAAeb,QAAOC,WAAW,gCAAA;AACnC;AAMO,IAAMa,sBAA0D;EACrEC,eAAef,QAAOC,WAAW,2BAAA;AACnC;AAMO,IAAMe,mBAAoD;EAC/DC,YAAYjB,QAAOC,WAAW,wBAAA;AAChC;AAMO,IAAMiB,qBAAwD;EACnEC,cAAcnB,QAAOC,WAAW,0BAAA;AAClC;;;ACvGO,IAAMmB,2BAA2B;AAKjC,IAAMC,eAAe;AAKrB,IAAMC,iBAAiB;AAKvB,IAAMC,wBAAwB;AAM9B,IAAMC,0BAA0B;AAKhC,IAAMC,uBAAuB;AAK7B,IAAMC,6BAA6B;",
|
|
6
|
+
"names": ["DEFAULT_INTERNAL_CHANNEL", "DEFAULT_CLIENT_CHANNEL", "DEFAULT_SHELL_CHANNEL", "DEFAULT_VAULT_ORIGIN", "DEFAULT_VAULT_URL", "EXPECTED_CONFIG_VERSION", "defaultConfig", "version", "HOME", "process", "env", "getProfilePath", "root", "profile", "file", "undefined", "DX_CONFIG", "DX_CACHE", "DX_DATA", "DX_STATE", "DX_RUNTIME", "ENV_DX_CONFIG", "ENV_DX_PROFILE", "ENV_DX_PROFILE_DEFAULT", "defaultKey", "base", "schema", "base62", "base", "codec", "schema", "getCodecForType", "InvitationEncoder", "decode", "text", "encode", "invitation", "invitationId", "type", "kind", "authMethod", "swarmKey", "state", "timeout", "MulticastObservable", "invariant", "Invitation", "AUTHENTICATION_CODE_LENGTH", "INVITATION_TIMEOUT", "CancellableInvitation", "constructor", "subscriber", "initialInvitation", "onCancel", "_onCancel", "cancel", "AuthenticatingInvitation", "onAuthenticate", "_onAuthenticate", "authenticate", "authCode", "wrapObservable", "observable", "Promise", "resolve", "reject", "subscription", "subscribe", "invitation", "state", "State", "SUCCESS", "unsubscribe", "err", "dxos_echo_schema", "schemaJson", "schema", "EchoSchema", "fromJson", "Properties", "TypedObject", "type", "getType", "filter", "opts", "createFilter", "constructor", "initValues", "registerPrototype", "schema", "createServiceBundle", "clientServiceBundle", "createServiceBundle", "SystemService", "schema", "getService", "NetworkService", "LoggingService", "IdentityService", "InvitationsService", "DevicesService", "SpacesService", "DataService", "FunctionRegistryService", "DevtoolsHost", "TracingService", "iframeServiceBundle", "BridgeService", "workerServiceBundle", "WorkerService", "appServiceBundle", "AppService", "shellServiceBundle", "ShellService", "PROXY_CONNECTION_TIMEOUT", "AUTH_TIMEOUT", "STATUS_TIMEOUT", "RESOURCE_LOCK_TIMEOUT", "LOAD_PROPERTIES_TIMEOUT", "CREATE_SPACE_TIMEOUT", "LOAD_CONTROL_FEEDS_TIMEOUT"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/sdk/client-protocol/src/config.ts":{"bytes":5848,"imports":[],"format":"esm"},"packages/sdk/client-protocol/src/echo.ts":{"bytes":
|
|
1
|
+
{"inputs":{"packages/sdk/client-protocol/src/config.ts":{"bytes":5848,"imports":[],"format":"esm"},"packages/sdk/client-protocol/src/echo.ts":{"bytes":2780,"imports":[],"format":"esm"},"packages/sdk/client-protocol/src/halo.ts":{"bytes":1687,"imports":[],"format":"esm"},"packages/sdk/client-protocol/src/invitations/encoder.ts":{"bytes":3446,"imports":[{"path":"base-x","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true}],"format":"esm"},"packages/sdk/client-protocol/src/invitations/invitations.ts":{"bytes":7737,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto/dxos/client/services","kind":"import-statement","external":true}],"format":"esm"},"packages/sdk/client-protocol/src/invitations/index.ts":{"bytes":578,"imports":[{"path":"packages/sdk/client-protocol/src/invitations/encoder.ts","kind":"import-statement","original":"./encoder"},{"path":"packages/sdk/client-protocol/src/invitations/invitations.ts","kind":"import-statement","original":"./invitations"}],"format":"esm"},"packages/sdk/client-protocol/src/proto/gen/schema.ts":{"bytes":3164,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"format":"esm"},"packages/sdk/client-protocol/src/proto/index.ts":{"bytes":480,"imports":[{"path":"packages/sdk/client-protocol/src/proto/gen/schema.ts","kind":"import-statement","original":"./gen/schema"}],"format":"esm"},"packages/sdk/client-protocol/src/service-definitions.ts":{"bytes":8188,"imports":[{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true}],"format":"esm"},"packages/sdk/client-protocol/src/shell.ts":{"bytes":1004,"imports":[],"format":"esm"},"packages/sdk/client-protocol/src/space.ts":{"bytes":3784,"imports":[],"format":"esm"},"packages/sdk/client-protocol/src/timeouts.ts":{"bytes":3134,"imports":[],"format":"esm"},"packages/sdk/client-protocol/src/index.ts":{"bytes":1167,"imports":[{"path":"packages/sdk/client-protocol/src/config.ts","kind":"import-statement","original":"./config"},{"path":"packages/sdk/client-protocol/src/echo.ts","kind":"import-statement","original":"./echo"},{"path":"packages/sdk/client-protocol/src/halo.ts","kind":"import-statement","original":"./halo"},{"path":"packages/sdk/client-protocol/src/invitations/index.ts","kind":"import-statement","original":"./invitations"},{"path":"packages/sdk/client-protocol/src/proto/index.ts","kind":"import-statement","original":"./proto"},{"path":"packages/sdk/client-protocol/src/service-definitions.ts","kind":"import-statement","original":"./service-definitions"},{"path":"packages/sdk/client-protocol/src/shell.ts","kind":"import-statement","original":"./shell"},{"path":"packages/sdk/client-protocol/src/space.ts","kind":"import-statement","original":"./space"},{"path":"packages/sdk/client-protocol/src/timeouts.ts","kind":"import-statement","original":"./timeouts"}],"format":"esm"}},"outputs":{"packages/sdk/client-protocol/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":17749},"packages/sdk/client-protocol/dist/lib/browser/index.mjs":{"imports":[{"path":"base-x","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto/dxos/client/services","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true}],"exports":["AUTHENTICATION_CODE_LENGTH","AUTH_TIMEOUT","AuthenticatingInvitation","CREATE_SPACE_TIMEOUT","CancellableInvitation","DEFAULT_CLIENT_CHANNEL","DEFAULT_INTERNAL_CHANNEL","DEFAULT_SHELL_CHANNEL","DEFAULT_VAULT_ORIGIN","DEFAULT_VAULT_URL","DX_CACHE","DX_CONFIG","DX_DATA","DX_RUNTIME","DX_STATE","ENV_DX_CONFIG","ENV_DX_PROFILE","ENV_DX_PROFILE_DEFAULT","EXPECTED_CONFIG_VERSION","INVITATION_TIMEOUT","InvitationEncoder","LOAD_CONTROL_FEEDS_TIMEOUT","LOAD_PROPERTIES_TIMEOUT","PROXY_CONNECTION_TIMEOUT","Properties","RESOURCE_LOCK_TIMEOUT","STATUS_TIMEOUT","appServiceBundle","clientServiceBundle","defaultConfig","defaultKey","getProfilePath","iframeServiceBundle","schema","shellServiceBundle","workerServiceBundle","wrapObservable"],"entryPoint":"packages/sdk/client-protocol/src/index.ts","inputs":{"packages/sdk/client-protocol/src/config.ts":{"bytesInOutput":797},"packages/sdk/client-protocol/src/index.ts":{"bytesInOutput":0},"packages/sdk/client-protocol/src/echo.ts":{"bytesInOutput":32},"packages/sdk/client-protocol/src/invitations/encoder.ts":{"bytesInOutput":663},"packages/sdk/client-protocol/src/invitations/index.ts":{"bytesInOutput":0},"packages/sdk/client-protocol/src/invitations/invitations.ts":{"bytesInOutput":1495},"packages/sdk/client-protocol/src/proto/gen/schema.ts":{"bytesInOutput":671},"packages/sdk/client-protocol/src/proto/index.ts":{"bytesInOutput":0},"packages/sdk/client-protocol/src/service-definitions.ts":{"bytesInOutput":1426},"packages/sdk/client-protocol/src/timeouts.ts":{"bytesInOutput":224}},"bytes":6516}}}
|
package/dist/lib/node/index.cjs
CHANGED
|
@@ -32,9 +32,9 @@ var src_exports = {};
|
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
AUTHENTICATION_CODE_LENGTH: () => AUTHENTICATION_CODE_LENGTH,
|
|
34
34
|
AUTH_TIMEOUT: () => AUTH_TIMEOUT,
|
|
35
|
-
|
|
35
|
+
AuthenticatingInvitation: () => AuthenticatingInvitation,
|
|
36
36
|
CREATE_SPACE_TIMEOUT: () => CREATE_SPACE_TIMEOUT,
|
|
37
|
-
|
|
37
|
+
CancellableInvitation: () => CancellableInvitation,
|
|
38
38
|
DEFAULT_CLIENT_CHANNEL: () => DEFAULT_CLIENT_CHANNEL,
|
|
39
39
|
DEFAULT_INTERNAL_CHANNEL: () => DEFAULT_INTERNAL_CHANNEL,
|
|
40
40
|
DEFAULT_SHELL_CHANNEL: () => DEFAULT_SHELL_CHANNEL,
|
|
@@ -54,13 +54,16 @@ __export(src_exports, {
|
|
|
54
54
|
LOAD_CONTROL_FEEDS_TIMEOUT: () => LOAD_CONTROL_FEEDS_TIMEOUT,
|
|
55
55
|
LOAD_PROPERTIES_TIMEOUT: () => LOAD_PROPERTIES_TIMEOUT,
|
|
56
56
|
PROXY_CONNECTION_TIMEOUT: () => PROXY_CONNECTION_TIMEOUT,
|
|
57
|
+
Properties: () => Properties,
|
|
57
58
|
RESOURCE_LOCK_TIMEOUT: () => RESOURCE_LOCK_TIMEOUT,
|
|
58
59
|
STATUS_TIMEOUT: () => STATUS_TIMEOUT,
|
|
59
60
|
appServiceBundle: () => appServiceBundle,
|
|
60
61
|
clientServiceBundle: () => clientServiceBundle,
|
|
61
62
|
defaultConfig: () => defaultConfig,
|
|
63
|
+
defaultKey: () => defaultKey,
|
|
62
64
|
getProfilePath: () => getProfilePath,
|
|
63
65
|
iframeServiceBundle: () => iframeServiceBundle,
|
|
66
|
+
schema: () => schema2,
|
|
64
67
|
shellServiceBundle: () => shellServiceBundle,
|
|
65
68
|
workerServiceBundle: () => workerServiceBundle,
|
|
66
69
|
wrapObservable: () => wrapObservable
|
|
@@ -88,6 +91,9 @@ var ENV_DX_CONFIG = "DX_CONFIG";
|
|
|
88
91
|
var ENV_DX_PROFILE = "DX_PROFILE";
|
|
89
92
|
var ENV_DX_PROFILE_DEFAULT = "default";
|
|
90
93
|
|
|
94
|
+
// packages/sdk/client-protocol/src/echo.ts
|
|
95
|
+
var defaultKey = "__DEFAULT__";
|
|
96
|
+
|
|
91
97
|
// packages/sdk/client-protocol/src/invitations/encoder.ts
|
|
92
98
|
var import_base_x = __toESM(require("base-x"));
|
|
93
99
|
var import_protocols = require("@dxos/protocols");
|
|
@@ -117,7 +123,7 @@ var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
|
117
123
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-protocol/src/invitations/invitations.ts";
|
|
118
124
|
var AUTHENTICATION_CODE_LENGTH = 6;
|
|
119
125
|
var INVITATION_TIMEOUT = 3 * 6e4;
|
|
120
|
-
var
|
|
126
|
+
var CancellableInvitation = class extends import_async.MulticastObservable {
|
|
121
127
|
constructor({ subscriber, initialInvitation, onCancel }) {
|
|
122
128
|
super(subscriber, initialInvitation);
|
|
123
129
|
this._onCancel = onCancel;
|
|
@@ -126,7 +132,7 @@ var CancellableInvitationObservable = class extends import_async.MulticastObserv
|
|
|
126
132
|
return this._onCancel();
|
|
127
133
|
}
|
|
128
134
|
};
|
|
129
|
-
var
|
|
135
|
+
var AuthenticatingInvitation = class extends CancellableInvitation {
|
|
130
136
|
constructor({ subscriber, initialInvitation, onCancel, onAuthenticate }) {
|
|
131
137
|
super({
|
|
132
138
|
subscriber,
|
|
@@ -160,6 +166,25 @@ var wrapObservable = async (observable) => {
|
|
|
160
166
|
});
|
|
161
167
|
};
|
|
162
168
|
|
|
169
|
+
// packages/sdk/client-protocol/src/proto/gen/schema.ts
|
|
170
|
+
var dxos_echo_schema = __toESM(require("@dxos/echo-schema"));
|
|
171
|
+
var schemaJson = '{"nested":{"dxos":{"nested":{"sdk":{"nested":{"client":{"nested":{"Properties":{"options":{"(object)":true},"fields":{"name":{"type":"string","id":1}}}}}}}}}}}';
|
|
172
|
+
var schema2 = dxos_echo_schema.EchoSchema.fromJson(schemaJson);
|
|
173
|
+
var Properties = class _Properties extends dxos_echo_schema.TypedObject {
|
|
174
|
+
static {
|
|
175
|
+
this.type = schema2.getType("dxos.sdk.client.Properties");
|
|
176
|
+
}
|
|
177
|
+
static filter(opts) {
|
|
178
|
+
return _Properties.type.createFilter(opts);
|
|
179
|
+
}
|
|
180
|
+
constructor(initValues, opts) {
|
|
181
|
+
super({
|
|
182
|
+
...initValues
|
|
183
|
+
}, _Properties.type, opts);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
schema2.registerPrototype(Properties);
|
|
187
|
+
|
|
163
188
|
// packages/sdk/client-protocol/src/service-definitions.ts
|
|
164
189
|
var import_protocols2 = require("@dxos/protocols");
|
|
165
190
|
var import_rpc = require("@dxos/rpc");
|
|
@@ -203,9 +228,9 @@ var LOAD_CONTROL_FEEDS_TIMEOUT = 3e3;
|
|
|
203
228
|
0 && (module.exports = {
|
|
204
229
|
AUTHENTICATION_CODE_LENGTH,
|
|
205
230
|
AUTH_TIMEOUT,
|
|
206
|
-
|
|
231
|
+
AuthenticatingInvitation,
|
|
207
232
|
CREATE_SPACE_TIMEOUT,
|
|
208
|
-
|
|
233
|
+
CancellableInvitation,
|
|
209
234
|
DEFAULT_CLIENT_CHANNEL,
|
|
210
235
|
DEFAULT_INTERNAL_CHANNEL,
|
|
211
236
|
DEFAULT_SHELL_CHANNEL,
|
|
@@ -225,13 +250,16 @@ var LOAD_CONTROL_FEEDS_TIMEOUT = 3e3;
|
|
|
225
250
|
LOAD_CONTROL_FEEDS_TIMEOUT,
|
|
226
251
|
LOAD_PROPERTIES_TIMEOUT,
|
|
227
252
|
PROXY_CONNECTION_TIMEOUT,
|
|
253
|
+
Properties,
|
|
228
254
|
RESOURCE_LOCK_TIMEOUT,
|
|
229
255
|
STATUS_TIMEOUT,
|
|
230
256
|
appServiceBundle,
|
|
231
257
|
clientServiceBundle,
|
|
232
258
|
defaultConfig,
|
|
259
|
+
defaultKey,
|
|
233
260
|
getProfilePath,
|
|
234
261
|
iframeServiceBundle,
|
|
262
|
+
schema,
|
|
235
263
|
shellServiceBundle,
|
|
236
264
|
workerServiceBundle,
|
|
237
265
|
wrapObservable
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/index.ts", "../../../src/config.ts", "../../../src/invitations/encoder.ts", "../../../src/invitations/invitations.ts", "../../../src/service-definitions.ts", "../../../src/timeouts.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2020 DXOS.org\n//\n\nexport * from './config';\nexport * from './echo';\nexport * from './halo';\nexport * from './invitations';\nexport * from './service-definitions';\nexport * from './shell';\nexport * from './space';\nexport * from './timeouts';\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { ConfigProto } from '@dxos/config';\n\nexport const DEFAULT_INTERNAL_CHANNEL = 'dxos:vault';\nexport const DEFAULT_CLIENT_CHANNEL = 'dxos:app';\nexport const DEFAULT_SHELL_CHANNEL = 'dxos:shell';\n\nexport const DEFAULT_VAULT_ORIGIN = 'https://halo.dxos.org';\nexport const DEFAULT_VAULT_URL = DEFAULT_VAULT_ORIGIN + '/vault.html';\n\nexport const EXPECTED_CONFIG_VERSION = 1;\nexport const defaultConfig: ConfigProto = { version: 1 };\n\n// TODO(burdon): Allow override via env? Generalize since currently NodeJS only.\nconst HOME = typeof process !== 'undefined' ? process?.env?.HOME ?? '' : '';\n\n// Base directories.\n// TODO(burdon): Consider Windows, Linux, OSX.\n// https://wiki.archlinux.org/title/XDG_Base_Directory\n// Each `/dx` directory should contain `/profile/<DX_PROFILE>` subdirectories.\nexport const getProfilePath = (root: string, profile: string, file: string | undefined = undefined) =>\n `${root}/profile/${profile}` + (file ? `/${file}` : '');\n\n// XDG_CONFIG_HOME (Analogous to /etc.)\nexport const DX_CONFIG = `${HOME}/.config/dx`;\n\n// XDG_CACHE_HOME (Analogous to /var/cache).\nexport const DX_CACHE = `${HOME}/.cache/dx`;\n\n// TODO(burdon): Storage should use this by default (make path optional).\n// XDG_DATA_HOME (Analogous to /usr/share).\nexport const DX_DATA = `${HOME}/.local/share/dx`;\n\n// XDG_STATE_HOME (Analogous to /var/lib).\nexport const DX_STATE = `${HOME}/.local/state/dx`;\n\n// XDG_RUNTIME_DIR (Non-essential files, sockets, etc.)\nexport const DX_RUNTIME = '/tmp/dx/run';\n\nexport const ENV_DX_CONFIG = 'DX_CONFIG';\nexport const ENV_DX_PROFILE = 'DX_PROFILE';\nexport const ENV_DX_PROFILE_DEFAULT = 'default';\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport base from 'base-x';\n\nimport { schema } from '@dxos/protocols';\nimport { Invitation } from '@dxos/protocols/proto/dxos/client/services';\n\n// Encode with URL-safe alpha-numeric characters.\nconst base62 = base('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');\n\nconst codec = schema.getCodecForType('dxos.client.services.Invitation');\n\n/**\n * Encodes and decodes an invitation proto into/from alphanumeric chars.\n */\nexport class InvitationEncoder {\n static decode(text: string): Invitation {\n return codec.decode(base62.decode(text));\n }\n\n static encode(invitation: Invitation): string {\n return base62.encode(\n codec.encode({\n invitationId: invitation.invitationId,\n type: invitation.type,\n kind: invitation.kind,\n authMethod: invitation.authMethod,\n swarmKey: invitation.swarmKey,\n state: invitation.state,\n timeout: invitation.timeout,\n }),\n );\n }\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { MulticastObservable, Observable, Subscriber } from '@dxos/async';\nimport { invariant } from '@dxos/invariant';\nimport { Invitation } from '@dxos/protocols/proto/dxos/client/services';\n\nexport const AUTHENTICATION_CODE_LENGTH = 6;\n\nexport const INVITATION_TIMEOUT = 3 * 60_000; // 3 mins.\n\nexport interface Invitations {\n created: MulticastObservable<CancellableInvitationObservable[]>;\n accepted: MulticastObservable<AuthenticatingInvitationObservable[]>;\n createInvitation(options?: Partial<Invitation>): CancellableInvitationObservable;\n acceptInvitation(invitation: Invitation): AuthenticatingInvitationObservable;\n}\n\n/**\n * Base class for all invitation observables and providers.\n */\nexport class CancellableInvitationObservable extends MulticastObservable<Invitation> {\n private readonly _onCancel: () => Promise<void>;\n\n constructor({\n subscriber,\n initialInvitation,\n onCancel,\n }: {\n subscriber: Observable<Invitation> | Subscriber<Invitation>;\n initialInvitation: Invitation;\n onCancel: () => Promise<void>;\n }) {\n super(subscriber, initialInvitation);\n this._onCancel = onCancel;\n }\n\n cancel(): Promise<void> {\n return this._onCancel();\n }\n}\n\n/**\n * Cancelable observer that relays authentication requests.\n */\nexport class AuthenticatingInvitationObservable extends CancellableInvitationObservable {\n private readonly _onAuthenticate: (authCode: string) => Promise<void>;\n\n constructor({\n subscriber,\n initialInvitation,\n onCancel,\n onAuthenticate,\n }: {\n subscriber: Observable<Invitation> | Subscriber<Invitation>;\n initialInvitation: Invitation;\n onCancel: () => Promise<void>;\n onAuthenticate: (authCode: string) => Promise<void>;\n }) {\n super({ subscriber, initialInvitation, onCancel });\n this._onAuthenticate = onAuthenticate;\n }\n\n async authenticate(authCode: string): Promise<void> {\n return this._onAuthenticate(authCode);\n }\n}\n\n/**\n * Testing util to wrap non-authenticating observable with promise.\n * Don't use this in production code.\n * @deprecated\n */\n// TODO(wittjosiah): Move to testing.\nexport const wrapObservable = async (observable: CancellableInvitationObservable): Promise<Invitation> => {\n return new Promise((resolve, reject) => {\n const subscription = observable.subscribe(\n (invitation: Invitation | undefined) => {\n // TODO(burdon): Throw error if auth requested.\n invariant(invitation?.state === Invitation.State.SUCCESS);\n subscription.unsubscribe();\n resolve(invitation);\n },\n (err: Error) => {\n subscription.unsubscribe();\n reject(err);\n },\n );\n });\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { Context } from '@dxos/context';\nimport { schema } from '@dxos/protocols';\nimport { FunctionRegistryService } from '@dxos/protocols/proto/dxos/agent/functions';\nimport {\n DevicesService,\n IdentityService,\n InvitationsService,\n LoggingService,\n NetworkService,\n SpacesService,\n SystemService,\n} from '@dxos/protocols/proto/dxos/client/services';\nimport { DevtoolsHost } from '@dxos/protocols/proto/dxos/devtools/host';\nimport { DataService } from '@dxos/protocols/proto/dxos/echo/service';\nimport type { AppService, ShellService, WorkerService } from '@dxos/protocols/proto/dxos/iframe';\nimport type { BridgeService } from '@dxos/protocols/proto/dxos/mesh/bridge';\nimport { TracingService } from '@dxos/protocols/proto/dxos/tracing';\nimport { createServiceBundle, ServiceBundle } from '@dxos/rpc';\n\n//\n// NOTE: Should contain client/proxy dependencies only.\n//\n\nexport type ClientServices = {\n SystemService: SystemService;\n NetworkService: NetworkService;\n LoggingService: LoggingService;\n\n IdentityService: IdentityService;\n InvitationsService: InvitationsService;\n DevicesService: DevicesService;\n SpacesService: SpacesService;\n DataService: DataService;\n\n FunctionRegistryService: FunctionRegistryService;\n\n // TODO(burdon): Deprecated.\n DevtoolsHost: DevtoolsHost;\n\n TracingService: TracingService;\n};\n\n/**\n * Provide access to client services definitions and service handler.\n */\nexport interface ClientServicesProvider {\n descriptors: ServiceBundle<ClientServices>;\n services: Partial<ClientServices>;\n\n open(ctx: Context): Promise<void>;\n close(ctx: Context): Promise<void>;\n}\n\n/**\n * Services supported by host.\n */\nexport const clientServiceBundle = createServiceBundle<ClientServices>({\n SystemService: schema.getService('dxos.client.services.SystemService'),\n NetworkService: schema.getService('dxos.client.services.NetworkService'),\n LoggingService: schema.getService('dxos.client.services.LoggingService'),\n\n IdentityService: schema.getService('dxos.client.services.IdentityService'),\n InvitationsService: schema.getService('dxos.client.services.InvitationsService'),\n DevicesService: schema.getService('dxos.client.services.DevicesService'),\n SpacesService: schema.getService('dxos.client.services.SpacesService'),\n DataService: schema.getService('dxos.echo.service.DataService'),\n\n // Agent-only.\n FunctionRegistryService: schema.getService('dxos.agent.functions.FunctionRegistryService'),\n\n // TODO(burdon): Deprecated.\n DevtoolsHost: schema.getService('dxos.devtools.host.DevtoolsHost'),\n\n TracingService: schema.getService('dxos.tracing.TracingService'),\n});\n\nexport type IframeServiceBundle = {\n BridgeService: BridgeService;\n};\n\nexport const iframeServiceBundle: ServiceBundle<IframeServiceBundle> = {\n BridgeService: schema.getService('dxos.mesh.bridge.BridgeService'),\n};\n\nexport type WorkerServiceBundle = {\n WorkerService: WorkerService;\n};\n\nexport const workerServiceBundle: ServiceBundle<WorkerServiceBundle> = {\n WorkerService: schema.getService('dxos.iframe.WorkerService'),\n};\n\nexport type AppServiceBundle = {\n AppService: AppService;\n};\n\nexport const appServiceBundle: ServiceBundle<AppServiceBundle> = {\n AppService: schema.getService('dxos.iframe.AppService'),\n};\n\nexport type ShellServiceBundle = {\n ShellService: ShellService;\n};\n\nexport const shellServiceBundle: ServiceBundle<ShellServiceBundle> = {\n ShellService: schema.getService('dxos.iframe.ShellService'),\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\n/**\n * Timeout for making rpc connections from remote proxies.\n */\nexport const PROXY_CONNECTION_TIMEOUT = 30_000;\n\n/**\n * Timeout for the device to be added to the trusted set during auth.\n */\nexport const AUTH_TIMEOUT = 30_000;\n\n/**\n * Timeout for how long the remote client will wait before assuming the connection is lost.\n */\nexport const STATUS_TIMEOUT = 10_000;\n\n/**\n * Timeout for waiting before stealing resource lock.\n */\nexport const RESOURCE_LOCK_TIMEOUT = 3_000;\n\n/**\n * Timeout for space properties to be loaded in the set of tracked items.\n * Accounts for latency between SpaceService reporting the space as READY and DataService streaming the item states.\n */\nexport const LOAD_PROPERTIES_TIMEOUT = 3_000;\n\n/**\n * Timeout for creating new spaces.\n */\nexport const CREATE_SPACE_TIMEOUT = 3_000;\n\n/**\n * Timeout for loading of control feeds.\n */\nexport const LOAD_CONTROL_FEEDS_TIMEOUT = 3_000;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA
|
|
6
|
-
"names": ["DEFAULT_INTERNAL_CHANNEL", "DEFAULT_CLIENT_CHANNEL", "DEFAULT_SHELL_CHANNEL", "DEFAULT_VAULT_ORIGIN", "DEFAULT_VAULT_URL", "EXPECTED_CONFIG_VERSION", "defaultConfig", "version", "HOME", "process", "env", "getProfilePath", "root", "profile", "file", "undefined", "DX_CONFIG", "DX_CACHE", "DX_DATA", "DX_STATE", "DX_RUNTIME", "ENV_DX_CONFIG", "ENV_DX_PROFILE", "ENV_DX_PROFILE_DEFAULT", "base62", "base", "codec", "schema", "getCodecForType", "InvitationEncoder", "decode", "text", "encode", "invitation", "invitationId", "type", "kind", "authMethod", "swarmKey", "state", "timeout", "AUTHENTICATION_CODE_LENGTH", "INVITATION_TIMEOUT", "
|
|
3
|
+
"sources": ["../../../src/index.ts", "../../../src/config.ts", "../../../src/echo.ts", "../../../src/invitations/encoder.ts", "../../../src/invitations/invitations.ts", "../../../src/proto/gen/schema.ts", "../../../src/service-definitions.ts", "../../../src/timeouts.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2020 DXOS.org\n//\n\nexport * from './config';\nexport * from './echo';\nexport * from './halo';\nexport * from './invitations';\nexport * from './proto';\nexport * from './service-definitions';\nexport * from './shell';\nexport * from './space';\nexport * from './timeouts';\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { ConfigProto } from '@dxos/config';\n\nexport const DEFAULT_INTERNAL_CHANNEL = 'dxos:vault';\nexport const DEFAULT_CLIENT_CHANNEL = 'dxos:app';\nexport const DEFAULT_SHELL_CHANNEL = 'dxos:shell';\n\nexport const DEFAULT_VAULT_ORIGIN = 'https://halo.dxos.org';\nexport const DEFAULT_VAULT_URL = DEFAULT_VAULT_ORIGIN + '/vault.html';\n\nexport const EXPECTED_CONFIG_VERSION = 1;\nexport const defaultConfig: ConfigProto = { version: 1 };\n\n// TODO(burdon): Allow override via env? Generalize since currently NodeJS only.\nconst HOME = typeof process !== 'undefined' ? process?.env?.HOME ?? '' : '';\n\n// Base directories.\n// TODO(burdon): Consider Windows, Linux, OSX.\n// https://wiki.archlinux.org/title/XDG_Base_Directory\n// Each `/dx` directory should contain `/profile/<DX_PROFILE>` subdirectories.\nexport const getProfilePath = (root: string, profile: string, file: string | undefined = undefined) =>\n `${root}/profile/${profile}` + (file ? `/${file}` : '');\n\n// XDG_CONFIG_HOME (Analogous to /etc.)\nexport const DX_CONFIG = `${HOME}/.config/dx`;\n\n// XDG_CACHE_HOME (Analogous to /var/cache).\nexport const DX_CACHE = `${HOME}/.cache/dx`;\n\n// TODO(burdon): Storage should use this by default (make path optional).\n// XDG_DATA_HOME (Analogous to /usr/share).\nexport const DX_DATA = `${HOME}/.local/share/dx`;\n\n// XDG_STATE_HOME (Analogous to /var/lib).\nexport const DX_STATE = `${HOME}/.local/state/dx`;\n\n// XDG_RUNTIME_DIR (Non-essential files, sockets, etc.)\nexport const DX_RUNTIME = '/tmp/dx/run';\n\nexport const ENV_DX_CONFIG = 'DX_CONFIG';\nexport const ENV_DX_PROFILE = 'DX_PROFILE';\nexport const ENV_DX_PROFILE_DEFAULT = 'default';\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport type { MulticastObservable } from '@dxos/async';\nimport type { EchoSchema } from '@dxos/echo-schema';\nimport type { PublicKey } from '@dxos/keys';\nimport type { Invitation } from '@dxos/protocols/proto/dxos/client/services';\n\nimport type { AuthenticatingInvitation } from './invitations';\nimport type { Space } from './space';\n\n// Space properties key for default metadata.\n// TODO(wittjosiah): Remove. Default space should be indicated by data in HALO space.\nexport const defaultKey = '__DEFAULT__';\n\n/**\n * TODO(burdon): Public API (move comments here).\n */\n// TODO(wittjosiah): Rename?\n// https://ts.dev/style/#naming-style\n// ClientApi? ClientProtocol?\nexport interface Echo extends MulticastObservable<Space[]> {\n /**\n * Resolves when the default space is available.\n */\n // TODO(wittjosiah): Remove. Ensure default space is always available.\n get isReady(): MulticastObservable<boolean>;\n\n /**\n * Returns the list of spaces.\n */\n get(): Space[];\n\n /**\n * Returns the space with the given key.\n */\n get(spaceKey: PublicKey): Space | undefined;\n\n /**\n * Returns the default space.\n */\n get default(): Space;\n\n /**\n * Creates a new space.\n */\n create(): Promise<Space>;\n\n /**\n * Creates a space from the given snapshot.\n */\n // clone(snapshot: SpaceSnapshot): Promise<Space>;\n\n /**\n * Joins an existing space using the given invitation.\n */\n join(invitation: Invitation | string): AuthenticatingInvitation;\n\n /**\n * Adds a schema to ECHO.\n */\n addSchema(schema: EchoSchema): void;\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport base from 'base-x';\n\nimport { schema } from '@dxos/protocols';\nimport { Invitation } from '@dxos/protocols/proto/dxos/client/services';\n\n// Encode with URL-safe alpha-numeric characters.\nconst base62 = base('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');\n\nconst codec = schema.getCodecForType('dxos.client.services.Invitation');\n\n/**\n * Encodes and decodes an invitation proto into/from alphanumeric chars.\n */\nexport class InvitationEncoder {\n static decode(text: string): Invitation {\n return codec.decode(base62.decode(text));\n }\n\n static encode(invitation: Invitation): string {\n return base62.encode(\n codec.encode({\n invitationId: invitation.invitationId,\n type: invitation.type,\n kind: invitation.kind,\n authMethod: invitation.authMethod,\n swarmKey: invitation.swarmKey,\n state: invitation.state,\n timeout: invitation.timeout,\n }),\n );\n }\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { MulticastObservable, Observable, Subscriber } from '@dxos/async';\nimport { invariant } from '@dxos/invariant';\nimport { Invitation } from '@dxos/protocols/proto/dxos/client/services';\n\nexport const AUTHENTICATION_CODE_LENGTH = 6;\n\nexport const INVITATION_TIMEOUT = 3 * 60_000; // 3 mins.\n\nexport interface Invitations {\n created: MulticastObservable<CancellableInvitation[]>;\n accepted: MulticastObservable<AuthenticatingInvitation[]>;\n share(options?: Partial<Invitation>): CancellableInvitation;\n join(invitation: Invitation): AuthenticatingInvitation;\n}\n\n/**\n * Base class for all invitation observables and providers.\n */\nexport class CancellableInvitation extends MulticastObservable<Invitation> {\n private readonly _onCancel: () => Promise<void>;\n\n constructor({\n subscriber,\n initialInvitation,\n onCancel,\n }: {\n subscriber: Observable<Invitation> | Subscriber<Invitation>;\n initialInvitation: Invitation;\n onCancel: () => Promise<void>;\n }) {\n super(subscriber, initialInvitation);\n this._onCancel = onCancel;\n }\n\n cancel(): Promise<void> {\n return this._onCancel();\n }\n}\n\n/**\n * Cancelable observer that relays authentication requests.\n */\nexport class AuthenticatingInvitation extends CancellableInvitation {\n private readonly _onAuthenticate: (authCode: string) => Promise<void>;\n\n constructor({\n subscriber,\n initialInvitation,\n onCancel,\n onAuthenticate,\n }: {\n subscriber: Observable<Invitation> | Subscriber<Invitation>;\n initialInvitation: Invitation;\n onCancel: () => Promise<void>;\n onAuthenticate: (authCode: string) => Promise<void>;\n }) {\n super({ subscriber, initialInvitation, onCancel });\n this._onAuthenticate = onAuthenticate;\n }\n\n async authenticate(authCode: string): Promise<void> {\n return this._onAuthenticate(authCode);\n }\n}\n\n/**\n * Testing util to wrap non-authenticating observable with promise.\n * Don't use this in production code.\n * @deprecated\n */\n// TODO(wittjosiah): Move to testing.\nexport const wrapObservable = async (observable: CancellableInvitation): Promise<Invitation> => {\n return new Promise((resolve, reject) => {\n const subscription = observable.subscribe(\n (invitation: Invitation | undefined) => {\n // TODO(burdon): Throw error if auth requested.\n invariant(invitation?.state === Invitation.State.SUCCESS);\n subscription.unsubscribe();\n resolve(invitation);\n },\n (err: Error) => {\n subscription.unsubscribe();\n reject(err);\n },\n );\n });\n};\n", "/**\n * @generated @dxos/echo-typegen src/proto/schema.proto\n **/\n\nimport * as dxos_echo_schema from \"@dxos/echo-schema\";\n\nconst schemaJson =\n '{\"nested\":{\"dxos\":{\"nested\":{\"sdk\":{\"nested\":{\"client\":{\"nested\":{\"Properties\":{\"options\":{\"(object)\":true},\"fields\":{\"name\":{\"type\":\"string\",\"id\":1}}}}}}}}}}}';\n\nexport const schema = dxos_echo_schema.EchoSchema.fromJson(schemaJson);\n\nexport type PropertiesProps = {\n name: string;\n};\n\nexport class Properties extends dxos_echo_schema.TypedObject<PropertiesProps> {\n static readonly type = schema.getType(\"dxos.sdk.client.Properties\");\n\n static filter(\n opts?: Partial<PropertiesProps>\n ): dxos_echo_schema.TypeFilter<Properties> {\n return Properties.type.createFilter(opts);\n }\n\n constructor(\n initValues?: Partial<PropertiesProps>,\n opts?: dxos_echo_schema.TypedObjectOpts\n ) {\n super({ ...initValues }, Properties.type, opts);\n }\n declare name: string;\n}\n\nschema.registerPrototype(Properties);\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { Context } from '@dxos/context';\nimport { schema } from '@dxos/protocols';\nimport { FunctionRegistryService } from '@dxos/protocols/proto/dxos/agent/functions';\nimport {\n DevicesService,\n IdentityService,\n InvitationsService,\n LoggingService,\n NetworkService,\n SpacesService,\n SystemService,\n} from '@dxos/protocols/proto/dxos/client/services';\nimport { DevtoolsHost } from '@dxos/protocols/proto/dxos/devtools/host';\nimport { DataService } from '@dxos/protocols/proto/dxos/echo/service';\nimport type { AppService, ShellService, WorkerService } from '@dxos/protocols/proto/dxos/iframe';\nimport type { BridgeService } from '@dxos/protocols/proto/dxos/mesh/bridge';\nimport { TracingService } from '@dxos/protocols/proto/dxos/tracing';\nimport { createServiceBundle, ServiceBundle } from '@dxos/rpc';\n\n//\n// NOTE: Should contain client/proxy dependencies only.\n//\n\nexport type ClientServices = {\n SystemService: SystemService;\n NetworkService: NetworkService;\n LoggingService: LoggingService;\n\n IdentityService: IdentityService;\n InvitationsService: InvitationsService;\n DevicesService: DevicesService;\n SpacesService: SpacesService;\n DataService: DataService;\n\n FunctionRegistryService: FunctionRegistryService;\n\n // TODO(burdon): Deprecated.\n DevtoolsHost: DevtoolsHost;\n\n TracingService: TracingService;\n};\n\n/**\n * Provide access to client services definitions and service handler.\n */\nexport interface ClientServicesProvider {\n descriptors: ServiceBundle<ClientServices>;\n services: Partial<ClientServices>;\n\n open(ctx: Context): Promise<void>;\n close(ctx: Context): Promise<void>;\n}\n\n/**\n * Services supported by host.\n */\nexport const clientServiceBundle = createServiceBundle<ClientServices>({\n SystemService: schema.getService('dxos.client.services.SystemService'),\n NetworkService: schema.getService('dxos.client.services.NetworkService'),\n LoggingService: schema.getService('dxos.client.services.LoggingService'),\n\n IdentityService: schema.getService('dxos.client.services.IdentityService'),\n InvitationsService: schema.getService('dxos.client.services.InvitationsService'),\n DevicesService: schema.getService('dxos.client.services.DevicesService'),\n SpacesService: schema.getService('dxos.client.services.SpacesService'),\n DataService: schema.getService('dxos.echo.service.DataService'),\n\n // Agent-only.\n FunctionRegistryService: schema.getService('dxos.agent.functions.FunctionRegistryService'),\n\n // TODO(burdon): Deprecated.\n DevtoolsHost: schema.getService('dxos.devtools.host.DevtoolsHost'),\n\n TracingService: schema.getService('dxos.tracing.TracingService'),\n});\n\nexport type IframeServiceBundle = {\n BridgeService: BridgeService;\n};\n\nexport const iframeServiceBundle: ServiceBundle<IframeServiceBundle> = {\n BridgeService: schema.getService('dxos.mesh.bridge.BridgeService'),\n};\n\nexport type WorkerServiceBundle = {\n WorkerService: WorkerService;\n};\n\nexport const workerServiceBundle: ServiceBundle<WorkerServiceBundle> = {\n WorkerService: schema.getService('dxos.iframe.WorkerService'),\n};\n\nexport type AppServiceBundle = {\n AppService: AppService;\n};\n\nexport const appServiceBundle: ServiceBundle<AppServiceBundle> = {\n AppService: schema.getService('dxos.iframe.AppService'),\n};\n\nexport type ShellServiceBundle = {\n ShellService: ShellService;\n};\n\nexport const shellServiceBundle: ServiceBundle<ShellServiceBundle> = {\n ShellService: schema.getService('dxos.iframe.ShellService'),\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\n/**\n * Timeout for making rpc connections from remote proxies.\n */\nexport const PROXY_CONNECTION_TIMEOUT = 30_000;\n\n/**\n * Timeout for the device to be added to the trusted set during auth.\n */\nexport const AUTH_TIMEOUT = 30_000;\n\n/**\n * Timeout for how long the remote client will wait before assuming the connection is lost.\n */\nexport const STATUS_TIMEOUT = 10_000;\n\n/**\n * Timeout for waiting before stealing resource lock.\n */\nexport const RESOURCE_LOCK_TIMEOUT = 3_000;\n\n/**\n * Timeout for space properties to be loaded in the set of tracked items.\n * Accounts for latency between SpaceService reporting the space as READY and DataService streaming the item states.\n */\nexport const LOAD_PROPERTIES_TIMEOUT = 3_000;\n\n/**\n * Timeout for creating new spaces.\n */\nexport const CREATE_SPACE_TIMEOUT = 3_000;\n\n/**\n * Timeout for loading of control feeds.\n */\nexport const LOAD_CONTROL_FEEDS_TIMEOUT = 3_000;\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["schema", "DEFAULT_INTERNAL_CHANNEL", "DEFAULT_CLIENT_CHANNEL", "DEFAULT_SHELL_CHANNEL", "DEFAULT_VAULT_ORIGIN", "DEFAULT_VAULT_URL", "EXPECTED_CONFIG_VERSION", "defaultConfig", "version", "HOME", "process", "env", "getProfilePath", "root", "profile", "file", "undefined", "DX_CONFIG", "DX_CACHE", "DX_DATA", "DX_STATE", "DX_RUNTIME", "ENV_DX_CONFIG", "ENV_DX_PROFILE", "ENV_DX_PROFILE_DEFAULT", "defaultKey", "base62", "base", "codec", "schema", "getCodecForType", "InvitationEncoder", "decode", "text", "encode", "invitation", "invitationId", "type", "kind", "authMethod", "swarmKey", "state", "timeout", "AUTHENTICATION_CODE_LENGTH", "INVITATION_TIMEOUT", "CancellableInvitation", "MulticastObservable", "constructor", "subscriber", "initialInvitation", "onCancel", "_onCancel", "cancel", "AuthenticatingInvitation", "onAuthenticate", "_onAuthenticate", "authenticate", "authCode", "wrapObservable", "observable", "Promise", "resolve", "reject", "subscription", "subscribe", "invitation", "invariant", "state", "Invitation", "State", "SUCCESS", "unsubscribe", "err", "schemaJson", "schema", "EchoSchema", "fromJson", "Properties", "TypedObject", "type", "getType", "filter", "opts", "createFilter", "constructor", "initValues", "registerPrototype", "import_protocols", "clientServiceBundle", "createServiceBundle", "SystemService", "schema", "getService", "NetworkService", "LoggingService", "IdentityService", "InvitationsService", "DevicesService", "SpacesService", "DataService", "FunctionRegistryService", "DevtoolsHost", "TracingService", "iframeServiceBundle", "BridgeService", "workerServiceBundle", "WorkerService", "appServiceBundle", "AppService", "shellServiceBundle", "ShellService", "PROXY_CONNECTION_TIMEOUT", "AUTH_TIMEOUT", "STATUS_TIMEOUT", "RESOURCE_LOCK_TIMEOUT", "LOAD_PROPERTIES_TIMEOUT", "CREATE_SPACE_TIMEOUT", "LOAD_CONTROL_FEEDS_TIMEOUT"]
|
|
7
7
|
}
|
package/dist/lib/node/meta.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/sdk/client-protocol/src/config.ts":{"bytes":5848,"imports":[],"format":"esm"},"packages/sdk/client-protocol/src/echo.ts":{"bytes":
|
|
1
|
+
{"inputs":{"packages/sdk/client-protocol/src/config.ts":{"bytes":5848,"imports":[],"format":"esm"},"packages/sdk/client-protocol/src/echo.ts":{"bytes":2780,"imports":[],"format":"esm"},"packages/sdk/client-protocol/src/halo.ts":{"bytes":1687,"imports":[],"format":"esm"},"packages/sdk/client-protocol/src/invitations/encoder.ts":{"bytes":3446,"imports":[{"path":"base-x","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true}],"format":"esm"},"packages/sdk/client-protocol/src/invitations/invitations.ts":{"bytes":7737,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto/dxos/client/services","kind":"import-statement","external":true}],"format":"esm"},"packages/sdk/client-protocol/src/invitations/index.ts":{"bytes":578,"imports":[{"path":"packages/sdk/client-protocol/src/invitations/encoder.ts","kind":"import-statement","original":"./encoder"},{"path":"packages/sdk/client-protocol/src/invitations/invitations.ts","kind":"import-statement","original":"./invitations"}],"format":"esm"},"packages/sdk/client-protocol/src/proto/gen/schema.ts":{"bytes":3164,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"format":"esm"},"packages/sdk/client-protocol/src/proto/index.ts":{"bytes":480,"imports":[{"path":"packages/sdk/client-protocol/src/proto/gen/schema.ts","kind":"import-statement","original":"./gen/schema"}],"format":"esm"},"packages/sdk/client-protocol/src/service-definitions.ts":{"bytes":8188,"imports":[{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true}],"format":"esm"},"packages/sdk/client-protocol/src/shell.ts":{"bytes":1004,"imports":[],"format":"esm"},"packages/sdk/client-protocol/src/space.ts":{"bytes":3784,"imports":[],"format":"esm"},"packages/sdk/client-protocol/src/timeouts.ts":{"bytes":3134,"imports":[],"format":"esm"},"packages/sdk/client-protocol/src/index.ts":{"bytes":1167,"imports":[{"path":"packages/sdk/client-protocol/src/config.ts","kind":"import-statement","original":"./config"},{"path":"packages/sdk/client-protocol/src/echo.ts","kind":"import-statement","original":"./echo"},{"path":"packages/sdk/client-protocol/src/halo.ts","kind":"import-statement","original":"./halo"},{"path":"packages/sdk/client-protocol/src/invitations/index.ts","kind":"import-statement","original":"./invitations"},{"path":"packages/sdk/client-protocol/src/proto/index.ts","kind":"import-statement","original":"./proto"},{"path":"packages/sdk/client-protocol/src/service-definitions.ts","kind":"import-statement","original":"./service-definitions"},{"path":"packages/sdk/client-protocol/src/shell.ts","kind":"import-statement","original":"./shell"},{"path":"packages/sdk/client-protocol/src/space.ts","kind":"import-statement","original":"./space"},{"path":"packages/sdk/client-protocol/src/timeouts.ts","kind":"import-statement","original":"./timeouts"}],"format":"esm"}},"outputs":{"packages/sdk/client-protocol/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":18094},"packages/sdk/client-protocol/dist/lib/node/index.cjs":{"imports":[{"path":"base-x","kind":"require-call","external":true},{"path":"@dxos/protocols","kind":"require-call","external":true},{"path":"@dxos/async","kind":"require-call","external":true},{"path":"@dxos/invariant","kind":"require-call","external":true},{"path":"@dxos/protocols/proto/dxos/client/services","kind":"require-call","external":true},{"path":"@dxos/echo-schema","kind":"require-call","external":true},{"path":"@dxos/protocols","kind":"require-call","external":true},{"path":"@dxos/rpc","kind":"require-call","external":true}],"exports":[],"entryPoint":"packages/sdk/client-protocol/src/index.ts","inputs":{"packages/sdk/client-protocol/src/index.ts":{"bytesInOutput":1782},"packages/sdk/client-protocol/src/config.ts":{"bytesInOutput":797},"packages/sdk/client-protocol/src/echo.ts":{"bytesInOutput":32},"packages/sdk/client-protocol/src/invitations/encoder.ts":{"bytesInOutput":732},"packages/sdk/client-protocol/src/invitations/index.ts":{"bytesInOutput":0},"packages/sdk/client-protocol/src/invitations/invitations.ts":{"bytesInOutput":1548},"packages/sdk/client-protocol/src/proto/gen/schema.ts":{"bytesInOutput":678},"packages/sdk/client-protocol/src/proto/index.ts":{"bytesInOutput":0},"packages/sdk/client-protocol/src/service-definitions.ts":{"bytesInOutput":1686},"packages/sdk/client-protocol/src/timeouts.ts":{"bytesInOutput":224}},"bytes":10198}}}
|
package/dist/types/src/echo.d.ts
CHANGED
|
@@ -1,17 +1,44 @@
|
|
|
1
1
|
import type { MulticastObservable } from '@dxos/async';
|
|
2
|
-
import type {
|
|
2
|
+
import type { EchoSchema } from '@dxos/echo-schema';
|
|
3
3
|
import type { PublicKey } from '@dxos/keys';
|
|
4
4
|
import type { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
5
|
-
import type {
|
|
5
|
+
import type { AuthenticatingInvitation } from './invitations';
|
|
6
6
|
import type { Space } from './space';
|
|
7
|
+
export declare const defaultKey = "__DEFAULT__";
|
|
7
8
|
/**
|
|
8
9
|
* TODO(burdon): Public API (move comments here).
|
|
9
10
|
*/
|
|
10
|
-
export interface Echo {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
export interface Echo extends MulticastObservable<Space[]> {
|
|
12
|
+
/**
|
|
13
|
+
* Resolves when the default space is available.
|
|
14
|
+
*/
|
|
15
|
+
get isReady(): MulticastObservable<boolean>;
|
|
16
|
+
/**
|
|
17
|
+
* Returns the list of spaces.
|
|
18
|
+
*/
|
|
19
|
+
get(): Space[];
|
|
20
|
+
/**
|
|
21
|
+
* Returns the space with the given key.
|
|
22
|
+
*/
|
|
23
|
+
get(spaceKey: PublicKey): Space | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Returns the default space.
|
|
26
|
+
*/
|
|
27
|
+
get default(): Space;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new space.
|
|
30
|
+
*/
|
|
31
|
+
create(): Promise<Space>;
|
|
32
|
+
/**
|
|
33
|
+
* Creates a space from the given snapshot.
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* Joins an existing space using the given invitation.
|
|
37
|
+
*/
|
|
38
|
+
join(invitation: Invitation | string): AuthenticatingInvitation;
|
|
39
|
+
/**
|
|
40
|
+
* Adds a schema to ECHO.
|
|
41
|
+
*/
|
|
42
|
+
addSchema(schema: EchoSchema): void;
|
|
16
43
|
}
|
|
17
44
|
//# sourceMappingURL=echo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"echo.d.ts","sourceRoot":"","sources":["../../../src/echo.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"echo.d.ts","sourceRoot":"","sources":["../../../src/echo.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAE7E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAIrC,eAAO,MAAM,UAAU,gBAAgB,CAAC;AAExC;;GAEG;AAIH,MAAM,WAAW,IAAK,SAAQ,mBAAmB,CAAC,KAAK,EAAE,CAAC;IACxD;;OAEG;IAEH,IAAI,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAE5C;;OAEG;IACH,GAAG,IAAI,KAAK,EAAE,CAAC;IAEf;;OAEG;IACH,GAAG,CAAC,QAAQ,EAAE,SAAS,GAAG,KAAK,GAAG,SAAS,CAAC;IAE5C;;OAEG;IACH,IAAI,OAAO,IAAI,KAAK,CAAC;IAErB;;OAEG;IACH,MAAM,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;IAEzB;;OAEG;IAGH;;OAEG;IACH,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,GAAG,wBAAwB,CAAC;IAEhE;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;CACrC"}
|
package/dist/types/src/halo.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MulticastObservable } from '@dxos/async';
|
|
2
2
|
import { Contact, Device, Identity, Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
3
3
|
import { ProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
4
|
-
import {
|
|
4
|
+
import { AuthenticatingInvitation, CancellableInvitation } from './invitations';
|
|
5
5
|
/**
|
|
6
6
|
* TODO(burdon): Public API (move comments here).
|
|
7
7
|
*/
|
|
@@ -10,11 +10,11 @@ export interface Halo {
|
|
|
10
10
|
get devices(): MulticastObservable<Device[]>;
|
|
11
11
|
get device(): Device | undefined;
|
|
12
12
|
get contacts(): MulticastObservable<Contact[]>;
|
|
13
|
-
get invitations(): MulticastObservable<
|
|
13
|
+
get invitations(): MulticastObservable<CancellableInvitation[]>;
|
|
14
14
|
createIdentity(options?: ProfileDocument): Promise<Identity>;
|
|
15
15
|
recoverIdentity(recoveryKey: Uint8Array): Promise<Identity>;
|
|
16
16
|
updateProfile(profile: ProfileDocument): Promise<Identity>;
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
share(): CancellableInvitation;
|
|
18
|
+
join(invitation: Invitation): AuthenticatingInvitation;
|
|
19
19
|
}
|
|
20
20
|
//# sourceMappingURL=halo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"halo.d.ts","sourceRoot":"","sources":["../../../src/halo.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AACnG,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAE9E,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"halo.d.ts","sourceRoot":"","sources":["../../../src/halo.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AACnG,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAE9E,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEhF;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,IAAI,QAAQ,IAAI,mBAAmB,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;IACrD,IAAI,OAAO,IAAI,mBAAmB,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7C,IAAI,MAAM,IAAI,MAAM,GAAG,SAAS,CAAC;IACjC,IAAI,QAAQ,IAAI,mBAAmB,CAAC,OAAO,EAAE,CAAC,CAAC;IAC/C,IAAI,WAAW,IAAI,mBAAmB,CAAC,qBAAqB,EAAE,CAAC,CAAC;IAEhE,cAAc,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7D,eAAe,CAAC,WAAW,EAAE,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC5D,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE3D,KAAK,IAAI,qBAAqB,CAAC;IAC/B,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,wBAAwB,CAAC;CACxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,uBAAuB,CAAC;AACtC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC"}
|
|
@@ -3,15 +3,15 @@ import { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
|
3
3
|
export declare const AUTHENTICATION_CODE_LENGTH = 6;
|
|
4
4
|
export declare const INVITATION_TIMEOUT: number;
|
|
5
5
|
export interface Invitations {
|
|
6
|
-
created: MulticastObservable<
|
|
7
|
-
accepted: MulticastObservable<
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
created: MulticastObservable<CancellableInvitation[]>;
|
|
7
|
+
accepted: MulticastObservable<AuthenticatingInvitation[]>;
|
|
8
|
+
share(options?: Partial<Invitation>): CancellableInvitation;
|
|
9
|
+
join(invitation: Invitation): AuthenticatingInvitation;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Base class for all invitation observables and providers.
|
|
13
13
|
*/
|
|
14
|
-
export declare class
|
|
14
|
+
export declare class CancellableInvitation extends MulticastObservable<Invitation> {
|
|
15
15
|
private readonly _onCancel;
|
|
16
16
|
constructor({ subscriber, initialInvitation, onCancel, }: {
|
|
17
17
|
subscriber: Observable<Invitation> | Subscriber<Invitation>;
|
|
@@ -23,7 +23,7 @@ export declare class CancellableInvitationObservable extends MulticastObservable
|
|
|
23
23
|
/**
|
|
24
24
|
* Cancelable observer that relays authentication requests.
|
|
25
25
|
*/
|
|
26
|
-
export declare class
|
|
26
|
+
export declare class AuthenticatingInvitation extends CancellableInvitation {
|
|
27
27
|
private readonly _onAuthenticate;
|
|
28
28
|
constructor({ subscriber, initialInvitation, onCancel, onAuthenticate, }: {
|
|
29
29
|
subscriber: Observable<Invitation> | Subscriber<Invitation>;
|
|
@@ -38,5 +38,5 @@ export declare class AuthenticatingInvitationObservable extends CancellableInvit
|
|
|
38
38
|
* Don't use this in production code.
|
|
39
39
|
* @deprecated
|
|
40
40
|
*/
|
|
41
|
-
export declare const wrapObservable: (observable:
|
|
41
|
+
export declare const wrapObservable: (observable: CancellableInvitation) => Promise<Invitation>;
|
|
42
42
|
//# sourceMappingURL=invitations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invitations.d.ts","sourceRoot":"","sources":["../../../../src/invitations/invitations.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE1E,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAExE,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAE5C,eAAO,MAAM,kBAAkB,QAAa,CAAC;AAE7C,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,mBAAmB,CAAC
|
|
1
|
+
{"version":3,"file":"invitations.d.ts","sourceRoot":"","sources":["../../../../src/invitations/invitations.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE1E,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAExE,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAE5C,eAAO,MAAM,kBAAkB,QAAa,CAAC;AAE7C,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,mBAAmB,CAAC,qBAAqB,EAAE,CAAC,CAAC;IACtD,QAAQ,EAAE,mBAAmB,CAAC,wBAAwB,EAAE,CAAC,CAAC;IAC1D,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,qBAAqB,CAAC;IAC5D,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,wBAAwB,CAAC;CACxD;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,mBAAmB,CAAC,UAAU,CAAC;IACxE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAsB;gBAEpC,EACV,UAAU,EACV,iBAAiB,EACjB,QAAQ,GACT,EAAE;QACD,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;QAC5D,iBAAiB,EAAE,UAAU,CAAC;QAC9B,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;KAC/B;IAKD,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAGxB;AAED;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,qBAAqB;IACjE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAsC;gBAE1D,EACV,UAAU,EACV,iBAAiB,EACjB,QAAQ,EACR,cAAc,GACf,EAAE;QACD,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;QAC5D,iBAAiB,EAAE,UAAU,CAAC;QAC9B,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;QAC9B,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;KACrD;IAKK,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGpD;AAED;;;;GAIG;AAEH,eAAO,MAAM,cAAc,eAAsB,qBAAqB,KAAG,QAAQ,UAAU,CAe1F,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @generated @dxos/echo-typegen src/proto/schema.proto
|
|
3
|
+
**/
|
|
4
|
+
import * as dxos_echo_schema from "@dxos/echo-schema";
|
|
5
|
+
export declare const schema: dxos_echo_schema.EchoSchema;
|
|
6
|
+
export type PropertiesProps = {
|
|
7
|
+
name: string;
|
|
8
|
+
};
|
|
9
|
+
export declare class Properties extends dxos_echo_schema.TypedObject<PropertiesProps> {
|
|
10
|
+
static readonly type: dxos_echo_schema.EchoSchemaType;
|
|
11
|
+
static filter(opts?: Partial<PropertiesProps>): dxos_echo_schema.TypeFilter<Properties>;
|
|
12
|
+
constructor(initValues?: Partial<PropertiesProps>, opts?: dxos_echo_schema.TypedObjectOpts);
|
|
13
|
+
name: string;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../../src/proto/gen/schema.ts"],"names":[],"mappings":"AAAA;;IAEI;AAEJ,OAAO,KAAK,gBAAgB,MAAM,mBAAmB,CAAC;AAKtD,eAAO,MAAM,MAAM,6BAAmD,CAAC;AAEvE,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,qBAAa,UAAW,SAAQ,gBAAgB,CAAC,WAAW,CAAC,eAAe,CAAC;IAC3E,MAAM,CAAC,QAAQ,CAAC,IAAI,kCAAgD;IAEpE,MAAM,CAAC,MAAM,CACX,IAAI,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,GAC9B,gBAAgB,CAAC,UAAU,CAAC,UAAU,CAAC;gBAKxC,UAAU,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,EACrC,IAAI,CAAC,EAAE,gBAAgB,CAAC,eAAe;IAIjC,IAAI,EAAE,MAAM,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/proto/index.ts"],"names":[],"mappings":"AAIA,cAAc,cAAc,CAAC"}
|
|
@@ -6,7 +6,7 @@ export interface ShellRuntime {
|
|
|
6
6
|
layout: ShellLayout;
|
|
7
7
|
invitationCode?: string;
|
|
8
8
|
spaceKey?: PublicKey;
|
|
9
|
-
setLayout: (
|
|
9
|
+
setLayout: (request: LayoutRequest) => void;
|
|
10
10
|
setAppContext: (context: AppContextRequest) => Promise<void>;
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=shell.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../../src/shell.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAElG,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IACnC,MAAM,EAAE,WAAW,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../../src/shell.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAElG,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IACnC,MAAM,EAAE,WAAW,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,CAAC;IAC5C,aAAa,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9D"}
|
|
@@ -5,7 +5,7 @@ import { PublicKey } from '@dxos/keys';
|
|
|
5
5
|
import { Invitation, Space as SpaceData, SpaceMember, SpaceState } from '@dxos/protocols/proto/dxos/client/services';
|
|
6
6
|
import { SpaceSnapshot } from '@dxos/protocols/proto/dxos/echo/snapshot';
|
|
7
7
|
import { GossipMessage } from '@dxos/protocols/proto/dxos/mesh/teleport/gossip';
|
|
8
|
-
import {
|
|
8
|
+
import { CancellableInvitation } from './invitations';
|
|
9
9
|
export interface SpaceInternal {
|
|
10
10
|
get db(): DatabaseProxy;
|
|
11
11
|
get data(): SpaceData;
|
|
@@ -21,6 +21,7 @@ export interface SpaceInternal {
|
|
|
21
21
|
*/
|
|
22
22
|
close(): Promise<void>;
|
|
23
23
|
createEpoch(): Promise<void>;
|
|
24
|
+
removeMember(memberKey: PublicKey): Promise<void>;
|
|
24
25
|
}
|
|
25
26
|
export interface Space {
|
|
26
27
|
get key(): PublicKey;
|
|
@@ -43,7 +44,7 @@ export interface Space {
|
|
|
43
44
|
* Current state of space pipeline.
|
|
44
45
|
*/
|
|
45
46
|
get pipeline(): MulticastObservable<SpaceData.PipelineState>;
|
|
46
|
-
get invitations(): MulticastObservable<
|
|
47
|
+
get invitations(): MulticastObservable<CancellableInvitation[]>;
|
|
47
48
|
get members(): MulticastObservable<SpaceMember[]>;
|
|
48
49
|
get internal(): SpaceInternal;
|
|
49
50
|
open(): Promise<void>;
|
|
@@ -54,7 +55,7 @@ export interface Space {
|
|
|
54
55
|
waitUntilReady(): Promise<this>;
|
|
55
56
|
postMessage: (channel: string, message: any) => Promise<void>;
|
|
56
57
|
listen: (channel: string, callback: (message: GossipMessage) => void) => UnsubscribeCallback;
|
|
57
|
-
|
|
58
|
+
share(options?: Partial<Invitation>): CancellableInvitation;
|
|
58
59
|
createSnapshot(): Promise<SpaceSnapshot>;
|
|
59
60
|
}
|
|
60
61
|
//# sourceMappingURL=space.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"space.d.ts","sourceRoot":"","sources":["../../../src/space.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,KAAK,IAAI,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AACrH,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAEhF,OAAO,EAAE
|
|
1
|
+
{"version":3,"file":"space.d.ts","sourceRoot":"","sources":["../../../src/space.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,KAAK,IAAI,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AACrH,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAEhF,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,IAAI,aAAa,CAAC;IACxB,IAAI,IAAI,IAAI,SAAS,CAAC;IAEtB;;;OAGG;IACH,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtB;;;;OAIG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAGvB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7B,YAAY,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnD;AAGD,MAAM,WAAW,KAAK;IACpB,IAAI,GAAG,IAAI,SAAS,CAAC;IAErB;;OAEG;IACH,IAAI,EAAE,IAAI,YAAY,CAAC;IACvB,IAAI,MAAM,IAAI,OAAO,CAAC;IAEtB;;OAEG;IACH,IAAI,UAAU,IAAI,WAAW,CAAC;IAE9B;;;;OAIG;IACH,IAAI,KAAK,IAAI,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAE7C;;OAEG;IACH,IAAI,QAAQ,IAAI,mBAAmB,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;IAE7D,IAAI,WAAW,IAAI,mBAAmB,CAAC,qBAAqB,EAAE,CAAC,CAAC;IAChE,IAAI,OAAO,IAAI,mBAAmB,CAAC,WAAW,EAAE,CAAC,CAAC;IAElD,IAAI,QAAQ,IAAI,aAAa,CAAC;IAE9B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB;;OAEG;IACH,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAGhC,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9D,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,KAAK,mBAAmB,CAAC;IAE7F,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,qBAAqB,CAAC;IAE5D,cAAc,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;CAC1C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/client-protocol",
|
|
3
|
-
"version": "0.1.58-main.
|
|
3
|
+
"version": "0.1.58-main.7822bed",
|
|
4
4
|
"description": "Core DXOS Client API.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -18,21 +18,27 @@
|
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"base-x": "~3.0.9",
|
|
21
|
-
"@dxos/async": "0.1.58-main.
|
|
22
|
-
"@dxos/config": "0.1.58-main.
|
|
23
|
-
"@dxos/context": "0.1.58-main.
|
|
24
|
-
"@dxos/document-model": "0.1.58-main.
|
|
25
|
-
"@dxos/echo-db": "0.1.58-main.
|
|
26
|
-
"@dxos/echo-schema": "0.1.58-main.
|
|
27
|
-
"@dxos/invariant": "0.1.58-main.
|
|
28
|
-
"@dxos/keys": "0.1.58-main.
|
|
29
|
-
"@dxos/model-factory": "0.1.58-main.
|
|
30
|
-
"@dxos/node-std": "0.1.58-main.
|
|
31
|
-
"@dxos/protocols": "0.1.58-main.
|
|
32
|
-
"@dxos/rpc": "0.1.58-main.
|
|
33
|
-
"@dxos/text-model": "0.1.58-main.
|
|
21
|
+
"@dxos/async": "0.1.58-main.7822bed",
|
|
22
|
+
"@dxos/config": "0.1.58-main.7822bed",
|
|
23
|
+
"@dxos/context": "0.1.58-main.7822bed",
|
|
24
|
+
"@dxos/document-model": "0.1.58-main.7822bed",
|
|
25
|
+
"@dxos/echo-db": "0.1.58-main.7822bed",
|
|
26
|
+
"@dxos/echo-schema": "0.1.58-main.7822bed",
|
|
27
|
+
"@dxos/invariant": "0.1.58-main.7822bed",
|
|
28
|
+
"@dxos/keys": "0.1.58-main.7822bed",
|
|
29
|
+
"@dxos/model-factory": "0.1.58-main.7822bed",
|
|
30
|
+
"@dxos/node-std": "0.1.58-main.7822bed",
|
|
31
|
+
"@dxos/protocols": "0.1.58-main.7822bed",
|
|
32
|
+
"@dxos/rpc": "0.1.58-main.7822bed",
|
|
33
|
+
"@dxos/text-model": "0.1.58-main.7822bed"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@dxos/echo-typegen": "0.1.58-main.7822bed"
|
|
34
37
|
},
|
|
35
38
|
"publishConfig": {
|
|
36
39
|
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"prebuild": "dxtype src/proto/schema.proto src/proto/gen/schema.ts"
|
|
37
43
|
}
|
|
38
44
|
}
|
package/src/echo.ts
CHANGED
|
@@ -3,28 +3,62 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import type { MulticastObservable } from '@dxos/async';
|
|
6
|
-
import type {
|
|
6
|
+
import type { EchoSchema } from '@dxos/echo-schema';
|
|
7
7
|
import type { PublicKey } from '@dxos/keys';
|
|
8
8
|
import type { Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
9
9
|
|
|
10
|
-
import type {
|
|
10
|
+
import type { AuthenticatingInvitation } from './invitations';
|
|
11
11
|
import type { Space } from './space';
|
|
12
12
|
|
|
13
|
+
// Space properties key for default metadata.
|
|
14
|
+
// TODO(wittjosiah): Remove. Default space should be indicated by data in HALO space.
|
|
15
|
+
export const defaultKey = '__DEFAULT__';
|
|
16
|
+
|
|
13
17
|
/**
|
|
14
18
|
* TODO(burdon): Public API (move comments here).
|
|
15
19
|
*/
|
|
16
20
|
// TODO(wittjosiah): Rename?
|
|
17
21
|
// https://ts.dev/style/#naming-style
|
|
18
22
|
// ClientApi? ClientProtocol?
|
|
19
|
-
export interface Echo {
|
|
20
|
-
|
|
23
|
+
export interface Echo extends MulticastObservable<Space[]> {
|
|
24
|
+
/**
|
|
25
|
+
* Resolves when the default space is available.
|
|
26
|
+
*/
|
|
27
|
+
// TODO(wittjosiah): Remove. Ensure default space is always available.
|
|
28
|
+
get isReady(): MulticastObservable<boolean>;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Returns the list of spaces.
|
|
32
|
+
*/
|
|
33
|
+
get(): Space[];
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Returns the space with the given key.
|
|
37
|
+
*/
|
|
38
|
+
get(spaceKey: PublicKey): Space | undefined;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Returns the default space.
|
|
42
|
+
*/
|
|
43
|
+
get default(): Space;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Creates a new space.
|
|
47
|
+
*/
|
|
48
|
+
create(): Promise<Space>;
|
|
21
49
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Creates a space from the given snapshot.
|
|
52
|
+
*/
|
|
53
|
+
// clone(snapshot: SpaceSnapshot): Promise<Space>;
|
|
25
54
|
|
|
26
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Joins an existing space using the given invitation.
|
|
57
|
+
*/
|
|
58
|
+
join(invitation: Invitation | string): AuthenticatingInvitation;
|
|
27
59
|
|
|
28
|
-
|
|
29
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Adds a schema to ECHO.
|
|
62
|
+
*/
|
|
63
|
+
addSchema(schema: EchoSchema): void;
|
|
30
64
|
}
|
package/src/halo.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { MulticastObservable } from '@dxos/async';
|
|
|
6
6
|
import { Contact, Device, Identity, Invitation } from '@dxos/protocols/proto/dxos/client/services';
|
|
7
7
|
import { ProfileDocument } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { AuthenticatingInvitation, CancellableInvitation } from './invitations';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* TODO(burdon): Public API (move comments here).
|
|
@@ -16,12 +16,12 @@ export interface Halo {
|
|
|
16
16
|
get devices(): MulticastObservable<Device[]>;
|
|
17
17
|
get device(): Device | undefined;
|
|
18
18
|
get contacts(): MulticastObservable<Contact[]>;
|
|
19
|
-
get invitations(): MulticastObservable<
|
|
19
|
+
get invitations(): MulticastObservable<CancellableInvitation[]>;
|
|
20
20
|
|
|
21
21
|
createIdentity(options?: ProfileDocument): Promise<Identity>;
|
|
22
22
|
recoverIdentity(recoveryKey: Uint8Array): Promise<Identity>;
|
|
23
23
|
updateProfile(profile: ProfileDocument): Promise<Identity>;
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
share(): CancellableInvitation;
|
|
26
|
+
join(invitation: Invitation): AuthenticatingInvitation;
|
|
27
27
|
}
|
package/src/index.ts
CHANGED
|
@@ -11,16 +11,16 @@ export const AUTHENTICATION_CODE_LENGTH = 6;
|
|
|
11
11
|
export const INVITATION_TIMEOUT = 3 * 60_000; // 3 mins.
|
|
12
12
|
|
|
13
13
|
export interface Invitations {
|
|
14
|
-
created: MulticastObservable<
|
|
15
|
-
accepted: MulticastObservable<
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
created: MulticastObservable<CancellableInvitation[]>;
|
|
15
|
+
accepted: MulticastObservable<AuthenticatingInvitation[]>;
|
|
16
|
+
share(options?: Partial<Invitation>): CancellableInvitation;
|
|
17
|
+
join(invitation: Invitation): AuthenticatingInvitation;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Base class for all invitation observables and providers.
|
|
22
22
|
*/
|
|
23
|
-
export class
|
|
23
|
+
export class CancellableInvitation extends MulticastObservable<Invitation> {
|
|
24
24
|
private readonly _onCancel: () => Promise<void>;
|
|
25
25
|
|
|
26
26
|
constructor({
|
|
@@ -44,7 +44,7 @@ export class CancellableInvitationObservable extends MulticastObservable<Invitat
|
|
|
44
44
|
/**
|
|
45
45
|
* Cancelable observer that relays authentication requests.
|
|
46
46
|
*/
|
|
47
|
-
export class
|
|
47
|
+
export class AuthenticatingInvitation extends CancellableInvitation {
|
|
48
48
|
private readonly _onAuthenticate: (authCode: string) => Promise<void>;
|
|
49
49
|
|
|
50
50
|
constructor({
|
|
@@ -73,7 +73,7 @@ export class AuthenticatingInvitationObservable extends CancellableInvitationObs
|
|
|
73
73
|
* @deprecated
|
|
74
74
|
*/
|
|
75
75
|
// TODO(wittjosiah): Move to testing.
|
|
76
|
-
export const wrapObservable = async (observable:
|
|
76
|
+
export const wrapObservable = async (observable: CancellableInvitation): Promise<Invitation> => {
|
|
77
77
|
return new Promise((resolve, reject) => {
|
|
78
78
|
const subscription = observable.subscribe(
|
|
79
79
|
(invitation: Invitation | undefined) => {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @generated @dxos/echo-typegen src/proto/schema.proto
|
|
3
|
+
**/
|
|
4
|
+
|
|
5
|
+
import * as dxos_echo_schema from "@dxos/echo-schema";
|
|
6
|
+
|
|
7
|
+
const schemaJson =
|
|
8
|
+
'{"nested":{"dxos":{"nested":{"sdk":{"nested":{"client":{"nested":{"Properties":{"options":{"(object)":true},"fields":{"name":{"type":"string","id":1}}}}}}}}}}}';
|
|
9
|
+
|
|
10
|
+
export const schema = dxos_echo_schema.EchoSchema.fromJson(schemaJson);
|
|
11
|
+
|
|
12
|
+
export type PropertiesProps = {
|
|
13
|
+
name: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export class Properties extends dxos_echo_schema.TypedObject<PropertiesProps> {
|
|
17
|
+
static readonly type = schema.getType("dxos.sdk.client.Properties");
|
|
18
|
+
|
|
19
|
+
static filter(
|
|
20
|
+
opts?: Partial<PropertiesProps>
|
|
21
|
+
): dxos_echo_schema.TypeFilter<Properties> {
|
|
22
|
+
return Properties.type.createFilter(opts);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
constructor(
|
|
26
|
+
initValues?: Partial<PropertiesProps>,
|
|
27
|
+
opts?: dxos_echo_schema.TypedObjectOpts
|
|
28
|
+
) {
|
|
29
|
+
super({ ...initValues }, Properties.type, opts);
|
|
30
|
+
}
|
|
31
|
+
declare name: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
schema.registerPrototype(Properties);
|
package/src/shell.ts
CHANGED
|
@@ -11,6 +11,6 @@ export interface ShellRuntime {
|
|
|
11
11
|
layout: ShellLayout;
|
|
12
12
|
invitationCode?: string;
|
|
13
13
|
spaceKey?: PublicKey;
|
|
14
|
-
setLayout: (
|
|
14
|
+
setLayout: (request: LayoutRequest) => void;
|
|
15
15
|
setAppContext: (context: AppContextRequest) => Promise<void>;
|
|
16
16
|
}
|
package/src/space.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { Invitation, Space as SpaceData, SpaceMember, SpaceState } from '@dxos/p
|
|
|
10
10
|
import { SpaceSnapshot } from '@dxos/protocols/proto/dxos/echo/snapshot';
|
|
11
11
|
import { GossipMessage } from '@dxos/protocols/proto/dxos/mesh/teleport/gossip';
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { CancellableInvitation } from './invitations';
|
|
14
14
|
|
|
15
15
|
export interface SpaceInternal {
|
|
16
16
|
get db(): DatabaseProxy;
|
|
@@ -31,6 +31,8 @@ export interface SpaceInternal {
|
|
|
31
31
|
|
|
32
32
|
// TODO(dmaretskyi): Return epoch info.
|
|
33
33
|
createEpoch(): Promise<void>;
|
|
34
|
+
|
|
35
|
+
removeMember(memberKey: PublicKey): Promise<void>;
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
// TODO(burdon): Separate public API form implementation (move comments here).
|
|
@@ -60,7 +62,7 @@ export interface Space {
|
|
|
60
62
|
*/
|
|
61
63
|
get pipeline(): MulticastObservable<SpaceData.PipelineState>;
|
|
62
64
|
|
|
63
|
-
get invitations(): MulticastObservable<
|
|
65
|
+
get invitations(): MulticastObservable<CancellableInvitation[]>;
|
|
64
66
|
get members(): MulticastObservable<SpaceMember[]>;
|
|
65
67
|
|
|
66
68
|
get internal(): SpaceInternal;
|
|
@@ -78,7 +80,7 @@ export interface Space {
|
|
|
78
80
|
|
|
79
81
|
listen: (channel: string, callback: (message: GossipMessage) => void) => UnsubscribeCallback;
|
|
80
82
|
|
|
81
|
-
|
|
83
|
+
share(options?: Partial<Invitation>): CancellableInvitation;
|
|
82
84
|
|
|
83
85
|
createSnapshot(): Promise<SpaceSnapshot>;
|
|
84
86
|
}
|