@wireapp/core 43.7.1 → 43.8.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.
Files changed (38) hide show
  1. package/lib/Account.d.ts +12 -3
  2. package/lib/Account.d.ts.map +1 -1
  3. package/lib/Account.js +3 -3
  4. package/lib/messagingProtocols/mls/E2EIdentityService/Connection/AcmeServer/AcmeService.d.ts +73 -104
  5. package/lib/messagingProtocols/mls/E2EIdentityService/Connection/AcmeServer/AcmeService.d.ts.map +1 -1
  6. package/lib/messagingProtocols/mls/E2EIdentityService/Connection/AcmeServer/AcmeService.js +13 -31
  7. package/lib/messagingProtocols/mls/E2EIdentityService/Connection/AcmeServer/AcmeService.types.d.ts +2 -3
  8. package/lib/messagingProtocols/mls/E2EIdentityService/Connection/AcmeServer/AcmeService.types.d.ts.map +1 -1
  9. package/lib/messagingProtocols/mls/E2EIdentityService/Connection/AcmeServer/schema.d.ts +3 -0
  10. package/lib/messagingProtocols/mls/E2EIdentityService/Connection/AcmeServer/schema.d.ts.map +1 -1
  11. package/lib/messagingProtocols/mls/E2EIdentityService/Connection/AcmeServer/schema.js +1 -0
  12. package/lib/messagingProtocols/mls/E2EIdentityService/E2EIService.types.d.ts +3 -9
  13. package/lib/messagingProtocols/mls/E2EIdentityService/E2EIService.types.d.ts.map +1 -1
  14. package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.d.ts +12 -7
  15. package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.d.ts.map +1 -1
  16. package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.js +57 -119
  17. package/lib/messagingProtocols/mls/E2EIdentityService/Steps/Authorization.d.ts +4 -7
  18. package/lib/messagingProtocols/mls/E2EIdentityService/Steps/Authorization.d.ts.map +1 -1
  19. package/lib/messagingProtocols/mls/E2EIdentityService/Steps/Authorization.js +36 -27
  20. package/lib/messagingProtocols/mls/E2EIdentityService/Steps/DpopChallenge/DpopChallenge.d.ts +7 -10
  21. package/lib/messagingProtocols/mls/E2EIdentityService/Steps/DpopChallenge/DpopChallenge.d.ts.map +1 -1
  22. package/lib/messagingProtocols/mls/E2EIdentityService/Steps/DpopChallenge/DpopChallenge.js +3 -3
  23. package/lib/messagingProtocols/mls/E2EIdentityService/Steps/DpopChallenge/DpopChallenge.types.d.ts +2 -2
  24. package/lib/messagingProtocols/mls/E2EIdentityService/Steps/DpopChallenge/DpopChallenge.types.d.ts.map +1 -1
  25. package/lib/messagingProtocols/mls/E2EIdentityService/Steps/OidcChallenge.d.ts +13 -17
  26. package/lib/messagingProtocols/mls/E2EIdentityService/Steps/OidcChallenge.d.ts.map +1 -1
  27. package/lib/messagingProtocols/mls/E2EIdentityService/Steps/OidcChallenge.js +3 -3
  28. package/lib/messagingProtocols/mls/E2EIdentityService/Steps/Order.d.ts +4 -4
  29. package/lib/messagingProtocols/mls/E2EIdentityService/Steps/Order.d.ts.map +1 -1
  30. package/lib/messagingProtocols/mls/E2EIdentityService/Steps/Order.js +9 -10
  31. package/lib/messagingProtocols/mls/E2EIdentityService/Storage/E2EIStorage.js +2 -2
  32. package/lib/messagingProtocols/mls/E2EIdentityService/Storage/E2EIStorage.schema.d.ts +25 -25
  33. package/lib/messagingProtocols/mls/E2EIdentityService/Storage/E2EIStorage.schema.d.ts.map +1 -1
  34. package/lib/messagingProtocols/mls/E2EIdentityService/Storage/E2EIStorage.schema.js +3 -3
  35. package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts +11 -2
  36. package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts.map +1 -1
  37. package/lib/messagingProtocols/mls/MLSService/MLSService.js +36 -40
  38. package/package.json +5 -5
@@ -66,27 +66,15 @@ class E2EIServiceInternal {
66
66
  async startCertificateProcess(hasActiveCertificate) {
67
67
  // Step 0: Check if we have a handle in local storage
68
68
  // If we don't have a handle, we need to start a new OAuth flow
69
- try {
70
- // Initialize the identity
71
- await this.initIdentity(hasActiveCertificate);
72
- return this.startNewOAuthFlow();
73
- }
74
- catch (error) {
75
- return this.exitWithError('Error while trying to start OAuth flow with error:', error);
76
- }
69
+ await this.initIdentity(hasActiveCertificate);
70
+ return this.startNewOAuthFlow();
77
71
  }
78
72
  async continueCertificateProcess(oAuthIdToken) {
79
73
  // If we don't have a handle, we need to start a new OAuth flow
80
74
  if (this.e2eServiceExternal.isEnrollmentInProgress()) {
81
- try {
82
- return this.continueOAuthFlow(oAuthIdToken);
83
- }
84
- catch (error) {
85
- return this.exitWithError('Error while trying to continue OAuth flow with error:', error);
86
- }
75
+ return this.continueOAuthFlow(oAuthIdToken);
87
76
  }
88
- this.logger.error('Error while trying to continue OAuth flow. No handle found in local storage');
89
- return undefined;
77
+ throw new Error('Error while trying to continue OAuth flow. No enrollment in progress found');
90
78
  }
91
79
  // ############ Internal Functions ############
92
80
  async initIdentity(hasActiveCertificate) {
@@ -95,63 +83,35 @@ class E2EIServiceInternal {
95
83
  const expiryDays = 90;
96
84
  const ciphersuite = E2EIService_types_1.Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519;
97
85
  if (hasActiveCertificate) {
98
- try {
99
- this.identity = await this.coreCryptoClient.e2eiNewRotateEnrollment(expiryDays, ciphersuite, user.displayName, user.handle);
100
- }
101
- catch (error) {
102
- this.logger.error('Error while trying to initIdentity e2eiNewRotateEnrollment', error);
103
- throw error;
104
- }
86
+ this.identity = await this.coreCryptoClient.e2eiNewRotateEnrollment(expiryDays, ciphersuite, user.displayName, user.handle, user.teamId);
105
87
  }
106
88
  else {
107
- this.identity = await this.coreCryptoClient.e2eiNewActivationEnrollment(user.displayName, user.handle, expiryDays, ciphersuite);
89
+ this.identity = await this.coreCryptoClient.e2eiNewActivationEnrollment(user.displayName, user.handle, expiryDays, ciphersuite, user.teamId);
108
90
  }
109
91
  }
110
- exitWithError(message, error) {
111
- this.logger.error(message, error);
112
- return undefined;
113
- }
114
92
  async init(params) {
115
- try {
116
- const { user, clientId, discoveryUrl } = params;
117
- if (!user || !clientId) {
118
- this.logger.error('user and clientId are required to initialize E2eIdentityService');
119
- throw new Error();
120
- }
121
- this.acmeService = new AcmeServer_1.AcmeService(discoveryUrl);
122
- this.isInitialized = true;
123
- }
124
- catch (error) {
125
- this.logger.error('Error while trying to initialize E2eIdentityService', error);
126
- throw error;
93
+ const { user, clientId, discoveryUrl } = params;
94
+ if (!user || !clientId) {
95
+ this.logger.error('user and clientId are required to initialize E2eIdentityService');
96
+ throw new Error();
127
97
  }
98
+ this.acmeService = new AcmeServer_1.AcmeService(discoveryUrl);
99
+ this.isInitialized = true;
128
100
  }
129
101
  async getDirectory(identity, connection) {
130
- try {
131
- const directory = await connection.getDirectory();
132
- if (directory) {
133
- const parsedDirectory = identity.directoryResponse(directory);
134
- return parsedDirectory;
135
- }
136
- }
137
- catch (error) {
138
- this.logger.error('Error while trying to receive a directory', error);
139
- throw error;
102
+ const directory = await connection.getDirectory();
103
+ if (directory) {
104
+ const parsedDirectory = identity.directoryResponse(directory);
105
+ return parsedDirectory;
140
106
  }
141
107
  return undefined;
142
108
  }
143
109
  async getInitialNonce(directory, connection) {
144
- try {
145
- const nonce = await connection.getInitialNonce(directory.newNonce);
146
- if (nonce) {
147
- return nonce;
148
- }
110
+ const nonce = await connection.getInitialNonce(directory.newNonce);
111
+ if (!nonce) {
149
112
  throw new Error('No initial-nonce received');
150
113
  }
151
- catch (error) {
152
- this.logger.error('Error while trying to receive a nonce', error);
153
- throw error;
154
- }
114
+ return nonce;
155
115
  }
156
116
  /**
157
117
  * Start of the ACME enrollment flow
@@ -159,7 +119,7 @@ class E2EIServiceInternal {
159
119
  *
160
120
  * @returns authData
161
121
  */
162
- async getAndStoreInitialEnrollmentData() {
122
+ async getEnrollmentChallenges() {
163
123
  if (!this.isInitialized || !this.identity || !this.acmeService) {
164
124
  throw new Error('Error while trying to start OAuth flow. E2eIdentityService is not fully initialized');
165
125
  }
@@ -173,31 +133,32 @@ class E2EIServiceInternal {
173
133
  if (!nonce) {
174
134
  throw new Error('Error while trying to start OAuth flow. No nonce received');
175
135
  }
136
+ const { acmeService, identity } = this;
176
137
  // Step 2: Create a new account
177
138
  const newAccountNonce = await (0, Account_1.createNewAccount)({
178
- connection: this.acmeService,
139
+ connection: acmeService,
179
140
  directory,
180
- identity: this.identity,
141
+ identity,
181
142
  nonce,
182
143
  });
183
144
  // Step 3: Create a new order
184
145
  const orderData = await (0, Order_1.createNewOrder)({
185
146
  directory,
186
- connection: this.acmeService,
187
- identity: this.identity,
147
+ connection: acmeService,
148
+ identity,
188
149
  nonce: newAccountNonce,
189
150
  });
190
151
  // Step 4: Get authorization challenges
191
- const authData = await (0, Authorization_1.getAuthorization)({
192
- connection: this.acmeService,
193
- identity: this.identity,
194
- authzUrl: orderData.authzUrl,
152
+ const authChallenges = await (0, Authorization_1.getAuthorizationChallenges)({
153
+ connection: acmeService,
154
+ identity: identity,
155
+ authzUrls: orderData.authzUrls,
195
156
  nonce: orderData.nonce,
196
157
  });
197
158
  // Store the values in local storage for later use (e.g. in the continue flow)
198
- E2EIStorage_1.E2EIStorage.store.authData(authData);
159
+ E2EIStorage_1.E2EIStorage.store.authData(authChallenges);
199
160
  E2EIStorage_1.E2EIStorage.store.orderData({ orderUrl: orderData.orderUrl });
200
- return { authData };
161
+ return authChallenges;
201
162
  }
202
163
  /**
203
164
  * Continuation of the ACME enrollment flow
@@ -207,14 +168,10 @@ class E2EIServiceInternal {
207
168
  * @param oAuthIdToken
208
169
  * @returns RotateBundle
209
170
  */
210
- async getRotateBundleAndStoreCertificateData(oAuthIdToken) {
171
+ async getRotateBundleAndStoreCertificateData(oAuthIdToken, authData) {
211
172
  if (!this.isInitialized || !this.identity || !this.acmeService) {
212
173
  throw new Error('Error while trying to start OAuth flow. E2eIdentityService is not fully initialized');
213
174
  }
214
- const authData = E2EIStorage_1.E2EIStorage.get.authData();
215
- if (!authData.authorization.wireOidcChallenge) {
216
- throw new Error('Error while trying to continue OAuth flow. No wireOidcChallenge received');
217
- }
218
175
  // Step 7: Do OIDC client challenge
219
176
  const oidcData = await (0, OidcChallenge_1.doWireOidcChallenge)({
220
177
  coreCryptoClient: this.coreCryptoClient,
@@ -266,13 +223,7 @@ class E2EIServiceInternal {
266
223
  throw new Error('Error while trying to continue OAuth flow. No certificate received');
267
224
  }
268
225
  // Step 10: Initialize MLS with the certificate
269
- try {
270
- return await this.coreCryptoClient.e2eiRotateAll(this.identity, certificate, this.keyPackagesAmount);
271
- }
272
- catch (error) {
273
- this.logger.error('Error while e2eiRotateAll', error);
274
- throw error;
275
- }
226
+ return this.coreCryptoClient.e2eiRotateAll(this.identity, certificate, this.keyPackagesAmount);
276
227
  }
277
228
  /**
278
229
  * This function starts a new ACME enrollment flow for either a new client
@@ -280,23 +231,21 @@ class E2EIServiceInternal {
280
231
  */
281
232
  async startNewOAuthFlow() {
282
233
  if (this.e2eServiceExternal.isEnrollmentInProgress()) {
283
- return this.exitWithError('Error while trying to start OAuth flow. There is already a flow in progress');
234
+ throw new Error('Error while trying to start OAuth flow. There is already a flow in progress');
284
235
  }
285
236
  if (!this.isInitialized || !this.identity) {
286
- return this.exitWithError('Error while trying to start OAuth flow. E2eIdentityService is not fully initialized');
237
+ throw new Error('Error while trying to start OAuth flow. E2eIdentityService is not fully initialized');
287
238
  }
288
- const { authData } = await this.getAndStoreInitialEnrollmentData();
289
- // Step 6: Start E2E OAuth flow
290
- const { authorization: { wireOidcChallenge, keyauth }, } = authData;
291
- if (wireOidcChallenge && keyauth) {
292
- // stash the identity for later use
293
- const handle = await this.coreCryptoClient.e2eiEnrollmentStash(this.identity);
294
- // stash the handle in local storage
295
- E2EIStorage_1.E2EIStorage.store.handle(bazinga64_1.Encoder.toBase64(handle).asString);
296
- // we need to pass back the aquired wireOidcChallenge to the UI
297
- return { challenge: wireOidcChallenge, keyAuth: keyauth };
239
+ const { authorization: { oidcChallenge: wireOidcChallenge, keyauth }, } = await this.getEnrollmentChallenges();
240
+ if (!wireOidcChallenge || !keyauth) {
241
+ throw new Error('missing wireOidcChallenge or keyauth');
298
242
  }
299
- return undefined;
243
+ // stash the identity for later use
244
+ const handle = await this.coreCryptoClient.e2eiEnrollmentStash(this.identity);
245
+ // stash the handle in local storage
246
+ E2EIStorage_1.E2EIStorage.store.handle(bazinga64_1.Encoder.toBase64(handle).asString);
247
+ // we need to pass back the aquired wireOidcChallenge to the UI
248
+ return { challenge: wireOidcChallenge, keyAuth: keyauth };
300
249
  }
301
250
  /**
302
251
  * This function continues an ACME flow for either a new client
@@ -307,19 +256,14 @@ class E2EIServiceInternal {
307
256
  */
308
257
  async continueOAuthFlow(oAuthIdToken) {
309
258
  // If we have a handle, the user has already started the process to authenticate with the OIDC provider. We can continue the flow.
310
- try {
311
- if (!this.acmeService) {
312
- return this.exitWithError('Error while trying to continue OAuth flow. AcmeService is not initialized');
313
- }
314
- const handle = E2EIStorage_1.E2EIStorage.get.handle();
315
- this.identity = await this.coreCryptoClient.e2eiEnrollmentStashPop(bazinga64_1.Decoder.fromBase64(handle).asBytes);
316
- this.logger.log('retrieved identity from stash');
317
- return await this.getRotateBundleAndStoreCertificateData(oAuthIdToken);
318
- }
319
- catch (error) {
320
- this.logger.error('Error while trying to continue OAuth flow', error);
321
- throw error;
259
+ if (!this.acmeService) {
260
+ throw new Error('Error while trying to continue OAuth flow. AcmeService is not initialized');
322
261
  }
262
+ const handle = E2EIStorage_1.E2EIStorage.get.handle();
263
+ const authData = E2EIStorage_1.E2EIStorage.get.authData();
264
+ this.identity = await this.coreCryptoClient.e2eiEnrollmentStashPop(bazinga64_1.Decoder.fromBase64(handle).asBytes);
265
+ this.logger.log('retrieved identity from stash');
266
+ return this.getRotateBundleAndStoreCertificateData(oAuthIdToken, authData);
323
267
  }
324
268
  /**
325
269
  * This function starts a ACME refresh flow for an existing client with a valid refresh token
@@ -329,19 +273,13 @@ class E2EIServiceInternal {
329
273
  */
330
274
  async startRefreshCertficateFlow(oAuthIdToken, hasActiveCertificate) {
331
275
  // we dont have an oauth flow since we already get the oAuthIdToken from the client
332
- try {
333
- if (!this.acmeService) {
334
- return this.exitWithError('Error while trying to continue OAuth flow. AcmeService is not initialized');
335
- }
336
- // We need to initialize the identity
337
- await this.initIdentity(hasActiveCertificate);
338
- await this.getAndStoreInitialEnrollmentData();
339
- return await this.getRotateBundleAndStoreCertificateData(oAuthIdToken);
340
- }
341
- catch (error) {
342
- this.logger.error('Error while trying do the certificate refresh flow', error);
343
- throw error;
276
+ if (!this.acmeService) {
277
+ throw new Error('Error while trying to continue OAuth flow. AcmeService is not initialized');
344
278
  }
279
+ // We need to initialize the identity
280
+ await this.initIdentity(hasActiveCertificate);
281
+ const authData = await this.getEnrollmentChallenges();
282
+ return this.getRotateBundleAndStoreCertificateData(oAuthIdToken, authData);
345
283
  }
346
284
  }
347
285
  exports.E2EIServiceInternal = E2EIServiceInternal;
@@ -1,15 +1,12 @@
1
1
  import { AcmeService } from '../Connection';
2
- import { E2eiEnrollment, NewAcmeAuthz, Nonce } from '../E2EIService.types';
2
+ import { E2eiEnrollment, Nonce } from '../E2EIService.types';
3
+ import { AuthData } from '../Storage/E2EIStorage.schema';
3
4
  interface GetAuthorizationParams {
4
5
  nonce: Nonce;
5
- authzUrl: string;
6
+ authzUrls: string[];
6
7
  identity: E2eiEnrollment;
7
8
  connection: AcmeService;
8
9
  }
9
- export type GetAuthorizationReturnValue = {
10
- authorization: NewAcmeAuthz;
11
- nonce: Nonce;
12
- };
13
- export declare const getAuthorization: ({ authzUrl, nonce, identity, connection, }: GetAuthorizationParams) => Promise<GetAuthorizationReturnValue>;
10
+ export declare const getAuthorizationChallenges: ({ authzUrls, nonce, identity, connection, }: GetAuthorizationParams) => Promise<AuthData>;
14
11
  export {};
15
12
  //# sourceMappingURL=Authorization.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Authorization.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/mls/E2EIdentityService/Steps/Authorization.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,cAAc,EAAE,YAAY,EAAE,KAAK,EAAC,MAAM,sBAAsB,CAAC;AAGzE,UAAU,sBAAsB;IAC9B,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,cAAc,CAAC;IACzB,UAAU,EAAE,WAAW,CAAC;CACzB;AACD,MAAM,MAAM,2BAA2B,GAAG;IAAC,aAAa,EAAE,YAAY,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAC,CAAC;AAEtF,eAAO,MAAM,gBAAgB,+CAK1B,sBAAsB,KAAG,QAAQ,2BAA2B,CA4B9D,CAAC"}
1
+ {"version":3,"file":"Authorization.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/mls/E2EIdentityService/Steps/Authorization.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,cAAc,EAAgB,KAAK,EAAC,MAAM,sBAAsB,CAAC;AAEzE,OAAO,EAAC,QAAQ,EAAC,MAAM,+BAA+B,CAAC;AAEvD,UAAU,sBAAsB;IAC9B,KAAK,EAAE,KAAK,CAAC;IACb,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE,cAAc,CAAC;IACzB,UAAU,EAAE,WAAW,CAAC;CACzB;AAED,eAAO,MAAM,0BAA0B,gDAKpC,sBAAsB,KAAG,QAAQ,QAAQ,CAsC3C,CAAC"}
@@ -18,33 +18,42 @@
18
18
  *
19
19
  */
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.getAuthorization = void 0;
21
+ exports.getAuthorizationChallenges = void 0;
22
22
  const Helper_1 = require("../Helper");
23
- const getAuthorization = async ({ authzUrl, nonce, identity, connection, }) => {
24
- const reqBody = await identity.newAuthzRequest(authzUrl, nonce);
25
- const response = await connection.getAuthorization(authzUrl, reqBody);
26
- if ((response === null || response === void 0 ? void 0 : response.data) && !!response.data.status.length && !!response.nonce.length) {
27
- const wasmData = await identity.newAuthzResponse((0, Helper_1.jsonToByteArray)(response.data));
28
- // manual copy of the wasm data because of a problem while cloning it
29
- const authorization = {
30
- identifier: wasmData.identifier,
31
- keyauth: wasmData.keyauth,
32
- wireDpopChallenge: {
33
- delegate: wasmData.wireDpopChallenge.delegate,
34
- target: wasmData.wireDpopChallenge.target,
35
- url: wasmData.wireDpopChallenge.url,
36
- },
37
- wireOidcChallenge: {
38
- delegate: wasmData.wireOidcChallenge.delegate,
39
- target: wasmData.wireOidcChallenge.target,
40
- url: wasmData.wireOidcChallenge.url,
41
- },
42
- };
43
- return {
44
- authorization,
45
- nonce: response.nonce,
46
- };
23
+ const getAuthorizationChallenges = async ({ authzUrls, nonce, identity, connection, }) => {
24
+ var _a, _b;
25
+ const challenges = [];
26
+ for (const authzUrl of authzUrls) {
27
+ const reqBody = await identity.newAuthzRequest(authzUrl, nonce);
28
+ const response = await connection.getAuthorization(authzUrl, reqBody);
29
+ // The backend returns a list of challenges (to be inline with the protocol), but in our case we are only ever going to have a single element in the list
30
+ const backendChallenge = response.data.challenges[0];
31
+ const challenge = await identity.newAuthzResponse((0, Helper_1.jsonToByteArray)(response.data));
32
+ challenges.push({ type: backendChallenge.type, challenge });
33
+ nonce = response.nonce;
47
34
  }
48
- throw new Error('No authorization-data received');
35
+ const { challenge: oidcChallenge } = (_a = challenges.find(challenge => challenge.type.includes('oidc'))) !== null && _a !== void 0 ? _a : {};
36
+ const { challenge: dpopChallenge } = (_b = challenges.find(challenge => challenge.type.includes('dpop'))) !== null && _b !== void 0 ? _b : {};
37
+ if (!dpopChallenge || !oidcChallenge) {
38
+ throw new Error('missing dpop or oidc challenge');
39
+ }
40
+ // manual copy of the wasm data because of a problem while cloning it
41
+ const authorization = {
42
+ keyauth: oidcChallenge.keyauth,
43
+ dpopChallenge: {
44
+ delegate: dpopChallenge.challenge.delegate,
45
+ target: dpopChallenge.challenge.target,
46
+ url: dpopChallenge.challenge.url,
47
+ },
48
+ oidcChallenge: {
49
+ delegate: oidcChallenge.challenge.delegate,
50
+ target: oidcChallenge.challenge.target,
51
+ url: oidcChallenge.challenge.url,
52
+ },
53
+ };
54
+ return {
55
+ authorization,
56
+ nonce,
57
+ };
49
58
  };
50
- exports.getAuthorization = getAuthorization;
59
+ exports.getAuthorizationChallenges = getAuthorizationChallenges;
@@ -1,12 +1,9 @@
1
1
  import { DoWireDpopChallengeParams } from './DpopChallenge.types';
2
- export declare const doWireDpopChallenge: ({ apiClient, clientId, authData, identity, nonce, connection, expirySecs, userDomain, }: DoWireDpopChallengeParams) => Promise<{
3
- data: {
4
- type: string;
5
- url: string;
6
- status: string;
7
- token: string;
8
- };
9
- nonce: string;
10
- location?: string | undefined;
11
- }>;
2
+ export declare const doWireDpopChallenge: ({ apiClient, clientId, authData, identity, nonce, connection, expirySecs, userDomain, }: DoWireDpopChallengeParams) => Promise<import("../../Connection/AcmeServer/AcmeService.types").PostJoseRequestReturnValue<{
3
+ type: string;
4
+ url: string;
5
+ target: string;
6
+ status: string;
7
+ token: string;
8
+ }>>;
12
9
  //# sourceMappingURL=DpopChallenge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DpopChallenge.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/mls/E2EIdentityService/Steps/DpopChallenge/DpopChallenge.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAC,yBAAyB,EAAmD,MAAM,uBAAuB,CAAC;AA6BlH,eAAO,MAAM,mBAAmB,4FAS7B,yBAAyB;;;;;;;;;EA+B3B,CAAC"}
1
+ {"version":3,"file":"DpopChallenge.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/mls/E2EIdentityService/Steps/DpopChallenge/DpopChallenge.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAC,yBAAyB,EAAmD,MAAM,uBAAuB,CAAC;AA6BlH,eAAO,MAAM,mBAAmB,4FAS7B,yBAAyB;;;;;;GA+B3B,CAAC"}
@@ -39,8 +39,8 @@ const getClientAccessToken = async ({ apiClient, clientNonce, identity, clientId
39
39
  return apiClient.api.client.getAccessToken(clientId, dpopToken);
40
40
  };
41
41
  const doWireDpopChallenge = async ({ apiClient, clientId, authData, identity, nonce, connection, expirySecs, userDomain, }) => {
42
- const { wireDpopChallenge } = authData.authorization;
43
- if (!wireDpopChallenge) {
42
+ const { dpopChallenge } = authData.authorization;
43
+ if (!dpopChallenge) {
44
44
  throw new Error('No wireDpopChallenge defined');
45
45
  }
46
46
  const clientNonce = await getClientNonce({ clientId, apiClient });
@@ -55,7 +55,7 @@ const doWireDpopChallenge = async ({ apiClient, clientId, authData, identity, no
55
55
  userDomain,
56
56
  });
57
57
  const reqBody = await identity.newDpopChallengeRequest(clientAccessTokenData.token, nonce);
58
- const dpopChallengeResponse = await connection.validateDpopChallenge(wireDpopChallenge.url, reqBody);
58
+ const dpopChallengeResponse = await connection.validateDpopChallenge(dpopChallenge.url, reqBody);
59
59
  if (!dpopChallengeResponse) {
60
60
  throw new Error('No response received while validating DPOP challenge');
61
61
  }
@@ -2,12 +2,12 @@ import { APIClient } from '@wireapp/api-client';
2
2
  import { ClientId } from '../../../types';
3
3
  import { AcmeService } from '../../Connection/AcmeServer';
4
4
  import { E2eiEnrollment, Nonce, User } from '../../E2EIService.types';
5
- import { GetAuthorizationReturnValue } from '../Authorization';
5
+ import { AuthData } from '../../Storage/E2EIStorage.schema';
6
6
  export interface DoWireDpopChallengeParams {
7
7
  apiClient: APIClient;
8
8
  clientId: ClientId;
9
9
  userDomain: User['domain'];
10
- authData: GetAuthorizationReturnValue;
10
+ authData: AuthData;
11
11
  identity: E2eiEnrollment;
12
12
  connection: AcmeService;
13
13
  nonce: Nonce;
@@ -1 +1 @@
1
- {"version":3,"file":"DpopChallenge.types.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/mls/E2EIdentityService/Steps/DpopChallenge/DpopChallenge.types.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAC,WAAW,EAAC,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAC,cAAc,EAAE,KAAK,EAAE,IAAI,EAAC,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAC,2BAA2B,EAAC,MAAM,kBAAkB,CAAC;AAE7D,MAAM,WAAW,yBAAyB;IACxC,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC3B,QAAQ,EAAE,2BAA2B,CAAC;IACtC,QAAQ,EAAE,cAAc,CAAC;IACzB,UAAU,EAAE,WAAW,CAAC;IACxB,KAAK,EAAE,KAAK,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,yBAAyB,EAAE,UAAU,GAAG,WAAW,CAAC,CAAC;AAE7F,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAC3C,yBAAyB,EACzB,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,YAAY,GAAG,YAAY,CACpE,GAAG;IACF,WAAW,EAAE,KAAK,CAAC;CACpB,CAAC"}
1
+ {"version":3,"file":"DpopChallenge.types.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/mls/E2EIdentityService/Steps/DpopChallenge/DpopChallenge.types.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAC,WAAW,EAAC,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAC,cAAc,EAAE,KAAK,EAAE,IAAI,EAAC,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAC,QAAQ,EAAC,MAAM,kCAAkC,CAAC;AAE1D,MAAM,WAAW,yBAAyB;IACxC,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC3B,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,cAAc,CAAC;IACzB,UAAU,EAAE,WAAW,CAAC;IACxB,KAAK,EAAE,KAAK,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,yBAAyB,EAAE,UAAU,GAAG,WAAW,CAAC,CAAC;AAE7F,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAC3C,yBAAyB,EACzB,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,YAAY,GAAG,YAAY,CACpE,GAAG;IACF,WAAW,EAAE,KAAK,CAAC;CACpB,CAAC"}
@@ -1,29 +1,25 @@
1
- import { GetAuthorizationReturnValue } from './Authorization';
2
1
  import { AcmeService } from '../Connection/AcmeServer';
3
2
  import { CoreCrypto, E2eiEnrollment, Nonce } from '../E2EIService.types';
3
+ import { AuthData } from '../Storage/E2EIStorage.schema';
4
4
  interface DoWireOidcChallengeParams {
5
5
  coreCryptoClient: CoreCrypto;
6
- authData: GetAuthorizationReturnValue;
6
+ authData: AuthData;
7
7
  identity: E2eiEnrollment;
8
8
  connection: AcmeService;
9
9
  nonce: Nonce;
10
10
  oAuthIdToken: string;
11
11
  }
12
- export declare const doWireOidcChallenge: ({ coreCryptoClient, connection, authData, identity, nonce, oAuthIdToken, }: DoWireOidcChallengeParams) => Promise<{
13
- data: {
12
+ export declare const doWireOidcChallenge: ({ coreCryptoClient, connection, authData, identity, nonce, oAuthIdToken, }: DoWireOidcChallengeParams) => Promise<import("../Connection/AcmeServer/AcmeService.types").PostJoseRequestReturnValue<{
13
+ type: string;
14
+ url: string;
15
+ target: string;
16
+ status: string;
17
+ token: string;
18
+ validated?: string | undefined;
19
+ error?: {
14
20
  type: string;
15
- url: string;
16
- target: string;
17
- status: string;
18
- token: string;
19
- validated?: string | undefined;
20
- error?: {
21
- type: string;
22
- detail: string;
23
- } | undefined;
24
- };
25
- nonce: string;
26
- location?: string | undefined;
27
- }>;
21
+ detail: string;
22
+ } | undefined;
23
+ }>>;
28
24
  export {};
29
25
  //# sourceMappingURL=OidcChallenge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"OidcChallenge.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/mls/E2EIdentityService/Steps/OidcChallenge.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAC,2BAA2B,EAAC,MAAM,iBAAiB,CAAC;AAE5D,OAAO,EAAC,WAAW,EAAC,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAC,UAAU,EAAE,cAAc,EAAE,KAAK,EAAC,MAAM,sBAAsB,CAAC;AAEvE,UAAU,yBAAyB;IACjC,gBAAgB,EAAE,UAAU,CAAC;IAC7B,QAAQ,EAAE,2BAA2B,CAAC;IACtC,QAAQ,EAAE,cAAc,CAAC;IACzB,UAAU,EAAE,WAAW,CAAC;IACxB,KAAK,EAAE,KAAK,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,mBAAmB,+EAO7B,yBAAyB;;;;;;;;;;;;;;;EAmB3B,CAAC"}
1
+ {"version":3,"file":"OidcChallenge.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/mls/E2EIdentityService/Steps/OidcChallenge.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAC,WAAW,EAAC,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAC,UAAU,EAAE,cAAc,EAAE,KAAK,EAAC,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAC,QAAQ,EAAC,MAAM,+BAA+B,CAAC;AAEvD,UAAU,yBAAyB;IACjC,gBAAgB,EAAE,UAAU,CAAC;IAC7B,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,cAAc,CAAC;IACzB,UAAU,EAAE,WAAW,CAAC;IACxB,KAAK,EAAE,KAAK,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,mBAAmB,+EAO7B,yBAAyB;;;;;;;;;;;GAmB3B,CAAC"}
@@ -21,13 +21,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.doWireOidcChallenge = void 0;
22
22
  const bazinga64_1 = require("bazinga64");
23
23
  const doWireOidcChallenge = async ({ coreCryptoClient, connection, authData, identity, nonce, oAuthIdToken, }) => {
24
- const { wireOidcChallenge } = authData.authorization;
25
- if (!wireOidcChallenge) {
24
+ const { oidcChallenge } = authData.authorization;
25
+ if (!oidcChallenge) {
26
26
  throw new Error('No wireOIDCChallenge defined');
27
27
  }
28
28
  const refreshToken = 'empty'; // CC just stores the refresh token (which we don't need for web, as our oidc library does that for us)
29
29
  const reqBody = await identity.newOidcChallengeRequest(oAuthIdToken, refreshToken, nonce);
30
- const oidcChallengeResponse = await connection.validateOidcChallenge(wireOidcChallenge.url, reqBody);
30
+ const oidcChallengeResponse = await connection.validateOidcChallenge(oidcChallenge.url, reqBody);
31
31
  if (!oidcChallengeResponse) {
32
32
  throw new Error('No response received while validating OIDC challenge');
33
33
  }
@@ -7,13 +7,13 @@ export interface CreateNewOrderParams {
7
7
  directory: AcmeDirectory;
8
8
  connection: AcmeService;
9
9
  }
10
- export type CreateNewOrderReturnValue = Promise<{
10
+ export type CreateNewOrderReturnValue = {
11
11
  order: NewAcmeOrder;
12
12
  nonce: string;
13
- authzUrl: string;
13
+ authzUrls: string[];
14
14
  orderUrl: OrderUrl;
15
- }>;
16
- export declare const createNewOrder: ({ identity, nonce, directory, connection, }: CreateNewOrderParams) => CreateNewOrderReturnValue;
15
+ };
16
+ export declare const createNewOrder: ({ identity, nonce, directory, connection, }: CreateNewOrderParams) => Promise<CreateNewOrderReturnValue>;
17
17
  export interface FinalizeOrderParams {
18
18
  connection: AcmeService;
19
19
  identity: E2eiEnrollment;
@@ -1 +1 @@
1
- {"version":3,"file":"Order.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/mls/E2EIdentityService/Steps/Order.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,KAAK,EAAC,MAAM,sBAAsB,CAAC;AAGxF,KAAK,QAAQ,GAAG,MAAM,CAAC;AAEvB,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,cAAc,CAAC;IACzB,KAAK,EAAE,KAAK,CAAC;IACb,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,WAAW,CAAC;CACzB;AACD,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAAC;IAC9C,KAAK,EAAE,YAAY,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC,CAAC;AAEH,eAAO,MAAM,cAAc,gDAKxB,oBAAoB,8BAatB,CAAC;AAEF,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,WAAW,CAAC;IACxB,QAAQ,EAAE,cAAc,CAAC;IACzB,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,QAAQ,CAAC;CACpB;AACD,eAAO,MAAM,aAAa,8CAAmD,mBAAmB;;;EAqB/F,CAAC"}
1
+ {"version":3,"file":"Order.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/mls/E2EIdentityService/Steps/Order.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,KAAK,EAAC,MAAM,sBAAsB,CAAC;AAGxF,KAAK,QAAQ,GAAG,MAAM,CAAC;AAEvB,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,cAAc,CAAC;IACzB,KAAK,EAAE,KAAK,CAAC;IACb,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,WAAW,CAAC;CACzB;AACD,MAAM,MAAM,yBAAyB,GAAG;IACtC,KAAK,EAAE,YAAY,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,cAAc,gDAKxB,oBAAoB,KAAG,QAAQ,yBAAyB,CAY1D,CAAC;AAEF,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,WAAW,CAAC;IACxB,QAAQ,EAAE,cAAc,CAAC;IACzB,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,QAAQ,CAAC;CACpB;AACD,eAAO,MAAM,aAAa,8CAAmD,mBAAmB;;;EAqB/F,CAAC"}
@@ -21,18 +21,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.finalizeOrder = exports.createNewOrder = void 0;
22
22
  const Helper_1 = require("../Helper");
23
23
  const createNewOrder = async ({ identity, nonce, directory, connection, }) => {
24
- var _a;
25
24
  const reqBody = await identity.newOrderRequest(nonce);
26
- const response = await connection.createNewOrder(directory.newOrder, reqBody);
27
- if ((response === null || response === void 0 ? void 0 : response.data) && !!response.data.status.length && !!response.nonce.length && !!((_a = response.location) === null || _a === void 0 ? void 0 : _a.length)) {
28
- return {
29
- order: await identity.newOrderResponse((0, Helper_1.jsonToByteArray)(response.data)),
30
- authzUrl: response.data.authorizations[0],
31
- nonce: response.nonce,
32
- orderUrl: response.location,
33
- };
25
+ const { data, nonce: responseNonce, location } = await connection.createNewOrder(directory.newOrder, reqBody);
26
+ if (!location) {
27
+ throw new Error('No location header from API received for order creation');
34
28
  }
35
- throw new Error('No createNewOrder-data received');
29
+ return {
30
+ order: await identity.newOrderResponse((0, Helper_1.jsonToByteArray)(data)),
31
+ authzUrls: data.authorizations,
32
+ nonce: responseNonce,
33
+ orderUrl: location,
34
+ };
36
35
  };
37
36
  exports.createNewOrder = createNewOrder;
38
37
  const finalizeOrder = async ({ identity, nonce, orderUrl, connection }) => {
@@ -45,8 +45,8 @@ const getAndVerifyAuthData = () => {
45
45
  if (!data) {
46
46
  throw new Error('ACME: AuthData not found');
47
47
  }
48
- const atob = window.atob(data);
49
- return E2EIStorage_schema_1.AuthDataSchema.parse(JSON.parse(atob));
48
+ const decodedData = window.atob(data);
49
+ return E2EIStorage_schema_1.AuthDataSchema.parse(JSON.parse(decodedData));
50
50
  };
51
51
  const getInitialData = () => {
52
52
  const data = storage.get(InitialDataKey);