@wireapp/core 42.22.1 → 42.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/Account.d.ts CHANGED
@@ -72,6 +72,8 @@ export declare class Account extends TypedEventEmitter<Events> {
72
72
  private readonly nbPrekeys;
73
73
  private readonly cryptoProtocolConfig?;
74
74
  private readonly isMlsEnabled;
75
+ /** this is the client the consumer is currently using. Will be set as soon as `initClient` is called and will be rest upon logout */
76
+ private currentClient?;
75
77
  private storeEngine?;
76
78
  private db?;
77
79
  private coreCallbacks?;
@@ -115,7 +117,7 @@ export declare class Account extends TypedEventEmitter<Events> {
115
117
  useAPIVersion(min: number, max: number, allowDev?: boolean): Promise<BackendFeatures>;
116
118
  private persistCookie;
117
119
  private getE2EIStatus;
118
- enrollE2EI(displayName: string, handle: string, discoveryUrl: string, client: RegisteredClient, oAuthIdToken?: string): Promise<AcmeChallenge | boolean>;
120
+ enrollE2EI(displayName: string, handle: string, discoveryUrl: string, oAuthIdToken?: string): Promise<AcmeChallenge | boolean>;
119
121
  get clientId(): string;
120
122
  get userId(): string;
121
123
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Account.d.ts","sourceRoot":"","sources":["../src/Account.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,YAAY,EAGZ,OAAO,EACP,MAAM,EAEN,SAAS,EACV,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAuB,UAAU,EAAE,gBAAgB,EAAC,MAAM,iCAAiC,CAAC;AAEnG,OAAO,KAAK,MAAM,MAAM,+BAA+B,CAAC;AASxD,OAAO,EAAC,SAAS,EAAE,eAAe,EAAC,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAC,UAAU,EAAe,MAAM,uBAAuB,CAAC;AAE/D,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAC,gBAAgB,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AC,KAAK,IAAI,CAAC;QAEtF;;WAEG;QACH,wBAAwB,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;QAE5D;;;;;;WAMG;QACH,qBAAqB,CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAC;QAEzD;;WAEG;QACH,MAAM,CAAC,EAAE,OAAO,CAAC;KACb,GAAG,MAAM,IAAI;IA2FnB,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,kBAAkB;YAIZ,UAAU;IAsBxB,OAAO,CAAC,yBAAyB,CAS/B;CACH"}
package/lib/Account.js CHANGED
@@ -162,10 +162,13 @@ class Account extends commons_1.TypedEventEmitter {
162
162
  isFeatureEnabled: ((_a = features[team_1.FEATURE_KEY.MLSE2EID]) === null || _a === void 0 ? void 0 : _a.status) === team_1.FeatureStatus.ENABLED,
163
163
  };
164
164
  }
165
- async enrollE2EI(displayName, handle, discoveryUrl, client, oAuthIdToken) {
165
+ async enrollE2EI(displayName, handle, discoveryUrl, oAuthIdToken) {
166
166
  var _a, _b, _c;
167
167
  const context = this.apiClient.context;
168
168
  const domain = (_a = context === null || context === void 0 ? void 0 : context.domain) !== null && _a !== void 0 ? _a : '';
169
+ if (!this.currentClient) {
170
+ throw new Error('Client has not been initialized - please login first');
171
+ }
169
172
  if (!((_b = this.service) === null || _b === void 0 ? void 0 : _b.mls) || !((_c = this.service) === null || _c === void 0 ? void 0 : _c.e2eIdentity)) {
170
173
  this.logger.info('MLS not initialized, unable to enroll E2EI');
171
174
  return false;
@@ -176,7 +179,7 @@ class Account extends commons_1.TypedEventEmitter {
176
179
  domain,
177
180
  id: this.userId,
178
181
  };
179
- return this.service.mls.enrollE2EI(discoveryUrl, this.service.e2eIdentity, user, client, this.nbPrekeys, oAuthIdToken);
182
+ return this.service.mls.enrollE2EI(discoveryUrl, this.service.e2eIdentity, user, this.currentClient, this.nbPrekeys, oAuthIdToken);
180
183
  }
181
184
  get clientId() {
182
185
  return this.apiClient.validatedClientId;
@@ -275,6 +278,7 @@ class Account extends commons_1.TypedEventEmitter {
275
278
  // leave stale conference subconversations (e.g after a crash)
276
279
  await this.service.subconversation.leaveStaleConferenceSubconversations();
277
280
  }
281
+ this.currentClient = validClient;
278
282
  return validClient;
279
283
  }
280
284
  async buildCryptoClient(context, storeEngine) {
@@ -321,7 +325,7 @@ class Account extends commons_1.TypedEventEmitter {
321
325
  let mlsService;
322
326
  let e2eIdentityService;
323
327
  if (clientType === CryptoClient_1.CryptoClientType.CORE_CRYPTO && (await this.isMlsEnabled())) {
324
- e2eIdentityService = await E2EIdentityService_1.E2EIServiceExternal.getInstance(cryptoClient.getNativeClient());
328
+ e2eIdentityService = new E2EIdentityService_1.E2EIServiceExternal(cryptoClient.getNativeClient());
325
329
  mlsService = new mls_1.MLSService(this.apiClient, cryptoClient.getNativeClient(), this.db, this.recurringTaskScheduler, Object.assign({}, (_a = this.cryptoProtocolConfig) === null || _a === void 0 ? void 0 : _a.mls));
326
330
  }
327
331
  const proteusService = new proteus_1.ProteusService(this.apiClient, cryptoClient, {
@@ -359,6 +363,7 @@ class Account extends commons_1.TypedEventEmitter {
359
363
  };
360
364
  }
361
365
  resetContext() {
366
+ this.currentClient = undefined;
362
367
  delete this.apiClient.context;
363
368
  delete this.service;
364
369
  }
@@ -393,8 +398,8 @@ class Account extends commons_1.TypedEventEmitter {
393
398
  * @returns close a function that will disconnect from the websocket
394
399
  */
395
400
  listen({ onEvent = () => { }, onConnectionStateChanged = () => { }, onNotificationStreamProgress = () => { }, onMissedNotifications = () => { }, dryRun = false, } = {}) {
396
- if (!this.apiClient.context) {
397
- throw new Error('Context is not set - please login first');
401
+ if (!this.currentClient) {
402
+ throw new Error('Client has not been initialized - please login first');
398
403
  }
399
404
  const handleEvent = async (payload, source) => {
400
405
  const { event } = payload;
@@ -162,6 +162,14 @@ describe('Account', () => {
162
162
  afterEach(() => {
163
163
  (0, nock_1.cleanAll)();
164
164
  });
165
+ const currentClient = {
166
+ id: CLIENT_ID,
167
+ cookie: '',
168
+ time: '',
169
+ type: client_1.ClientType.TEMPORARY,
170
+ class: client_1.ClientClassification.DESKTOP,
171
+ mls_public_keys: {},
172
+ };
165
173
  describe('"init"', () => {
166
174
  it('initializes the Protocol buffers', async () => {
167
175
  const account = new Account_1.Account();
@@ -218,6 +226,7 @@ describe('Account', () => {
218
226
  email: 'hello@example.com',
219
227
  password: 'my-secret',
220
228
  });
229
+ account['currentClient'] = currentClient;
221
230
  jest.spyOn(apiClient, 'connect').mockImplementation();
222
231
  jest.spyOn(account.service.notification, 'handleEvent').mockReturnValue({
223
232
  status: 'handled',
@@ -265,11 +274,13 @@ describe('Account', () => {
265
274
  });
266
275
  beforeEach(async () => {
267
276
  dependencies = await createAccount();
268
- await dependencies.account.login({
277
+ const { account } = dependencies;
278
+ await account.login({
269
279
  clientType: client_1.ClientType.TEMPORARY,
270
280
  email: 'hello@example.com',
271
281
  password: 'my-secret',
272
282
  });
283
+ account['currentClient'] = currentClient;
273
284
  jest
274
285
  .spyOn(dependencies.account.service.notification, 'handleNotification')
275
286
  .mockImplementation(notif => notif.payload);
@@ -1,18 +1,19 @@
1
1
  import { QualifiedId } from '@wireapp/api-client/lib/user';
2
2
  import { Ciphersuite, CoreCrypto, E2eiConversationState, WireIdentity } from '@wireapp/core-crypto';
3
+ export type DeviceIdentity = Omit<WireIdentity, 'free'> & {
4
+ deviceId: string;
5
+ };
3
6
  export declare class E2EIServiceExternal {
4
- private static instance;
7
+ private coreCryptoClient;
5
8
  private readonly logger;
6
- private readonly coreCryptoClient;
7
- private constructor();
8
- static getInstance(coreCryptoClient: CoreCrypto): Promise<E2EIServiceExternal>;
9
+ constructor(coreCryptoClient: CoreCrypto);
9
10
  hasActiveCertificate(): boolean;
10
11
  getCertificateData(): string | undefined;
11
12
  isEnrollmentInProgress(): boolean;
12
13
  clearAllProgress(): void;
13
14
  getConversationState(conversationId: Uint8Array): Promise<E2eiConversationState>;
14
15
  isE2EIEnabled(ciphersuite: Ciphersuite): Promise<boolean>;
15
- getUsersIdentities(groupId: string, userIds: QualifiedId[]): Promise<Map<string, WireIdentity[]>>;
16
- getUserDeviceEntities(groupId: string, userClientsMap: Record<string, QualifiedId>): Promise<WireIdentity[]>;
16
+ getUsersIdentities(groupId: string, userIds: QualifiedId[]): Promise<Map<string, DeviceIdentity[]>>;
17
+ getDevicesIdentities(groupId: string, userClientsMap: Record<string, QualifiedId>): Promise<DeviceIdentity[]>;
17
18
  }
18
19
  //# sourceMappingURL=E2EIServiceExternal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"E2EIServiceExternal.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAIzD,OAAO,EAAC,WAAW,EAAE,UAAU,EAAE,qBAAqB,EAAE,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAMlG,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAsB;IAC7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuD;IAC9E,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAa;IAE9C,OAAO;WAIa,WAAW,CAAC,gBAAgB,EAAE,UAAU,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAWpF,oBAAoB,IAAI,OAAO;IAK/B,kBAAkB,IAAI,MAAM,GAAG,SAAS;IAUxC,sBAAsB,IAAI,OAAO;IAIjC,gBAAgB,IAAI,IAAI;IAIxB,oBAAoB,CAAC,cAAc,EAAE,UAAU,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAIhF,aAAa,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IAInD,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE;IAQ1D,qBAAqB,CAChC,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAC1C,OAAO,CAAC,YAAY,EAAE,CAAC;CAM3B"}
1
+ {"version":3,"file":"E2EIServiceExternal.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAIzD,OAAO,EAAC,WAAW,EAAE,UAAU,EAAE,qBAAqB,EAAE,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAOlG,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,CAAC;AAG7E,qBAAa,mBAAmB;IAGX,OAAO,CAAC,gBAAgB;IAF3C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuD;gBAEnD,gBAAgB,EAAE,UAAU;IAGhD,oBAAoB,IAAI,OAAO;IAK/B,kBAAkB,IAAI,MAAM,GAAG,SAAS;IAUxC,sBAAsB,IAAI,OAAO;IAIjC,gBAAgB,IAAI,IAAI;IAIxB,oBAAoB,CAAC,cAAc,EAAE,UAAU,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAIhF,aAAa,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IAInD,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC;IA4BnG,oBAAoB,CAC/B,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAC1C,OAAO,CAAC,cAAc,EAAE,CAAC;CAc7B"}
@@ -26,20 +26,12 @@ const bazinga64_1 = require("bazinga64");
26
26
  const logdown_1 = __importDefault(require("logdown"));
27
27
  const Helper_1 = require("./Helper");
28
28
  const E2EIStorage_1 = require("./Storage/E2EIStorage");
29
+ const fullyQualifiedClientIdUtils_1 = require("../../../util/fullyQualifiedClientIdUtils");
29
30
  // This export is meant to be accessible from the outside (e.g the Webapp / UI)
30
31
  class E2EIServiceExternal {
31
- constructor(coreCryptClient) {
32
+ constructor(coreCryptoClient) {
33
+ this.coreCryptoClient = coreCryptoClient;
32
34
  this.logger = (0, logdown_1.default)('@wireapp/core/E2EIdentityServiceExternal');
33
- this.coreCryptoClient = coreCryptClient;
34
- }
35
- static async getInstance(coreCryptoClient) {
36
- if (!E2EIServiceExternal.instance) {
37
- if (!coreCryptoClient) {
38
- throw new Error('E2EIServiceExternal is not initialized. Please call getInstance with params.');
39
- }
40
- E2EIServiceExternal.instance = new E2EIServiceExternal(coreCryptoClient);
41
- }
42
- return E2EIServiceExternal.instance;
43
35
  }
44
36
  // Checks if there is a certificate stored in the local storage
45
37
  hasActiveCertificate() {
@@ -69,12 +61,24 @@ class E2EIServiceExternal {
69
61
  return this.coreCryptoClient.e2eiIsEnabled(ciphersuite);
70
62
  }
71
63
  async getUsersIdentities(groupId, userIds) {
72
- return this.coreCryptoClient.getUserIdentities(bazinga64_1.Decoder.fromBase64(groupId).asBytes, userIds.map(userId => (0, Helper_1.uuidTobase64url)(userId.id).asString));
64
+ // We keep track of the ID we give to CoreCrypto in order to map it back to regular userIds afterwards
65
+ const hashedIdMap = new Map(userIds.map(userId => [(0, Helper_1.uuidTobase64url)(userId.id).asString, userId]));
66
+ const userIdentities = await this.coreCryptoClient.getUserIdentities(bazinga64_1.Decoder.fromBase64(groupId).asBytes, Array.from(hashedIdMap.keys()));
67
+ const mappedUserIdentities = new Map();
68
+ for (const [base64Id, identities] of userIdentities) {
69
+ // remapping coreCrypto user ids to regular userIds
70
+ const userId = hashedIdMap.get(base64Id);
71
+ if (userId) {
72
+ mappedUserIdentities.set(userId.id, identities.map(identity => (Object.assign(Object.assign({}, identity), { deviceId: (0, fullyQualifiedClientIdUtils_1.parseFullQualifiedClientId)(identity.client_id).client }))));
73
+ }
74
+ }
75
+ return mappedUserIdentities;
73
76
  }
74
77
  // Returns devices e2ei certificates
75
- async getUserDeviceEntities(groupId, userClientsMap) {
78
+ async getDevicesIdentities(groupId, userClientsMap) {
76
79
  const clientIds = Object.entries(userClientsMap).map(([clientId, userId]) => (0, Helper_1.getE2EIClientId)(clientId, userId.id, userId.domain).asBytes);
77
- return this.coreCryptoClient.getDeviceIdentities(bazinga64_1.Decoder.fromBase64(groupId).asBytes, clientIds);
80
+ const deviceIdentities = await this.coreCryptoClient.getDeviceIdentities(bazinga64_1.Decoder.fromBase64(groupId).asBytes, clientIds);
81
+ return deviceIdentities.map(identity => (Object.assign(Object.assign({}, identity), { deviceId: (0, fullyQualifiedClientIdUtils_1.parseFullQualifiedClientId)(identity.client_id).client })));
78
82
  }
79
83
  }
80
84
  exports.E2EIServiceExternal = E2EIServiceExternal;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=E2EIServiceExternal.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"E2EIServiceExternal.test.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ /*
3
+ * Wire
4
+ * Copyright (C) 2023 Wire Swiss GmbH
5
+ *
6
+ * This program is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program. If not, see http://www.gnu.org/licenses/.
18
+ *
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ const E2EIServiceExternal_1 = require("./E2EIServiceExternal");
22
+ function buildE2EIService() {
23
+ const coreCrypto = {
24
+ getUserIdentities: jest.fn(),
25
+ };
26
+ return [new E2EIServiceExternal_1.E2EIServiceExternal(coreCrypto), { coreCrypto }];
27
+ }
28
+ function generateCoreCryptoIdentity({ status = 'Valid', deviceId = 'aaaaa' } = {}) {
29
+ return {
30
+ client_id: `SKHDsEsOS82TrWTHNEsVNA:${deviceId}@elna.wire.link`,
31
+ handle: 'adrian_wire2@elna.wire.link',
32
+ display_name: 'Adrian Weiss 2',
33
+ domain: 'elna.wire.link',
34
+ certificate: '-----BEGIN CERTIFICATE-----\nMIICRTCCAeqgAwIBAgIQcpcbKbgHLM5qoB7xgxm6BTAKBggqhkjOPQQDAjAuMSww\nKgYDVQQDEyNlbG5hLndpcmUubGluayBFMkVJIEludGVybWVkaWF0ZSBDQTAeFw0y\nMzExMjIxMTIwMDVaFw0yMzExMjQxMTIwMDVaMDIxFzAVBgNVBAoTDmVsbmEud2ly\nZS5saW5rMRcwFQYDVQQDEw5BZHJpYW4gV2Vpc3MgMjAqMAUGAytlcAMhAMwP5B9X\nwanLL7JUmHEc1SJYAvHUvMnL1MS/D4CK3JaMo4IBEzCCAQ8wDgYDVR0PAQH/BAQD\nAgeAMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAdBgNVHQ4EFgQUrIPC\nem20zAl1ybZqXm2LkvD2U1swHwYDVR0jBBgwFoAU5bQTjX1Ps09suTYe4tzXUKgl\nN9YwdwYDVR0RBHAwboYpaW06d2lyZWFwcD0lNDBhZHJpYW5fd2lyZTJAZWxuYS53\naXJlLmxpbmuGQWltOndpcmVhcHA9U0tIRHNFc09TODJUcldUSE5Fc1ZOQS9lYjll\nMDM4NjE4MzllOWRhQGVsbmEud2lyZS5saW5rMCUGDCsGAQQBgqRkxihAAQQVMBMC\nAQYEDGRlZmF1bHR0ZWFtcwQAMAoGCCqGSM49BAMCA0kAMEYCIQCQQHVAd6wjp2A+\nVvKIXu4oVlCMZkAUATU5bXY4njvapwIhAO8rION7Mz5rSjixJsdEL8E+HHsNvCax\ndjrSL0FL9SM6\n-----END CERTIFICATE-----\n',
35
+ status,
36
+ thumbprint: 'mNyAo88vAF5s7v0UWBNxlQKxP3dfT91A-4PbuzEA5uQ',
37
+ };
38
+ }
39
+ const groupId = 'AAEAAhJrE+8TbFFUqiagedTYDUMAZWxuYS53aXJlLmxpbms=';
40
+ describe('E2EIServiceExternal', () => {
41
+ describe('getUsersIdentities', () => {
42
+ it('returns the user identities', async () => {
43
+ const [service, { coreCrypto }] = buildE2EIService();
44
+ const user1 = { domain: 'elna.wire.link', id: '48a1c3b0-4b0e-4bcd-93ad-64c7344b1534' };
45
+ const user2 = { domain: 'elna.wire.link', id: 'b7d287e4-7bbd-40e0-a550-6b18dcaf5f31' };
46
+ const userIds = [user1, user2];
47
+ coreCrypto.getUserIdentities.mockResolvedValue(new Map([
48
+ ['SKHDsEsOS82TrWTHNEsVNA', [generateCoreCryptoIdentity(), generateCoreCryptoIdentity()]],
49
+ ['t9KH5Hu9QOClUGsY3K9fMQ', [generateCoreCryptoIdentity()]],
50
+ ]));
51
+ const userIdentities = await service.getUsersIdentities(groupId, userIds);
52
+ expect(userIdentities.get(user1.id)).toBeDefined();
53
+ expect(userIdentities.get(user2.id)).toBeDefined();
54
+ });
55
+ });
56
+ });
@@ -53,7 +53,7 @@ const optionalToUint8Array = (array) => {
53
53
  };
54
54
  exports.optionalToUint8Array = optionalToUint8Array;
55
55
  const defaultConfig = {
56
- keyingMaterialUpdateThreshold: 1000 * 60 * 60 * 24 * 30,
56
+ keyingMaterialUpdateThreshold: 1000 * 60 * 60 * 24 * 30, //30 days
57
57
  nbKeyPackages: 100,
58
58
  defaultCiphersuite: core_crypto_1.Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519,
59
59
  defaultCredentialType: core_crypto_1.CredentialType.Basic,
@@ -21,8 +21,9 @@ var __await = (this && this.__await) || function (v) { return this instanceof __
21
21
  var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
22
22
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
23
23
  var g = generator.apply(thisArg, _arguments || []), i, q = [];
24
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
25
- function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
24
+ return i = {}, verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
25
+ function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
26
+ function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
26
27
  function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
27
28
  function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
28
29
  function fulfill(value) { resume("next", value); }
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "./lib/cryptography/AssetCryptography/crypto.node": "./lib/cryptography/AssetCryptography/crypto.browser.js"
12
12
  },
13
13
  "dependencies": {
14
- "@wireapp/api-client": "^26.5.3",
14
+ "@wireapp/api-client": "^26.5.4",
15
15
  "@wireapp/commons": "^5.2.3",
16
16
  "@wireapp/core-crypto": "1.0.0-rc.19",
17
17
  "@wireapp/cryptobox": "12.8.0",
@@ -61,6 +61,6 @@
61
61
  "test:coverage": "jest --coverage",
62
62
  "watch": "tsc --watch"
63
63
  },
64
- "version": "42.22.1",
65
- "gitHead": "a27913ebd6661bf2bd165eb3fe7770c4f6fee546"
64
+ "version": "42.23.1",
65
+ "gitHead": "173bd1a715a4c060a50de4d0ea52320cd7d4d6da"
66
66
  }