@wireapp/core 27.3.9 → 27.4.2-0
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/package.json +4 -3
- package/src/main/Account.d.ts +5 -1
- package/src/main/Account.js +22 -2
- package/src/main/client/ClientService.d.ts +8 -0
- package/src/main/client/ClientService.js +15 -1
- package/CHANGELOG.md +0 -11613
- package/LICENSE +0 -674
package/package.json
CHANGED
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
"./src/main/cryptography/AssetCryptography/crypto.node": "./src/main/cryptography/AssetCryptography/crypto.browser.js"
|
|
4
4
|
},
|
|
5
5
|
"dependencies": {
|
|
6
|
+
"@open-wc/webpack-import-meta-loader": "0.4.7",
|
|
7
|
+
"@otak/core-crypto": "0.2.0-beta-3",
|
|
6
8
|
"@types/long": "4.0.1",
|
|
7
9
|
"@types/node": "~14",
|
|
8
|
-
"@wireapp/api-client": "19.
|
|
10
|
+
"@wireapp/api-client": "19.7.1-1",
|
|
9
11
|
"@wireapp/cryptobox": "12.8.0",
|
|
10
12
|
"bazinga64": "5.10.0",
|
|
11
13
|
"hash.js": "1.1.7",
|
|
@@ -69,6 +71,5 @@
|
|
|
69
71
|
"test:project": "yarn dist && yarn test",
|
|
70
72
|
"test:node": "nyc jasmine --config=jasmine.json"
|
|
71
73
|
},
|
|
72
|
-
"version": "27.
|
|
73
|
-
"gitHead": "484551420463b87202957bc68969cc6d4e8c06a2"
|
|
74
|
+
"version": "27.4.2-0"
|
|
74
75
|
}
|
package/src/main/Account.d.ts
CHANGED
|
@@ -68,6 +68,7 @@ interface AccountOptions {
|
|
|
68
68
|
* - make it likely that all prekeys get consumed while the device is offline and the last resort prekey will be used to create new session
|
|
69
69
|
*/
|
|
70
70
|
nbPrekeys?: number;
|
|
71
|
+
enableMLS?: boolean;
|
|
71
72
|
}
|
|
72
73
|
export declare class Account extends EventEmitter {
|
|
73
74
|
private readonly apiClient;
|
|
@@ -75,6 +76,8 @@ export declare class Account extends EventEmitter {
|
|
|
75
76
|
private readonly createStore;
|
|
76
77
|
private storeEngine?;
|
|
77
78
|
private readonly nbPrekeys;
|
|
79
|
+
private readonly enableMLS;
|
|
80
|
+
private coreCryptoClient?;
|
|
78
81
|
static readonly TOPIC: typeof TOPIC;
|
|
79
82
|
service?: {
|
|
80
83
|
account: AccountService;
|
|
@@ -96,7 +99,7 @@ export declare class Account extends EventEmitter {
|
|
|
96
99
|
* @param apiClient The apiClient instance to use in the core (will create a new new one if undefined)
|
|
97
100
|
* @param storeEngineProvider
|
|
98
101
|
*/
|
|
99
|
-
constructor(apiClient?: APIClient, { createStore, nbPrekeys }?: AccountOptions);
|
|
102
|
+
constructor(apiClient?: APIClient, { createStore, nbPrekeys, enableMLS }?: AccountOptions);
|
|
100
103
|
private persistCookie;
|
|
101
104
|
get clientId(): string;
|
|
102
105
|
get userId(): string;
|
|
@@ -140,6 +143,7 @@ export declare class Account extends EventEmitter {
|
|
|
140
143
|
}>;
|
|
141
144
|
initServices(context: Context): Promise<void>;
|
|
142
145
|
loadAndValidateLocalClient(): Promise<RegisteredClient>;
|
|
146
|
+
private createMLSClient;
|
|
143
147
|
private registerClient;
|
|
144
148
|
private resetContext;
|
|
145
149
|
logout(): Promise<void>;
|
package/src/main/Account.js
CHANGED
|
@@ -84,12 +84,13 @@ class Account extends events_1.EventEmitter {
|
|
|
84
84
|
* @param apiClient The apiClient instance to use in the core (will create a new new one if undefined)
|
|
85
85
|
* @param storeEngineProvider
|
|
86
86
|
*/
|
|
87
|
-
constructor(apiClient = new api_client_1.APIClient(), { createStore = () => undefined, nbPrekeys = 2 } = {}) {
|
|
87
|
+
constructor(apiClient = new api_client_1.APIClient(), { createStore = () => undefined, nbPrekeys = 2, enableMLS = false } = {}) {
|
|
88
88
|
super();
|
|
89
89
|
this.apiClient = apiClient;
|
|
90
90
|
this.backendFeatures = this.apiClient.backendFeatures;
|
|
91
91
|
this.nbPrekeys = nbPrekeys;
|
|
92
92
|
this.createStore = createStore;
|
|
93
|
+
this.enableMLS = enableMLS;
|
|
93
94
|
apiClient.on(api_client_1.APIClient.TOPIC.COOKIE_REFRESH, async (cookie) => {
|
|
94
95
|
if (cookie && this.storeEngine) {
|
|
95
96
|
try {
|
|
@@ -256,17 +257,36 @@ class Account extends events_1.EventEmitter {
|
|
|
256
257
|
const loadedClient = await this.service.client.getLocalClient();
|
|
257
258
|
await this.apiClient.api.client.getClient(loadedClient.id);
|
|
258
259
|
this.apiClient.context.clientId = loadedClient.id;
|
|
260
|
+
if (this.enableMLS) {
|
|
261
|
+
this.coreCryptoClient = await this.createMLSClient(loadedClient);
|
|
262
|
+
}
|
|
259
263
|
return loadedClient;
|
|
260
264
|
}
|
|
265
|
+
async createMLSClient(client) {
|
|
266
|
+
const { CoreCrypto } = await Promise.resolve().then(() => __importStar(require('@otak/core-crypto')));
|
|
267
|
+
const { userId, domain } = this.apiClient.context;
|
|
268
|
+
return CoreCrypto.init({
|
|
269
|
+
path: 'path/to/database',
|
|
270
|
+
key: 'a root identity key (i.e. enclaved encryption key for this device)',
|
|
271
|
+
clientId: `${userId}:${client.id}@${domain}`,
|
|
272
|
+
});
|
|
273
|
+
}
|
|
261
274
|
async registerClient(loginData, clientInfo = coreDefaultClient, entropyData) {
|
|
262
275
|
if (!this.service) {
|
|
263
276
|
throw new Error('Services are not set.');
|
|
264
277
|
}
|
|
278
|
+
this.logger.info(`Creating new client {mls: ${!!this.enableMLS}}`);
|
|
265
279
|
const registeredClient = await this.service.client.register(loginData, clientInfo, entropyData);
|
|
280
|
+
if (this.enableMLS) {
|
|
281
|
+
this.coreCryptoClient = await this.createMLSClient(registeredClient);
|
|
282
|
+
await this.service.client.uploadMLSPublicKeys(this.coreCryptoClient.clientPublicKey(), registeredClient.id);
|
|
283
|
+
await this.service.client.uploadMLSKeyPackages(this.coreCryptoClient.clientKeypackages(this.nbPrekeys), registeredClient.id);
|
|
284
|
+
}
|
|
266
285
|
this.apiClient.context.clientId = registeredClient.id;
|
|
267
|
-
this.logger.
|
|
286
|
+
this.logger.info('Client is created');
|
|
268
287
|
await this.service.notification.initializeNotificationStream();
|
|
269
288
|
await this.service.client.synchronizeClients();
|
|
289
|
+
await this.service.cryptography.initCryptobox();
|
|
270
290
|
return { isNewClient: true, localClient: registeredClient };
|
|
271
291
|
}
|
|
272
292
|
resetContext() {
|
|
@@ -37,4 +37,12 @@ export declare class ClientService {
|
|
|
37
37
|
createLocalClient(client: RegisteredClient, domain?: string): Promise<MetaClient>;
|
|
38
38
|
synchronizeClients(): Promise<MetaClient[]>;
|
|
39
39
|
register(loginData: LoginData, clientInfo: ClientInfo, entropyData?: Uint8Array): Promise<RegisteredClient>;
|
|
40
|
+
/**
|
|
41
|
+
* Will make the given client mls capable (generate and upload key packages)
|
|
42
|
+
*
|
|
43
|
+
* @param mlsClient Intance of the coreCrypto that represents the mls client
|
|
44
|
+
* @param clientId The id of the client
|
|
45
|
+
*/
|
|
46
|
+
uploadMLSPublicKeys(publicKey: Uint8Array, clientId: string): Promise<void>;
|
|
47
|
+
uploadMLSKeyPackages(keypackages: Uint8Array[], clientId: string): Promise<void>;
|
|
40
48
|
}
|
|
@@ -21,6 +21,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
21
21
|
exports.ClientService = void 0;
|
|
22
22
|
const client_1 = require("@wireapp/api-client/src/client/");
|
|
23
23
|
const _1 = require("./");
|
|
24
|
+
const bazinga64_1 = require("bazinga64");
|
|
24
25
|
class ClientService {
|
|
25
26
|
constructor(apiClient, storeEngine, cryptographyService) {
|
|
26
27
|
this.apiClient = apiClient;
|
|
@@ -96,9 +97,22 @@ class ClientService {
|
|
|
96
97
|
};
|
|
97
98
|
const client = await this.backend.postClient(newClient);
|
|
98
99
|
await this.createLocalClient(client, this.apiClient.context.domain);
|
|
99
|
-
await this.cryptographyService.initCryptobox();
|
|
100
100
|
return client;
|
|
101
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Will make the given client mls capable (generate and upload key packages)
|
|
104
|
+
*
|
|
105
|
+
* @param mlsClient Intance of the coreCrypto that represents the mls client
|
|
106
|
+
* @param clientId The id of the client
|
|
107
|
+
*/
|
|
108
|
+
async uploadMLSPublicKeys(publicKey, clientId) {
|
|
109
|
+
return this.backend.putClient(clientId, {
|
|
110
|
+
mls_public_keys: { ed25519: btoa(bazinga64_1.Converter.arrayBufferViewToBaselineString(publicKey)) },
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
async uploadMLSKeyPackages(keypackages, clientId) {
|
|
114
|
+
return this.backend.uploadMLSKeyPackages(clientId, keypackages.map(keypackage => btoa(bazinga64_1.Converter.arrayBufferViewToBaselineString(keypackage))));
|
|
115
|
+
}
|
|
102
116
|
}
|
|
103
117
|
exports.ClientService = ClientService;
|
|
104
118
|
//# sourceMappingURL=ClientService.js.map
|