@dxos/halo-adapter-client 0.0.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -0
- package/dist/lib/index.mjs +358 -0
- package/dist/lib/index.mjs.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/moon.yml +1 -7
- package/package.json +9 -9
- package/vite.config.ts +7 -0
- package/dist/lib/neutral/index.mjs +0 -479
- package/dist/lib/neutral/index.mjs.map +0 -7
- package/dist/lib/neutral/meta.json +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# @dxos/halo-adapter-client
|
|
2
|
+
|
|
3
|
+
## 0.11.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @dxos/async@0.11.1
|
|
8
|
+
- @dxos/client@0.11.1
|
|
9
|
+
- @dxos/client-protocol@0.11.1
|
|
10
|
+
- @dxos/halo@0.11.1
|
|
11
|
+
- @dxos/invariant@0.11.1
|
|
12
|
+
- @dxos/keys@0.11.1
|
|
13
|
+
- @dxos/protocols@0.11.1
|
|
14
|
+
|
|
15
|
+
## 0.11.0
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [aea1e6e]
|
|
20
|
+
- Updated dependencies [eec72c5]
|
|
21
|
+
- Updated dependencies [6df314a]
|
|
22
|
+
- Updated dependencies [962c8cd]
|
|
23
|
+
- Updated dependencies [856c4f0]
|
|
24
|
+
- Updated dependencies [6a03a30]
|
|
25
|
+
- Updated dependencies [6439417]
|
|
26
|
+
- Updated dependencies [410a019]
|
|
27
|
+
- Updated dependencies [c727a43]
|
|
28
|
+
- Updated dependencies [d547045]
|
|
29
|
+
- Updated dependencies [114fb98]
|
|
30
|
+
- Updated dependencies [b591791]
|
|
31
|
+
- Updated dependencies [f15c632]
|
|
32
|
+
- Updated dependencies [c727a43]
|
|
33
|
+
- Updated dependencies [08a3eea]
|
|
34
|
+
- @dxos/async@0.11.0
|
|
35
|
+
- @dxos/client@0.11.0
|
|
36
|
+
- @dxos/client-protocol@0.11.0
|
|
37
|
+
- @dxos/protocols@0.11.0
|
|
38
|
+
- @dxos/keys@0.11.0
|
|
39
|
+
- @dxos/halo@0.11.0
|
|
40
|
+
- @dxos/invariant@0.11.0
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import * as Layer from "effect/Layer";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Option from "effect/Option";
|
|
4
|
+
import * as Stream from "effect/Stream";
|
|
5
|
+
import { AuthenticatingInvitationObservable, Invitation, InvitationEncoder } from "@dxos/client/invitations";
|
|
6
|
+
import { Identity, IdentityError, InvitationError, Space, SpaceError } from "@dxos/halo";
|
|
7
|
+
import { IdentityDid } from "@dxos/keys";
|
|
8
|
+
import { DeviceKind, SpaceArchive, SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
|
|
9
|
+
import { MembershipPolicy, SpaceMember as SpaceMember$1 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
10
|
+
import { SpaceState } from "@dxos/client/echo";
|
|
11
|
+
import { EdgeReplicationSetting } from "@dxos/protocols/proto/dxos/echo/metadata";
|
|
12
|
+
//#region src/util.ts
|
|
13
|
+
/**
|
|
14
|
+
* Bridges a {@link MulticastObservable} into an Effect {@link Stream}. The current value is
|
|
15
|
+
* emitted on subscription (matching the observable's semantics); the stream runs until the
|
|
16
|
+
* consumer stops or the observable errors.
|
|
17
|
+
*/
|
|
18
|
+
var streamFromObservable = (observable) => Stream.async((emit) => {
|
|
19
|
+
const subscription = observable.subscribe((value) => void emit.single(value), (err) => void emit.fail(err));
|
|
20
|
+
return Effect.sync(() => subscription.unsubscribe());
|
|
21
|
+
}).pipe(Stream.orDie);
|
|
22
|
+
var TERMINAL_STATES = /* @__PURE__ */ new Set([
|
|
23
|
+
Invitation.State.SUCCESS,
|
|
24
|
+
Invitation.State.CANCELLED,
|
|
25
|
+
Invitation.State.TIMEOUT,
|
|
26
|
+
Invitation.State.ERROR,
|
|
27
|
+
Invitation.State.EXPIRED
|
|
28
|
+
]);
|
|
29
|
+
var toEvent = (invitation) => {
|
|
30
|
+
switch (invitation.state) {
|
|
31
|
+
case Invitation.State.CONNECTING: return { _tag: "connecting" };
|
|
32
|
+
case Invitation.State.CONNECTED: return { _tag: "connected" };
|
|
33
|
+
case Invitation.State.READY_FOR_AUTHENTICATION: return {
|
|
34
|
+
_tag: "readyForAuthentication",
|
|
35
|
+
authCode: invitation.authCode
|
|
36
|
+
};
|
|
37
|
+
case Invitation.State.AUTHENTICATING: return { _tag: "authenticating" };
|
|
38
|
+
case Invitation.State.SUCCESS: return {
|
|
39
|
+
_tag: "success",
|
|
40
|
+
result: {}
|
|
41
|
+
};
|
|
42
|
+
case Invitation.State.CANCELLED: return { _tag: "cancelled" };
|
|
43
|
+
case Invitation.State.TIMEOUT:
|
|
44
|
+
case Invitation.State.ERROR:
|
|
45
|
+
case Invitation.State.EXPIRED: return {
|
|
46
|
+
_tag: "error",
|
|
47
|
+
message: `Invitation ${Invitation.State[invitation.state]}`
|
|
48
|
+
};
|
|
49
|
+
default: return;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Maps an invitation observable's state transitions to the {@link HaloInvitation.Event} stream,
|
|
54
|
+
* completing after a terminal event.
|
|
55
|
+
*/
|
|
56
|
+
var invitationEvents = (observable) => Stream.async((emit) => {
|
|
57
|
+
const subscription = observable.subscribe((invitation) => {
|
|
58
|
+
const event = toEvent(invitation);
|
|
59
|
+
if (event) {
|
|
60
|
+
emit.single(event);
|
|
61
|
+
if (TERMINAL_STATES.has(invitation.state)) emit.end();
|
|
62
|
+
}
|
|
63
|
+
}, (err) => {
|
|
64
|
+
emit.single({
|
|
65
|
+
_tag: "error",
|
|
66
|
+
message: err.message
|
|
67
|
+
});
|
|
68
|
+
emit.end();
|
|
69
|
+
});
|
|
70
|
+
return Effect.sync(() => subscription.unsubscribe());
|
|
71
|
+
});
|
|
72
|
+
/**
|
|
73
|
+
* Wraps a client invitation observable as a {@link HaloInvitation.Flow}.
|
|
74
|
+
*/
|
|
75
|
+
var makeFlow = (observable, kind) => ({
|
|
76
|
+
id: observable.get().invitationId,
|
|
77
|
+
kind,
|
|
78
|
+
events: invitationEvents(observable),
|
|
79
|
+
authenticate: (code) => observable instanceof AuthenticatingInvitationObservable ? Effect.tryPromise({
|
|
80
|
+
try: () => observable.authenticate(code),
|
|
81
|
+
catch: (error) => new InvitationError({ context: { error } })
|
|
82
|
+
}) : Effect.fail(new InvitationError({ context: { reason: "flow is not awaiting authentication" } })),
|
|
83
|
+
cancel: () => Effect.promise(() => observable.cancel()),
|
|
84
|
+
code: Effect.sync(() => InvitationEncoder.encode(observable.get()))
|
|
85
|
+
});
|
|
86
|
+
/**
|
|
87
|
+
* Maps {@link HaloInvitation.ShareOptions} to the client invitation options. Defaults to a
|
|
88
|
+
* no-auth interactive invitation so programmatic flows complete without an auth code.
|
|
89
|
+
*/
|
|
90
|
+
var toShareOptions = (options) => ({
|
|
91
|
+
authMethod: toAuthMethod(options?.authMethod),
|
|
92
|
+
type: toType(options?.type),
|
|
93
|
+
...options?.multiUse !== void 0 ? { multiUse: options.multiUse } : {},
|
|
94
|
+
...options?.target !== void 0 ? { target: options.target } : {}
|
|
95
|
+
});
|
|
96
|
+
var toAuthMethod = (method) => {
|
|
97
|
+
switch (method) {
|
|
98
|
+
case "shared-secret": return Invitation.AuthMethod.SHARED_SECRET;
|
|
99
|
+
case "known-public-key": return Invitation.AuthMethod.KNOWN_PUBLIC_KEY;
|
|
100
|
+
default: return Invitation.AuthMethod.NONE;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
var toType = (type) => {
|
|
104
|
+
switch (type) {
|
|
105
|
+
case "delegated": return Invitation.Type.DELEGATED;
|
|
106
|
+
case "multiuse": return Invitation.Type.MULTIUSE;
|
|
107
|
+
default: return Invitation.Type.INTERACTIVE;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Maps a legacy space-member role to the Keyhive-aligned {@link HaloSpace.Access} level.
|
|
112
|
+
* Returns `undefined` for `REMOVED` (not a current member).
|
|
113
|
+
*/
|
|
114
|
+
var toAccess = (role) => {
|
|
115
|
+
switch (role) {
|
|
116
|
+
case SpaceMember$1.Role.OWNER:
|
|
117
|
+
case SpaceMember$1.Role.ADMIN: return "admin";
|
|
118
|
+
case SpaceMember$1.Role.EDITOR: return "edit";
|
|
119
|
+
case SpaceMember$1.Role.READER: return "read";
|
|
120
|
+
default: return;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Maps a Keyhive-aligned {@link HaloSpace.Access} level to a legacy space-member role.
|
|
125
|
+
* Returns `undefined` for `pull` (no legacy equivalent — reject at the call site).
|
|
126
|
+
*/
|
|
127
|
+
var fromAccess = (access) => {
|
|
128
|
+
switch (access) {
|
|
129
|
+
case "admin": return SpaceMember$1.Role.ADMIN;
|
|
130
|
+
case "edit": return SpaceMember$1.Role.EDITOR;
|
|
131
|
+
case "read": return SpaceMember$1.Role.READER;
|
|
132
|
+
default: return;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Whether a member is currently online.
|
|
137
|
+
*/
|
|
138
|
+
var isOnline = (member) => member.presence === SpaceMember.PresenceState.ONLINE;
|
|
139
|
+
//#endregion
|
|
140
|
+
//#region src/identity.ts
|
|
141
|
+
var toInfo = (identity) => ({
|
|
142
|
+
did: IdentityDid.make(identity.did),
|
|
143
|
+
identityKey: identity.identityKey?.toHex(),
|
|
144
|
+
displayName: identity.profile?.displayName,
|
|
145
|
+
data: identity.profile?.data
|
|
146
|
+
});
|
|
147
|
+
var toDeviceInfo = (device) => ({
|
|
148
|
+
key: device.deviceKey.toHex(),
|
|
149
|
+
label: device.profile?.label,
|
|
150
|
+
current: device.kind === DeviceKind.CURRENT
|
|
151
|
+
});
|
|
152
|
+
var toCredential = (credential) => ({
|
|
153
|
+
id: credential.id?.toHex(),
|
|
154
|
+
type: credential.subject.assertion["@type"],
|
|
155
|
+
issuanceDate: credential.issuanceDate
|
|
156
|
+
});
|
|
157
|
+
/**
|
|
158
|
+
* Builds the {@link HaloIdentity.Service} implementation over a client's `halo` proxy.
|
|
159
|
+
*/
|
|
160
|
+
var makeIdentityService = (client) => ({
|
|
161
|
+
identity: streamFromObservable(client.halo.identity).pipe(Stream.map((identity) => identity ? Option.some(toInfo(identity)) : Option.none())),
|
|
162
|
+
getSnapshot: () => {
|
|
163
|
+
const identity = client.halo.identity.get();
|
|
164
|
+
return identity ? Option.some(toInfo(identity)) : Option.none();
|
|
165
|
+
},
|
|
166
|
+
subscribe: (callback) => {
|
|
167
|
+
const subscription = client.halo.identity.subscribe((identity) => callback(identity ? Option.some(toInfo(identity)) : Option.none()));
|
|
168
|
+
return () => subscription.unsubscribe();
|
|
169
|
+
},
|
|
170
|
+
create: (options) => Effect.tryPromise({
|
|
171
|
+
try: async () => toInfo(await client.halo.createIdentity(options?.displayName !== void 0 ? { displayName: options.displayName } : {}, options?.deviceLabel !== void 0 ? { label: options.deviceLabel } : void 0)),
|
|
172
|
+
catch: (error) => new IdentityError({ context: { error } })
|
|
173
|
+
}),
|
|
174
|
+
recover: (args) => Effect.tryPromise({
|
|
175
|
+
try: async () => toInfo(await client.halo.recoverIdentity(args)),
|
|
176
|
+
catch: (error) => new IdentityError({ context: { error } })
|
|
177
|
+
}),
|
|
178
|
+
updateProfile: (profile) => Effect.tryPromise({
|
|
179
|
+
try: async () => toInfo(await client.halo.updateProfile(profile)),
|
|
180
|
+
catch: (error) => new IdentityError({ context: { error } })
|
|
181
|
+
}),
|
|
182
|
+
devices: streamFromObservable(client.halo.devices).pipe(Stream.map((devices) => devices.map(toDeviceInfo))),
|
|
183
|
+
getDevicesSnapshot: () => client.halo.devices.get().map(toDeviceInfo),
|
|
184
|
+
credentials: streamFromObservable(client.halo.credentials).pipe(Stream.map((credentials) => credentials.map(toCredential))),
|
|
185
|
+
grantServiceAccess: (options) => Effect.tryPromise({
|
|
186
|
+
try: async () => {
|
|
187
|
+
const identityKey = client.halo.identity.get()?.identityKey;
|
|
188
|
+
if (!identityKey) throw new Error("No identity.");
|
|
189
|
+
await client.halo.writeCredentials([{
|
|
190
|
+
issuer: identityKey,
|
|
191
|
+
issuanceDate: /* @__PURE__ */ new Date(),
|
|
192
|
+
subject: {
|
|
193
|
+
id: identityKey,
|
|
194
|
+
assertion: {
|
|
195
|
+
"@type": "dxos.halo.credentials.ServiceAccess",
|
|
196
|
+
"serverName": options.serverName,
|
|
197
|
+
"serverKey": identityKey,
|
|
198
|
+
identityKey,
|
|
199
|
+
"capabilities": [...options.capabilities]
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}]);
|
|
203
|
+
},
|
|
204
|
+
catch: (error) => new IdentityError({ context: { error } })
|
|
205
|
+
}),
|
|
206
|
+
share: (options) => Effect.try({
|
|
207
|
+
try: () => makeFlow(client.halo.share(toShareOptions(options)), "device"),
|
|
208
|
+
catch: (error) => new IdentityError({ context: { error } })
|
|
209
|
+
}),
|
|
210
|
+
join: (code) => Effect.try({
|
|
211
|
+
try: () => makeFlow(client.halo.join(InvitationEncoder.decode(code)), "device"),
|
|
212
|
+
catch: (error) => new IdentityError({ context: { error } })
|
|
213
|
+
}),
|
|
214
|
+
invitations: streamFromObservable(client.halo.invitations).pipe(Stream.map((invitations) => invitations.map((invitation) => makeFlow(invitation, "device"))))
|
|
215
|
+
});
|
|
216
|
+
/**
|
|
217
|
+
* Layer providing {@link HaloIdentity.Service} backed by the given client.
|
|
218
|
+
*/
|
|
219
|
+
var layerIdentity = (client) => Layer.succeed(Identity.Service, makeIdentityService(client));
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region src/space.ts
|
|
222
|
+
var toState = (state) => {
|
|
223
|
+
switch (state) {
|
|
224
|
+
case SpaceState.SPACE_READY: return "ready";
|
|
225
|
+
case SpaceState.SPACE_CLOSED: return "closed";
|
|
226
|
+
default: return "inactive";
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
var toSpaceInfo = (space) => ({
|
|
230
|
+
id: space.id,
|
|
231
|
+
name: space.state.get() === SpaceState.SPACE_READY ? space.properties.name : void 0,
|
|
232
|
+
state: toState(space.state.get())
|
|
233
|
+
});
|
|
234
|
+
var toMembers = (members) => members.flatMap((member) => {
|
|
235
|
+
const role = toAccess(member.role);
|
|
236
|
+
if (role === void 0) return [];
|
|
237
|
+
return [{
|
|
238
|
+
did: member.identity?.did !== void 0 ? IdentityDid.make(member.identity.did) : void 0,
|
|
239
|
+
identityKey: member.identity?.identityKey?.toHex(),
|
|
240
|
+
displayName: member.identity?.profile?.displayName,
|
|
241
|
+
data: member.identity?.profile?.data,
|
|
242
|
+
role,
|
|
243
|
+
online: isOnline(member)
|
|
244
|
+
}];
|
|
245
|
+
});
|
|
246
|
+
var toMembershipPolicy = (policy) => policy === "locked" ? MembershipPolicy.LOCKED : MembershipPolicy.INVITE;
|
|
247
|
+
var toEdgeReplicationSetting = (setting) => setting === "enabled" ? EdgeReplicationSetting.ENABLED : EdgeReplicationSetting.DISABLED;
|
|
248
|
+
var resolveSpace = (client, id) => {
|
|
249
|
+
const space = client.spaces.get(id);
|
|
250
|
+
if (!space) throw new Error(`Space not found: ${id}`);
|
|
251
|
+
return space;
|
|
252
|
+
};
|
|
253
|
+
var setMemberRole = async (client, id, subject, newRole) => {
|
|
254
|
+
const space = resolveSpace(client, id);
|
|
255
|
+
const member = space.members.get().find((entry) => entry.identity?.did === subject);
|
|
256
|
+
if (!member) throw new Error(`Member not found: ${subject}`);
|
|
257
|
+
await space.updateMemberRole({
|
|
258
|
+
memberKey: member.identity.identityKey,
|
|
259
|
+
newRole
|
|
260
|
+
});
|
|
261
|
+
};
|
|
262
|
+
/**
|
|
263
|
+
* Builds the {@link HaloSpace.Service} implementation over a client's `spaces` proxy.
|
|
264
|
+
*/
|
|
265
|
+
var makeSpaceService = (client) => ({
|
|
266
|
+
spaces: streamFromObservable(client.spaces).pipe(Stream.map((spaces) => (spaces ?? []).map(toSpaceInfo))),
|
|
267
|
+
get: (id) => Effect.sync(() => {
|
|
268
|
+
const space = client.spaces.get(id);
|
|
269
|
+
return space ? Option.some(toSpaceInfo(space)) : Option.none();
|
|
270
|
+
}),
|
|
271
|
+
create: (options) => Effect.tryPromise({
|
|
272
|
+
try: async () => {
|
|
273
|
+
const createOptions = {};
|
|
274
|
+
if (options?.tags !== void 0) createOptions.tags = [...options.tags];
|
|
275
|
+
if (options?.membershipPolicy !== void 0) createOptions.membershipPolicy = toMembershipPolicy(options.membershipPolicy);
|
|
276
|
+
return toSpaceInfo(await client.spaces.create(options?.name !== void 0 ? { name: options.name } : {}, createOptions));
|
|
277
|
+
},
|
|
278
|
+
catch: (error) => new SpaceError({ context: { error } })
|
|
279
|
+
}),
|
|
280
|
+
waitReady: (id) => Effect.tryPromise({
|
|
281
|
+
try: async () => {
|
|
282
|
+
await resolveSpace(client, id).waitUntilReady();
|
|
283
|
+
},
|
|
284
|
+
catch: (error) => new SpaceError({ context: { error } })
|
|
285
|
+
}),
|
|
286
|
+
setEdgeReplication: (id, setting) => Effect.tryPromise({
|
|
287
|
+
try: async () => {
|
|
288
|
+
await resolveSpace(client, id).internal.setEdgeReplicationPreference(toEdgeReplicationSetting(setting));
|
|
289
|
+
},
|
|
290
|
+
catch: (error) => new SpaceError({ context: { error } })
|
|
291
|
+
}),
|
|
292
|
+
members: (id) => {
|
|
293
|
+
const space = client.spaces.get(id);
|
|
294
|
+
return space ? streamFromObservable(space.members).pipe(Stream.map(toMembers)) : Stream.empty;
|
|
295
|
+
},
|
|
296
|
+
updateMemberRole: (id, subject, role) => Effect.tryPromise({
|
|
297
|
+
try: async () => {
|
|
298
|
+
const newRole = fromAccess(role);
|
|
299
|
+
if (newRole === void 0) throw new Error(`No legacy role for access level: ${role}`);
|
|
300
|
+
await setMemberRole(client, id, subject, newRole);
|
|
301
|
+
},
|
|
302
|
+
catch: (error) => new SpaceError({ context: { error } })
|
|
303
|
+
}),
|
|
304
|
+
removeMember: (id, subject) => Effect.tryPromise({
|
|
305
|
+
try: () => setMemberRole(client, id, subject, SpaceMember$1.Role.REMOVED),
|
|
306
|
+
catch: (error) => new SpaceError({ context: { error } })
|
|
307
|
+
}),
|
|
308
|
+
share: (id, options) => Effect.try({
|
|
309
|
+
try: () => makeFlow(resolveSpace(client, id).share(toShareOptions(options)), "space"),
|
|
310
|
+
catch: (error) => new SpaceError({ context: { error } })
|
|
311
|
+
}),
|
|
312
|
+
join: (code) => Effect.try({
|
|
313
|
+
try: () => makeFlow(client.spaces.join(code), "space"),
|
|
314
|
+
catch: (error) => new SpaceError({ context: { error } })
|
|
315
|
+
}),
|
|
316
|
+
invitations: (id) => {
|
|
317
|
+
const space = client.spaces.get(id);
|
|
318
|
+
return space ? streamFromObservable(space.invitations).pipe(Stream.map((invitations) => invitations.map((invitation) => makeFlow(invitation, "space")))) : Stream.empty;
|
|
319
|
+
},
|
|
320
|
+
export: (id) => Effect.tryPromise({
|
|
321
|
+
try: async () => {
|
|
322
|
+
const archive = await resolveSpace(client, id).internal.export();
|
|
323
|
+
return {
|
|
324
|
+
filename: archive.filename,
|
|
325
|
+
contents: archive.contents
|
|
326
|
+
};
|
|
327
|
+
},
|
|
328
|
+
catch: (error) => new SpaceError({ context: { error } })
|
|
329
|
+
}),
|
|
330
|
+
import: (archive, options) => Effect.tryPromise({
|
|
331
|
+
try: async () => {
|
|
332
|
+
const format = archive.filename.endsWith(".json") ? SpaceArchive.Format.JSON : SpaceArchive.Format.BINARY;
|
|
333
|
+
return toSpaceInfo(await client.spaces.import({
|
|
334
|
+
filename: archive.filename,
|
|
335
|
+
contents: archive.contents,
|
|
336
|
+
format
|
|
337
|
+
}, options?.tags !== void 0 ? { tags: [...options.tags] } : void 0));
|
|
338
|
+
},
|
|
339
|
+
catch: (error) => new SpaceError({ context: { error } })
|
|
340
|
+
})
|
|
341
|
+
});
|
|
342
|
+
/**
|
|
343
|
+
* Layer providing {@link HaloSpace.Service} backed by the given client.
|
|
344
|
+
*/
|
|
345
|
+
var layerSpace = (client) => Layer.succeed(Space.Service, makeSpaceService(client));
|
|
346
|
+
//#endregion
|
|
347
|
+
//#region src/index.ts
|
|
348
|
+
/**
|
|
349
|
+
* A single layer providing both HALO services ({@link Identity.Service}, {@link Space.Service})
|
|
350
|
+
* backed by one {@link Client}. This is the composition-root layer that replaces direct
|
|
351
|
+
* `@dxos/client` access for HALO concerns. Invitation querying lives on these two services;
|
|
352
|
+
* flow-level verbs need no service.
|
|
353
|
+
*/
|
|
354
|
+
var layerClient = (client) => Layer.mergeAll(layerIdentity(client), layerSpace(client));
|
|
355
|
+
//#endregion
|
|
356
|
+
export { layerClient, layerIdentity, layerSpace, makeIdentityService, makeSpaceService };
|
|
357
|
+
|
|
358
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/util.ts","../../src/identity.ts","../../src/space.ts","../../src/index.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Stream from 'effect/Stream';\n\nimport { type MulticastObservable } from '@dxos/async';\nimport {\n AuthenticatingInvitationObservable,\n type CancellableInvitationObservable,\n Invitation as ClientInvitation,\n InvitationEncoder,\n} from '@dxos/client/invitations';\nimport { Invitation as HaloInvitation, Space as HaloSpace, InvitationError } from '@dxos/halo';\nimport { SpaceMember } from '@dxos/protocols/proto/dxos/client/services';\nimport { SpaceMember as HaloSpaceMember } from '@dxos/protocols/proto/dxos/halo/credentials';\n\n/**\n * Bridges a {@link MulticastObservable} into an Effect {@link Stream}. The current value is\n * emitted on subscription (matching the observable's semantics); the stream runs until the\n * consumer stops or the observable errors.\n */\nexport const streamFromObservable = <T>(observable: MulticastObservable<T>): Stream.Stream<T> =>\n Stream.async<T, Error>((emit) => {\n const subscription = observable.subscribe(\n (value: T) => void emit.single(value),\n (err: Error) => void emit.fail(err),\n );\n return Effect.sync(() => subscription.unsubscribe());\n }).pipe(Stream.orDie);\n\nconst TERMINAL_STATES: ReadonlySet<ClientInvitation.State> = new Set([\n ClientInvitation.State.SUCCESS,\n ClientInvitation.State.CANCELLED,\n ClientInvitation.State.TIMEOUT,\n ClientInvitation.State.ERROR,\n ClientInvitation.State.EXPIRED,\n]);\n\nconst toEvent = (invitation: ClientInvitation): HaloInvitation.Event | undefined => {\n switch (invitation.state) {\n case ClientInvitation.State.CONNECTING:\n return { _tag: 'connecting' };\n case ClientInvitation.State.CONNECTED:\n return { _tag: 'connected' };\n case ClientInvitation.State.READY_FOR_AUTHENTICATION:\n return { _tag: 'readyForAuthentication', authCode: invitation.authCode };\n case ClientInvitation.State.AUTHENTICATING:\n return { _tag: 'authenticating' };\n case ClientInvitation.State.SUCCESS:\n return { _tag: 'success', result: {} };\n case ClientInvitation.State.CANCELLED:\n return { _tag: 'cancelled' };\n case ClientInvitation.State.TIMEOUT:\n case ClientInvitation.State.ERROR:\n case ClientInvitation.State.EXPIRED:\n return { _tag: 'error', message: `Invitation ${ClientInvitation.State[invitation.state]}` };\n default:\n // INIT and any unmodeled state — not surfaced.\n return undefined;\n }\n};\n\n/**\n * Maps an invitation observable's state transitions to the {@link HaloInvitation.Event} stream,\n * completing after a terminal event.\n */\nexport const invitationEvents = (observable: CancellableInvitationObservable): Stream.Stream<HaloInvitation.Event> =>\n Stream.async<HaloInvitation.Event>((emit) => {\n const subscription = observable.subscribe(\n (invitation: ClientInvitation) => {\n const event = toEvent(invitation);\n if (event) {\n void emit.single(event);\n if (TERMINAL_STATES.has(invitation.state)) {\n void emit.end();\n }\n }\n },\n (err: Error) => {\n void emit.single({ _tag: 'error', message: err.message });\n void emit.end();\n },\n );\n return Effect.sync(() => subscription.unsubscribe());\n });\n\n/**\n * Wraps a client invitation observable as a {@link HaloInvitation.Flow}.\n */\nexport const makeFlow = (\n observable: CancellableInvitationObservable,\n kind: HaloInvitation.Kind,\n): HaloInvitation.Flow => ({\n id: observable.get().invitationId,\n kind,\n events: invitationEvents(observable),\n authenticate: (code: string) =>\n observable instanceof AuthenticatingInvitationObservable\n ? Effect.tryPromise({\n try: () => observable.authenticate(code),\n catch: (error) => new InvitationError({ context: { error } }),\n })\n : Effect.fail(new InvitationError({ context: { reason: 'flow is not awaiting authentication' } })),\n cancel: () => Effect.promise(() => observable.cancel()),\n code: Effect.sync(() => InvitationEncoder.encode(observable.get())),\n});\n\n/**\n * Maps {@link HaloInvitation.ShareOptions} to the client invitation options. Defaults to a\n * no-auth interactive invitation so programmatic flows complete without an auth code.\n */\nexport const toShareOptions = (options?: HaloInvitation.ShareOptions): Partial<ClientInvitation> => ({\n authMethod: toAuthMethod(options?.authMethod),\n type: toType(options?.type),\n ...(options?.multiUse !== undefined ? { multiUse: options.multiUse } : {}),\n ...(options?.target !== undefined ? { target: options.target } : {}),\n});\n\nconst toAuthMethod = (method?: HaloInvitation.AuthMethod): ClientInvitation.AuthMethod => {\n switch (method) {\n case 'shared-secret':\n return ClientInvitation.AuthMethod.SHARED_SECRET;\n case 'known-public-key':\n return ClientInvitation.AuthMethod.KNOWN_PUBLIC_KEY;\n case 'none':\n default:\n return ClientInvitation.AuthMethod.NONE;\n }\n};\n\nconst toType = (type?: HaloInvitation.Type): ClientInvitation.Type => {\n switch (type) {\n case 'delegated':\n return ClientInvitation.Type.DELEGATED;\n case 'multiuse':\n return ClientInvitation.Type.MULTIUSE;\n case 'interactive':\n default:\n return ClientInvitation.Type.INTERACTIVE;\n }\n};\n\n/**\n * Maps a legacy space-member role to the Keyhive-aligned {@link HaloSpace.Access} level.\n * Returns `undefined` for `REMOVED` (not a current member).\n */\nexport const toAccess = (role: HaloSpaceMember.Role): HaloSpace.Access | undefined => {\n switch (role) {\n case HaloSpaceMember.Role.OWNER:\n case HaloSpaceMember.Role.ADMIN:\n return 'admin';\n case HaloSpaceMember.Role.EDITOR:\n return 'edit';\n case HaloSpaceMember.Role.READER:\n return 'read';\n default:\n return undefined;\n }\n};\n\n/**\n * Maps a Keyhive-aligned {@link HaloSpace.Access} level to a legacy space-member role.\n * Returns `undefined` for `pull` (no legacy equivalent — reject at the call site).\n */\nexport const fromAccess = (access: HaloSpace.Access): HaloSpaceMember.Role | undefined => {\n switch (access) {\n case 'admin':\n return HaloSpaceMember.Role.ADMIN;\n case 'edit':\n return HaloSpaceMember.Role.EDITOR;\n case 'read':\n return HaloSpaceMember.Role.READER;\n default:\n return undefined;\n }\n};\n\n/**\n * Whether a member is currently online.\n */\nexport const isOnline = (member: SpaceMember): boolean => member.presence === SpaceMember.PresenceState.ONLINE;\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Option from 'effect/Option';\nimport * as Stream from 'effect/Stream';\n\nimport { type Client } from '@dxos/client';\nimport { InvitationEncoder } from '@dxos/client/invitations';\nimport { Identity as HaloIdentity, IdentityError } from '@dxos/halo';\nimport { IdentityDid } from '@dxos/keys';\nimport {\n type Device as ClientDevice,\n type Identity as ClientIdentity,\n DeviceKind,\n} from '@dxos/protocols/proto/dxos/client/services';\nimport { type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';\n\nimport { makeFlow, streamFromObservable, toShareOptions } from './util';\n\nconst toInfo = (identity: ClientIdentity): HaloIdentity.Info => ({\n did: IdentityDid.make(identity.did),\n identityKey: identity.identityKey?.toHex(),\n displayName: identity.profile?.displayName,\n data: identity.profile?.data,\n});\n\nconst toDeviceInfo = (device: ClientDevice): HaloIdentity.DeviceInfo => ({\n key: device.deviceKey.toHex(),\n label: device.profile?.label,\n current: device.kind === DeviceKind.CURRENT,\n});\n\nconst toCredential = (credential: Credential): HaloIdentity.Credential => ({\n id: credential.id?.toHex(),\n type: credential.subject.assertion['@type'],\n issuanceDate: credential.issuanceDate,\n});\n\n/**\n * Builds the {@link HaloIdentity.Service} implementation over a client's `halo` proxy.\n */\nexport const makeIdentityService = (client: Client): Context.Tag.Service<HaloIdentity.Service> => ({\n identity: streamFromObservable(client.halo.identity).pipe(\n Stream.map((identity) => (identity ? Option.some(toInfo(identity)) : Option.none())),\n ),\n\n getSnapshot: () => {\n const identity = client.halo.identity.get();\n return identity ? Option.some(toInfo(identity)) : Option.none();\n },\n\n subscribe: (callback) => {\n const subscription = client.halo.identity.subscribe((identity) =>\n callback(identity ? Option.some(toInfo(identity)) : Option.none()),\n );\n return () => subscription.unsubscribe();\n },\n\n create: (options) =>\n Effect.tryPromise({\n try: async () =>\n toInfo(\n await client.halo.createIdentity(\n options?.displayName !== undefined ? { displayName: options.displayName } : {},\n options?.deviceLabel !== undefined ? { label: options.deviceLabel } : undefined,\n ),\n ),\n catch: (error) => new IdentityError({ context: { error } }),\n }),\n\n recover: (args) =>\n Effect.tryPromise({\n try: async () => toInfo(await client.halo.recoverIdentity(args)),\n catch: (error) => new IdentityError({ context: { error } }),\n }),\n\n updateProfile: (profile) =>\n Effect.tryPromise({\n try: async () => toInfo(await client.halo.updateProfile(profile)),\n catch: (error) => new IdentityError({ context: { error } }),\n }),\n\n devices: streamFromObservable(client.halo.devices).pipe(Stream.map((devices) => devices.map(toDeviceInfo))),\n\n getDevicesSnapshot: () => client.halo.devices.get().map(toDeviceInfo),\n\n credentials: streamFromObservable(client.halo.credentials).pipe(\n Stream.map((credentials) => credentials.map(toCredential)),\n ),\n\n grantServiceAccess: (options) =>\n Effect.tryPromise({\n try: async () => {\n const identityKey = client.halo.identity.get()?.identityKey;\n if (!identityKey) {\n throw new Error('No identity.');\n }\n await client.halo.writeCredentials([\n {\n issuer: identityKey,\n issuanceDate: new Date(),\n subject: {\n id: identityKey,\n assertion: {\n '@type': 'dxos.halo.credentials.ServiceAccess',\n 'serverName': options.serverName,\n 'serverKey': identityKey,\n identityKey,\n 'capabilities': [...options.capabilities],\n },\n },\n },\n ]);\n },\n catch: (error) => new IdentityError({ context: { error } }),\n }),\n\n share: (options) =>\n Effect.try({\n try: () => makeFlow(client.halo.share(toShareOptions(options)), 'device'),\n catch: (error) => new IdentityError({ context: { error } }),\n }),\n\n join: (code) =>\n Effect.try({\n try: () => makeFlow(client.halo.join(InvitationEncoder.decode(code)), 'device'),\n catch: (error) => new IdentityError({ context: { error } }),\n }),\n\n invitations: streamFromObservable(client.halo.invitations).pipe(\n Stream.map((invitations) => invitations.map((invitation) => makeFlow(invitation, 'device'))),\n ),\n});\n\n/**\n * Layer providing {@link HaloIdentity.Service} backed by the given client.\n */\nexport const layerIdentity = (client: Client): Layer.Layer<HaloIdentity.Service> =>\n Layer.succeed(HaloIdentity.Service, makeIdentityService(client));\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Option from 'effect/Option';\nimport * as Stream from 'effect/Stream';\n\nimport { type Client } from '@dxos/client';\nimport { type Space as ClientSpace, SpaceState } from '@dxos/client/echo';\nimport { Space as HaloSpace, SpaceError } from '@dxos/halo';\nimport { IdentityDid, type SpaceId } from '@dxos/keys';\nimport { SpaceArchive, type SpaceMember } from '@dxos/protocols/proto/dxos/client/services';\nimport { EdgeReplicationSetting } from '@dxos/protocols/proto/dxos/echo/metadata';\nimport { SpaceMember as HaloSpaceMember, MembershipPolicy } from '@dxos/protocols/proto/dxos/halo/credentials';\n\nimport { fromAccess, isOnline, makeFlow, streamFromObservable, toAccess, toShareOptions } from './util';\n\nconst toState = (state: SpaceState): HaloSpace.State => {\n switch (state) {\n case SpaceState.SPACE_READY:\n return 'ready';\n case SpaceState.SPACE_CLOSED:\n return 'closed';\n default:\n return 'inactive';\n }\n};\n\nconst toSpaceInfo = (space: ClientSpace): HaloSpace.Info => ({\n id: space.id,\n name: space.state.get() === SpaceState.SPACE_READY ? space.properties.name : undefined,\n state: toState(space.state.get()),\n});\n\nconst toMembers = (members: readonly SpaceMember[]): HaloSpace.Member[] =>\n members.flatMap((member) => {\n const role = toAccess(member.role);\n if (role === undefined) {\n // Skip removed members.\n return [];\n }\n return [\n {\n did: member.identity?.did !== undefined ? IdentityDid.make(member.identity.did) : undefined,\n identityKey: member.identity?.identityKey?.toHex(),\n displayName: member.identity?.profile?.displayName,\n data: member.identity?.profile?.data,\n role,\n online: isOnline(member),\n },\n ];\n });\n\nconst toMembershipPolicy = (policy: HaloSpace.MembershipPolicy): MembershipPolicy =>\n policy === 'locked' ? MembershipPolicy.LOCKED : MembershipPolicy.INVITE;\n\nconst toEdgeReplicationSetting = (setting: HaloSpace.EdgeReplication): EdgeReplicationSetting =>\n setting === 'enabled' ? EdgeReplicationSetting.ENABLED : EdgeReplicationSetting.DISABLED;\n\nconst resolveSpace = (client: Client, id: SpaceId): ClientSpace => {\n const space = client.spaces.get(id);\n if (!space) {\n throw new Error(`Space not found: ${id}`);\n }\n return space;\n};\n\n// The HALO API addresses members by DID; the legacy proxy needs the identity key, resolved here\n// from the materialized membership.\nconst setMemberRole = async (\n client: Client,\n id: SpaceId,\n subject: IdentityDid,\n newRole: HaloSpaceMember.Role,\n): Promise<void> => {\n const space = resolveSpace(client, id);\n const member = space.members.get().find((entry) => entry.identity?.did === subject);\n if (!member) {\n throw new Error(`Member not found: ${subject}`);\n }\n await space.updateMemberRole({ memberKey: member.identity.identityKey, newRole });\n};\n\n/**\n * Builds the {@link HaloSpace.Service} implementation over a client's `spaces` proxy.\n */\nexport const makeSpaceService = (client: Client): Context.Tag.Service<HaloSpace.Service> => ({\n spaces: streamFromObservable(client.spaces).pipe(Stream.map((spaces) => (spaces ?? []).map(toSpaceInfo))),\n\n get: (id) =>\n Effect.sync(() => {\n const space = client.spaces.get(id);\n return space ? Option.some(toSpaceInfo(space)) : Option.none();\n }),\n\n create: (options) =>\n Effect.tryPromise({\n try: async () => {\n const createOptions: { tags?: string[]; membershipPolicy?: MembershipPolicy } = {};\n if (options?.tags !== undefined) {\n createOptions.tags = [...options.tags];\n }\n if (options?.membershipPolicy !== undefined) {\n createOptions.membershipPolicy = toMembershipPolicy(options.membershipPolicy);\n }\n return toSpaceInfo(\n await client.spaces.create(options?.name !== undefined ? { name: options.name } : {}, createOptions),\n );\n },\n catch: (error) => new SpaceError({ context: { error } }),\n }),\n\n waitReady: (id) =>\n Effect.tryPromise({\n try: async () => {\n await resolveSpace(client, id).waitUntilReady();\n },\n catch: (error) => new SpaceError({ context: { error } }),\n }),\n\n setEdgeReplication: (id, setting) =>\n Effect.tryPromise({\n try: async () => {\n await resolveSpace(client, id).internal.setEdgeReplicationPreference(toEdgeReplicationSetting(setting));\n },\n catch: (error) => new SpaceError({ context: { error } }),\n }),\n\n members: (id) => {\n const space = client.spaces.get(id);\n return space ? streamFromObservable(space.members).pipe(Stream.map(toMembers)) : Stream.empty;\n },\n\n updateMemberRole: (id, subject, role) =>\n Effect.tryPromise({\n try: async () => {\n const newRole = fromAccess(role);\n if (newRole === undefined) {\n throw new Error(`No legacy role for access level: ${role}`);\n }\n await setMemberRole(client, id, subject, newRole);\n },\n catch: (error) => new SpaceError({ context: { error } }),\n }),\n\n removeMember: (id, subject) =>\n Effect.tryPromise({\n try: () => setMemberRole(client, id, subject, HaloSpaceMember.Role.REMOVED),\n catch: (error) => new SpaceError({ context: { error } }),\n }),\n\n share: (id, options) =>\n Effect.try({\n try: () => makeFlow(resolveSpace(client, id).share(toShareOptions(options)), 'space'),\n catch: (error) => new SpaceError({ context: { error } }),\n }),\n\n join: (code) =>\n Effect.try({\n try: () => makeFlow(client.spaces.join(code), 'space'),\n catch: (error) => new SpaceError({ context: { error } }),\n }),\n\n invitations: (id) => {\n const space = client.spaces.get(id);\n return space\n ? streamFromObservable(space.invitations).pipe(\n Stream.map((invitations) => invitations.map((invitation) => makeFlow(invitation, 'space'))),\n )\n : Stream.empty;\n },\n\n export: (id) =>\n Effect.tryPromise({\n try: async () => {\n const archive = await resolveSpace(client, id).internal.export();\n return { filename: archive.filename, contents: archive.contents };\n },\n catch: (error) => new SpaceError({ context: { error } }),\n }),\n\n import: (archive, options) =>\n Effect.tryPromise({\n try: async () => {\n const format = archive.filename.endsWith('.json') ? SpaceArchive.Format.JSON : SpaceArchive.Format.BINARY;\n const space = await client.spaces.import(\n { filename: archive.filename, contents: archive.contents, format },\n options?.tags !== undefined ? { tags: [...options.tags] } : undefined,\n );\n return toSpaceInfo(space);\n },\n catch: (error) => new SpaceError({ context: { error } }),\n }),\n});\n\n/**\n * Layer providing {@link HaloSpace.Service} backed by the given client.\n */\nexport const layerSpace = (client: Client): Layer.Layer<HaloSpace.Service> =>\n Layer.succeed(HaloSpace.Service, makeSpaceService(client));\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Layer from 'effect/Layer';\n\nimport { type Client } from '@dxos/client';\nimport { type Identity, type Space } from '@dxos/halo';\n\nimport { layerIdentity } from './identity';\nimport { layerSpace } from './space';\n\nexport { layerIdentity, makeIdentityService } from './identity';\nexport { layerSpace, makeSpaceService } from './space';\n\n/**\n * A single layer providing both HALO services ({@link Identity.Service}, {@link Space.Service})\n * backed by one {@link Client}. This is the composition-root layer that replaces direct\n * `@dxos/client` access for HALO concerns. Invitation querying lives on these two services;\n * flow-level verbs need no service.\n */\nexport const layerClient = (client: Client): Layer.Layer<Identity.Service | Space.Service> =>\n Layer.mergeAll(layerIdentity(client), layerSpace(client));\n"],"mappings":";;;;;;;;;;;;;;;;;AAuBA,IAAa,wBAA2B,eACtC,OAAO,OAAiB,SAAS;CAC/B,MAAM,eAAe,WAAW,WAC7B,UAAa,KAAK,KAAK,OAAO,KAAK,IACnC,QAAe,KAAK,KAAK,KAAK,GAAG,CACpC;CACA,OAAO,OAAO,WAAW,aAAa,YAAY,CAAC;AACrD,CAAC,CAAC,CAAC,KAAK,OAAO,KAAK;AAEtB,IAAM,kCAAuD,IAAI,IAAI;CACnE,WAAiB,MAAM;CACvB,WAAiB,MAAM;CACvB,WAAiB,MAAM;CACvB,WAAiB,MAAM;CACvB,WAAiB,M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