@dxos/echo-db 2.33.1 → 2.33.2-dev.0286e021
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/src/echo.d.ts +8 -8
- package/dist/src/echo.d.ts.map +1 -1
- package/dist/src/echo.js +15 -16
- package/dist/src/echo.js.map +1 -1
- package/dist/src/echo.test.js +7 -13
- package/dist/src/echo.test.js.map +1 -1
- package/dist/src/halo/contact-manager.d.ts +4 -4
- package/dist/src/halo/contact-manager.d.ts.map +1 -1
- package/dist/src/halo/contact-manager.js +10 -4
- package/dist/src/halo/contact-manager.js.map +1 -1
- package/dist/src/halo/halo-factory.d.ts +14 -9
- package/dist/src/halo/halo-factory.d.ts.map +1 -1
- package/dist/src/halo/halo-factory.js +47 -14
- package/dist/src/halo/halo-factory.js.map +1 -1
- package/dist/src/halo/halo-party.d.ts +35 -7
- package/dist/src/halo/halo-party.d.ts.map +1 -1
- package/dist/src/halo/halo-party.js +97 -18
- package/dist/src/halo/halo-party.js.map +1 -1
- package/dist/src/halo/halo.d.ts +14 -12
- package/dist/src/halo/halo.d.ts.map +1 -1
- package/dist/src/halo/halo.js +31 -29
- package/dist/src/halo/halo.js.map +1 -1
- package/dist/src/halo/halo.test.d.ts +2 -0
- package/dist/src/halo/halo.test.d.ts.map +1 -0
- package/dist/src/halo/halo.test.js +162 -0
- package/dist/src/halo/halo.test.js.map +1 -0
- package/dist/src/halo/identity-manager.d.ts +10 -8
- package/dist/src/halo/identity-manager.d.ts.map +1 -1
- package/dist/src/halo/identity-manager.js +24 -20
- package/dist/src/halo/identity-manager.js.map +1 -1
- package/dist/src/halo/identity.d.ts +12 -6
- package/dist/src/halo/identity.d.ts.map +1 -1
- package/dist/src/halo/identity.js +11 -15
- package/dist/src/halo/identity.js.map +1 -1
- package/dist/src/halo/index.d.ts +1 -1
- package/dist/src/halo/index.d.ts.map +1 -1
- package/dist/src/halo/index.js +1 -1
- package/dist/src/halo/index.js.map +1 -1
- package/dist/src/halo/party-opener.js +1 -1
- package/dist/src/halo/party-opener.js.map +1 -1
- package/dist/src/halo/preferences.d.ts +9 -9
- package/dist/src/halo/preferences.d.ts.map +1 -1
- package/dist/src/halo/preferences.js +25 -15
- package/dist/src/halo/preferences.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/invitations/greeting-initiator.d.ts +14 -4
- package/dist/src/invitations/greeting-initiator.d.ts.map +1 -1
- package/dist/src/invitations/greeting-initiator.js +15 -16
- package/dist/src/invitations/greeting-initiator.js.map +1 -1
- package/dist/src/invitations/greeting-responder.d.ts +3 -3
- package/dist/src/invitations/greeting-responder.d.ts.map +1 -1
- package/dist/src/invitations/greeting-responder.js +3 -4
- package/dist/src/invitations/greeting-responder.js.map +1 -1
- package/dist/src/invitations/halo-recovery-initiator.d.ts +6 -4
- package/dist/src/invitations/halo-recovery-initiator.d.ts.map +1 -1
- package/dist/src/invitations/halo-recovery-initiator.js +15 -26
- package/dist/src/invitations/halo-recovery-initiator.js.map +1 -1
- package/dist/src/invitations/index.d.ts +1 -1
- package/dist/src/invitations/index.js +1 -1
- package/dist/src/invitations/{invitation-manager.d.ts → invitation-factory.d.ts} +5 -6
- package/dist/src/invitations/invitation-factory.d.ts.map +1 -0
- package/dist/src/invitations/{invitation-manager.js → invitation-factory.js} +9 -15
- package/dist/src/invitations/invitation-factory.js.map +1 -0
- package/dist/src/invitations/offline-invitation-claimer.d.ts +3 -3
- package/dist/src/invitations/offline-invitation-claimer.js +1 -1
- package/dist/src/parties/{party-internal.d.ts → data-party.d.ts} +13 -11
- package/dist/src/parties/data-party.d.ts.map +1 -0
- package/dist/src/parties/{party-internal.js → data-party.js} +27 -37
- package/dist/src/parties/data-party.js.map +1 -0
- package/dist/src/parties/index.d.ts +1 -2
- package/dist/src/parties/index.d.ts.map +1 -1
- package/dist/src/parties/index.js +1 -2
- package/dist/src/parties/index.js.map +1 -1
- package/dist/src/parties/party-factory.d.ts +10 -11
- package/dist/src/parties/party-factory.d.ts.map +1 -1
- package/dist/src/parties/party-factory.js +25 -16
- package/dist/src/parties/party-factory.js.map +1 -1
- package/dist/src/parties/party-manager.d.ts +9 -9
- package/dist/src/parties/party-manager.d.ts.map +1 -1
- package/dist/src/parties/party-manager.js +13 -13
- package/dist/src/parties/party-manager.js.map +1 -1
- package/dist/src/parties/party-manager.test.js +69 -68
- package/dist/src/parties/party-manager.test.js.map +1 -1
- package/dist/src/{halo → parties}/party-preferences.d.ts +3 -3
- package/dist/src/parties/party-preferences.d.ts.map +1 -0
- package/dist/src/{halo → parties}/party-preferences.js +3 -3
- package/dist/src/parties/party-preferences.js.map +1 -0
- package/dist/src/pipeline/index.d.ts +3 -1
- package/dist/src/pipeline/index.d.ts.map +1 -1
- package/dist/src/pipeline/index.js +3 -1
- package/dist/src/pipeline/index.js.map +1 -1
- package/dist/src/{metadata → pipeline}/metadata-store.d.ts +0 -0
- package/dist/src/{metadata → pipeline}/metadata-store.d.ts.map +1 -1
- package/dist/src/{metadata → pipeline}/metadata-store.js +0 -0
- package/dist/src/{metadata → pipeline}/metadata-store.js.map +1 -1
- package/dist/src/{metadata → pipeline}/metadata-store.test.d.ts +0 -0
- package/dist/src/pipeline/metadata-store.test.d.ts.map +1 -0
- package/dist/src/{metadata → pipeline}/metadata-store.test.js +0 -0
- package/dist/src/{metadata → pipeline}/metadata-store.test.js.map +1 -1
- package/dist/src/{parties → pipeline}/party-core.d.ts +0 -0
- package/dist/src/pipeline/party-core.d.ts.map +1 -0
- package/dist/src/{parties → pipeline}/party-core.js +8 -4
- package/dist/src/pipeline/party-core.js.map +1 -0
- package/dist/src/{parties → pipeline}/party-core.test.d.ts +0 -0
- package/dist/src/pipeline/party-core.test.d.ts.map +1 -0
- package/dist/src/{parties → pipeline}/party-core.test.js +3 -4
- package/dist/src/pipeline/party-core.test.js.map +1 -0
- package/dist/src/pipeline/party-feed-provider.d.ts +3 -2
- package/dist/src/pipeline/party-feed-provider.d.ts.map +1 -1
- package/dist/src/pipeline/party-feed-provider.js +40 -19
- package/dist/src/pipeline/party-feed-provider.js.map +1 -1
- package/dist/src/protocol/auth-plugin.d.ts +7 -0
- package/dist/src/protocol/auth-plugin.d.ts.map +1 -0
- package/dist/src/protocol/auth-plugin.js +16 -0
- package/dist/src/protocol/auth-plugin.js.map +1 -0
- package/dist/src/protocol/authenticator.d.ts +14 -0
- package/dist/src/protocol/authenticator.d.ts.map +1 -0
- package/dist/src/protocol/authenticator.js +31 -0
- package/dist/src/protocol/authenticator.js.map +1 -0
- package/dist/src/protocol/authenticator.test.d.ts +2 -0
- package/dist/src/protocol/authenticator.test.d.ts.map +1 -0
- package/dist/src/protocol/authenticator.test.js +45 -0
- package/dist/src/protocol/authenticator.test.js.map +1 -0
- package/dist/src/protocol/credentials-signer.d.ts +31 -0
- package/dist/src/protocol/credentials-signer.d.ts.map +1 -0
- package/dist/src/protocol/credentials-signer.js +53 -0
- package/dist/src/protocol/credentials-signer.js.map +1 -0
- package/dist/src/protocol/halo-recovery-plugin.d.ts +10 -0
- package/dist/src/protocol/halo-recovery-plugin.d.ts.map +1 -0
- package/dist/src/protocol/halo-recovery-plugin.js +18 -0
- package/dist/src/protocol/halo-recovery-plugin.js.map +1 -0
- package/dist/src/protocol/index.d.ts +7 -0
- package/dist/src/protocol/index.d.ts.map +1 -0
- package/dist/src/{metadata → protocol}/index.js +7 -2
- package/dist/src/protocol/index.js.map +1 -0
- package/dist/src/protocol/offline-invitation-plugin.d.ts +9 -0
- package/dist/src/protocol/offline-invitation-plugin.d.ts.map +1 -0
- package/dist/src/protocol/offline-invitation-plugin.js +17 -0
- package/dist/src/protocol/offline-invitation-plugin.js.map +1 -0
- package/dist/src/{pipeline → protocol}/party-protocol-factory.d.ts +7 -17
- package/dist/src/protocol/party-protocol-factory.d.ts.map +1 -0
- package/dist/src/{pipeline → protocol}/party-protocol-factory.js +7 -47
- package/dist/src/protocol/party-protocol-factory.js.map +1 -0
- package/dist/src/snapshots/snapshot-generator.d.ts +1 -1
- package/dist/src/snapshots/snapshot-generator.d.ts.map +1 -1
- package/dist/src/testing/testing-factories.js.map +1 -1
- package/dist/src/testing/testing.d.ts +2 -2
- package/dist/src/testing/testing.d.ts.map +1 -1
- package/dist/src/testing/testing.js +1 -7
- package/dist/src/testing/testing.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +17 -17
- package/src/echo.test.ts +8 -14
- package/src/echo.ts +107 -109
- package/src/halo/contact-manager.ts +9 -5
- package/src/halo/halo-factory.ts +82 -19
- package/src/halo/halo-party.ts +137 -21
- package/src/halo/halo.test.ts +198 -0
- package/src/halo/halo.ts +40 -38
- package/src/halo/identity-manager.ts +33 -28
- package/src/halo/identity.ts +19 -23
- package/src/halo/index.ts +1 -1
- package/src/halo/party-opener.ts +1 -1
- package/src/halo/preferences.ts +29 -18
- package/src/index.ts +1 -1
- package/src/invitations/greeting-initiator.ts +37 -32
- package/src/invitations/greeting-responder.ts +4 -5
- package/src/invitations/halo-recovery-initiator.ts +16 -24
- package/src/invitations/index.ts +1 -1
- package/src/invitations/{invitation-manager.ts → invitation-factory.ts} +8 -15
- package/src/invitations/offline-invitation-claimer.ts +3 -3
- package/src/parties/{party-internal.ts → data-party.ts} +30 -55
- package/src/parties/index.ts +1 -2
- package/src/parties/party-factory.ts +31 -21
- package/src/parties/party-manager.test.ts +99 -73
- package/src/parties/party-manager.ts +17 -17
- package/src/{halo → parties}/party-preferences.ts +3 -3
- package/src/pipeline/index.ts +3 -1
- package/src/{metadata → pipeline}/metadata-store.test.ts +0 -0
- package/src/{metadata → pipeline}/metadata-store.ts +0 -0
- package/src/{parties → pipeline}/party-core.test.ts +1 -2
- package/src/{parties → pipeline}/party-core.ts +12 -7
- package/src/pipeline/party-feed-provider.ts +32 -21
- package/src/protocol/auth-plugin.ts +14 -0
- package/src/protocol/authenticator.test.ts +66 -0
- package/src/protocol/authenticator.ts +56 -0
- package/src/protocol/credentials-signer.ts +60 -0
- package/src/protocol/halo-recovery-plugin.ts +20 -0
- package/src/protocol/index.ts +10 -0
- package/src/protocol/offline-invitation-plugin.ts +19 -0
- package/src/{pipeline → protocol}/party-protocol-factory.ts +10 -82
- package/src/snapshots/snapshot-generator.ts +1 -1
- package/src/testing/testing-factories.ts +2 -2
- package/src/testing/testing.ts +3 -9
- package/dist/src/halo/party-preferences.d.ts.map +0 -1
- package/dist/src/halo/party-preferences.js.map +0 -1
- package/dist/src/invitations/invitation-manager.d.ts.map +0 -1
- package/dist/src/invitations/invitation-manager.js.map +0 -1
- package/dist/src/metadata/index.d.ts +0 -2
- package/dist/src/metadata/index.d.ts.map +0 -1
- package/dist/src/metadata/index.js.map +0 -1
- package/dist/src/metadata/metadata-store.test.d.ts.map +0 -1
- package/dist/src/parties/authenticator.d.ts +0 -5
- package/dist/src/parties/authenticator.d.ts.map +0 -1
- package/dist/src/parties/authenticator.js +0 -27
- package/dist/src/parties/authenticator.js.map +0 -1
- package/dist/src/parties/party-core.d.ts.map +0 -1
- package/dist/src/parties/party-core.js.map +0 -1
- package/dist/src/parties/party-core.test.d.ts.map +0 -1
- package/dist/src/parties/party-core.test.js.map +0 -1
- package/dist/src/parties/party-internal.d.ts.map +0 -1
- package/dist/src/parties/party-internal.js.map +0 -1
- package/dist/src/pipeline/party-protocol-factory.d.ts.map +0 -1
- package/dist/src/pipeline/party-protocol-factory.js.map +0 -1
- package/src/metadata/index.ts +0 -5
- package/src/parties/authenticator.ts +0 -31
|
@@ -14,19 +14,26 @@ const crypto_1 = require("@dxos/crypto");
|
|
|
14
14
|
const object_model_1 = require("@dxos/object-model");
|
|
15
15
|
const invitations_1 = require("../invitations");
|
|
16
16
|
const parties_1 = require("../parties");
|
|
17
|
+
const credentials_signer_1 = require("../protocol/credentials-signer");
|
|
17
18
|
const halo_party_1 = require("./halo-party");
|
|
18
19
|
const log = (0, debug_1.default)('dxos:echo-db:halo-factory');
|
|
19
20
|
/**
|
|
20
21
|
* Create and manage HALO parties.
|
|
21
22
|
*/
|
|
22
23
|
class HaloFactory {
|
|
23
|
-
constructor(
|
|
24
|
-
this._partyFactory = _partyFactory;
|
|
24
|
+
constructor(_networkManager, _modelFactory, _snapshotStore, _feedProviderFactory, _keyring, _options = {}) {
|
|
25
25
|
this._networkManager = _networkManager;
|
|
26
|
+
this._modelFactory = _modelFactory;
|
|
27
|
+
this._snapshotStore = _snapshotStore;
|
|
28
|
+
this._feedProviderFactory = _feedProviderFactory;
|
|
26
29
|
this._keyring = _keyring;
|
|
30
|
+
this._options = _options;
|
|
27
31
|
}
|
|
28
|
-
async constructParty(
|
|
29
|
-
|
|
32
|
+
async constructParty(hints) {
|
|
33
|
+
const credentialsSigner = credentials_signer_1.CredentialsSigner.createDirectDeviceSigner(this._keyring);
|
|
34
|
+
const feedProvider = this._feedProviderFactory(credentialsSigner.getIdentityKey().publicKey);
|
|
35
|
+
const halo = new halo_party_1.HaloParty(this._modelFactory, this._snapshotStore, feedProvider, credentialsSigner, this._networkManager, hints, undefined, this._options);
|
|
36
|
+
return halo;
|
|
30
37
|
}
|
|
31
38
|
async createHalo(options = {}) {
|
|
32
39
|
var _a;
|
|
@@ -35,8 +42,10 @@ class HaloFactory {
|
|
|
35
42
|
(0, assert_1.default)(identityKey, 'Identity key required.');
|
|
36
43
|
const deviceKey = (_a = this._keyring.findKey(credentials_1.Keyring.signingFilter({ type: credentials_1.KeyType.DEVICE }))) !== null && _a !== void 0 ? _a : await this._keyring.createKeyRecord({ type: credentials_1.KeyType.DEVICE });
|
|
37
44
|
// 1. Create a feed for the HALO.
|
|
38
|
-
const halo = await this.
|
|
39
|
-
const
|
|
45
|
+
const halo = await this.constructParty([]);
|
|
46
|
+
const feedKey = await halo.getWriteFeedKey();
|
|
47
|
+
const feedKeyPair = this._keyring.getKey(feedKey);
|
|
48
|
+
(0, assert_1.default)(feedKeyPair);
|
|
40
49
|
// Connect the pipeline.
|
|
41
50
|
await halo.open();
|
|
42
51
|
/* 2. Write a PartyGenesis message for the HALO. This message must be signed by the:
|
|
@@ -44,8 +53,6 @@ class HaloFactory {
|
|
|
44
53
|
* B. Device key (the first "member" of the Identity's HALO).
|
|
45
54
|
* C. Feed key (the feed owned by the Device).
|
|
46
55
|
*/
|
|
47
|
-
const feedKeyPair = this._keyring.getKey(feed.key);
|
|
48
|
-
(0, assert_1.default)(feedKeyPair);
|
|
49
56
|
await halo.processor.writeHaloMessage((0, credentials_1.createPartyGenesisMessage)(this._keyring, identityKey, feedKeyPair.publicKey, deviceKey));
|
|
50
57
|
/* 3. Make a special self-signed KeyAdmit message which will serve as an "IdentityGenesis" message. This
|
|
51
58
|
* message will be copied into other Parties which we create or join.
|
|
@@ -72,29 +79,30 @@ class HaloFactory {
|
|
|
72
79
|
await this._keyring.deleteSecretKey(identityKey);
|
|
73
80
|
return halo;
|
|
74
81
|
}
|
|
75
|
-
async recoverHalo(
|
|
82
|
+
async recoverHalo(seedPhrase) {
|
|
76
83
|
const recoveredKeyPair = (0, crypto_1.keyPairFromSeedPhrase)(seedPhrase);
|
|
77
84
|
await this._keyring.addKeyRecord({
|
|
78
85
|
publicKey: crypto_1.PublicKey.from(recoveredKeyPair.publicKey),
|
|
79
86
|
secretKey: recoveredKeyPair.secretKey,
|
|
80
87
|
type: credentials_1.KeyType.IDENTITY
|
|
81
88
|
});
|
|
82
|
-
|
|
89
|
+
await this._keyring.createKeyRecord({ type: credentials_1.KeyType.DEVICE });
|
|
90
|
+
const recoverer = new invitations_1.HaloRecoveryInitiator(this._networkManager, credentials_signer_1.CredentialsSigner.createDirectDeviceSigner(this._keyring));
|
|
83
91
|
await recoverer.connect();
|
|
84
92
|
const invitationDescriptor = await recoverer.claim();
|
|
85
93
|
return this._joinHalo(invitationDescriptor, recoverer.createSecretProvider());
|
|
86
94
|
}
|
|
87
95
|
async joinHalo(invitationDescriptor, secretProvider) {
|
|
88
|
-
(0, assert_1.default)(!this._keyring.findKey(credentials_1.Filter.matches({ type: credentials_1.KeyType.
|
|
96
|
+
(0, assert_1.default)(!this._keyring.findKey(credentials_1.Filter.matches({ type: credentials_1.KeyType.IDENTITY })), 'Identity key must not exist.');
|
|
89
97
|
return this._joinHalo(invitationDescriptor, secretProvider);
|
|
90
98
|
}
|
|
91
99
|
async _joinHalo(invitationDescriptor, secretProvider) {
|
|
92
100
|
var _a;
|
|
93
101
|
log(`Admitting device with invitation: ${(0, crypto_1.keyToString)(invitationDescriptor.invitation)}`);
|
|
94
102
|
(0, assert_1.default)(invitationDescriptor.identityKey);
|
|
95
|
-
|
|
103
|
+
let identityKey = this._keyring.findKey(credentials_1.Keyring.signingFilter({ type: credentials_1.KeyType.IDENTITY }));
|
|
96
104
|
if (!identityKey) {
|
|
97
|
-
await this._keyring.addPublicKey({
|
|
105
|
+
identityKey = await this._keyring.addPublicKey({
|
|
98
106
|
type: credentials_1.KeyType.IDENTITY,
|
|
99
107
|
publicKey: invitationDescriptor.identityKey,
|
|
100
108
|
own: true,
|
|
@@ -104,8 +112,33 @@ class HaloFactory {
|
|
|
104
112
|
else {
|
|
105
113
|
(0, assert_1.default)(identityKey.publicKey.equals(invitationDescriptor.identityKey), 'Identity key must match invitation');
|
|
106
114
|
}
|
|
115
|
+
(0, assert_1.default)(identityKey);
|
|
107
116
|
const deviceKey = (_a = this._keyring.findKey(credentials_1.Keyring.signingFilter({ type: credentials_1.KeyType.DEVICE }))) !== null && _a !== void 0 ? _a : await this._keyring.createKeyRecord({ type: credentials_1.KeyType.DEVICE });
|
|
108
|
-
const
|
|
117
|
+
const originalInvitation = invitationDescriptor;
|
|
118
|
+
const credentialsSigner = credentials_signer_1.CredentialsSigner.createDirectDeviceSigner(this._keyring);
|
|
119
|
+
// Claim the offline invitation and convert it into an interactive invitation.
|
|
120
|
+
if (invitationDescriptor.type === invitations_1.InvitationDescriptorType.OFFLINE) {
|
|
121
|
+
const invitationClaimer = new invitations_1.OfflineInvitationClaimer(this._networkManager, invitationDescriptor);
|
|
122
|
+
await invitationClaimer.connect();
|
|
123
|
+
invitationDescriptor = await invitationClaimer.claim();
|
|
124
|
+
log(`Party invitation triggered interactive Greeting at: ${JSON.stringify({ original: originalInvitation.invitation, interactive: invitationDescriptor.invitation })}`);
|
|
125
|
+
await invitationClaimer.destroy();
|
|
126
|
+
}
|
|
127
|
+
const initiator = new invitations_1.GreetingInitiator(this._networkManager, invitationDescriptor, async (partyKey, nonce) => {
|
|
128
|
+
(0, assert_1.default)(partyKey.equals(identityKey.publicKey));
|
|
129
|
+
return [(0, invitations_1.createHaloPartyAdmissionMessage)(credentialsSigner, nonce)];
|
|
130
|
+
});
|
|
131
|
+
await initiator.connect();
|
|
132
|
+
const { partyKey, hints } = await initiator.redeemInvitation(secretProvider);
|
|
133
|
+
/*
|
|
134
|
+
* TODO(telackey): We shouldn't have to add our key here, it should be in the hints, but our hint
|
|
135
|
+
* mechanism is broken by not waiting on the messages to be processed before returning.
|
|
136
|
+
*/
|
|
137
|
+
const halo = await this.constructParty(hints);
|
|
138
|
+
await halo.open();
|
|
139
|
+
// Write the Feed genesis message.
|
|
140
|
+
await halo.processor.writeHaloMessage((0, credentials_1.createFeedAdmitMessage)(credentialsSigner.signer, partyKey, await halo.getWriteFeedKey(), [credentialsSigner.getDeviceKey()]));
|
|
141
|
+
await initiator.destroy();
|
|
109
142
|
await halo.database.createItem({
|
|
110
143
|
model: object_model_1.ObjectModel,
|
|
111
144
|
type: halo_party_1.HALO_PARTY_DEVICE_PREFERENCES_TYPE,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"halo-factory.js","sourceRoot":"","sources":["../../../src/halo/halo-factory.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;AAEF,oDAA4B;AAC5B,kDAA0B;AAE1B,
|
|
1
|
+
{"version":3,"file":"halo-factory.js","sourceRoot":"","sources":["../../../src/halo/halo-factory.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;AAEF,oDAA4B;AAC5B,kDAA0B;AAE1B,mDA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AAC,CAAC;YAChD,OAAO,CAAC,IAAA,6CAA+B,EAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC,CAAC;QACrE,CAAC,CACF,CAAC;QAEF,MAAM,SAAS,CAAC,OAAO,EAAE,CAAC;QAC1B,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,MAAM,SAAS,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC;QAE7E;;;WAGG;QACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QAC9C,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAElB,kCAAkC;QAClC,MAAM,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,IAAA,oCAAsB,EAC1D,iBAAiB,CAAC,MAAM,EACxB,QAAQ,EACR,MAAM,IAAI,CAAC,eAAe,EAAE,EAC5B,CAAC,iBAAiB,CAAC,YAAY,EAAE,CAAC,CACnC,CAAC,CAAC;QACH,MAAM,SAAS,CAAC,OAAO,EAAE,CAAC;QAE1B,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;YAC7B,KAAK,EAAE,0BAAW;YAClB,IAAI,EAAE,+CAAkC;YACxC,KAAK,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE;SACrD,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA9KD,kCA8KC"}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import { Event } from '@dxos/async';
|
|
1
2
|
import { KeyHint } from '@dxos/credentials';
|
|
2
3
|
import { PublicKey } from '@dxos/crypto';
|
|
3
|
-
import {
|
|
4
|
+
import { Timeframe } from '@dxos/echo-protocol';
|
|
5
|
+
import { ModelFactory } from '@dxos/model-factory';
|
|
6
|
+
import { NetworkManager } from '@dxos/network-manager';
|
|
7
|
+
import { InvitationAuthenticator, InvitationDescriptor, InvitationOptions } from '../invitations';
|
|
8
|
+
import { PartyFeedProvider, PartyOptions } from '../pipeline';
|
|
9
|
+
import { CredentialsSigner } from '../protocol/credentials-signer';
|
|
10
|
+
import { SnapshotStore } from '../snapshots';
|
|
4
11
|
import { ContactManager } from './contact-manager';
|
|
5
12
|
import { Preferences } from './preferences';
|
|
6
13
|
export declare const HALO_PARTY_DESCRIPTOR_TYPE = "dxos:item/halo/party-descriptor";
|
|
@@ -15,24 +22,45 @@ export interface JoinedParty {
|
|
|
15
22
|
keyHints: KeyHint[];
|
|
16
23
|
}
|
|
17
24
|
/**
|
|
18
|
-
*
|
|
25
|
+
* Provides all HALO-related functionality.
|
|
19
26
|
*/
|
|
20
27
|
export declare class HaloParty {
|
|
21
|
-
private readonly
|
|
22
|
-
private readonly
|
|
28
|
+
private readonly _feedProvider;
|
|
29
|
+
private readonly _credentialsSigner;
|
|
30
|
+
private readonly _networkManager;
|
|
31
|
+
private readonly _hints;
|
|
32
|
+
readonly update: Event<void>;
|
|
33
|
+
private readonly _partyCore;
|
|
34
|
+
private _invitationManager?;
|
|
35
|
+
private _protocol?;
|
|
23
36
|
private readonly _contactManager;
|
|
24
37
|
private readonly _preferences;
|
|
25
|
-
constructor(
|
|
38
|
+
constructor(modelFactory: ModelFactory, snapshotStore: SnapshotStore, _feedProvider: PartyFeedProvider, _credentialsSigner: CredentialsSigner, _networkManager: NetworkManager, _hints: KeyHint[], _initialTimeframe: Timeframe | undefined, _options: PartyOptions);
|
|
39
|
+
/**
|
|
40
|
+
* Party key.
|
|
41
|
+
* Always equal to the identity key.
|
|
42
|
+
* @deprecated Should remove.
|
|
43
|
+
*/
|
|
44
|
+
get key(): PublicKey;
|
|
26
45
|
get isOpen(): boolean;
|
|
27
46
|
get contacts(): ContactManager;
|
|
28
47
|
get preferences(): Preferences;
|
|
29
48
|
get database(): import("..").Database;
|
|
30
|
-
get invitationManager(): import("..").InvitationManager;
|
|
31
49
|
get identityInfo(): import("@dxos/credentials").SignedMessage | undefined;
|
|
32
50
|
get identityGenesis(): import("@dxos/credentials").SignedMessage | undefined;
|
|
33
51
|
get memberKeys(): PublicKey[];
|
|
34
52
|
get credentialMessages(): Map<string, import("@dxos/credentials").SignedMessage>;
|
|
35
53
|
get feedKeys(): PublicKey[];
|
|
36
|
-
|
|
54
|
+
getWriteFeedKey(): Promise<PublicKey>;
|
|
55
|
+
get processor(): import("../pipeline").PartyProcessor;
|
|
56
|
+
/**
|
|
57
|
+
* Opens the pipeline and connects the streams.
|
|
58
|
+
*/
|
|
59
|
+
open(): Promise<this>;
|
|
60
|
+
/**
|
|
61
|
+
* Closes the pipeline and streams.
|
|
62
|
+
*/
|
|
63
|
+
close(): Promise<this>;
|
|
64
|
+
createInvitation(authenticationDetails: InvitationAuthenticator, options?: InvitationOptions): Promise<InvitationDescriptor>;
|
|
37
65
|
}
|
|
38
66
|
//# sourceMappingURL=halo-party.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"halo-party.d.ts","sourceRoot":"","sources":["../../../src/halo/halo-party.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"halo-party.d.ts","sourceRoot":"","sources":["../../../src/halo/halo-party.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAgB,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAqB,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAErH,OAAO,EAAE,iBAAiB,EAAmC,YAAY,EAAE,MAAM,aAAa,CAAC;AAE/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAA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Y,0DAEf;IAED,IAAI,eAAe,0DAElB;IAED,IAAI,UAAU,gBAEb;IAED,IAAI,kBAAkB,2DAErB;IAED,IAAI,QAAQ,gBAEX;IAEK,eAAe;IAKrB,IAAI,SAAS,yCAEZ;IAED;;OAEG;IAGG,IAAI;IAyCV;;MAEE;IAEI,KAAK;IAgBL,gBAAgB,CAAE,qBAAqB,EAAE,uBAAuB,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAIpI"}
|
|
@@ -2,8 +2,24 @@
|
|
|
2
2
|
//
|
|
3
3
|
// Copyright 2020 DXOS.org
|
|
4
4
|
//
|
|
5
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
6
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
7
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
8
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
9
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
5
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
15
|
exports.HaloParty = exports.HALO_PARTY_DEVICE_PREFERENCES_TYPE = exports.HALO_PARTY_PREFERENCES_TYPE = exports.HALO_PARTY_CONTACT_LIST_TYPE = exports.HALO_PARTY_DESCRIPTOR_TYPE = void 0;
|
|
16
|
+
const assert_1 = __importDefault(require("assert"));
|
|
17
|
+
const async_1 = require("@dxos/async");
|
|
18
|
+
const debug_1 = require("@dxos/debug");
|
|
19
|
+
const invitations_1 = require("../invitations");
|
|
20
|
+
const parties_1 = require("../parties");
|
|
21
|
+
const pipeline_1 = require("../pipeline");
|
|
22
|
+
const protocol_1 = require("../protocol");
|
|
7
23
|
const contact_manager_1 = require("./contact-manager");
|
|
8
24
|
const preferences_1 = require("./preferences");
|
|
9
25
|
exports.HALO_PARTY_DESCRIPTOR_TYPE = 'dxos:item/halo/party-descriptor';
|
|
@@ -11,17 +27,29 @@ exports.HALO_PARTY_CONTACT_LIST_TYPE = 'dxos:item/halo/contact-list';
|
|
|
11
27
|
exports.HALO_PARTY_PREFERENCES_TYPE = 'dxos:item/halo/preferences';
|
|
12
28
|
exports.HALO_PARTY_DEVICE_PREFERENCES_TYPE = 'dxos:item/halo/device/preferences';
|
|
13
29
|
/**
|
|
14
|
-
*
|
|
30
|
+
* Provides all HALO-related functionality.
|
|
15
31
|
*/
|
|
16
32
|
class HaloParty {
|
|
17
|
-
constructor(
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
33
|
+
constructor(modelFactory, snapshotStore, _feedProvider, _credentialsSigner, _networkManager, _hints = [], _initialTimeframe, _options) {
|
|
34
|
+
this._feedProvider = _feedProvider;
|
|
35
|
+
this._credentialsSigner = _credentialsSigner;
|
|
36
|
+
this._networkManager = _networkManager;
|
|
37
|
+
this._hints = _hints;
|
|
38
|
+
this.update = new async_1.Event();
|
|
39
|
+
this._partyCore = new pipeline_1.PartyCore(_credentialsSigner.getIdentityKey().publicKey, _feedProvider, modelFactory, snapshotStore, _credentialsSigner.getIdentityKey().publicKey, _initialTimeframe, _options);
|
|
40
|
+
this._contactManager = new contact_manager_1.ContactManager(() => this.isOpen ? this.database : undefined);
|
|
41
|
+
this._preferences = new preferences_1.Preferences(() => this.isOpen ? this.database : undefined, _credentialsSigner.getDeviceKey().publicKey);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Party key.
|
|
45
|
+
* Always equal to the identity key.
|
|
46
|
+
* @deprecated Should remove.
|
|
47
|
+
*/
|
|
48
|
+
get key() {
|
|
49
|
+
return this._partyCore.key;
|
|
22
50
|
}
|
|
23
51
|
get isOpen() {
|
|
24
|
-
return this.
|
|
52
|
+
return !!(this._partyCore.isOpen && this._protocol);
|
|
25
53
|
}
|
|
26
54
|
get contacts() {
|
|
27
55
|
return this._contactManager;
|
|
@@ -31,34 +59,85 @@ class HaloParty {
|
|
|
31
59
|
}
|
|
32
60
|
// TODO(burdon): Remove.
|
|
33
61
|
get database() {
|
|
34
|
-
return this.
|
|
62
|
+
return this._partyCore.database;
|
|
35
63
|
}
|
|
36
64
|
//
|
|
37
65
|
// TODO(burdon): Factor out getters into other class abstractions (grouping functionality).
|
|
38
66
|
// (eg, identity, credentials, device management.)
|
|
39
67
|
//
|
|
40
|
-
get invitationManager() {
|
|
41
|
-
return this._party.invitationManager;
|
|
42
|
-
}
|
|
43
68
|
get identityInfo() {
|
|
44
|
-
return this.
|
|
69
|
+
return this._partyCore.processor.infoMessages.get(this._credentialsSigner.getIdentityKey().publicKey.toHex());
|
|
45
70
|
}
|
|
46
71
|
get identityGenesis() {
|
|
47
|
-
return this.
|
|
72
|
+
return this._partyCore.processor.credentialMessages.get(this._credentialsSigner.getIdentityKey().publicKey.toHex());
|
|
48
73
|
}
|
|
49
74
|
get memberKeys() {
|
|
50
|
-
return this.
|
|
75
|
+
return this._partyCore.processor.memberKeys;
|
|
51
76
|
}
|
|
52
77
|
get credentialMessages() {
|
|
53
|
-
return this.
|
|
78
|
+
return this._partyCore.processor.credentialMessages;
|
|
54
79
|
}
|
|
55
80
|
get feedKeys() {
|
|
56
|
-
return this.
|
|
81
|
+
return this._partyCore.processor.feedKeys;
|
|
82
|
+
}
|
|
83
|
+
async getWriteFeedKey() {
|
|
84
|
+
const feed = await this._feedProvider.createOrOpenWritableFeed();
|
|
85
|
+
return feed.key;
|
|
57
86
|
}
|
|
58
|
-
|
|
87
|
+
get processor() {
|
|
88
|
+
return this._partyCore.processor;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Opens the pipeline and connects the streams.
|
|
92
|
+
*/
|
|
93
|
+
async open() {
|
|
94
|
+
if (this.isOpen) {
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
await this._partyCore.open(this._hints);
|
|
98
|
+
this._invitationManager = new invitations_1.InvitationFactory(this._partyCore.processor, this._credentialsSigner, this._networkManager);
|
|
99
|
+
//
|
|
100
|
+
// Network/swarm.
|
|
101
|
+
//
|
|
102
|
+
const writeFeed = await this._partyCore.getWriteFeed();
|
|
103
|
+
const peerId = this._credentialsSigner.getDeviceKey().publicKey;
|
|
104
|
+
this._protocol = new pipeline_1.PartyProtocolFactory(this._partyCore.key, this._networkManager, this._feedProvider, peerId, (0, protocol_1.createCredentialsProvider)(this._credentialsSigner, this._partyCore.key, writeFeed.key), this._partyCore.processor.getActiveFeedSet());
|
|
105
|
+
// Replication.
|
|
106
|
+
await this._protocol.start([
|
|
107
|
+
(0, protocol_1.createAuthPlugin)((0, protocol_1.createAuthenticator)(this._partyCore.processor, this._credentialsSigner), peerId),
|
|
108
|
+
(0, protocol_1.createHaloRecoveryPlugin)(this._credentialsSigner.getIdentityKey().publicKey, this._invitationManager, peerId)
|
|
109
|
+
]);
|
|
110
|
+
// Issue an 'update' whenever the properties change.
|
|
111
|
+
this.database.select({ type: parties_1.PARTY_ITEM_TYPE }).exec().update.on(() => this.update.emit());
|
|
112
|
+
this.update.emit();
|
|
113
|
+
return this;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Closes the pipeline and streams.
|
|
117
|
+
*/
|
|
59
118
|
async close() {
|
|
60
|
-
|
|
119
|
+
var _a;
|
|
120
|
+
if (!this.isOpen) {
|
|
121
|
+
return this;
|
|
122
|
+
}
|
|
123
|
+
await this._partyCore.close();
|
|
124
|
+
await ((_a = this._protocol) === null || _a === void 0 ? void 0 : _a.stop());
|
|
125
|
+
this._protocol = undefined;
|
|
126
|
+
this._invitationManager = undefined;
|
|
127
|
+
this.update.emit();
|
|
128
|
+
return this;
|
|
129
|
+
}
|
|
130
|
+
async createInvitation(authenticationDetails, options) {
|
|
131
|
+
(0, assert_1.default)(this._invitationManager, 'HALO party not open.');
|
|
132
|
+
return this._invitationManager.createInvitation(authenticationDetails, options);
|
|
61
133
|
}
|
|
62
134
|
}
|
|
135
|
+
__decorate([
|
|
136
|
+
async_1.synchronized,
|
|
137
|
+
(0, debug_1.timed)(5000)
|
|
138
|
+
], HaloParty.prototype, "open", null);
|
|
139
|
+
__decorate([
|
|
140
|
+
async_1.synchronized
|
|
141
|
+
], HaloParty.prototype, "close", null);
|
|
63
142
|
exports.HaloParty = HaloParty;
|
|
64
143
|
//# sourceMappingURL=halo-party.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"halo-party.js","sourceRoot":"","sources":["../../../src/halo/halo-party.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE
|
|
1
|
+
{"version":3,"file":"halo-party.js","sourceRoot":"","sources":["../../../src/halo/halo-party.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;;;;;;;AAEF,oDAA4B;AAE5B,uCAAkD;AAGlD,uCAAoC;AAKpC,gDAAqH;AACrH,wCAA6C;AAC7C,0CAA+F;AAC/F,0CAAyH;AAGzH,uDAAmD;AACnD,+CAA4C;AAE/B,QAAA,0BAA0B,GAAG,iCAAiC,CAAC;AAC/D,QAAA,4BAA4B,GAAG,6BAA6B,CAAC;AAC7D,QAAA,2BAA2B,GAAG,4BAA4B,CAAC;AAC3D,QAAA,kCAAkC,GAAG,mCAAmC,CAAC;AAUtF;;GAEG;AACH,MAAa,SAAS;IAUpB,YACE,YAA0B,EAC1B,aAA4B,EACX,aAAgC,EAChC,kBAAqC,EACrC,eAA+B,EAC/B,SAAoB,EAAE,EACvC,iBAAwC,EACxC,QAAsB;QALL,kBAAa,GAAb,aAAa,CAAmB;QAChC,uBAAkB,GAAlB,kBAAkB,CAAmB;QACrC,oBA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AS,0CAAE,IAAI,EAAE,CAAA,CAAC;QAE7B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;QAEpC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAEnB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAE,qBAA8C,EAAE,OAA2B;QACjG,IAAA,gBAAM,EAAC,IAAI,CAAC,kBAAkB,EAAE,sBAAsB,CAAC,CAAC;QACxD,OAAO,IAAI,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC;IAClF,CAAC;CACF;AAjEC;IAFC,oBAAY;IACZ,IAAA,aAAK,EAAC,IAAK,CAAC;qCAwCZ;AAMD;IADC,oBAAY;sCAeZ;AAjKH,8BAuKC"}
|
package/dist/src/halo/halo.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { KeyRecord, Keyring, SecretProvider } from '@dxos/credentials';
|
|
2
|
-
import {
|
|
2
|
+
import { PublicKey } from '@dxos/crypto';
|
|
3
|
+
import { ModelFactory } from '@dxos/model-factory';
|
|
3
4
|
import { NetworkManager } from '@dxos/network-manager';
|
|
4
5
|
import { ResultSet } from '../api';
|
|
5
6
|
import { InvitationAuthenticator, InvitationDescriptor, InvitationOptions } from '../invitations';
|
|
6
|
-
import { MetadataStore } from '../
|
|
7
|
-
import {
|
|
7
|
+
import { MetadataStore, PartyOptions, PartyFeedProvider } from '../pipeline';
|
|
8
|
+
import { SnapshotStore } from '../snapshots';
|
|
8
9
|
import { Contact } from './contact-manager';
|
|
9
10
|
import type { CreateProfileOptions } from './types';
|
|
10
11
|
export interface ProfileInfo {
|
|
@@ -13,19 +14,20 @@ export interface ProfileInfo {
|
|
|
13
14
|
}
|
|
14
15
|
export interface HaloConfiguration {
|
|
15
16
|
keyring: Keyring;
|
|
16
|
-
partyFactory: PartyFactory;
|
|
17
17
|
networkManager: NetworkManager;
|
|
18
|
-
partyManager: PartyManager;
|
|
19
18
|
metadataStore: MetadataStore;
|
|
19
|
+
modelFactory: ModelFactory;
|
|
20
|
+
snapshotStore: SnapshotStore;
|
|
21
|
+
feedProviderFactory: (partyKey: PublicKey) => PartyFeedProvider;
|
|
22
|
+
options: PartyOptions;
|
|
20
23
|
}
|
|
21
24
|
/**
|
|
22
25
|
* Manages user's identity and devices.
|
|
23
26
|
*/
|
|
24
27
|
export declare class HALO {
|
|
25
28
|
private readonly _keyring;
|
|
26
|
-
private readonly _partyManager;
|
|
27
29
|
private readonly _identityManager;
|
|
28
|
-
constructor({ keyring,
|
|
30
|
+
constructor({ keyring, networkManager, metadataStore, modelFactory, snapshotStore, feedProviderFactory, options }: HaloConfiguration);
|
|
29
31
|
toString(): string;
|
|
30
32
|
info(): {
|
|
31
33
|
initialized: boolean;
|
|
@@ -39,7 +41,7 @@ export declare class HALO {
|
|
|
39
41
|
/**
|
|
40
42
|
* Get user's identity.
|
|
41
43
|
*/
|
|
42
|
-
get identity(): import("./identity").Identity;
|
|
44
|
+
get identity(): import("./identity").Identity | undefined;
|
|
43
45
|
/**
|
|
44
46
|
* Event that is fired when the user's identity has been initialized.
|
|
45
47
|
*/
|
|
@@ -69,19 +71,19 @@ export declare class HALO {
|
|
|
69
71
|
*
|
|
70
72
|
* NOTE: This method does not initialize the HALO party.
|
|
71
73
|
*/
|
|
72
|
-
|
|
74
|
+
private _createIdentityKeypair;
|
|
73
75
|
/**
|
|
74
76
|
* Creates the initial HALO party.
|
|
75
77
|
*/
|
|
76
|
-
|
|
78
|
+
private _createHaloParty;
|
|
77
79
|
/**
|
|
78
80
|
* Joins an existing identity HALO from a recovery seed phrase.
|
|
79
81
|
*/
|
|
80
|
-
recover(seedPhrase: string): Promise<import("
|
|
82
|
+
recover(seedPhrase: string): Promise<import("./halo-party").HaloParty>;
|
|
81
83
|
/**
|
|
82
84
|
* Joins an existing identity HALO by invitation.
|
|
83
85
|
*/
|
|
84
|
-
join(invitationDescriptor: InvitationDescriptor, secretProvider: SecretProvider): Promise<import("
|
|
86
|
+
join(invitationDescriptor: InvitationDescriptor, secretProvider: SecretProvider): Promise<import("./halo-party").HaloParty>;
|
|
85
87
|
/**
|
|
86
88
|
* Create an invitation to an exiting identity HALO.
|
|
87
89
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"halo.d.ts","sourceRoot":"","sources":["../../../src/halo/halo.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAW,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,
|
|
1
|
+
{"version":3,"file":"halo.d.ts","sourceRoot":"","sources":["../../../src/halo/halo.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAW,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAA0B,SAAS,EAAE,MAAM,cAAc,CAAC;AAEjE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAElG,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAIpD,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;CAC7B;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CA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QAAQ,EAAE,GAAE,oBAAyB,GAAG,OAAO,CAAC,WAAW,CAAC;IAkBzG;;OAEG;IAEH,UAAU,IAAK,WAAW,GAAG,SAAS;IAYtC,kBAAkB,CAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;CAGtD"}
|
package/dist/src/halo/halo.js
CHANGED
|
@@ -18,6 +18,7 @@ const debug_1 = __importDefault(require("debug"));
|
|
|
18
18
|
const async_1 = require("@dxos/async");
|
|
19
19
|
const credentials_1 = require("@dxos/credentials");
|
|
20
20
|
const crypto_1 = require("@dxos/crypto");
|
|
21
|
+
const debug_2 = require("@dxos/debug");
|
|
21
22
|
const halo_factory_1 = require("./halo-factory");
|
|
22
23
|
const identity_manager_1 = require("./identity-manager");
|
|
23
24
|
const log = (0, debug_1.default)('dxos:echo');
|
|
@@ -25,10 +26,9 @@ const log = (0, debug_1.default)('dxos:echo');
|
|
|
25
26
|
* Manages user's identity and devices.
|
|
26
27
|
*/
|
|
27
28
|
class HALO {
|
|
28
|
-
constructor({ keyring,
|
|
29
|
+
constructor({ keyring, networkManager, metadataStore, modelFactory, snapshotStore, feedProviderFactory, options }) {
|
|
29
30
|
this._keyring = keyring;
|
|
30
|
-
|
|
31
|
-
const haloFactory = new halo_factory_1.HaloFactory(partyFactory, networkManager, this._keyring);
|
|
31
|
+
const haloFactory = new halo_factory_1.HaloFactory(networkManager, modelFactory, snapshotStore, feedProviderFactory, keyring, options);
|
|
32
32
|
this._identityManager = new identity_manager_1.IdentityManager(this._keyring, haloFactory, metadataStore);
|
|
33
33
|
}
|
|
34
34
|
toString() {
|
|
@@ -64,14 +64,16 @@ class HALO {
|
|
|
64
64
|
* User's IDENTITY keypair.
|
|
65
65
|
*/
|
|
66
66
|
get identityKey() {
|
|
67
|
-
|
|
67
|
+
var _a;
|
|
68
|
+
return (_a = this.identity) === null || _a === void 0 ? void 0 : _a.identityKey;
|
|
68
69
|
}
|
|
69
70
|
/**
|
|
70
71
|
* User's identity display name.
|
|
71
72
|
*/
|
|
72
73
|
// TODO(burdon): Rename username (here and in data structure).
|
|
73
74
|
get identityDisplayName() {
|
|
74
|
-
|
|
75
|
+
var _a;
|
|
76
|
+
return (_a = this.identity) === null || _a === void 0 ? void 0 : _a.displayName;
|
|
75
77
|
}
|
|
76
78
|
/**
|
|
77
79
|
* Local keyring. Stores locally known keypairs.
|
|
@@ -95,9 +97,7 @@ class HALO {
|
|
|
95
97
|
* Closes HALO. Automatically called when client is destroyed.
|
|
96
98
|
*/
|
|
97
99
|
async close() {
|
|
98
|
-
|
|
99
|
-
// TODO(marik-d): Should be `_identityManager.close()`.
|
|
100
|
-
await ((_a = this.identity.halo) === null || _a === void 0 ? void 0 : _a.close());
|
|
100
|
+
await this._identityManager.close();
|
|
101
101
|
}
|
|
102
102
|
/**
|
|
103
103
|
* Reset the identity and delete all key records.
|
|
@@ -115,12 +115,12 @@ class HALO {
|
|
|
115
115
|
*
|
|
116
116
|
* NOTE: This method does not initialize the HALO party.
|
|
117
117
|
*/
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
async _createIdentityKeypair(keyPair) {
|
|
119
|
+
var _a;
|
|
120
120
|
const { publicKey, secretKey } = keyPair;
|
|
121
121
|
(0, assert_1.default)(publicKey, 'Invalid publicKey');
|
|
122
122
|
(0, assert_1.default)(secretKey, 'Invalid secretKey');
|
|
123
|
-
if (this.identity.identityKey) {
|
|
123
|
+
if ((_a = this.identity) === null || _a === void 0 ? void 0 : _a.identityKey) {
|
|
124
124
|
// TODO(burdon): Bad API: Semantics change based on options.
|
|
125
125
|
// TODO(burdon): `createProfile` isn't part of this package.
|
|
126
126
|
throw new Error('Identity key already exists. Call createProfile without a keypair to only create a halo party.');
|
|
@@ -130,49 +130,51 @@ class HALO {
|
|
|
130
130
|
/**
|
|
131
131
|
* Creates the initial HALO party.
|
|
132
132
|
*/
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
async _createHaloParty(displayName) {
|
|
134
|
+
var _a;
|
|
135
135
|
// TODO(burdon): Why not assert?
|
|
136
|
-
if (this.identity
|
|
137
|
-
throw new Error('
|
|
138
|
-
}
|
|
139
|
-
if (!this.identity.identityKey) {
|
|
140
|
-
throw new Error('Cannot create HALO. Identity key not found.');
|
|
136
|
+
if (this.identity) {
|
|
137
|
+
throw new Error('Identity already initialized');
|
|
141
138
|
}
|
|
139
|
+
const identityKey = (_a = this._identityManager.getIdentityKey()) !== null && _a !== void 0 ? _a : (0, debug_2.raise)(new Error('Cannot create HALO. Identity key not found.'));
|
|
142
140
|
await this._identityManager.createHalo({
|
|
143
|
-
identityDisplayName: displayName ||
|
|
141
|
+
identityDisplayName: displayName || identityKey.publicKey.humanize()
|
|
144
142
|
});
|
|
145
143
|
}
|
|
146
144
|
/**
|
|
147
145
|
* Joins an existing identity HALO from a recovery seed phrase.
|
|
148
146
|
*/
|
|
147
|
+
// TODO(dmaretskyi): Do not return HALO party here.
|
|
149
148
|
async recover(seedPhrase) {
|
|
150
|
-
|
|
151
|
-
(0, assert_1.default)(!this.identity.halo, 'HALO already exists.');
|
|
152
|
-
(0, assert_1.default)(!this.identity.identityKey, 'Identity key already exists.');
|
|
149
|
+
var _a, _b;
|
|
150
|
+
(0, assert_1.default)(!((_a = this.identity) === null || _a === void 0 ? void 0 : _a.halo), 'HALO already exists.');
|
|
151
|
+
(0, assert_1.default)(!((_b = this.identity) === null || _b === void 0 ? void 0 : _b.identityKey), 'Identity key already exists.');
|
|
153
152
|
return this._identityManager.recoverHalo(seedPhrase);
|
|
154
153
|
}
|
|
155
154
|
/**
|
|
156
155
|
* Joins an existing identity HALO by invitation.
|
|
157
156
|
*/
|
|
157
|
+
// TODO(dmaretskyi): Do not return HALO party here.
|
|
158
158
|
async join(invitationDescriptor, secretProvider) {
|
|
159
|
-
|
|
160
|
-
(0, assert_1.default)(!this.identity.halo, 'HALO already exists.');
|
|
159
|
+
var _a;
|
|
160
|
+
(0, assert_1.default)(!((_a = this.identity) === null || _a === void 0 ? void 0 : _a.halo), 'HALO already exists.');
|
|
161
161
|
return this._identityManager.joinHalo(invitationDescriptor, secretProvider);
|
|
162
162
|
}
|
|
163
163
|
/**
|
|
164
164
|
* Create an invitation to an exiting identity HALO.
|
|
165
165
|
*/
|
|
166
166
|
async createInvitation(authenticationDetails, options) {
|
|
167
|
-
|
|
168
|
-
|
|
167
|
+
var _a;
|
|
168
|
+
(0, assert_1.default)((_a = this.identity) === null || _a === void 0 ? void 0 : _a.halo, 'HALO not initialized.');
|
|
169
|
+
return this.identity.halo.createInvitation(authenticationDetails, options);
|
|
169
170
|
}
|
|
170
171
|
/**
|
|
171
172
|
* Query for contacts. Contacts represent member keys across all known Parties.
|
|
172
173
|
*/
|
|
173
174
|
// TODO(burdon): Expose ContactManager directly.
|
|
174
175
|
queryContacts() {
|
|
175
|
-
|
|
176
|
+
var _a;
|
|
177
|
+
(0, assert_1.default)((_a = this.identity) === null || _a === void 0 ? void 0 : _a.contacts, 'HALO not initialized.');
|
|
176
178
|
return this.identity.contacts.queryContacts();
|
|
177
179
|
}
|
|
178
180
|
/**
|
|
@@ -189,8 +191,8 @@ class HALO {
|
|
|
189
191
|
throw new Error('Both publicKey and secretKey must be provided or neither.');
|
|
190
192
|
}
|
|
191
193
|
const keyPair = publicKey ? { publicKey: Buffer.from(publicKey), secretKey: Buffer.from(secretKey) } : (0, crypto_1.createKeyPair)();
|
|
192
|
-
await this.
|
|
193
|
-
await this.
|
|
194
|
+
await this._createIdentityKeypair(keyPair);
|
|
195
|
+
await this._createHaloParty(username);
|
|
194
196
|
const profile = this.getProfile();
|
|
195
197
|
(0, assert_1.default)(profile);
|
|
196
198
|
return profile;
|