@wireapp/core 24.4.6 → 25.1.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/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,71 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [25.1.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@25.0.0...@wireapp/core@25.1.0) (2022-05-04)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Allow complete payload to crete conversations ([#4258](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4258)) ([a6d53e2](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/a6d53e219e6ed96309ab02469b803ac461d38603))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [25.0.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@24.4.7...@wireapp/core@25.0.0) (2022-05-02)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Code Refactoring
|
|
21
|
+
|
|
22
|
+
* Cleanup storage initialization ([#4257](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4257)) ([cf952c5](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/cf952c5522ccebe2c4e97d7dbb27de447a532032))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### BREAKING CHANGES
|
|
26
|
+
|
|
27
|
+
* The way custom database are given to the `Account` has changed.
|
|
28
|
+
- The constructor signature now changes.
|
|
29
|
+
If you were doing
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
const account = new Account(apiClient, createStoreEngine);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Now you need to do
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
const account = new Account(apiClient, {createStore: createStoreEngine});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
- The `login` and `init` function do not take a storage engine parameter anymore. You now need to give a `createStore` function to the constructor in order to give a custom storage engine to the core.
|
|
42
|
+
|
|
43
|
+
BEFORE
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
const account = new Accoun(apiClient);
|
|
47
|
+
|
|
48
|
+
account.login(data, initClient, clientInfo, database);
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
AFTER
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
const account = new Accoun(apiClient, {createStore: () => database});
|
|
55
|
+
|
|
56
|
+
account.login(data, initClient, clientInfo);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
## [24.4.7](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@24.4.6...@wireapp/core@24.4.7) (2022-04-21)
|
|
64
|
+
|
|
65
|
+
**Note:** Version bump only for package @wireapp/core
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
6
71
|
## [24.4.6](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@24.4.5...@wireapp/core@24.4.6) (2022-04-20)
|
|
7
72
|
|
|
8
73
|
**Note:** Version bump only for package @wireapp/core
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@types/long": "4.0.1",
|
|
7
7
|
"@types/node": "~14",
|
|
8
|
-
"@wireapp/api-client": "
|
|
8
|
+
"@wireapp/api-client": "19.0.0",
|
|
9
9
|
"@wireapp/cryptobox": "12.8.0",
|
|
10
10
|
"bazinga64": "5.10.0",
|
|
11
11
|
"hash.js": "1.1.7",
|
|
@@ -69,6 +69,6 @@
|
|
|
69
69
|
"test:project": "yarn dist && yarn test",
|
|
70
70
|
"test:node": "nyc jasmine --config=jasmine.json"
|
|
71
71
|
},
|
|
72
|
-
"version": "
|
|
73
|
-
"gitHead": "
|
|
72
|
+
"version": "25.1.0",
|
|
73
|
+
"gitHead": "9140ae5dd579fe31eed877a4ce8d5ab4f5b493cf"
|
|
74
74
|
}
|
package/src/main/Account.d.ts
CHANGED
|
@@ -52,11 +52,11 @@ export interface Account {
|
|
|
52
52
|
on(event: PayloadBundleType.UNKNOWN, listener: (payload: any) => void): this;
|
|
53
53
|
on(event: TOPIC.ERROR, listener: (payload: CoreError) => void): this;
|
|
54
54
|
}
|
|
55
|
-
export declare type
|
|
55
|
+
export declare type CreateStoreFn = (storeName: string, context: Context) => undefined | Promise<CRUDEngine | undefined>;
|
|
56
56
|
export declare class Account extends EventEmitter {
|
|
57
57
|
private readonly apiClient;
|
|
58
58
|
private readonly logger;
|
|
59
|
-
private readonly
|
|
59
|
+
private readonly createStore;
|
|
60
60
|
private storeEngine?;
|
|
61
61
|
static readonly TOPIC: typeof TOPIC;
|
|
62
62
|
service?: {
|
|
@@ -77,16 +77,18 @@ export declare class Account extends EventEmitter {
|
|
|
77
77
|
backendFeatures: BackendFeatures;
|
|
78
78
|
/**
|
|
79
79
|
* @param apiClient The apiClient instance to use in the core (will create a new new one if undefined)
|
|
80
|
-
* @param storeEngineProvider Used to store info in the database (will create a inMemory engine if undefined)
|
|
80
|
+
* @param storeEngineProvider Used to store info in the database (will create a inMemory engine if returns undefined)
|
|
81
81
|
*/
|
|
82
|
-
constructor(apiClient?: APIClient,
|
|
82
|
+
constructor(apiClient?: APIClient, { createStore }?: {
|
|
83
|
+
createStore?: CreateStoreFn;
|
|
84
|
+
});
|
|
83
85
|
private persistCookie;
|
|
84
86
|
get clientId(): string;
|
|
85
87
|
get userId(): string;
|
|
86
88
|
register(registration: RegisterData, clientType: ClientType): Promise<Context>;
|
|
87
|
-
init(clientType: ClientType, cookie?: Cookie,
|
|
88
|
-
initServices(
|
|
89
|
-
login(loginData: LoginData, initClient?: boolean, clientInfo?: ClientInfo
|
|
89
|
+
init(clientType: ClientType, cookie?: Cookie, initClient?: boolean): Promise<Context>;
|
|
90
|
+
initServices(context: Context): Promise<void>;
|
|
91
|
+
login(loginData: LoginData, initClient?: boolean, clientInfo?: ClientInfo): Promise<Context>;
|
|
90
92
|
initClient(loginData: LoginData, clientInfo?: ClientInfo, entropyData?: Uint8Array): Promise<{
|
|
91
93
|
isNewClient: boolean;
|
|
92
94
|
localClient: RegisteredClient;
|
package/src/main/Account.js
CHANGED
|
@@ -70,9 +70,9 @@ var TOPIC;
|
|
|
70
70
|
class Account extends events_1.EventEmitter {
|
|
71
71
|
/**
|
|
72
72
|
* @param apiClient The apiClient instance to use in the core (will create a new new one if undefined)
|
|
73
|
-
* @param storeEngineProvider Used to store info in the database (will create a inMemory engine if undefined)
|
|
73
|
+
* @param storeEngineProvider Used to store info in the database (will create a inMemory engine if returns undefined)
|
|
74
74
|
*/
|
|
75
|
-
constructor(apiClient = new api_client_1.APIClient(),
|
|
75
|
+
constructor(apiClient = new api_client_1.APIClient(), { createStore = () => undefined } = {}) {
|
|
76
76
|
super();
|
|
77
77
|
this.handlePayload = async (payload) => {
|
|
78
78
|
switch (payload.type) {
|
|
@@ -90,16 +90,7 @@ class Account extends events_1.EventEmitter {
|
|
|
90
90
|
};
|
|
91
91
|
this.apiClient = apiClient;
|
|
92
92
|
this.backendFeatures = this.apiClient.backendFeatures;
|
|
93
|
-
|
|
94
|
-
this.storeEngineProvider = storeEngineProvider;
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
this.storeEngineProvider = async (storeName) => {
|
|
98
|
-
const engine = new store_engine_1.MemoryEngine();
|
|
99
|
-
await engine.init(storeName);
|
|
100
|
-
return engine;
|
|
101
|
-
};
|
|
102
|
-
}
|
|
93
|
+
this.createStore = createStore;
|
|
103
94
|
apiClient.on(api_client_1.APIClient.TOPIC.COOKIE_REFRESH, async (cookie) => {
|
|
104
95
|
if (cookie && this.storeEngine) {
|
|
105
96
|
try {
|
|
@@ -127,35 +118,26 @@ class Account extends events_1.EventEmitter {
|
|
|
127
118
|
}
|
|
128
119
|
async register(registration, clientType) {
|
|
129
120
|
const context = await this.apiClient.register(registration, clientType);
|
|
130
|
-
|
|
131
|
-
await this.initServices(storeEngine);
|
|
121
|
+
await this.initServices(context);
|
|
132
122
|
return context;
|
|
133
123
|
}
|
|
134
|
-
async init(clientType, cookie,
|
|
124
|
+
async init(clientType, cookie, initClient = true) {
|
|
135
125
|
const context = await this.apiClient.init(clientType, cookie);
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
this.
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
this.storeEngine = await this.initEngine(context);
|
|
142
|
-
}
|
|
143
|
-
await this.initServices(this.storeEngine);
|
|
144
|
-
if (initializedStoreEngine) {
|
|
145
|
-
await this.initClient({
|
|
146
|
-
clientType,
|
|
147
|
-
});
|
|
126
|
+
await this.initServices(context);
|
|
127
|
+
if (initClient) {
|
|
128
|
+
await this.initClient({ clientType });
|
|
148
129
|
}
|
|
149
130
|
return context;
|
|
150
131
|
}
|
|
151
|
-
async initServices(
|
|
132
|
+
async initServices(context) {
|
|
133
|
+
this.storeEngine = await this.initEngine(context);
|
|
152
134
|
const accountService = new account_1.AccountService(this.apiClient);
|
|
153
135
|
const assetService = new conversation_1.AssetService(this.apiClient);
|
|
154
|
-
const cryptographyService = new cryptography_1.CryptographyService(this.apiClient, storeEngine, {
|
|
136
|
+
const cryptographyService = new cryptography_1.CryptographyService(this.apiClient, this.storeEngine, {
|
|
155
137
|
// We want to encrypt with fully qualified session ids, only if the backend is federated with other backends
|
|
156
138
|
useQualifiedIds: this.backendFeatures.isFederated,
|
|
157
139
|
});
|
|
158
|
-
const clientService = new client_2.ClientService(this.apiClient, storeEngine, cryptographyService);
|
|
140
|
+
const clientService = new client_2.ClientService(this.apiClient, this.storeEngine, cryptographyService);
|
|
159
141
|
const connectionService = new connection_1.ConnectionService(this.apiClient);
|
|
160
142
|
const giphyService = new giphy_1.GiphyService(this.apiClient);
|
|
161
143
|
const linkPreviewService = new linkPreview_1.LinkPreviewService(assetService);
|
|
@@ -163,7 +145,7 @@ class Account extends events_1.EventEmitter {
|
|
|
163
145
|
// We can use qualified ids to send messages as long as the backend supports federated endpoints
|
|
164
146
|
useQualifiedIds: this.backendFeatures.federationEndpoints,
|
|
165
147
|
});
|
|
166
|
-
const notificationService = new notification_1.NotificationService(this.apiClient, cryptographyService, storeEngine);
|
|
148
|
+
const notificationService = new notification_1.NotificationService(this.apiClient, cryptographyService, this.storeEngine);
|
|
167
149
|
const selfService = new self_1.SelfService(this.apiClient);
|
|
168
150
|
const teamService = new team_1.TeamService(this.apiClient);
|
|
169
151
|
const broadcastService = new broadcast_1.BroadcastService(this.apiClient, cryptographyService);
|
|
@@ -184,18 +166,11 @@ class Account extends events_1.EventEmitter {
|
|
|
184
166
|
user: userService,
|
|
185
167
|
};
|
|
186
168
|
}
|
|
187
|
-
async login(loginData, initClient = true, clientInfo
|
|
169
|
+
async login(loginData, initClient = true, clientInfo) {
|
|
188
170
|
this.resetContext();
|
|
189
171
|
auth_2.LoginSanitizer.removeNonPrintableCharacters(loginData);
|
|
190
172
|
const context = await this.apiClient.login(loginData);
|
|
191
|
-
|
|
192
|
-
this.storeEngine = initializedStoreEngine;
|
|
193
|
-
this.logger.log(`Initialized store with existing engine "${this.storeEngine.storeName}".`);
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
this.storeEngine = await this.initEngine(context);
|
|
197
|
-
}
|
|
198
|
-
await this.initServices(this.storeEngine);
|
|
173
|
+
await this.initServices(context);
|
|
199
174
|
if (initClient) {
|
|
200
175
|
await this.initClient(loginData, clientInfo);
|
|
201
176
|
}
|
|
@@ -291,12 +266,23 @@ class Account extends events_1.EventEmitter {
|
|
|
291
266
|
const clientType = context.clientType === client_1.ClientType.NONE ? '' : `@${context.clientType}`;
|
|
292
267
|
const dbName = `wire@${this.apiClient.config.urls.name}@${context.userId}${clientType}`;
|
|
293
268
|
this.logger.log(`Initialising store with name "${dbName}"...`);
|
|
294
|
-
|
|
269
|
+
const openDb = async () => {
|
|
270
|
+
const initializedDb = await this.createStore(dbName, context);
|
|
271
|
+
if (initializedDb) {
|
|
272
|
+
this.logger.log(`Initialized store with existing engine "${dbName}".`);
|
|
273
|
+
return initializedDb;
|
|
274
|
+
}
|
|
275
|
+
this.logger.log(`Initialized store with new memory engine "${dbName}".`);
|
|
276
|
+
const memoryEngine = new store_engine_1.MemoryEngine();
|
|
277
|
+
await memoryEngine.init(dbName);
|
|
278
|
+
return memoryEngine;
|
|
279
|
+
};
|
|
280
|
+
const storeEngine = await openDb();
|
|
295
281
|
const cookie = auth_1.CookieStore.getCookie();
|
|
296
282
|
if (cookie) {
|
|
297
|
-
await this.persistCookie(
|
|
283
|
+
await this.persistCookie(storeEngine, cookie);
|
|
298
284
|
}
|
|
299
|
-
return
|
|
285
|
+
return storeEngine;
|
|
300
286
|
}
|
|
301
287
|
}
|
|
302
288
|
exports.Account = Account;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { APIClient } from '@wireapp/api-client';
|
|
2
|
-
import { MessageSendingStatus, Conversation, DefaultConversationRoleName, MutedStatus, QualifiedUserClients, UserClients, ClientMismatch } from '@wireapp/api-client/src/conversation';
|
|
2
|
+
import { MessageSendingStatus, Conversation, DefaultConversationRoleName, MutedStatus, NewConversation, QualifiedUserClients, UserClients, ClientMismatch } from '@wireapp/api-client/src/conversation';
|
|
3
3
|
import type { ConversationMemberLeaveEvent } from '@wireapp/api-client/src/event';
|
|
4
4
|
import type { QualifiedId, UserPreKeyBundleMap } from '@wireapp/api-client/src/user';
|
|
5
5
|
import { GenericMessage } from '@wireapp/protocol-messaging';
|
|
@@ -149,7 +149,24 @@ export declare class ConversationService {
|
|
|
149
149
|
deleteMessageEveryone(conversationId: string, messageIdToDelete: string, userIds?: string[] | QualifiedId[] | UserClients | QualifiedUserClients, sendAsProtobuf?: boolean, conversationDomain?: string, callbacks?: MessageSendingCallbacks): Promise<DeleteMessage>;
|
|
150
150
|
leaveConversation(conversationId: string): Promise<ConversationMemberLeaveEvent>;
|
|
151
151
|
leaveConversations(conversationIds?: string[]): Promise<ConversationMemberLeaveEvent[]>;
|
|
152
|
-
|
|
152
|
+
/**
|
|
153
|
+
* Create a group conversation.
|
|
154
|
+
* @param {string} name
|
|
155
|
+
* @param {string|string[]} otherUserIds
|
|
156
|
+
* @deprecated
|
|
157
|
+
* @returns Promise
|
|
158
|
+
*/
|
|
159
|
+
createConversation(name: string, otherUserIds: string | string[]): Promise<Conversation>;
|
|
160
|
+
/**
|
|
161
|
+
* Create a group conversation.
|
|
162
|
+
*
|
|
163
|
+
* @note Do not include yourself as the requestor
|
|
164
|
+
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/conversations/createGroupConversation
|
|
165
|
+
*
|
|
166
|
+
* @param conversationData Payload object for group creation
|
|
167
|
+
* @returns Resolves when the conversation was created
|
|
168
|
+
*/
|
|
169
|
+
createConversation(conversationData: NewConversation): Promise<Conversation>;
|
|
153
170
|
getConversations(conversationId: string): Promise<Conversation>;
|
|
154
171
|
getConversations(conversationIds?: string[]): Promise<Conversation[]>;
|
|
155
172
|
getAsset({ assetId, assetToken, otrKey, sha256 }: RemoteData): Promise<Uint8Array>;
|
|
@@ -613,14 +613,20 @@ class ConversationService {
|
|
|
613
613
|
}
|
|
614
614
|
return Promise.all(conversationIds.map(conversationId => this.leaveConversation(conversationId)));
|
|
615
615
|
}
|
|
616
|
-
createConversation(
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
616
|
+
createConversation(conversationData, otherUserIds) {
|
|
617
|
+
let payload;
|
|
618
|
+
if (typeof conversationData === 'string') {
|
|
619
|
+
const ids = typeof otherUserIds === 'string' ? [otherUserIds] : otherUserIds;
|
|
620
|
+
payload = {
|
|
621
|
+
name: conversationData,
|
|
622
|
+
receipt_mode: null,
|
|
623
|
+
users: ids !== null && ids !== void 0 ? ids : [],
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
else {
|
|
627
|
+
payload = conversationData;
|
|
628
|
+
}
|
|
629
|
+
return this.apiClient.api.conversation.postConversation(payload);
|
|
624
630
|
}
|
|
625
631
|
async getConversations(conversationIds) {
|
|
626
632
|
if (!conversationIds || !conversationIds.length) {
|