@dxos/client-services 0.7.5-main.e9bb01b → 0.7.5-staging.2ff1350
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{chunk-O46EJ5BJ.mjs → chunk-VWRYD6LV.mjs} +194 -127
- package/dist/lib/browser/chunk-VWRYD6LV.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/node/{chunk-WFDMSV4I.cjs → chunk-K6H3KWWB.cjs} +192 -125
- package/dist/lib/node/chunk-K6H3KWWB.cjs.map +7 -0
- package/dist/lib/node/index.cjs +47 -47
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +8 -8
- package/dist/lib/node-esm/{chunk-UWR5XM7L.mjs → chunk-6OZO2NH7.mjs} +194 -127
- package/dist/lib/node-esm/chunk-6OZO2NH7.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1 -1
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +1 -1
- package/dist/types/src/packlets/agents/edge-agent-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts +0 -3
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts +12 -4
- package/dist/types/src/packlets/identity/identity-recovery-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-service.d.ts +8 -3
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +3 -1
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/dist/types/src/version.d.ts.map +1 -1
- package/package.json +39 -38
- package/src/packlets/agents/edge-agent-manager.ts +6 -0
- package/src/packlets/diagnostics/diagnostics-collector.ts +2 -2
- package/src/packlets/diagnostics/diagnostics.ts +17 -13
- package/src/packlets/identity/identity-manager.ts +3 -29
- package/src/packlets/identity/identity-recovery-manager.ts +86 -9
- package/src/packlets/identity/identity-service.ts +16 -3
- package/src/packlets/identity/identity.test.ts +2 -1
- package/src/packlets/identity/identity.ts +4 -1
- package/src/packlets/spaces/data-space-manager.ts +2 -2
- package/src/packlets/spaces/edge-feed-replicator.ts +8 -8
- package/src/packlets/spaces/spaces-service.ts +30 -20
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-O46EJ5BJ.mjs.map +0 -7
- package/dist/lib/node/chunk-WFDMSV4I.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-UWR5XM7L.mjs.map +0 -7
|
@@ -390,14 +390,14 @@ var DevtoolsServiceImpl = class {
|
|
|
390
390
|
// packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts
|
|
391
391
|
import { asyncTimeout } from "@dxos/async";
|
|
392
392
|
import { getFirstStreamValue } from "@dxos/codec-protobuf";
|
|
393
|
-
import { credentialTypeFilter } from "@dxos/credentials";
|
|
393
|
+
import { createDidFromIdentityKey, credentialTypeFilter } from "@dxos/credentials";
|
|
394
394
|
import { invariant } from "@dxos/invariant";
|
|
395
395
|
import { STORAGE_VERSION } from "@dxos/protocols";
|
|
396
396
|
import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
|
|
397
397
|
import { TRACE_PROCESSOR } from "@dxos/tracing";
|
|
398
398
|
|
|
399
399
|
// packages/sdk/client-services/src/version.ts
|
|
400
|
-
var DXOS_VERSION = "0.7.5-
|
|
400
|
+
var DXOS_VERSION = "0.7.5-staging.2ff1350";
|
|
401
401
|
|
|
402
402
|
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
403
403
|
import { Platform } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -466,6 +466,7 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
466
466
|
const identity = serviceContext.identityManager.identity;
|
|
467
467
|
if (identity) {
|
|
468
468
|
diagnostics.identity = {
|
|
469
|
+
did: identity.did,
|
|
469
470
|
identityKey: identity.identityKey,
|
|
470
471
|
spaceKey: identity.space.key,
|
|
471
472
|
profile: identity.profileDocument
|
|
@@ -504,16 +505,17 @@ var getSpaceStats = async (space) => {
|
|
|
504
505
|
...credential.subject.assertion,
|
|
505
506
|
id: credential.id
|
|
506
507
|
})),
|
|
507
|
-
members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
|
|
508
|
+
members: await Promise.all(Array.from(space.inner.spaceState.members.values()).map(async (member) => ({
|
|
508
509
|
role: member.role,
|
|
509
510
|
identity: {
|
|
511
|
+
did: await createDidFromIdentityKey(member.key),
|
|
510
512
|
identityKey: member.key,
|
|
511
513
|
profile: {
|
|
512
514
|
displayName: member.assertion.profile?.displayName
|
|
513
515
|
}
|
|
514
516
|
},
|
|
515
517
|
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? SpaceMember.PresenceState.ONLINE : SpaceMember.PresenceState.OFFLINE
|
|
516
|
-
})),
|
|
518
|
+
}))),
|
|
517
519
|
pipeline: {
|
|
518
520
|
// TODO(burdon): Pick properties from credentials if needed.
|
|
519
521
|
currentEpoch: space.automergeSpaceState.lastEpoch,
|
|
@@ -647,7 +649,7 @@ import { ClientServicesProviderResource } from "@dxos/client-protocol";
|
|
|
647
649
|
import { ConfigResource } from "@dxos/config";
|
|
648
650
|
import { GetDiagnosticsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
649
651
|
import { TRACE_PROCESSOR as TRACE_PROCESSOR2 } from "@dxos/tracing";
|
|
650
|
-
import { jsonKeyReplacer,
|
|
652
|
+
import { jsonKeyReplacer, isNonNullable } from "@dxos/util";
|
|
651
653
|
var GET_DIAGNOSTICS_RPC_TIMEOUT = 1e4;
|
|
652
654
|
var DiagnosticsCollector = class {
|
|
653
655
|
static {
|
|
@@ -680,7 +682,7 @@ var findSystemServiceProvider = () => {
|
|
|
680
682
|
};
|
|
681
683
|
var findConfigs = () => {
|
|
682
684
|
const configs = TRACE_PROCESSOR2.findResourcesByAnnotation(ConfigResource);
|
|
683
|
-
return configs.map((r) => r.instance.deref()).filter(
|
|
685
|
+
return configs.map((r) => r.instance.deref()).filter(isNonNullable);
|
|
684
686
|
};
|
|
685
687
|
|
|
686
688
|
// packages/sdk/client-services/src/packlets/identity/authenticator.ts
|
|
@@ -991,7 +993,7 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
991
993
|
this._remoteLength.clear();
|
|
992
994
|
}
|
|
993
995
|
async addFeed(feed) {
|
|
994
|
-
log4
|
|
996
|
+
log4("addFeed", {
|
|
995
997
|
key: feed.key,
|
|
996
998
|
connected: this._connected,
|
|
997
999
|
hasConnectionCtx: !!this._connectionCtx
|
|
@@ -1028,7 +1030,7 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1028
1030
|
}
|
|
1029
1031
|
async _sendMessage(message) {
|
|
1030
1032
|
if (!this._connectionCtx) {
|
|
1031
|
-
log4
|
|
1033
|
+
log4("message dropped because connection was disposed", void 0, {
|
|
1032
1034
|
F: __dxlog_file6,
|
|
1033
1035
|
L: 146,
|
|
1034
1036
|
S: this,
|
|
@@ -1037,7 +1039,7 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1037
1039
|
return;
|
|
1038
1040
|
}
|
|
1039
1041
|
if (message.type === "data") {
|
|
1040
|
-
log4
|
|
1042
|
+
log4("sending blocks", {
|
|
1041
1043
|
feedKey: message.feedKey,
|
|
1042
1044
|
blocks: message.blocks.map((b) => b.index)
|
|
1043
1045
|
}, {
|
|
@@ -1112,7 +1114,7 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1112
1114
|
feedKey
|
|
1113
1115
|
};
|
|
1114
1116
|
if (message.length > feed.length) {
|
|
1115
|
-
log4
|
|
1117
|
+
log4("requesting missing blocks", logMeta, {
|
|
1116
1118
|
F: __dxlog_file6,
|
|
1117
1119
|
L: 194,
|
|
1118
1120
|
S: this,
|
|
@@ -1127,7 +1129,7 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1127
1129
|
}
|
|
1128
1130
|
});
|
|
1129
1131
|
} else if (message.length < feed.length) {
|
|
1130
|
-
log4
|
|
1132
|
+
log4("pushing blocks to remote", logMeta, {
|
|
1131
1133
|
F: __dxlog_file6,
|
|
1132
1134
|
L: 202,
|
|
1133
1135
|
S: this,
|
|
@@ -1143,7 +1145,7 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1143
1145
|
}
|
|
1144
1146
|
}
|
|
1145
1147
|
case "data": {
|
|
1146
|
-
log4
|
|
1148
|
+
log4("received data", {
|
|
1147
1149
|
feed: message.feedKey,
|
|
1148
1150
|
blocks: message.blocks.map((b) => b.index)
|
|
1149
1151
|
}, {
|
|
@@ -1182,7 +1184,7 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1182
1184
|
});
|
|
1183
1185
|
}
|
|
1184
1186
|
async _pushBlocks(feed, from, to) {
|
|
1185
|
-
log4
|
|
1187
|
+
log4("pushing blocks", {
|
|
1186
1188
|
feed: feed.key.toHex(),
|
|
1187
1189
|
from,
|
|
1188
1190
|
to
|
|
@@ -1221,7 +1223,7 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1221
1223
|
this._remoteLength.set(feed.key, to);
|
|
1222
1224
|
}
|
|
1223
1225
|
async _integrateBlocks(feed, blocks) {
|
|
1224
|
-
log4
|
|
1226
|
+
log4("integrating blocks", {
|
|
1225
1227
|
feed: feed.key.toHex(),
|
|
1226
1228
|
blocks: blocks.length
|
|
1227
1229
|
}, {
|
|
@@ -2528,7 +2530,7 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2528
2530
|
});
|
|
2529
2531
|
dataSpace.postOpen.append(async () => {
|
|
2530
2532
|
const setting = dataSpace.getEdgeReplicationSetting();
|
|
2531
|
-
if (setting === EdgeReplicationSetting.ENABLED) {
|
|
2533
|
+
if (!setting || setting === EdgeReplicationSetting.ENABLED) {
|
|
2532
2534
|
await this._echoEdgeReplicator?.connectToSpace(dataSpace.id);
|
|
2533
2535
|
} else if (this._echoEdgeReplicator) {
|
|
2534
2536
|
log7("not connecting EchoEdgeReplicator because of EdgeReplicationSetting", {
|
|
@@ -2543,7 +2545,7 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2543
2545
|
});
|
|
2544
2546
|
dataSpace.preClose.append(async () => {
|
|
2545
2547
|
const setting = dataSpace.getEdgeReplicationSetting();
|
|
2546
|
-
if (setting === EdgeReplicationSetting.ENABLED) {
|
|
2548
|
+
if (!setting || setting === EdgeReplicationSetting.ENABLED) {
|
|
2547
2549
|
await this._echoEdgeReplicator?.disconnectFromSpace(dataSpace.id);
|
|
2548
2550
|
}
|
|
2549
2551
|
});
|
|
@@ -2676,7 +2678,7 @@ DataSpaceManager = _ts_decorate3([
|
|
|
2676
2678
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
2677
2679
|
import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as scheduleTask3 } from "@dxos/async";
|
|
2678
2680
|
import { Stream as Stream7 } from "@dxos/codec-protobuf/stream";
|
|
2679
|
-
import { createAdmissionCredentials as createAdmissionCredentials2, getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
2681
|
+
import { createAdmissionCredentials as createAdmissionCredentials2, createDidFromIdentityKey as createDidFromIdentityKey2, getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
2680
2682
|
import { raise } from "@dxos/debug";
|
|
2681
2683
|
import { writeMessages as writeMessages2 } from "@dxos/feed-store";
|
|
2682
2684
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
@@ -2732,7 +2734,7 @@ var SpacesServiceImpl = class {
|
|
|
2732
2734
|
const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
|
|
2733
2735
|
invariant6(credentials[0].credential, void 0, {
|
|
2734
2736
|
F: __dxlog_file11,
|
|
2735
|
-
L:
|
|
2737
|
+
L: 111,
|
|
2736
2738
|
S: this,
|
|
2737
2739
|
A: [
|
|
2738
2740
|
"credentials[0].credential",
|
|
@@ -2742,7 +2744,7 @@ var SpacesServiceImpl = class {
|
|
|
2742
2744
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2743
2745
|
invariant6(getCredentialAssertion3(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2744
2746
|
F: __dxlog_file11,
|
|
2745
|
-
L:
|
|
2747
|
+
L: 113,
|
|
2746
2748
|
S: this,
|
|
2747
2749
|
A: [
|
|
2748
2750
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2755,12 +2757,12 @@ var SpacesServiceImpl = class {
|
|
|
2755
2757
|
return new Stream7(({ next, ctx }) => {
|
|
2756
2758
|
const scheduler = new UpdateScheduler(ctx, async () => {
|
|
2757
2759
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2758
|
-
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
2760
|
+
const spaces = await Promise.all(Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space)));
|
|
2759
2761
|
log8("update", () => ({
|
|
2760
2762
|
ids: spaces.map((space) => space.id)
|
|
2761
2763
|
}), {
|
|
2762
2764
|
F: __dxlog_file11,
|
|
2763
|
-
L:
|
|
2765
|
+
L: 126,
|
|
2764
2766
|
S: this,
|
|
2765
2767
|
C: (f, a) => f(...a)
|
|
2766
2768
|
});
|
|
@@ -2852,7 +2854,7 @@ var SpacesServiceImpl = class {
|
|
|
2852
2854
|
} else {
|
|
2853
2855
|
invariant6(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
2854
2856
|
F: __dxlog_file11,
|
|
2855
|
-
L:
|
|
2857
|
+
L: 224,
|
|
2856
2858
|
S: this,
|
|
2857
2859
|
A: [
|
|
2858
2860
|
"!credential.id",
|
|
@@ -2861,7 +2863,7 @@ var SpacesServiceImpl = class {
|
|
|
2861
2863
|
});
|
|
2862
2864
|
invariant6(this._identityManager.identity, "Identity is not available", {
|
|
2863
2865
|
F: __dxlog_file11,
|
|
2864
|
-
L:
|
|
2866
|
+
L: 225,
|
|
2865
2867
|
S: this,
|
|
2866
2868
|
A: [
|
|
2867
2869
|
"this._identityManager.identity",
|
|
@@ -2871,7 +2873,7 @@ var SpacesServiceImpl = class {
|
|
|
2871
2873
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
2872
2874
|
invariant6(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
2873
2875
|
F: __dxlog_file11,
|
|
2874
|
-
L:
|
|
2876
|
+
L: 227,
|
|
2875
2877
|
S: this,
|
|
2876
2878
|
A: [
|
|
2877
2879
|
"credential.issuer.equals(signer.getIssuer())",
|
|
@@ -2921,7 +2923,7 @@ var SpacesServiceImpl = class {
|
|
|
2921
2923
|
const assertion = getCredentialAssertion3(credential);
|
|
2922
2924
|
invariant6(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2923
2925
|
F: __dxlog_file11,
|
|
2924
|
-
L:
|
|
2926
|
+
L: 261,
|
|
2925
2927
|
S: this,
|
|
2926
2928
|
A: [
|
|
2927
2929
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2931,7 +2933,7 @@ var SpacesServiceImpl = class {
|
|
|
2931
2933
|
const myIdentity = this._identityManager.identity;
|
|
2932
2934
|
invariant6(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
|
|
2933
2935
|
F: __dxlog_file11,
|
|
2934
|
-
L:
|
|
2936
|
+
L: 263,
|
|
2935
2937
|
S: this,
|
|
2936
2938
|
A: [
|
|
2937
2939
|
"myIdentity && credential.subject.id.equals(myIdentity.identityKey)",
|
|
@@ -2952,10 +2954,10 @@ var SpacesServiceImpl = class {
|
|
|
2952
2954
|
});
|
|
2953
2955
|
}
|
|
2954
2956
|
return {
|
|
2955
|
-
space: this._serializeSpace(dataSpace)
|
|
2957
|
+
space: await this._serializeSpace(dataSpace)
|
|
2956
2958
|
};
|
|
2957
2959
|
}
|
|
2958
|
-
_serializeSpace(space) {
|
|
2960
|
+
async _serializeSpace(space) {
|
|
2959
2961
|
return {
|
|
2960
2962
|
id: space.id,
|
|
2961
2963
|
spaceKey: space.key,
|
|
@@ -2975,7 +2977,7 @@ var SpacesServiceImpl = class {
|
|
|
2975
2977
|
totalDataTimeframe: void 0,
|
|
2976
2978
|
spaceRootUrl: space.databaseRoot?.url
|
|
2977
2979
|
},
|
|
2978
|
-
members: Array.from(space.inner.spaceState.members.values()).map((member) => {
|
|
2980
|
+
members: await Promise.all(Array.from(space.inner.spaceState.members.values()).map(async (member) => {
|
|
2979
2981
|
const peers = space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key));
|
|
2980
2982
|
const isMe = this._identityManager.identity?.identityKey.equals(member.key);
|
|
2981
2983
|
if (isMe) {
|
|
@@ -2983,6 +2985,7 @@ var SpacesServiceImpl = class {
|
|
|
2983
2985
|
}
|
|
2984
2986
|
return {
|
|
2985
2987
|
identity: {
|
|
2988
|
+
did: await createDidFromIdentityKey2(member.key),
|
|
2986
2989
|
identityKey: member.key,
|
|
2987
2990
|
profile: member.profile ?? {}
|
|
2988
2991
|
},
|
|
@@ -2990,7 +2993,7 @@ var SpacesServiceImpl = class {
|
|
|
2990
2993
|
presence: peers.length > 0 ? SpaceMember4.PresenceState.ONLINE : SpaceMember4.PresenceState.OFFLINE,
|
|
2991
2994
|
peerStates: peers
|
|
2992
2995
|
};
|
|
2993
|
-
}),
|
|
2996
|
+
})),
|
|
2994
2997
|
creator: space.inner.spaceState.creator?.key,
|
|
2995
2998
|
cache: space.cache,
|
|
2996
2999
|
metrics: space.metrics,
|
|
@@ -3035,13 +3038,14 @@ var Identity = class {
|
|
|
3035
3038
|
this.space = params.space;
|
|
3036
3039
|
this._signer = params.signer;
|
|
3037
3040
|
this._presence = params.presence;
|
|
3041
|
+
this.did = params.did;
|
|
3038
3042
|
this.identityKey = params.identityKey;
|
|
3039
3043
|
this.deviceKey = params.deviceKey;
|
|
3040
3044
|
log9.trace("dxos.halo.device", {
|
|
3041
3045
|
deviceKey: params.deviceKey
|
|
3042
3046
|
}, {
|
|
3043
3047
|
F: __dxlog_file12,
|
|
3044
|
-
L:
|
|
3048
|
+
L: 82,
|
|
3045
3049
|
S: this,
|
|
3046
3050
|
C: (f, a) => f(...a)
|
|
3047
3051
|
});
|
|
@@ -3143,7 +3147,7 @@ var Identity = class {
|
|
|
3143
3147
|
getIdentityCredentialSigner() {
|
|
3144
3148
|
invariant7(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
|
|
3145
3149
|
F: __dxlog_file12,
|
|
3146
|
-
L:
|
|
3150
|
+
L: 198,
|
|
3147
3151
|
S: this,
|
|
3148
3152
|
A: [
|
|
3149
3153
|
"this._deviceStateMachine.deviceCredentialChain",
|
|
@@ -3187,7 +3191,7 @@ var Identity = class {
|
|
|
3187
3191
|
dataFeedKey
|
|
3188
3192
|
}, {
|
|
3189
3193
|
F: __dxlog_file12,
|
|
3190
|
-
L:
|
|
3194
|
+
L: 223,
|
|
3191
3195
|
S: this,
|
|
3192
3196
|
C: (f, a) => f(...a)
|
|
3193
3197
|
});
|
|
@@ -3244,7 +3248,7 @@ Identity = _ts_decorate4([
|
|
|
3244
3248
|
import platform from "platform";
|
|
3245
3249
|
import { Event as Event6 } from "@dxos/async";
|
|
3246
3250
|
import { Context as Context4 } from "@dxos/context";
|
|
3247
|
-
import { createCredentialSignerWithKey as createCredentialSignerWithKey2,
|
|
3251
|
+
import { createCredentialSignerWithKey as createCredentialSignerWithKey2, createDidFromIdentityKey as createDidFromIdentityKey3, CredentialGenerator } from "@dxos/credentials";
|
|
3248
3252
|
import { invariant as invariant8 } from "@dxos/invariant";
|
|
3249
3253
|
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
3250
3254
|
import { log as log10 } from "@dxos/log";
|
|
@@ -3286,7 +3290,7 @@ var IdentityManager = class {
|
|
|
3286
3290
|
id: traceId
|
|
3287
3291
|
}), {
|
|
3288
3292
|
F: __dxlog_file13,
|
|
3289
|
-
L:
|
|
3293
|
+
L: 116,
|
|
3290
3294
|
S: this,
|
|
3291
3295
|
C: (f, a) => f(...a)
|
|
3292
3296
|
});
|
|
@@ -3295,7 +3299,7 @@ var IdentityManager = class {
|
|
|
3295
3299
|
identityRecord
|
|
3296
3300
|
}, {
|
|
3297
3301
|
F: __dxlog_file13,
|
|
3298
|
-
L:
|
|
3302
|
+
L: 119,
|
|
3299
3303
|
S: this,
|
|
3300
3304
|
C: (f, a) => f(...a)
|
|
3301
3305
|
});
|
|
@@ -3308,7 +3312,7 @@ var IdentityManager = class {
|
|
|
3308
3312
|
displayName: this._identity.profileDocument?.displayName
|
|
3309
3313
|
}, {
|
|
3310
3314
|
F: __dxlog_file13,
|
|
3311
|
-
L:
|
|
3315
|
+
L: 124,
|
|
3312
3316
|
S: this,
|
|
3313
3317
|
C: (f, a) => f(...a)
|
|
3314
3318
|
});
|
|
@@ -3318,7 +3322,7 @@ var IdentityManager = class {
|
|
|
3318
3322
|
id: traceId
|
|
3319
3323
|
}), {
|
|
3320
3324
|
F: __dxlog_file13,
|
|
3321
|
-
L:
|
|
3325
|
+
L: 131,
|
|
3322
3326
|
S: this,
|
|
3323
3327
|
C: (f, a) => f(...a)
|
|
3324
3328
|
});
|
|
@@ -3326,13 +3330,13 @@ var IdentityManager = class {
|
|
|
3326
3330
|
async close() {
|
|
3327
3331
|
await this._identity?.close(new Context4(void 0, {
|
|
3328
3332
|
F: __dxlog_file13,
|
|
3329
|
-
L:
|
|
3333
|
+
L: 135
|
|
3330
3334
|
}));
|
|
3331
3335
|
}
|
|
3332
3336
|
async createIdentity({ displayName, deviceProfile } = {}) {
|
|
3333
3337
|
invariant8(!this._identity, "Identity already exists.", {
|
|
3334
3338
|
F: __dxlog_file13,
|
|
3335
|
-
L:
|
|
3339
|
+
L: 140,
|
|
3336
3340
|
S: this,
|
|
3337
3341
|
A: [
|
|
3338
3342
|
"!this._identity",
|
|
@@ -3341,7 +3345,7 @@ var IdentityManager = class {
|
|
|
3341
3345
|
});
|
|
3342
3346
|
log10("creating identity...", void 0, {
|
|
3343
3347
|
F: __dxlog_file13,
|
|
3344
|
-
L:
|
|
3348
|
+
L: 141,
|
|
3345
3349
|
S: this,
|
|
3346
3350
|
C: (f, a) => f(...a)
|
|
3347
3351
|
});
|
|
@@ -3359,13 +3363,13 @@ var IdentityManager = class {
|
|
|
3359
3363
|
const identity = await this._constructIdentity(identityRecord);
|
|
3360
3364
|
await identity.open(new Context4(void 0, {
|
|
3361
3365
|
F: __dxlog_file13,
|
|
3362
|
-
L:
|
|
3366
|
+
L: 156
|
|
3363
3367
|
}));
|
|
3364
3368
|
{
|
|
3365
3369
|
const generator = new CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
|
|
3366
3370
|
invariant8(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
|
|
3367
3371
|
F: __dxlog_file13,
|
|
3368
|
-
L:
|
|
3372
|
+
L: 160,
|
|
3369
3373
|
S: this,
|
|
3370
3374
|
A: [
|
|
3371
3375
|
"identityRecord.haloSpace.genesisFeedKey",
|
|
@@ -3374,7 +3378,7 @@ var IdentityManager = class {
|
|
|
3374
3378
|
});
|
|
3375
3379
|
invariant8(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
|
|
3376
3380
|
F: __dxlog_file13,
|
|
3377
|
-
L:
|
|
3381
|
+
L: 161,
|
|
3378
3382
|
S: this,
|
|
3379
3383
|
A: [
|
|
3380
3384
|
"identityRecord.haloSpace.dataFeedKey",
|
|
@@ -3413,7 +3417,7 @@ var IdentityManager = class {
|
|
|
3413
3417
|
displayName: this._identity.profileDocument?.displayName
|
|
3414
3418
|
}, {
|
|
3415
3419
|
F: __dxlog_file13,
|
|
3416
|
-
L:
|
|
3420
|
+
L: 199,
|
|
3417
3421
|
S: this,
|
|
3418
3422
|
C: (f, a) => f(...a)
|
|
3419
3423
|
});
|
|
@@ -3424,7 +3428,7 @@ var IdentityManager = class {
|
|
|
3424
3428
|
profile: identity.profileDocument
|
|
3425
3429
|
}, {
|
|
3426
3430
|
F: __dxlog_file13,
|
|
3427
|
-
L:
|
|
3431
|
+
L: 205,
|
|
3428
3432
|
S: this,
|
|
3429
3433
|
C: (f, a) => f(...a)
|
|
3430
3434
|
});
|
|
@@ -3461,13 +3465,13 @@ var IdentityManager = class {
|
|
|
3461
3465
|
params
|
|
3462
3466
|
}, {
|
|
3463
3467
|
F: __dxlog_file13,
|
|
3464
|
-
L:
|
|
3468
|
+
L: 244,
|
|
3465
3469
|
S: this,
|
|
3466
3470
|
C: (f, a) => f(...a)
|
|
3467
3471
|
});
|
|
3468
3472
|
invariant8(!this._identity, "Identity already exists.", {
|
|
3469
3473
|
F: __dxlog_file13,
|
|
3470
|
-
L:
|
|
3474
|
+
L: 245,
|
|
3471
3475
|
S: this,
|
|
3472
3476
|
A: [
|
|
3473
3477
|
"!this._identity",
|
|
@@ -3488,7 +3492,7 @@ var IdentityManager = class {
|
|
|
3488
3492
|
const identity = await this._constructIdentity(identityRecord);
|
|
3489
3493
|
await identity.open(new Context4(void 0, {
|
|
3490
3494
|
F: __dxlog_file13,
|
|
3491
|
-
L:
|
|
3495
|
+
L: 259
|
|
3492
3496
|
}));
|
|
3493
3497
|
return {
|
|
3494
3498
|
identity,
|
|
@@ -3507,7 +3511,7 @@ var IdentityManager = class {
|
|
|
3507
3511
|
displayName: this._identity.profileDocument?.displayName
|
|
3508
3512
|
}, {
|
|
3509
3513
|
F: __dxlog_file13,
|
|
3510
|
-
L:
|
|
3514
|
+
L: 273,
|
|
3511
3515
|
S: this,
|
|
3512
3516
|
C: (f, a) => f(...a)
|
|
3513
3517
|
});
|
|
@@ -3521,7 +3525,7 @@ var IdentityManager = class {
|
|
|
3521
3525
|
deviceKey: identity.deviceKey
|
|
3522
3526
|
}, {
|
|
3523
3527
|
F: __dxlog_file13,
|
|
3524
|
-
L:
|
|
3528
|
+
L: 284,
|
|
3525
3529
|
S: this,
|
|
3526
3530
|
C: (f, a) => f(...a)
|
|
3527
3531
|
});
|
|
@@ -3532,7 +3536,7 @@ var IdentityManager = class {
|
|
|
3532
3536
|
async updateProfile(profile) {
|
|
3533
3537
|
invariant8(this._identity, "Identity not initialized.", {
|
|
3534
3538
|
F: __dxlog_file13,
|
|
3535
|
-
L:
|
|
3539
|
+
L: 291,
|
|
3536
3540
|
S: this,
|
|
3537
3541
|
A: [
|
|
3538
3542
|
"this._identity",
|
|
@@ -3563,7 +3567,7 @@ var IdentityManager = class {
|
|
|
3563
3567
|
async updateDeviceProfile(profile) {
|
|
3564
3568
|
invariant8(this._identity, "Identity not initialized.", {
|
|
3565
3569
|
F: __dxlog_file13,
|
|
3566
|
-
L:
|
|
3570
|
+
L: 308,
|
|
3567
3571
|
S: this,
|
|
3568
3572
|
A: [
|
|
3569
3573
|
"this._identity",
|
|
@@ -3596,48 +3600,10 @@ var IdentityManager = class {
|
|
|
3596
3600
|
profile
|
|
3597
3601
|
};
|
|
3598
3602
|
}
|
|
3599
|
-
async createRecoveryPhrase() {
|
|
3600
|
-
const identity = this._identity;
|
|
3601
|
-
invariant8(identity, void 0, {
|
|
3602
|
-
F: __dxlog_file13,
|
|
3603
|
-
L: 340,
|
|
3604
|
-
S: this,
|
|
3605
|
-
A: [
|
|
3606
|
-
"identity",
|
|
3607
|
-
""
|
|
3608
|
-
]
|
|
3609
|
-
});
|
|
3610
|
-
const seedphrase = generateSeedPhrase();
|
|
3611
|
-
const keypair = keyPairFromSeedPhrase(seedphrase);
|
|
3612
|
-
const recoveryKey = PublicKey7.from(keypair.publicKey);
|
|
3613
|
-
const identityKey = identity.identityKey;
|
|
3614
|
-
const credential = await identity.getIdentityCredentialSigner().createCredential({
|
|
3615
|
-
subject: identityKey,
|
|
3616
|
-
assertion: {
|
|
3617
|
-
"@type": "dxos.halo.credentials.IdentityRecovery",
|
|
3618
|
-
recoveryKey,
|
|
3619
|
-
identityKey
|
|
3620
|
-
}
|
|
3621
|
-
});
|
|
3622
|
-
const receipt = await identity.controlPipeline.writer.write({
|
|
3623
|
-
credential: {
|
|
3624
|
-
credential
|
|
3625
|
-
}
|
|
3626
|
-
});
|
|
3627
|
-
await identity.controlPipeline.state.waitUntilTimeframe(new Timeframe3([
|
|
3628
|
-
[
|
|
3629
|
-
receipt.feedKey,
|
|
3630
|
-
receipt.seq
|
|
3631
|
-
]
|
|
3632
|
-
]));
|
|
3633
|
-
return {
|
|
3634
|
-
seedphrase
|
|
3635
|
-
};
|
|
3636
|
-
}
|
|
3637
3603
|
async _constructIdentity(identityRecord) {
|
|
3638
3604
|
invariant8(!this._identity, void 0, {
|
|
3639
3605
|
F: __dxlog_file13,
|
|
3640
|
-
L:
|
|
3606
|
+
L: 334,
|
|
3641
3607
|
S: this,
|
|
3642
3608
|
A: [
|
|
3643
3609
|
"!this._identity",
|
|
@@ -3648,7 +3614,7 @@ var IdentityManager = class {
|
|
|
3648
3614
|
identityRecord
|
|
3649
3615
|
}, {
|
|
3650
3616
|
F: __dxlog_file13,
|
|
3651
|
-
L:
|
|
3617
|
+
L: 335,
|
|
3652
3618
|
S: this,
|
|
3653
3619
|
C: (f, a) => f(...a)
|
|
3654
3620
|
});
|
|
@@ -3663,7 +3629,7 @@ var IdentityManager = class {
|
|
|
3663
3629
|
});
|
|
3664
3630
|
invariant8(identityRecord.haloSpace.controlFeedKey, void 0, {
|
|
3665
3631
|
F: __dxlog_file13,
|
|
3666
|
-
L:
|
|
3632
|
+
L: 348,
|
|
3667
3633
|
S: this,
|
|
3668
3634
|
A: [
|
|
3669
3635
|
"identityRecord.haloSpace.controlFeedKey",
|
|
@@ -3675,7 +3641,7 @@ var IdentityManager = class {
|
|
|
3675
3641
|
});
|
|
3676
3642
|
invariant8(identityRecord.haloSpace.dataFeedKey, void 0, {
|
|
3677
3643
|
F: __dxlog_file13,
|
|
3678
|
-
L:
|
|
3644
|
+
L: 352,
|
|
3679
3645
|
S: this,
|
|
3680
3646
|
A: [
|
|
3681
3647
|
"identityRecord.haloSpace.dataFeedKey",
|
|
@@ -3699,10 +3665,12 @@ var IdentityManager = class {
|
|
|
3699
3665
|
});
|
|
3700
3666
|
await space.setControlFeed(controlFeed);
|
|
3701
3667
|
await space.setDataFeed(dataFeed);
|
|
3668
|
+
const did = await createDidFromIdentityKey3(identityRecord.identityKey);
|
|
3702
3669
|
const identity = new Identity({
|
|
3703
3670
|
space,
|
|
3704
3671
|
presence,
|
|
3705
3672
|
signer: this._keyring,
|
|
3673
|
+
did,
|
|
3706
3674
|
identityKey: identityRecord.identityKey,
|
|
3707
3675
|
deviceKey: identityRecord.deviceKey,
|
|
3708
3676
|
edgeConnection: this._edgeConnection,
|
|
@@ -3712,7 +3680,7 @@ var IdentityManager = class {
|
|
|
3712
3680
|
identityKey: identityRecord.identityKey
|
|
3713
3681
|
}, {
|
|
3714
3682
|
F: __dxlog_file13,
|
|
3715
|
-
L:
|
|
3683
|
+
L: 383,
|
|
3716
3684
|
S: this,
|
|
3717
3685
|
C: (f, a) => f(...a)
|
|
3718
3686
|
});
|
|
@@ -3737,7 +3705,7 @@ var IdentityManager = class {
|
|
|
3737
3705
|
onAuthFailure: () => {
|
|
3738
3706
|
log10.warn("auth failure", void 0, {
|
|
3739
3707
|
F: __dxlog_file13,
|
|
3740
|
-
L:
|
|
3708
|
+
L: 408,
|
|
3741
3709
|
S: this,
|
|
3742
3710
|
C: (f, a) => f(...a)
|
|
3743
3711
|
});
|
|
@@ -3800,7 +3768,7 @@ var IdentityServiceImpl = class extends Resource5 {
|
|
|
3800
3768
|
const identity = this._identityManager.identity;
|
|
3801
3769
|
invariant9(identity, void 0, {
|
|
3802
3770
|
F: __dxlog_file14,
|
|
3803
|
-
L:
|
|
3771
|
+
L: 61,
|
|
3804
3772
|
S: this,
|
|
3805
3773
|
A: [
|
|
3806
3774
|
"identity",
|
|
@@ -3823,6 +3791,7 @@ var IdentityServiceImpl = class extends Resource5 {
|
|
|
3823
3791
|
return void 0;
|
|
3824
3792
|
}
|
|
3825
3793
|
return {
|
|
3794
|
+
did: this._identityManager.identity.did,
|
|
3826
3795
|
identityKey: this._identityManager.identity.identityKey,
|
|
3827
3796
|
spaceKey: this._identityManager.identity.space.key,
|
|
3828
3797
|
profile: this._identityManager.identity.profileDocument
|
|
@@ -3831,7 +3800,7 @@ var IdentityServiceImpl = class extends Resource5 {
|
|
|
3831
3800
|
async updateProfile(profile) {
|
|
3832
3801
|
invariant9(this._identityManager.identity, "Identity not initialized.", {
|
|
3833
3802
|
F: __dxlog_file14,
|
|
3834
|
-
L:
|
|
3803
|
+
L: 88,
|
|
3835
3804
|
S: this,
|
|
3836
3805
|
A: [
|
|
3837
3806
|
"this._identityManager.identity",
|
|
@@ -3842,18 +3811,29 @@ var IdentityServiceImpl = class extends Resource5 {
|
|
|
3842
3811
|
await this._onProfileUpdate?.(this._identityManager.identity.profileDocument);
|
|
3843
3812
|
return this._getIdentity();
|
|
3844
3813
|
}
|
|
3845
|
-
async
|
|
3846
|
-
return this._recoveryManager.
|
|
3814
|
+
async createRecoveryCredential(request) {
|
|
3815
|
+
return this._recoveryManager.createRecoveryCredential(request);
|
|
3816
|
+
}
|
|
3817
|
+
async requestRecoveryChallenge() {
|
|
3818
|
+
return this._recoveryManager.requestRecoveryChallenge();
|
|
3847
3819
|
}
|
|
3848
3820
|
async recoverIdentity(request) {
|
|
3849
|
-
|
|
3821
|
+
if (request.recoveryCode) {
|
|
3822
|
+
await this._recoveryManager.recoverIdentity({
|
|
3823
|
+
recoveryCode: request.recoveryCode
|
|
3824
|
+
});
|
|
3825
|
+
} else if (request.external) {
|
|
3826
|
+
await this._recoveryManager.recoverIdentityWithExternalSignature(request.external);
|
|
3827
|
+
} else {
|
|
3828
|
+
throw new Error("Invalid request.");
|
|
3829
|
+
}
|
|
3850
3830
|
return this._getIdentity();
|
|
3851
3831
|
}
|
|
3852
3832
|
// TODO(burdon): Rename createPresentation?
|
|
3853
3833
|
async signPresentation({ presentation, nonce }) {
|
|
3854
3834
|
invariant9(this._identityManager.identity, "Identity not initialized.", {
|
|
3855
3835
|
F: __dxlog_file14,
|
|
3856
|
-
L:
|
|
3836
|
+
L: 116,
|
|
3857
3837
|
S: this,
|
|
3858
3838
|
A: [
|
|
3859
3839
|
"this._identityManager.identity",
|
|
@@ -3872,7 +3852,7 @@ var IdentityServiceImpl = class extends Resource5 {
|
|
|
3872
3852
|
const identity = this._identityManager.identity;
|
|
3873
3853
|
invariant9(identity, "Identity not initialized.", {
|
|
3874
3854
|
F: __dxlog_file14,
|
|
3875
|
-
L:
|
|
3855
|
+
L: 130,
|
|
3876
3856
|
S: this,
|
|
3877
3857
|
A: [
|
|
3878
3858
|
"identity",
|
|
@@ -3910,7 +3890,7 @@ var IdentityServiceImpl = class extends Resource5 {
|
|
|
3910
3890
|
duplicate: space.id
|
|
3911
3891
|
}, {
|
|
3912
3892
|
F: __dxlog_file14,
|
|
3913
|
-
L:
|
|
3893
|
+
L: 164,
|
|
3914
3894
|
S: this,
|
|
3915
3895
|
C: (f, a) => f(...a)
|
|
3916
3896
|
});
|
|
@@ -3924,7 +3904,7 @@ var IdentityServiceImpl = class extends Resource5 {
|
|
|
3924
3904
|
}, (err) => {
|
|
3925
3905
|
log11.catch(err, void 0, {
|
|
3926
3906
|
F: __dxlog_file14,
|
|
3927
|
-
L:
|
|
3907
|
+
L: 175,
|
|
3928
3908
|
S: this,
|
|
3929
3909
|
C: (f, a) => f(...a)
|
|
3930
3910
|
});
|
|
@@ -7179,6 +7159,18 @@ var EdgeAgentManager = class extends Resource6 {
|
|
|
7179
7159
|
haloSpaceKey: this._identity.haloSpaceKey.toHex()
|
|
7180
7160
|
});
|
|
7181
7161
|
const deviceKey = PublicKey13.fromHex(response.deviceKey);
|
|
7162
|
+
if (await this._identity.authorizedDeviceKeys.has(deviceKey)) {
|
|
7163
|
+
log22.info("agent was already added to HALO, ignoring response", {
|
|
7164
|
+
response
|
|
7165
|
+
}, {
|
|
7166
|
+
F: __dxlog_file26,
|
|
7167
|
+
L: 67,
|
|
7168
|
+
S: this,
|
|
7169
|
+
C: (f, a) => f(...a)
|
|
7170
|
+
});
|
|
7171
|
+
this._updateStatus(EdgeAgentStatus.ACTIVE, deviceKey);
|
|
7172
|
+
return;
|
|
7173
|
+
}
|
|
7182
7174
|
await this._identity.admitDevice({
|
|
7183
7175
|
deviceKey,
|
|
7184
7176
|
controlFeedKey: PublicKey13.fromHex(response.feedKey),
|
|
@@ -7187,7 +7179,7 @@ var EdgeAgentManager = class extends Resource6 {
|
|
|
7187
7179
|
});
|
|
7188
7180
|
log22("agent created", response, {
|
|
7189
7181
|
F: __dxlog_file26,
|
|
7190
|
-
L:
|
|
7182
|
+
L: 79,
|
|
7191
7183
|
S: this,
|
|
7192
7184
|
C: (f, a) => f(...a)
|
|
7193
7185
|
});
|
|
@@ -7199,7 +7191,7 @@ var EdgeAgentManager = class extends Resource6 {
|
|
|
7199
7191
|
isEnabled
|
|
7200
7192
|
}, {
|
|
7201
7193
|
F: __dxlog_file26,
|
|
7202
|
-
L:
|
|
7194
|
+
L: 87,
|
|
7203
7195
|
S: this,
|
|
7204
7196
|
C: (f, a) => f(...a)
|
|
7205
7197
|
});
|
|
@@ -7232,7 +7224,7 @@ var EdgeAgentManager = class extends Resource6 {
|
|
|
7232
7224
|
async _fetchAgentStatus() {
|
|
7233
7225
|
invariant18(this._edgeHttpClient, void 0, {
|
|
7234
7226
|
F: __dxlog_file26,
|
|
7235
|
-
L:
|
|
7227
|
+
L: 121,
|
|
7236
7228
|
S: this,
|
|
7237
7229
|
A: [
|
|
7238
7230
|
"this._edgeHttpClient",
|
|
@@ -7242,7 +7234,7 @@ var EdgeAgentManager = class extends Resource6 {
|
|
|
7242
7234
|
try {
|
|
7243
7235
|
log22("fetching agent status", void 0, {
|
|
7244
7236
|
F: __dxlog_file26,
|
|
7245
|
-
L:
|
|
7237
|
+
L: 123,
|
|
7246
7238
|
S: this,
|
|
7247
7239
|
C: (f, a) => f(...a)
|
|
7248
7240
|
});
|
|
@@ -7261,7 +7253,7 @@ var EdgeAgentManager = class extends Resource6 {
|
|
|
7261
7253
|
err
|
|
7262
7254
|
}, {
|
|
7263
7255
|
F: __dxlog_file26,
|
|
7264
|
-
L:
|
|
7256
|
+
L: 133,
|
|
7265
7257
|
S: this,
|
|
7266
7258
|
C: (f, a) => f(...a)
|
|
7267
7259
|
});
|
|
@@ -7274,7 +7266,7 @@ var EdgeAgentManager = class extends Resource6 {
|
|
|
7274
7266
|
retryAfterMs
|
|
7275
7267
|
}, {
|
|
7276
7268
|
F: __dxlog_file26,
|
|
7277
|
-
L:
|
|
7269
|
+
L: 138,
|
|
7278
7270
|
S: this,
|
|
7279
7271
|
C: (f, a) => f(...a)
|
|
7280
7272
|
});
|
|
@@ -7310,7 +7302,7 @@ var EdgeAgentManager = class extends Resource6 {
|
|
|
7310
7302
|
spaceId: space.id
|
|
7311
7303
|
}, {
|
|
7312
7304
|
F: __dxlog_file26,
|
|
7313
|
-
L:
|
|
7305
|
+
L: 165,
|
|
7314
7306
|
S: this,
|
|
7315
7307
|
C: (f, a) => f(...a)
|
|
7316
7308
|
});
|
|
@@ -7330,7 +7322,7 @@ var EdgeAgentManager = class extends Resource6 {
|
|
|
7330
7322
|
status
|
|
7331
7323
|
}, {
|
|
7332
7324
|
F: __dxlog_file26,
|
|
7333
|
-
L:
|
|
7325
|
+
L: 181,
|
|
7334
7326
|
S: this,
|
|
7335
7327
|
C: (f, a) => f(...a)
|
|
7336
7328
|
});
|
|
@@ -7420,7 +7412,7 @@ import { trace as Trace3 } from "@dxos/tracing";
|
|
|
7420
7412
|
import { safeInstanceof } from "@dxos/util";
|
|
7421
7413
|
|
|
7422
7414
|
// packages/sdk/client-services/src/packlets/identity/identity-recovery-manager.ts
|
|
7423
|
-
import { generateSeedPhrase
|
|
7415
|
+
import { generateSeedPhrase, keyPairFromSeedPhrase } from "@dxos/credentials";
|
|
7424
7416
|
import { sign as sign3 } from "@dxos/crypto";
|
|
7425
7417
|
import { invariant as invariant19 } from "@dxos/invariant";
|
|
7426
7418
|
import { PublicKey as PublicKey14 } from "@dxos/keys";
|
|
@@ -7436,27 +7428,41 @@ var EdgeIdentityRecoveryManager = class {
|
|
|
7436
7428
|
this._identityProvider = _identityProvider;
|
|
7437
7429
|
this._acceptRecoveredIdentity = _acceptRecoveredIdentity;
|
|
7438
7430
|
}
|
|
7439
|
-
async
|
|
7431
|
+
async createRecoveryCredential({ recoveryKey, algorithm }) {
|
|
7440
7432
|
const identity = this._identityProvider();
|
|
7441
7433
|
invariant19(identity, void 0, {
|
|
7442
7434
|
F: __dxlog_file27,
|
|
7443
|
-
L:
|
|
7435
|
+
L: 37,
|
|
7444
7436
|
S: this,
|
|
7445
7437
|
A: [
|
|
7446
7438
|
"identity",
|
|
7447
7439
|
""
|
|
7448
7440
|
]
|
|
7449
7441
|
});
|
|
7450
|
-
|
|
7451
|
-
|
|
7452
|
-
|
|
7442
|
+
let recoveryCode;
|
|
7443
|
+
if (!recoveryKey) {
|
|
7444
|
+
recoveryCode = generateSeedPhrase();
|
|
7445
|
+
const keypair = keyPairFromSeedPhrase(recoveryCode);
|
|
7446
|
+
recoveryKey = PublicKey14.from(keypair.publicKey);
|
|
7447
|
+
algorithm = "ED25519";
|
|
7448
|
+
}
|
|
7449
|
+
invariant19(algorithm, "Algorithm is required.", {
|
|
7450
|
+
F: __dxlog_file27,
|
|
7451
|
+
L: 47,
|
|
7452
|
+
S: this,
|
|
7453
|
+
A: [
|
|
7454
|
+
"algorithm",
|
|
7455
|
+
"'Algorithm is required.'"
|
|
7456
|
+
]
|
|
7457
|
+
});
|
|
7453
7458
|
const identityKey = identity.identityKey;
|
|
7454
7459
|
const credential = await identity.getIdentityCredentialSigner().createCredential({
|
|
7455
7460
|
subject: identityKey,
|
|
7456
7461
|
assertion: {
|
|
7457
7462
|
"@type": "dxos.halo.credentials.IdentityRecovery",
|
|
7458
7463
|
recoveryKey,
|
|
7459
|
-
identityKey
|
|
7464
|
+
identityKey,
|
|
7465
|
+
algorithm
|
|
7460
7466
|
}
|
|
7461
7467
|
});
|
|
7462
7468
|
const receipt = await identity.controlPipeline.writer.write({
|
|
@@ -7471,20 +7477,81 @@ var EdgeIdentityRecoveryManager = class {
|
|
|
7471
7477
|
]
|
|
7472
7478
|
]));
|
|
7473
7479
|
return {
|
|
7474
|
-
|
|
7480
|
+
recoveryCode
|
|
7475
7481
|
};
|
|
7476
7482
|
}
|
|
7477
|
-
async
|
|
7483
|
+
async requestRecoveryChallenge() {
|
|
7478
7484
|
invariant19(this._edgeClient, "Not connected to EDGE.", {
|
|
7479
7485
|
F: __dxlog_file27,
|
|
7480
|
-
L:
|
|
7486
|
+
L: 66,
|
|
7481
7487
|
S: this,
|
|
7482
7488
|
A: [
|
|
7483
7489
|
"this._edgeClient",
|
|
7484
7490
|
"'Not connected to EDGE.'"
|
|
7485
7491
|
]
|
|
7486
7492
|
});
|
|
7487
|
-
const
|
|
7493
|
+
const deviceKey = await this._keyring.createKey();
|
|
7494
|
+
const controlFeedKey = await this._keyring.createKey();
|
|
7495
|
+
const request = {
|
|
7496
|
+
deviceKey: deviceKey.toHex(),
|
|
7497
|
+
controlFeedKey: controlFeedKey.toHex()
|
|
7498
|
+
};
|
|
7499
|
+
try {
|
|
7500
|
+
await this._edgeClient.recoverIdentity(request);
|
|
7501
|
+
throw new Error("No challenge received.");
|
|
7502
|
+
} catch (error) {
|
|
7503
|
+
if (!(error instanceof EdgeAuthChallengeError2)) {
|
|
7504
|
+
throw error;
|
|
7505
|
+
}
|
|
7506
|
+
return {
|
|
7507
|
+
deviceKey,
|
|
7508
|
+
controlFeedKey,
|
|
7509
|
+
challenge: error.challenge
|
|
7510
|
+
};
|
|
7511
|
+
}
|
|
7512
|
+
}
|
|
7513
|
+
async recoverIdentityWithExternalSignature({ identityDid, deviceKey, controlFeedKey, signature, clientDataJson, authenticatorData }) {
|
|
7514
|
+
invariant19(this._edgeClient, "Not connected to EDGE.", {
|
|
7515
|
+
F: __dxlog_file27,
|
|
7516
|
+
L: 98,
|
|
7517
|
+
S: this,
|
|
7518
|
+
A: [
|
|
7519
|
+
"this._edgeClient",
|
|
7520
|
+
"'Not connected to EDGE.'"
|
|
7521
|
+
]
|
|
7522
|
+
});
|
|
7523
|
+
const request = {
|
|
7524
|
+
identityDid,
|
|
7525
|
+
deviceKey: deviceKey.toHex(),
|
|
7526
|
+
controlFeedKey: controlFeedKey.toHex(),
|
|
7527
|
+
signature: clientDataJson && authenticatorData ? {
|
|
7528
|
+
signature: Buffer.from(signature).toString("base64"),
|
|
7529
|
+
clientDataJson: Buffer.from(clientDataJson).toString("base64"),
|
|
7530
|
+
authenticatorData: Buffer.from(authenticatorData).toString("base64")
|
|
7531
|
+
} : Buffer.from(signature).toString("base64")
|
|
7532
|
+
};
|
|
7533
|
+
const response = await this._edgeClient.recoverIdentity(request);
|
|
7534
|
+
await this._acceptRecoveredIdentity({
|
|
7535
|
+
authorizedDeviceCredential: decodeCredential(response.deviceAuthCredential),
|
|
7536
|
+
haloGenesisFeedKey: PublicKey14.fromHex(response.genesisFeedKey),
|
|
7537
|
+
haloSpaceKey: PublicKey14.fromHex(response.haloSpaceKey),
|
|
7538
|
+
identityKey: PublicKey14.fromHex(response.identityKey),
|
|
7539
|
+
deviceKey,
|
|
7540
|
+
controlFeedKey,
|
|
7541
|
+
dataFeedKey: await this._keyring.createKey()
|
|
7542
|
+
});
|
|
7543
|
+
}
|
|
7544
|
+
async recoverIdentity({ recoveryCode }) {
|
|
7545
|
+
invariant19(this._edgeClient, "Not connected to EDGE.", {
|
|
7546
|
+
F: __dxlog_file27,
|
|
7547
|
+
L: 128,
|
|
7548
|
+
S: this,
|
|
7549
|
+
A: [
|
|
7550
|
+
"this._edgeClient",
|
|
7551
|
+
"'Not connected to EDGE.'"
|
|
7552
|
+
]
|
|
7553
|
+
});
|
|
7554
|
+
const recoveryKeypair = keyPairFromSeedPhrase(recoveryCode);
|
|
7488
7555
|
const recoveryKey = PublicKey14.from(recoveryKeypair.publicKey);
|
|
7489
7556
|
const deviceKey = await this._keyring.createKey();
|
|
7490
7557
|
const controlFeedKey = await this._keyring.createKey();
|
|
@@ -7508,7 +7575,7 @@ var EdgeIdentityRecoveryManager = class {
|
|
|
7508
7575
|
}
|
|
7509
7576
|
log23.info("recovering identity", response, {
|
|
7510
7577
|
F: __dxlog_file27,
|
|
7511
|
-
L:
|
|
7578
|
+
L: 154,
|
|
7512
7579
|
S: this,
|
|
7513
7580
|
C: (f, a) => f(...a)
|
|
7514
7581
|
});
|
|
@@ -9110,4 +9177,4 @@ export {
|
|
|
9110
9177
|
importProfileData,
|
|
9111
9178
|
ClientServicesHost
|
|
9112
9179
|
};
|
|
9113
|
-
//# sourceMappingURL=chunk-
|
|
9180
|
+
//# sourceMappingURL=chunk-VWRYD6LV.mjs.map
|