1 | "use strict";
|
2 |
|
3 | exports.__esModule = true;
|
4 | exports["default"] = void 0;
|
5 |
|
6 | var _buffer = require("buffer");
|
7 |
|
8 | var _core = _interopRequireDefault(require("crypto-js/core"));
|
9 |
|
10 | var _libTypedarrays = _interopRequireDefault(require("crypto-js/lib-typedarrays"));
|
11 |
|
12 | var _encBase = _interopRequireDefault(require("crypto-js/enc-base64"));
|
13 |
|
14 | var _hmacSha = _interopRequireDefault(require("crypto-js/hmac-sha256"));
|
15 |
|
16 | var _BigInteger = _interopRequireDefault(require("./BigInteger"));
|
17 |
|
18 | var _AuthenticationHelper = _interopRequireDefault(require("./AuthenticationHelper"));
|
19 |
|
20 | var _CognitoAccessToken = _interopRequireDefault(require("./CognitoAccessToken"));
|
21 |
|
22 | var _CognitoIdToken = _interopRequireDefault(require("./CognitoIdToken"));
|
23 |
|
24 | var _CognitoRefreshToken = _interopRequireDefault(require("./CognitoRefreshToken"));
|
25 |
|
26 | var _CognitoUserSession = _interopRequireDefault(require("./CognitoUserSession"));
|
27 |
|
28 | var _DateHelper = _interopRequireDefault(require("./DateHelper"));
|
29 |
|
30 | var _CognitoUserAttribute = _interopRequireDefault(require("./CognitoUserAttribute"));
|
31 |
|
32 | var _StorageHelper = _interopRequireDefault(require("./StorageHelper"));
|
33 |
|
34 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 | var isBrowser = typeof navigator !== 'undefined';
|
93 | var userAgent = isBrowser ? navigator.userAgent : 'nodejs';
|
94 |
|
95 |
|
96 | var CognitoUser = function () {
|
97 | |
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 | function CognitoUser(data) {
|
105 | if (data == null || data.Username == null || data.Pool == null) {
|
106 | throw new Error('Username and pool information are required.');
|
107 | }
|
108 |
|
109 | this.username = data.Username || '';
|
110 | this.pool = data.Pool;
|
111 | this.Session = null;
|
112 | this.client = data.Pool.client;
|
113 | this.signInUserSession = null;
|
114 | this.authenticationFlowType = 'USER_SRP_AUTH';
|
115 | this.storage = data.Storage || new _StorageHelper["default"]().getStorage();
|
116 | this.keyPrefix = "CognitoIdentityServiceProvider." + this.pool.getClientId();
|
117 | this.userDataKey = this.keyPrefix + "." + this.username + ".userData";
|
118 | }
|
119 | |
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 | var _proto = CognitoUser.prototype;
|
127 |
|
128 | _proto.setSignInUserSession = function setSignInUserSession(signInUserSession) {
|
129 | this.clearCachedUserData();
|
130 | this.signInUserSession = signInUserSession;
|
131 | this.cacheTokens();
|
132 | }
|
133 | |
134 |
|
135 |
|
136 | ;
|
137 |
|
138 | _proto.getSignInUserSession = function getSignInUserSession() {
|
139 | return this.signInUserSession;
|
140 | }
|
141 | |
142 |
|
143 |
|
144 | ;
|
145 |
|
146 | _proto.getUsername = function getUsername() {
|
147 | return this.username;
|
148 | }
|
149 | |
150 |
|
151 |
|
152 | ;
|
153 |
|
154 | _proto.getAuthenticationFlowType = function getAuthenticationFlowType() {
|
155 | return this.authenticationFlowType;
|
156 | }
|
157 | |
158 |
|
159 |
|
160 |
|
161 |
|
162 | ;
|
163 |
|
164 | _proto.setAuthenticationFlowType = function setAuthenticationFlowType(authenticationFlowType) {
|
165 | this.authenticationFlowType = authenticationFlowType;
|
166 | }
|
167 | |
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 | ;
|
178 |
|
179 | _proto.initiateAuth = function initiateAuth(authDetails, callback) {
|
180 | var _this = this;
|
181 |
|
182 | var authParameters = authDetails.getAuthParameters();
|
183 | authParameters.USERNAME = this.username;
|
184 | var clientMetaData = Object.keys(authDetails.getValidationData()).length !== 0 ? authDetails.getValidationData() : authDetails.getClientMetadata();
|
185 | var jsonReq = {
|
186 | AuthFlow: 'CUSTOM_AUTH',
|
187 | ClientId: this.pool.getClientId(),
|
188 | AuthParameters: authParameters,
|
189 | ClientMetadata: clientMetaData
|
190 | };
|
191 |
|
192 | if (this.getUserContextData()) {
|
193 | jsonReq.UserContextData = this.getUserContextData();
|
194 | }
|
195 |
|
196 | this.client.request('InitiateAuth', jsonReq, function (err, data) {
|
197 | if (err) {
|
198 | return callback.onFailure(err);
|
199 | }
|
200 |
|
201 | var challengeName = data.ChallengeName;
|
202 | var challengeParameters = data.ChallengeParameters;
|
203 |
|
204 | if (challengeName === 'CUSTOM_CHALLENGE') {
|
205 | _this.Session = data.Session;
|
206 | return callback.customChallenge(challengeParameters);
|
207 | }
|
208 |
|
209 | _this.signInUserSession = _this.getCognitoUserSession(data.AuthenticationResult);
|
210 |
|
211 | _this.cacheTokens();
|
212 |
|
213 | return callback.onSuccess(_this.signInUserSession);
|
214 | });
|
215 | }
|
216 | |
217 |
|
218 |
|
219 |
|
220 |
|
221 |
|
222 |
|
223 |
|
224 |
|
225 |
|
226 |
|
227 |
|
228 |
|
229 |
|
230 |
|
231 | ;
|
232 |
|
233 | _proto.authenticateUser = function authenticateUser(authDetails, callback) {
|
234 | if (this.authenticationFlowType === 'USER_PASSWORD_AUTH') {
|
235 | return this.authenticateUserPlainUsernamePassword(authDetails, callback);
|
236 | } else if (this.authenticationFlowType === 'USER_SRP_AUTH' || this.authenticationFlowType === 'CUSTOM_AUTH') {
|
237 | return this.authenticateUserDefaultAuth(authDetails, callback);
|
238 | }
|
239 |
|
240 | return callback.onFailure(new Error('Authentication flow type is invalid.'));
|
241 | }
|
242 | |
243 |
|
244 |
|
245 |
|
246 |
|
247 |
|
248 |
|
249 |
|
250 |
|
251 |
|
252 |
|
253 |
|
254 |
|
255 |
|
256 |
|
257 |
|
258 |
|
259 | ;
|
260 |
|
261 | _proto.authenticateUserDefaultAuth = function authenticateUserDefaultAuth(authDetails, callback) {
|
262 | var _this2 = this;
|
263 |
|
264 | var authenticationHelper = new _AuthenticationHelper["default"](this.pool.getUserPoolId().split('_')[1]);
|
265 | var dateHelper = new _DateHelper["default"]();
|
266 | var serverBValue;
|
267 | var salt;
|
268 | var authParameters = {};
|
269 |
|
270 | if (this.deviceKey != null) {
|
271 | authParameters.DEVICE_KEY = this.deviceKey;
|
272 | }
|
273 |
|
274 | authParameters.USERNAME = this.username;
|
275 | authenticationHelper.getLargeAValue(function (errOnAValue, aValue) {
|
276 |
|
277 | if (errOnAValue) {
|
278 | callback.onFailure(errOnAValue);
|
279 | }
|
280 |
|
281 | authParameters.SRP_A = aValue.toString(16);
|
282 |
|
283 | if (_this2.authenticationFlowType === 'CUSTOM_AUTH') {
|
284 | authParameters.CHALLENGE_NAME = 'SRP_A';
|
285 | }
|
286 |
|
287 | var clientMetaData = Object.keys(authDetails.getValidationData()).length !== 0 ? authDetails.getValidationData() : authDetails.getClientMetadata();
|
288 | var jsonReq = {
|
289 | AuthFlow: _this2.authenticationFlowType,
|
290 | ClientId: _this2.pool.getClientId(),
|
291 | AuthParameters: authParameters,
|
292 | ClientMetadata: clientMetaData
|
293 | };
|
294 |
|
295 | if (_this2.getUserContextData(_this2.username)) {
|
296 | jsonReq.UserContextData = _this2.getUserContextData(_this2.username);
|
297 | }
|
298 |
|
299 | _this2.client.request('InitiateAuth', jsonReq, function (err, data) {
|
300 | if (err) {
|
301 | return callback.onFailure(err);
|
302 | }
|
303 |
|
304 | var challengeParameters = data.ChallengeParameters;
|
305 | _this2.username = challengeParameters.USER_ID_FOR_SRP;
|
306 | serverBValue = new _BigInteger["default"](challengeParameters.SRP_B, 16);
|
307 | salt = new _BigInteger["default"](challengeParameters.SALT, 16);
|
308 |
|
309 | _this2.getCachedDeviceKeyAndPassword();
|
310 |
|
311 | authenticationHelper.getPasswordAuthenticationKey(_this2.username, authDetails.getPassword(), serverBValue, salt, function (errOnHkdf, hkdf) {
|
312 |
|
313 | if (errOnHkdf) {
|
314 | callback.onFailure(errOnHkdf);
|
315 | }
|
316 |
|
317 | var dateNow = dateHelper.getNowString();
|
318 |
|
319 | var message = _core["default"].lib.WordArray.create(_buffer.Buffer.concat([_buffer.Buffer.from(_this2.pool.getUserPoolId().split('_')[1], 'utf8'), _buffer.Buffer.from(_this2.username, 'utf8'), _buffer.Buffer.from(challengeParameters.SECRET_BLOCK, 'base64'), _buffer.Buffer.from(dateNow, 'utf8')]));
|
320 |
|
321 | var key = _core["default"].lib.WordArray.create(hkdf);
|
322 |
|
323 | var signatureString = _encBase["default"].stringify((0, _hmacSha["default"])(message, key));
|
324 |
|
325 | var challengeResponses = {};
|
326 | challengeResponses.USERNAME = _this2.username;
|
327 | challengeResponses.PASSWORD_CLAIM_SECRET_BLOCK = challengeParameters.SECRET_BLOCK;
|
328 | challengeResponses.TIMESTAMP = dateNow;
|
329 | challengeResponses.PASSWORD_CLAIM_SIGNATURE = signatureString;
|
330 |
|
331 | if (_this2.deviceKey != null) {
|
332 | challengeResponses.DEVICE_KEY = _this2.deviceKey;
|
333 | }
|
334 |
|
335 | var respondToAuthChallenge = function respondToAuthChallenge(challenge, challengeCallback) {
|
336 | return _this2.client.request('RespondToAuthChallenge', challenge, function (errChallenge, dataChallenge) {
|
337 | if (errChallenge && errChallenge.code === 'ResourceNotFoundException' && errChallenge.message.toLowerCase().indexOf('device') !== -1) {
|
338 | challengeResponses.DEVICE_KEY = null;
|
339 | _this2.deviceKey = null;
|
340 | _this2.randomPassword = null;
|
341 | _this2.deviceGroupKey = null;
|
342 |
|
343 | _this2.clearCachedDeviceKeyAndPassword();
|
344 |
|
345 | return respondToAuthChallenge(challenge, challengeCallback);
|
346 | }
|
347 |
|
348 | return challengeCallback(errChallenge, dataChallenge);
|
349 | });
|
350 | };
|
351 |
|
352 | var jsonReqResp = {
|
353 | ChallengeName: 'PASSWORD_VERIFIER',
|
354 | ClientId: _this2.pool.getClientId(),
|
355 | ChallengeResponses: challengeResponses,
|
356 | Session: data.Session,
|
357 | ClientMetadata: clientMetaData
|
358 | };
|
359 |
|
360 | if (_this2.getUserContextData()) {
|
361 | jsonReqResp.UserContextData = _this2.getUserContextData();
|
362 | }
|
363 |
|
364 | respondToAuthChallenge(jsonReqResp, function (errAuthenticate, dataAuthenticate) {
|
365 | if (errAuthenticate) {
|
366 | return callback.onFailure(errAuthenticate);
|
367 | }
|
368 |
|
369 | return _this2.authenticateUserInternal(dataAuthenticate, authenticationHelper, callback);
|
370 | });
|
371 | return undefined;
|
372 | });
|
373 | return undefined;
|
374 | });
|
375 |
|
376 | });
|
377 | }
|
378 | |
379 |
|
380 |
|
381 |
|
382 |
|
383 |
|
384 |
|
385 |
|
386 |
|
387 |
|
388 |
|
389 | ;
|
390 |
|
391 | _proto.authenticateUserPlainUsernamePassword = function authenticateUserPlainUsernamePassword(authDetails, callback) {
|
392 | var _this3 = this;
|
393 |
|
394 | var authParameters = {};
|
395 | authParameters.USERNAME = this.username;
|
396 | authParameters.PASSWORD = authDetails.getPassword();
|
397 |
|
398 | if (!authParameters.PASSWORD) {
|
399 | callback.onFailure(new Error('PASSWORD parameter is required'));
|
400 | return;
|
401 | }
|
402 |
|
403 | var authenticationHelper = new _AuthenticationHelper["default"](this.pool.getUserPoolId().split('_')[1]);
|
404 | this.getCachedDeviceKeyAndPassword();
|
405 |
|
406 | if (this.deviceKey != null) {
|
407 | authParameters.DEVICE_KEY = this.deviceKey;
|
408 | }
|
409 |
|
410 | var clientMetaData = Object.keys(authDetails.getValidationData()).length !== 0 ? authDetails.getValidationData() : authDetails.getClientMetadata();
|
411 | var jsonReq = {
|
412 | AuthFlow: 'USER_PASSWORD_AUTH',
|
413 | ClientId: this.pool.getClientId(),
|
414 | AuthParameters: authParameters,
|
415 | ClientMetadata: clientMetaData
|
416 | };
|
417 |
|
418 | if (this.getUserContextData(this.username)) {
|
419 | jsonReq.UserContextData = this.getUserContextData(this.username);
|
420 | }
|
421 |
|
422 |
|
423 |
|
424 | this.client.request('InitiateAuth', jsonReq, function (err, authResult) {
|
425 | if (err) {
|
426 | return callback.onFailure(err);
|
427 | }
|
428 |
|
429 | return _this3.authenticateUserInternal(authResult, authenticationHelper, callback);
|
430 | });
|
431 | }
|
432 | |
433 |
|
434 |
|
435 |
|
436 |
|
437 |
|
438 |
|
439 |
|
440 | ;
|
441 |
|
442 | _proto.authenticateUserInternal = function authenticateUserInternal(dataAuthenticate, authenticationHelper, callback) {
|
443 | var _this4 = this;
|
444 |
|
445 | var challengeName = dataAuthenticate.ChallengeName;
|
446 | var challengeParameters = dataAuthenticate.ChallengeParameters;
|
447 |
|
448 | if (challengeName === 'SMS_MFA') {
|
449 | this.Session = dataAuthenticate.Session;
|
450 | return callback.mfaRequired(challengeName, challengeParameters);
|
451 | }
|
452 |
|
453 | if (challengeName === 'SELECT_MFA_TYPE') {
|
454 | this.Session = dataAuthenticate.Session;
|
455 | return callback.selectMFAType(challengeName, challengeParameters);
|
456 | }
|
457 |
|
458 | if (challengeName === 'MFA_SETUP') {
|
459 | this.Session = dataAuthenticate.Session;
|
460 | return callback.mfaSetup(challengeName, challengeParameters);
|
461 | }
|
462 |
|
463 | if (challengeName === 'SOFTWARE_TOKEN_MFA') {
|
464 | this.Session = dataAuthenticate.Session;
|
465 | return callback.totpRequired(challengeName, challengeParameters);
|
466 | }
|
467 |
|
468 | if (challengeName === 'CUSTOM_CHALLENGE') {
|
469 | this.Session = dataAuthenticate.Session;
|
470 | return callback.customChallenge(challengeParameters);
|
471 | }
|
472 |
|
473 | if (challengeName === 'NEW_PASSWORD_REQUIRED') {
|
474 | this.Session = dataAuthenticate.Session;
|
475 | var userAttributes = null;
|
476 | var rawRequiredAttributes = null;
|
477 | var requiredAttributes = [];
|
478 | var userAttributesPrefix = authenticationHelper.getNewPasswordRequiredChallengeUserAttributePrefix();
|
479 |
|
480 | if (challengeParameters) {
|
481 | userAttributes = JSON.parse(dataAuthenticate.ChallengeParameters.userAttributes);
|
482 | rawRequiredAttributes = JSON.parse(dataAuthenticate.ChallengeParameters.requiredAttributes);
|
483 | }
|
484 |
|
485 | if (rawRequiredAttributes) {
|
486 | for (var i = 0; i < rawRequiredAttributes.length; i++) {
|
487 | requiredAttributes[i] = rawRequiredAttributes[i].substr(userAttributesPrefix.length);
|
488 | }
|
489 | }
|
490 |
|
491 | return callback.newPasswordRequired(userAttributes, requiredAttributes);
|
492 | }
|
493 |
|
494 | if (challengeName === 'DEVICE_SRP_AUTH') {
|
495 | this.getDeviceResponse(callback);
|
496 | return undefined;
|
497 | }
|
498 |
|
499 | this.signInUserSession = this.getCognitoUserSession(dataAuthenticate.AuthenticationResult);
|
500 | this.challengeName = challengeName;
|
501 | this.cacheTokens();
|
502 | var newDeviceMetadata = dataAuthenticate.AuthenticationResult.NewDeviceMetadata;
|
503 |
|
504 | if (newDeviceMetadata == null) {
|
505 | return callback.onSuccess(this.signInUserSession);
|
506 | }
|
507 |
|
508 | authenticationHelper.generateHashDevice(dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey, dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceKey, function (errGenHash) {
|
509 | if (errGenHash) {
|
510 | return callback.onFailure(errGenHash);
|
511 | }
|
512 |
|
513 | var deviceSecretVerifierConfig = {
|
514 | Salt: _buffer.Buffer.from(authenticationHelper.getSaltDevices(), 'hex').toString('base64'),
|
515 | PasswordVerifier: _buffer.Buffer.from(authenticationHelper.getVerifierDevices(), 'hex').toString('base64')
|
516 | };
|
517 | _this4.verifierDevices = deviceSecretVerifierConfig.PasswordVerifier;
|
518 | _this4.deviceGroupKey = newDeviceMetadata.DeviceGroupKey;
|
519 | _this4.randomPassword = authenticationHelper.getRandomPassword();
|
520 |
|
521 | _this4.client.request('ConfirmDevice', {
|
522 | DeviceKey: newDeviceMetadata.DeviceKey,
|
523 | AccessToken: _this4.signInUserSession.getAccessToken().getJwtToken(),
|
524 | DeviceSecretVerifierConfig: deviceSecretVerifierConfig,
|
525 | DeviceName: userAgent
|
526 | }, function (errConfirm, dataConfirm) {
|
527 | if (errConfirm) {
|
528 | return callback.onFailure(errConfirm);
|
529 | }
|
530 |
|
531 | _this4.deviceKey = dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceKey;
|
532 |
|
533 | _this4.cacheDeviceKeyAndPassword();
|
534 |
|
535 | if (dataConfirm.UserConfirmationNecessary === true) {
|
536 | return callback.onSuccess(_this4.signInUserSession, dataConfirm.UserConfirmationNecessary);
|
537 | }
|
538 |
|
539 | return callback.onSuccess(_this4.signInUserSession);
|
540 | });
|
541 |
|
542 | return undefined;
|
543 | });
|
544 | return undefined;
|
545 | }
|
546 | |
547 |
|
548 |
|
549 |
|
550 |
|
551 |
|
552 |
|
553 |
|
554 |
|
555 |
|
556 |
|
557 |
|
558 |
|
559 |
|
560 |
|
561 | ;
|
562 |
|
563 | _proto.completeNewPasswordChallenge = function completeNewPasswordChallenge(newPassword, requiredAttributeData, callback, clientMetadata) {
|
564 | var _this5 = this;
|
565 |
|
566 | if (!newPassword) {
|
567 | return callback.onFailure(new Error('New password is required.'));
|
568 | }
|
569 |
|
570 | var authenticationHelper = new _AuthenticationHelper["default"](this.pool.getUserPoolId().split('_')[1]);
|
571 | var userAttributesPrefix = authenticationHelper.getNewPasswordRequiredChallengeUserAttributePrefix();
|
572 | var finalUserAttributes = {};
|
573 |
|
574 | if (requiredAttributeData) {
|
575 | Object.keys(requiredAttributeData).forEach(function (key) {
|
576 | finalUserAttributes[userAttributesPrefix + key] = requiredAttributeData[key];
|
577 | });
|
578 | }
|
579 |
|
580 | finalUserAttributes.NEW_PASSWORD = newPassword;
|
581 | finalUserAttributes.USERNAME = this.username;
|
582 | var jsonReq = {
|
583 | ChallengeName: 'NEW_PASSWORD_REQUIRED',
|
584 | ClientId: this.pool.getClientId(),
|
585 | ChallengeResponses: finalUserAttributes,
|
586 | Session: this.Session,
|
587 | ClientMetadata: clientMetadata
|
588 | };
|
589 |
|
590 | if (this.getUserContextData()) {
|
591 | jsonReq.UserContextData = this.getUserContextData();
|
592 | }
|
593 |
|
594 | this.client.request('RespondToAuthChallenge', jsonReq, function (errAuthenticate, dataAuthenticate) {
|
595 | if (errAuthenticate) {
|
596 | return callback.onFailure(errAuthenticate);
|
597 | }
|
598 |
|
599 | return _this5.authenticateUserInternal(dataAuthenticate, authenticationHelper, callback);
|
600 | });
|
601 | return undefined;
|
602 | }
|
603 | |
604 |
|
605 |
|
606 |
|
607 |
|
608 |
|
609 |
|
610 |
|
611 |
|
612 |
|
613 |
|
614 | ;
|
615 |
|
616 | _proto.getDeviceResponse = function getDeviceResponse(callback, clientMetadata) {
|
617 | var _this6 = this;
|
618 |
|
619 | var authenticationHelper = new _AuthenticationHelper["default"](this.deviceGroupKey);
|
620 | var dateHelper = new _DateHelper["default"]();
|
621 | var authParameters = {};
|
622 | authParameters.USERNAME = this.username;
|
623 | authParameters.DEVICE_KEY = this.deviceKey;
|
624 | authenticationHelper.getLargeAValue(function (errAValue, aValue) {
|
625 |
|
626 | if (errAValue) {
|
627 | callback.onFailure(errAValue);
|
628 | }
|
629 |
|
630 | authParameters.SRP_A = aValue.toString(16);
|
631 | var jsonReq = {
|
632 | ChallengeName: 'DEVICE_SRP_AUTH',
|
633 | ClientId: _this6.pool.getClientId(),
|
634 | ChallengeResponses: authParameters,
|
635 | ClientMetadata: clientMetadata
|
636 | };
|
637 |
|
638 | if (_this6.getUserContextData()) {
|
639 | jsonReq.UserContextData = _this6.getUserContextData();
|
640 | }
|
641 |
|
642 | _this6.client.request('RespondToAuthChallenge', jsonReq, function (err, data) {
|
643 | if (err) {
|
644 | return callback.onFailure(err);
|
645 | }
|
646 |
|
647 | var challengeParameters = data.ChallengeParameters;
|
648 | var serverBValue = new _BigInteger["default"](challengeParameters.SRP_B, 16);
|
649 | var salt = new _BigInteger["default"](challengeParameters.SALT, 16);
|
650 | authenticationHelper.getPasswordAuthenticationKey(_this6.deviceKey, _this6.randomPassword, serverBValue, salt, function (errHkdf, hkdf) {
|
651 |
|
652 | if (errHkdf) {
|
653 | return callback.onFailure(errHkdf);
|
654 | }
|
655 |
|
656 | var dateNow = dateHelper.getNowString();
|
657 |
|
658 | var message = _core["default"].lib.WordArray.create(_buffer.Buffer.concat([_buffer.Buffer.from(_this6.deviceGroupKey, 'utf8'), _buffer.Buffer.from(_this6.deviceKey, 'utf8'), _buffer.Buffer.from(challengeParameters.SECRET_BLOCK, 'base64'), _buffer.Buffer.from(dateNow, 'utf8')]));
|
659 |
|
660 | var key = _core["default"].lib.WordArray.create(hkdf);
|
661 |
|
662 | var signatureString = _encBase["default"].stringify((0, _hmacSha["default"])(message, key));
|
663 |
|
664 | var challengeResponses = {};
|
665 | challengeResponses.USERNAME = _this6.username;
|
666 | challengeResponses.PASSWORD_CLAIM_SECRET_BLOCK = challengeParameters.SECRET_BLOCK;
|
667 | challengeResponses.TIMESTAMP = dateNow;
|
668 | challengeResponses.PASSWORD_CLAIM_SIGNATURE = signatureString;
|
669 | challengeResponses.DEVICE_KEY = _this6.deviceKey;
|
670 | var jsonReqResp = {
|
671 | ChallengeName: 'DEVICE_PASSWORD_VERIFIER',
|
672 | ClientId: _this6.pool.getClientId(),
|
673 | ChallengeResponses: challengeResponses,
|
674 | Session: data.Session
|
675 | };
|
676 |
|
677 | if (_this6.getUserContextData()) {
|
678 | jsonReqResp.UserContextData = _this6.getUserContextData();
|
679 | }
|
680 |
|
681 | _this6.client.request('RespondToAuthChallenge', jsonReqResp, function (errAuthenticate, dataAuthenticate) {
|
682 | if (errAuthenticate) {
|
683 | return callback.onFailure(errAuthenticate);
|
684 | }
|
685 |
|
686 | _this6.signInUserSession = _this6.getCognitoUserSession(dataAuthenticate.AuthenticationResult);
|
687 |
|
688 | _this6.cacheTokens();
|
689 |
|
690 | return callback.onSuccess(_this6.signInUserSession);
|
691 | });
|
692 |
|
693 | return undefined;
|
694 | });
|
695 | return undefined;
|
696 | });
|
697 |
|
698 | });
|
699 | }
|
700 | |
701 |
|
702 |
|
703 |
|
704 |
|
705 |
|
706 |
|
707 |
|
708 | ;
|
709 |
|
710 | _proto.confirmRegistration = function confirmRegistration(confirmationCode, forceAliasCreation, callback, clientMetadata) {
|
711 | var jsonReq = {
|
712 | ClientId: this.pool.getClientId(),
|
713 | ConfirmationCode: confirmationCode,
|
714 | Username: this.username,
|
715 | ForceAliasCreation: forceAliasCreation,
|
716 | ClientMetadata: clientMetadata
|
717 | };
|
718 |
|
719 | if (this.getUserContextData()) {
|
720 | jsonReq.UserContextData = this.getUserContextData();
|
721 | }
|
722 |
|
723 | this.client.request('ConfirmSignUp', jsonReq, function (err) {
|
724 | if (err) {
|
725 | return callback(err, null);
|
726 | }
|
727 |
|
728 | return callback(null, 'SUCCESS');
|
729 | });
|
730 | }
|
731 | |
732 |
|
733 |
|
734 |
|
735 |
|
736 |
|
737 |
|
738 |
|
739 |
|
740 |
|
741 |
|
742 | ;
|
743 |
|
744 | _proto.sendCustomChallengeAnswer = function sendCustomChallengeAnswer(answerChallenge, callback, clientMetadata) {
|
745 | var _this7 = this;
|
746 |
|
747 | var challengeResponses = {};
|
748 | challengeResponses.USERNAME = this.username;
|
749 | challengeResponses.ANSWER = answerChallenge;
|
750 | var authenticationHelper = new _AuthenticationHelper["default"](this.pool.getUserPoolId().split('_')[1]);
|
751 | this.getCachedDeviceKeyAndPassword();
|
752 |
|
753 | if (this.deviceKey != null) {
|
754 | challengeResponses.DEVICE_KEY = this.deviceKey;
|
755 | }
|
756 |
|
757 | var jsonReq = {
|
758 | ChallengeName: 'CUSTOM_CHALLENGE',
|
759 | ChallengeResponses: challengeResponses,
|
760 | ClientId: this.pool.getClientId(),
|
761 | Session: this.Session,
|
762 | ClientMetadata: clientMetadata
|
763 | };
|
764 |
|
765 | if (this.getUserContextData()) {
|
766 | jsonReq.UserContextData = this.getUserContextData();
|
767 | }
|
768 |
|
769 | this.client.request('RespondToAuthChallenge', jsonReq, function (err, data) {
|
770 | if (err) {
|
771 | return callback.onFailure(err);
|
772 | }
|
773 |
|
774 | return _this7.authenticateUserInternal(data, authenticationHelper, callback);
|
775 | });
|
776 | }
|
777 | |
778 |
|
779 |
|
780 |
|
781 |
|
782 |
|
783 |
|
784 |
|
785 |
|
786 |
|
787 | ;
|
788 |
|
789 | _proto.sendMFACode = function sendMFACode(confirmationCode, callback, mfaType, clientMetadata) {
|
790 | var _this8 = this;
|
791 |
|
792 | var challengeResponses = {};
|
793 | challengeResponses.USERNAME = this.username;
|
794 | challengeResponses.SMS_MFA_CODE = confirmationCode;
|
795 | var mfaTypeSelection = mfaType || 'SMS_MFA';
|
796 |
|
797 | if (mfaTypeSelection === 'SOFTWARE_TOKEN_MFA') {
|
798 | challengeResponses.SOFTWARE_TOKEN_MFA_CODE = confirmationCode;
|
799 | }
|
800 |
|
801 | if (this.deviceKey != null) {
|
802 | challengeResponses.DEVICE_KEY = this.deviceKey;
|
803 | }
|
804 |
|
805 | var jsonReq = {
|
806 | ChallengeName: mfaTypeSelection,
|
807 | ChallengeResponses: challengeResponses,
|
808 | ClientId: this.pool.getClientId(),
|
809 | Session: this.Session,
|
810 | ClientMetadata: clientMetadata
|
811 | };
|
812 |
|
813 | if (this.getUserContextData()) {
|
814 | jsonReq.UserContextData = this.getUserContextData();
|
815 | }
|
816 |
|
817 | this.client.request('RespondToAuthChallenge', jsonReq, function (err, dataAuthenticate) {
|
818 | if (err) {
|
819 | return callback.onFailure(err);
|
820 | }
|
821 |
|
822 | var challengeName = dataAuthenticate.ChallengeName;
|
823 |
|
824 | if (challengeName === 'DEVICE_SRP_AUTH') {
|
825 | _this8.getDeviceResponse(callback);
|
826 |
|
827 | return undefined;
|
828 | }
|
829 |
|
830 | _this8.signInUserSession = _this8.getCognitoUserSession(dataAuthenticate.AuthenticationResult);
|
831 |
|
832 | _this8.cacheTokens();
|
833 |
|
834 | if (dataAuthenticate.AuthenticationResult.NewDeviceMetadata == null) {
|
835 | return callback.onSuccess(_this8.signInUserSession);
|
836 | }
|
837 |
|
838 | var authenticationHelper = new _AuthenticationHelper["default"](_this8.pool.getUserPoolId().split('_')[1]);
|
839 | authenticationHelper.generateHashDevice(dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey, dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceKey, function (errGenHash) {
|
840 | if (errGenHash) {
|
841 | return callback.onFailure(errGenHash);
|
842 | }
|
843 |
|
844 | var deviceSecretVerifierConfig = {
|
845 | Salt: _buffer.Buffer.from(authenticationHelper.getSaltDevices(), 'hex').toString('base64'),
|
846 | PasswordVerifier: _buffer.Buffer.from(authenticationHelper.getVerifierDevices(), 'hex').toString('base64')
|
847 | };
|
848 | _this8.verifierDevices = deviceSecretVerifierConfig.PasswordVerifier;
|
849 | _this8.deviceGroupKey = dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey;
|
850 | _this8.randomPassword = authenticationHelper.getRandomPassword();
|
851 |
|
852 | _this8.client.request('ConfirmDevice', {
|
853 | DeviceKey: dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceKey,
|
854 | AccessToken: _this8.signInUserSession.getAccessToken().getJwtToken(),
|
855 | DeviceSecretVerifierConfig: deviceSecretVerifierConfig,
|
856 | DeviceName: userAgent
|
857 | }, function (errConfirm, dataConfirm) {
|
858 | if (errConfirm) {
|
859 | return callback.onFailure(errConfirm);
|
860 | }
|
861 |
|
862 | _this8.deviceKey = dataAuthenticate.AuthenticationResult.NewDeviceMetadata.DeviceKey;
|
863 |
|
864 | _this8.cacheDeviceKeyAndPassword();
|
865 |
|
866 | if (dataConfirm.UserConfirmationNecessary === true) {
|
867 | return callback.onSuccess(_this8.signInUserSession, dataConfirm.UserConfirmationNecessary);
|
868 | }
|
869 |
|
870 | return callback.onSuccess(_this8.signInUserSession);
|
871 | });
|
872 |
|
873 | return undefined;
|
874 | });
|
875 | return undefined;
|
876 | });
|
877 | }
|
878 | |
879 |
|
880 |
|
881 |
|
882 |
|
883 |
|
884 |
|
885 |
|
886 | ;
|
887 |
|
888 | _proto.changePassword = function changePassword(oldUserPassword, newUserPassword, callback, clientMetadata) {
|
889 | if (!(this.signInUserSession != null && this.signInUserSession.isValid())) {
|
890 | return callback(new Error('User is not authenticated'), null);
|
891 | }
|
892 |
|
893 | this.client.request('ChangePassword', {
|
894 | PreviousPassword: oldUserPassword,
|
895 | ProposedPassword: newUserPassword,
|
896 | AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),
|
897 | ClientMetadata: clientMetadata
|
898 | }, function (err) {
|
899 | if (err) {
|
900 | return callback(err, null);
|
901 | }
|
902 |
|
903 | return callback(null, 'SUCCESS');
|
904 | });
|
905 | return undefined;
|
906 | }
|
907 | |
908 |
|
909 |
|
910 |
|
911 |
|
912 |
|
913 | ;
|
914 |
|
915 | _proto.enableMFA = function enableMFA(callback) {
|
916 | if (this.signInUserSession == null || !this.signInUserSession.isValid()) {
|
917 | return callback(new Error('User is not authenticated'), null);
|
918 | }
|
919 |
|
920 | var mfaOptions = [];
|
921 | var mfaEnabled = {
|
922 | DeliveryMedium: 'SMS',
|
923 | AttributeName: 'phone_number'
|
924 | };
|
925 | mfaOptions.push(mfaEnabled);
|
926 | this.client.request('SetUserSettings', {
|
927 | MFAOptions: mfaOptions,
|
928 | AccessToken: this.signInUserSession.getAccessToken().getJwtToken()
|
929 | }, function (err) {
|
930 | if (err) {
|
931 | return callback(err, null);
|
932 | }
|
933 |
|
934 | return callback(null, 'SUCCESS');
|
935 | });
|
936 | return undefined;
|
937 | }
|
938 | |
939 |
|
940 |
|
941 |
|
942 |
|
943 |
|
944 |
|
945 | ;
|
946 |
|
947 | _proto.setUserMfaPreference = function setUserMfaPreference(smsMfaSettings, softwareTokenMfaSettings, callback) {
|
948 | if (this.signInUserSession == null || !this.signInUserSession.isValid()) {
|
949 | return callback(new Error('User is not authenticated'), null);
|
950 | }
|
951 |
|
952 | this.client.request('SetUserMFAPreference', {
|
953 | SMSMfaSettings: smsMfaSettings,
|
954 | SoftwareTokenMfaSettings: softwareTokenMfaSettings,
|
955 | AccessToken: this.signInUserSession.getAccessToken().getJwtToken()
|
956 | }, function (err) {
|
957 | if (err) {
|
958 | return callback(err, null);
|
959 | }
|
960 |
|
961 | return callback(null, 'SUCCESS');
|
962 | });
|
963 | return undefined;
|
964 | }
|
965 | |
966 |
|
967 |
|
968 |
|
969 |
|
970 |
|
971 | ;
|
972 |
|
973 | _proto.disableMFA = function disableMFA(callback) {
|
974 | if (this.signInUserSession == null || !this.signInUserSession.isValid()) {
|
975 | return callback(new Error('User is not authenticated'), null);
|
976 | }
|
977 |
|
978 | var mfaOptions = [];
|
979 | this.client.request('SetUserSettings', {
|
980 | MFAOptions: mfaOptions,
|
981 | AccessToken: this.signInUserSession.getAccessToken().getJwtToken()
|
982 | }, function (err) {
|
983 | if (err) {
|
984 | return callback(err, null);
|
985 | }
|
986 |
|
987 | return callback(null, 'SUCCESS');
|
988 | });
|
989 | return undefined;
|
990 | }
|
991 | |
992 |
|
993 |
|
994 |
|
995 |
|
996 |
|
997 | ;
|
998 |
|
999 | _proto.deleteUser = function deleteUser(callback, clientMetadata) {
|
1000 | var _this9 = this;
|
1001 |
|
1002 | if (this.signInUserSession == null || !this.signInUserSession.isValid()) {
|
1003 | return callback(new Error('User is not authenticated'), null);
|
1004 | }
|
1005 |
|
1006 | this.client.request('DeleteUser', {
|
1007 | AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),
|
1008 | ClientMetadata: clientMetadata
|
1009 | }, function (err) {
|
1010 | if (err) {
|
1011 | return callback(err, null);
|
1012 | }
|
1013 |
|
1014 | _this9.clearCachedUser();
|
1015 |
|
1016 | return callback(null, 'SUCCESS');
|
1017 | });
|
1018 | return undefined;
|
1019 | }
|
1020 | |
1021 |
|
1022 |
|
1023 |
|
1024 | |
1025 |
|
1026 |
|
1027 |
|
1028 |
|
1029 |
|
1030 |
|
1031 | ;
|
1032 |
|
1033 | _proto.updateAttributes = function updateAttributes(attributes, callback, clientMetadata) {
|
1034 | if (this.signInUserSession == null || !this.signInUserSession.isValid()) {
|
1035 | return callback(new Error('User is not authenticated'), null);
|
1036 | }
|
1037 |
|
1038 | this.client.request('UpdateUserAttributes', {
|
1039 | AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),
|
1040 | UserAttributes: attributes,
|
1041 | ClientMetadata: clientMetadata
|
1042 | }, function (err) {
|
1043 | if (err) {
|
1044 | return callback(err, null);
|
1045 | }
|
1046 |
|
1047 | return callback(null, 'SUCCESS');
|
1048 | });
|
1049 | return undefined;
|
1050 | }
|
1051 | |
1052 |
|
1053 |
|
1054 |
|
1055 |
|
1056 | ;
|
1057 |
|
1058 | _proto.getUserAttributes = function getUserAttributes(callback) {
|
1059 | if (!(this.signInUserSession != null && this.signInUserSession.isValid())) {
|
1060 | return callback(new Error('User is not authenticated'), null);
|
1061 | }
|
1062 |
|
1063 | this.client.request('GetUser', {
|
1064 | AccessToken: this.signInUserSession.getAccessToken().getJwtToken()
|
1065 | }, function (err, userData) {
|
1066 | if (err) {
|
1067 | return callback(err, null);
|
1068 | }
|
1069 |
|
1070 | var attributeList = [];
|
1071 |
|
1072 | for (var i = 0; i < userData.UserAttributes.length; i++) {
|
1073 | var attribute = {
|
1074 | Name: userData.UserAttributes[i].Name,
|
1075 | Value: userData.UserAttributes[i].Value
|
1076 | };
|
1077 | var userAttribute = new _CognitoUserAttribute["default"](attribute);
|
1078 | attributeList.push(userAttribute);
|
1079 | }
|
1080 |
|
1081 | return callback(null, attributeList);
|
1082 | });
|
1083 | return undefined;
|
1084 | }
|
1085 | |
1086 |
|
1087 |
|
1088 |
|
1089 |
|
1090 | ;
|
1091 |
|
1092 | _proto.getMFAOptions = function getMFAOptions(callback) {
|
1093 | if (!(this.signInUserSession != null && this.signInUserSession.isValid())) {
|
1094 | return callback(new Error('User is not authenticated'), null);
|
1095 | }
|
1096 |
|
1097 | this.client.request('GetUser', {
|
1098 | AccessToken: this.signInUserSession.getAccessToken().getJwtToken()
|
1099 | }, function (err, userData) {
|
1100 | if (err) {
|
1101 | return callback(err, null);
|
1102 | }
|
1103 |
|
1104 | return callback(null, userData.MFAOptions);
|
1105 | });
|
1106 | return undefined;
|
1107 | }
|
1108 | |
1109 |
|
1110 |
|
1111 |
|
1112 |
|
1113 | ;
|
1114 |
|
1115 | _proto.getUserData = function getUserData(callback, params) {
|
1116 | var _this10 = this;
|
1117 |
|
1118 | if (!(this.signInUserSession != null && this.signInUserSession.isValid())) {
|
1119 | this.clearCachedUserData();
|
1120 | return callback(new Error('User is not authenticated'), null);
|
1121 | }
|
1122 |
|
1123 | var bypassCache = params ? params.bypassCache : false;
|
1124 | var userData = this.storage.getItem(this.userDataKey);
|
1125 |
|
1126 | if (!userData || bypassCache) {
|
1127 | this.client.request('GetUser', {
|
1128 | AccessToken: this.signInUserSession.getAccessToken().getJwtToken()
|
1129 | }, function (err, latestUserData) {
|
1130 | if (err) {
|
1131 | return callback(err, null);
|
1132 | }
|
1133 |
|
1134 | _this10.cacheUserData(latestUserData);
|
1135 |
|
1136 | var refresh = _this10.signInUserSession.getRefreshToken();
|
1137 |
|
1138 | if (refresh && refresh.getToken()) {
|
1139 | _this10.refreshSession(refresh, function (refreshError, data) {
|
1140 | if (refreshError) {
|
1141 | return callback(refreshError, null);
|
1142 | }
|
1143 |
|
1144 | return callback(null, latestUserData);
|
1145 | });
|
1146 | } else {
|
1147 | return callback(null, latestUserData);
|
1148 | }
|
1149 | });
|
1150 | } else {
|
1151 | try {
|
1152 | return callback(null, JSON.parse(userData));
|
1153 | } catch (err) {
|
1154 | this.clearCachedUserData();
|
1155 | return callback(err, null);
|
1156 | }
|
1157 | }
|
1158 |
|
1159 | return undefined;
|
1160 | }
|
1161 | |
1162 |
|
1163 |
|
1164 |
|
1165 |
|
1166 |
|
1167 | ;
|
1168 |
|
1169 | _proto.deleteAttributes = function deleteAttributes(attributeList, callback) {
|
1170 | if (!(this.signInUserSession != null && this.signInUserSession.isValid())) {
|
1171 | return callback(new Error('User is not authenticated'), null);
|
1172 | }
|
1173 |
|
1174 | this.client.request('DeleteUserAttributes', {
|
1175 | UserAttributeNames: attributeList,
|
1176 | AccessToken: this.signInUserSession.getAccessToken().getJwtToken()
|
1177 | }, function (err) {
|
1178 | if (err) {
|
1179 | return callback(err, null);
|
1180 | }
|
1181 |
|
1182 | return callback(null, 'SUCCESS');
|
1183 | });
|
1184 | return undefined;
|
1185 | }
|
1186 | |
1187 |
|
1188 |
|
1189 |
|
1190 |
|
1191 |
|
1192 | ;
|
1193 |
|
1194 | _proto.resendConfirmationCode = function resendConfirmationCode(callback, clientMetadata) {
|
1195 | var jsonReq = {
|
1196 | ClientId: this.pool.getClientId(),
|
1197 | Username: this.username,
|
1198 | ClientMetadata: clientMetadata
|
1199 | };
|
1200 | this.client.request('ResendConfirmationCode', jsonReq, function (err, result) {
|
1201 | if (err) {
|
1202 | return callback(err, null);
|
1203 | }
|
1204 |
|
1205 | return callback(null, result);
|
1206 | });
|
1207 | }
|
1208 | |
1209 |
|
1210 |
|
1211 |
|
1212 |
|
1213 |
|
1214 |
|
1215 | ;
|
1216 |
|
1217 | _proto.getSession = function getSession(callback) {
|
1218 | if (this.username == null) {
|
1219 | return callback(new Error('Username is null. Cannot retrieve a new session'), null);
|
1220 | }
|
1221 |
|
1222 | if (this.signInUserSession != null && this.signInUserSession.isValid()) {
|
1223 | return callback(null, this.signInUserSession);
|
1224 | }
|
1225 |
|
1226 | var keyPrefix = "CognitoIdentityServiceProvider." + this.pool.getClientId() + "." + this.username;
|
1227 | var idTokenKey = keyPrefix + ".idToken";
|
1228 | var accessTokenKey = keyPrefix + ".accessToken";
|
1229 | var refreshTokenKey = keyPrefix + ".refreshToken";
|
1230 | var clockDriftKey = keyPrefix + ".clockDrift";
|
1231 |
|
1232 | if (this.storage.getItem(idTokenKey)) {
|
1233 | var idToken = new _CognitoIdToken["default"]({
|
1234 | IdToken: this.storage.getItem(idTokenKey)
|
1235 | });
|
1236 | var accessToken = new _CognitoAccessToken["default"]({
|
1237 | AccessToken: this.storage.getItem(accessTokenKey)
|
1238 | });
|
1239 | var refreshToken = new _CognitoRefreshToken["default"]({
|
1240 | RefreshToken: this.storage.getItem(refreshTokenKey)
|
1241 | });
|
1242 | var clockDrift = parseInt(this.storage.getItem(clockDriftKey), 0) || 0;
|
1243 | var sessionData = {
|
1244 | IdToken: idToken,
|
1245 | AccessToken: accessToken,
|
1246 | RefreshToken: refreshToken,
|
1247 | ClockDrift: clockDrift
|
1248 | };
|
1249 | var cachedSession = new _CognitoUserSession["default"](sessionData);
|
1250 |
|
1251 | if (cachedSession.isValid()) {
|
1252 | this.signInUserSession = cachedSession;
|
1253 | return callback(null, this.signInUserSession);
|
1254 | }
|
1255 |
|
1256 | if (!refreshToken.getToken()) {
|
1257 | return callback(new Error('Cannot retrieve a new session. Please authenticate.'), null);
|
1258 | }
|
1259 |
|
1260 | this.refreshSession(refreshToken, callback);
|
1261 | } else {
|
1262 | callback(new Error('Local storage is missing an ID Token, Please authenticate'), null);
|
1263 | }
|
1264 |
|
1265 | return undefined;
|
1266 | }
|
1267 | |
1268 |
|
1269 |
|
1270 |
|
1271 |
|
1272 |
|
1273 |
|
1274 | ;
|
1275 |
|
1276 | _proto.refreshSession = function refreshSession(refreshToken, callback, clientMetadata) {
|
1277 | var _this11 = this;
|
1278 |
|
1279 | var authParameters = {};
|
1280 | authParameters.REFRESH_TOKEN = refreshToken.getToken();
|
1281 | var keyPrefix = "CognitoIdentityServiceProvider." + this.pool.getClientId();
|
1282 | var lastUserKey = keyPrefix + ".LastAuthUser";
|
1283 |
|
1284 | if (this.storage.getItem(lastUserKey)) {
|
1285 | this.username = this.storage.getItem(lastUserKey);
|
1286 | var deviceKeyKey = keyPrefix + "." + this.username + ".deviceKey";
|
1287 | this.deviceKey = this.storage.getItem(deviceKeyKey);
|
1288 | authParameters.DEVICE_KEY = this.deviceKey;
|
1289 | }
|
1290 |
|
1291 | var jsonReq = {
|
1292 | ClientId: this.pool.getClientId(),
|
1293 | AuthFlow: 'REFRESH_TOKEN_AUTH',
|
1294 | AuthParameters: authParameters,
|
1295 | ClientMetadata: clientMetadata
|
1296 | };
|
1297 |
|
1298 | if (this.getUserContextData()) {
|
1299 | jsonReq.UserContextData = this.getUserContextData();
|
1300 | }
|
1301 |
|
1302 | this.client.request('InitiateAuth', jsonReq, function (err, authResult) {
|
1303 | if (err) {
|
1304 | if (err.code === 'NotAuthorizedException') {
|
1305 | _this11.clearCachedUser();
|
1306 | }
|
1307 |
|
1308 | return callback(err, null);
|
1309 | }
|
1310 |
|
1311 | if (authResult) {
|
1312 | var authenticationResult = authResult.AuthenticationResult;
|
1313 |
|
1314 | if (!Object.prototype.hasOwnProperty.call(authenticationResult, 'RefreshToken')) {
|
1315 | authenticationResult.RefreshToken = refreshToken.getToken();
|
1316 | }
|
1317 |
|
1318 | _this11.signInUserSession = _this11.getCognitoUserSession(authenticationResult);
|
1319 |
|
1320 | _this11.cacheTokens();
|
1321 |
|
1322 | return callback(null, _this11.signInUserSession);
|
1323 | }
|
1324 |
|
1325 | return undefined;
|
1326 | });
|
1327 | }
|
1328 | |
1329 |
|
1330 |
|
1331 |
|
1332 | ;
|
1333 |
|
1334 | _proto.cacheTokens = function cacheTokens() {
|
1335 | var keyPrefix = "CognitoIdentityServiceProvider." + this.pool.getClientId();
|
1336 | var idTokenKey = keyPrefix + "." + this.username + ".idToken";
|
1337 | var accessTokenKey = keyPrefix + "." + this.username + ".accessToken";
|
1338 | var refreshTokenKey = keyPrefix + "." + this.username + ".refreshToken";
|
1339 | var clockDriftKey = keyPrefix + "." + this.username + ".clockDrift";
|
1340 | var lastUserKey = keyPrefix + ".LastAuthUser";
|
1341 | this.storage.setItem(idTokenKey, this.signInUserSession.getIdToken().getJwtToken());
|
1342 | this.storage.setItem(accessTokenKey, this.signInUserSession.getAccessToken().getJwtToken());
|
1343 | this.storage.setItem(refreshTokenKey, this.signInUserSession.getRefreshToken().getToken());
|
1344 | this.storage.setItem(clockDriftKey, "" + this.signInUserSession.getClockDrift());
|
1345 | this.storage.setItem(lastUserKey, this.username);
|
1346 | }
|
1347 | |
1348 |
|
1349 |
|
1350 | ;
|
1351 |
|
1352 | _proto.cacheUserData = function cacheUserData(userData) {
|
1353 | this.storage.setItem(this.userDataKey, JSON.stringify(userData));
|
1354 | }
|
1355 | |
1356 |
|
1357 |
|
1358 | ;
|
1359 |
|
1360 | _proto.clearCachedUserData = function clearCachedUserData() {
|
1361 | this.storage.removeItem(this.userDataKey);
|
1362 | };
|
1363 |
|
1364 | _proto.clearCachedUser = function clearCachedUser() {
|
1365 | this.clearCachedTokens();
|
1366 | this.clearCachedUserData();
|
1367 | }
|
1368 | |
1369 |
|
1370 |
|
1371 |
|
1372 | ;
|
1373 |
|
1374 | _proto.cacheDeviceKeyAndPassword = function cacheDeviceKeyAndPassword() {
|
1375 | var keyPrefix = "CognitoIdentityServiceProvider." + this.pool.getClientId() + "." + this.username;
|
1376 | var deviceKeyKey = keyPrefix + ".deviceKey";
|
1377 | var randomPasswordKey = keyPrefix + ".randomPasswordKey";
|
1378 | var deviceGroupKeyKey = keyPrefix + ".deviceGroupKey";
|
1379 | this.storage.setItem(deviceKeyKey, this.deviceKey);
|
1380 | this.storage.setItem(randomPasswordKey, this.randomPassword);
|
1381 | this.storage.setItem(deviceGroupKeyKey, this.deviceGroupKey);
|
1382 | }
|
1383 | |
1384 |
|
1385 |
|
1386 |
|
1387 | ;
|
1388 |
|
1389 | _proto.getCachedDeviceKeyAndPassword = function getCachedDeviceKeyAndPassword() {
|
1390 | var keyPrefix = "CognitoIdentityServiceProvider." + this.pool.getClientId() + "." + this.username;
|
1391 | var deviceKeyKey = keyPrefix + ".deviceKey";
|
1392 | var randomPasswordKey = keyPrefix + ".randomPasswordKey";
|
1393 | var deviceGroupKeyKey = keyPrefix + ".deviceGroupKey";
|
1394 |
|
1395 | if (this.storage.getItem(deviceKeyKey)) {
|
1396 | this.deviceKey = this.storage.getItem(deviceKeyKey);
|
1397 | this.randomPassword = this.storage.getItem(randomPasswordKey);
|
1398 | this.deviceGroupKey = this.storage.getItem(deviceGroupKeyKey);
|
1399 | }
|
1400 | }
|
1401 | |
1402 |
|
1403 |
|
1404 |
|
1405 | ;
|
1406 |
|
1407 | _proto.clearCachedDeviceKeyAndPassword = function clearCachedDeviceKeyAndPassword() {
|
1408 | var keyPrefix = "CognitoIdentityServiceProvider." + this.pool.getClientId() + "." + this.username;
|
1409 | var deviceKeyKey = keyPrefix + ".deviceKey";
|
1410 | var randomPasswordKey = keyPrefix + ".randomPasswordKey";
|
1411 | var deviceGroupKeyKey = keyPrefix + ".deviceGroupKey";
|
1412 | this.storage.removeItem(deviceKeyKey);
|
1413 | this.storage.removeItem(randomPasswordKey);
|
1414 | this.storage.removeItem(deviceGroupKeyKey);
|
1415 | }
|
1416 | |
1417 |
|
1418 |
|
1419 |
|
1420 | ;
|
1421 |
|
1422 | _proto.clearCachedTokens = function clearCachedTokens() {
|
1423 | var keyPrefix = "CognitoIdentityServiceProvider." + this.pool.getClientId();
|
1424 | var idTokenKey = keyPrefix + "." + this.username + ".idToken";
|
1425 | var accessTokenKey = keyPrefix + "." + this.username + ".accessToken";
|
1426 | var refreshTokenKey = keyPrefix + "." + this.username + ".refreshToken";
|
1427 | var lastUserKey = keyPrefix + ".LastAuthUser";
|
1428 | var clockDriftKey = keyPrefix + "." + this.username + ".clockDrift";
|
1429 | this.storage.removeItem(idTokenKey);
|
1430 | this.storage.removeItem(accessTokenKey);
|
1431 | this.storage.removeItem(refreshTokenKey);
|
1432 | this.storage.removeItem(lastUserKey);
|
1433 | this.storage.removeItem(clockDriftKey);
|
1434 | }
|
1435 | |
1436 |
|
1437 |
|
1438 |
|
1439 |
|
1440 |
|
1441 | ;
|
1442 |
|
1443 | _proto.getCognitoUserSession = function getCognitoUserSession(authResult) {
|
1444 | var idToken = new _CognitoIdToken["default"](authResult);
|
1445 | var accessToken = new _CognitoAccessToken["default"](authResult);
|
1446 | var refreshToken = new _CognitoRefreshToken["default"](authResult);
|
1447 | var sessionData = {
|
1448 | IdToken: idToken,
|
1449 | AccessToken: accessToken,
|
1450 | RefreshToken: refreshToken
|
1451 | };
|
1452 | return new _CognitoUserSession["default"](sessionData);
|
1453 | }
|
1454 | |
1455 |
|
1456 |
|
1457 |
|
1458 |
|
1459 |
|
1460 |
|
1461 |
|
1462 |
|
1463 |
|
1464 | ;
|
1465 |
|
1466 | _proto.forgotPassword = function forgotPassword(callback, clientMetadata) {
|
1467 | var jsonReq = {
|
1468 | ClientId: this.pool.getClientId(),
|
1469 | Username: this.username,
|
1470 | ClientMetadata: clientMetadata
|
1471 | };
|
1472 |
|
1473 | if (this.getUserContextData()) {
|
1474 | jsonReq.UserContextData = this.getUserContextData();
|
1475 | }
|
1476 |
|
1477 | this.client.request('ForgotPassword', jsonReq, function (err, data) {
|
1478 | if (err) {
|
1479 | return callback.onFailure(err);
|
1480 | }
|
1481 |
|
1482 | if (typeof callback.inputVerificationCode === 'function') {
|
1483 | return callback.inputVerificationCode(data);
|
1484 | }
|
1485 |
|
1486 | return callback.onSuccess(data);
|
1487 | });
|
1488 | }
|
1489 | |
1490 |
|
1491 |
|
1492 |
|
1493 |
|
1494 |
|
1495 |
|
1496 |
|
1497 |
|
1498 |
|
1499 | ;
|
1500 |
|
1501 | _proto.confirmPassword = function confirmPassword(confirmationCode, newPassword, callback, clientMetadata) {
|
1502 | var jsonReq = {
|
1503 | ClientId: this.pool.getClientId(),
|
1504 | Username: this.username,
|
1505 | ConfirmationCode: confirmationCode,
|
1506 | Password: newPassword,
|
1507 | ClientMetadata: clientMetadata
|
1508 | };
|
1509 |
|
1510 | if (this.getUserContextData()) {
|
1511 | jsonReq.UserContextData = this.getUserContextData();
|
1512 | }
|
1513 |
|
1514 | this.client.request('ConfirmForgotPassword', jsonReq, function (err) {
|
1515 | if (err) {
|
1516 | return callback.onFailure(err);
|
1517 | }
|
1518 |
|
1519 | return callback.onSuccess();
|
1520 | });
|
1521 | }
|
1522 | |
1523 |
|
1524 |
|
1525 |
|
1526 |
|
1527 |
|
1528 |
|
1529 |
|
1530 |
|
1531 | ;
|
1532 |
|
1533 | _proto.getAttributeVerificationCode = function getAttributeVerificationCode(attributeName, callback, clientMetadata) {
|
1534 | if (this.signInUserSession == null || !this.signInUserSession.isValid()) {
|
1535 | return callback.onFailure(new Error('User is not authenticated'));
|
1536 | }
|
1537 |
|
1538 | this.client.request('GetUserAttributeVerificationCode', {
|
1539 | AttributeName: attributeName,
|
1540 | AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),
|
1541 | ClientMetadata: clientMetadata
|
1542 | }, function (err, data) {
|
1543 | if (err) {
|
1544 | return callback.onFailure(err);
|
1545 | }
|
1546 |
|
1547 | if (typeof callback.inputVerificationCode === 'function') {
|
1548 | return callback.inputVerificationCode(data);
|
1549 | }
|
1550 |
|
1551 | return callback.onSuccess();
|
1552 | });
|
1553 | return undefined;
|
1554 | }
|
1555 | |
1556 |
|
1557 |
|
1558 |
|
1559 |
|
1560 |
|
1561 |
|
1562 |
|
1563 |
|
1564 | ;
|
1565 |
|
1566 | _proto.verifyAttribute = function verifyAttribute(attributeName, confirmationCode, callback) {
|
1567 | if (this.signInUserSession == null || !this.signInUserSession.isValid()) {
|
1568 | return callback.onFailure(new Error('User is not authenticated'));
|
1569 | }
|
1570 |
|
1571 | this.client.request('VerifyUserAttribute', {
|
1572 | AttributeName: attributeName,
|
1573 | Code: confirmationCode,
|
1574 | AccessToken: this.signInUserSession.getAccessToken().getJwtToken()
|
1575 | }, function (err) {
|
1576 | if (err) {
|
1577 | return callback.onFailure(err);
|
1578 | }
|
1579 |
|
1580 | return callback.onSuccess('SUCCESS');
|
1581 | });
|
1582 | return undefined;
|
1583 | }
|
1584 | |
1585 |
|
1586 |
|
1587 |
|
1588 |
|
1589 |
|
1590 |
|
1591 | ;
|
1592 |
|
1593 | _proto.getDevice = function getDevice(callback) {
|
1594 | if (this.signInUserSession == null || !this.signInUserSession.isValid()) {
|
1595 | return callback.onFailure(new Error('User is not authenticated'));
|
1596 | }
|
1597 |
|
1598 | this.client.request('GetDevice', {
|
1599 | AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),
|
1600 | DeviceKey: this.deviceKey
|
1601 | }, function (err, data) {
|
1602 | if (err) {
|
1603 | return callback.onFailure(err);
|
1604 | }
|
1605 |
|
1606 | return callback.onSuccess(data);
|
1607 | });
|
1608 | return undefined;
|
1609 | }
|
1610 | |
1611 |
|
1612 |
|
1613 |
|
1614 |
|
1615 |
|
1616 |
|
1617 |
|
1618 | ;
|
1619 |
|
1620 | _proto.forgetSpecificDevice = function forgetSpecificDevice(deviceKey, callback) {
|
1621 | if (this.signInUserSession == null || !this.signInUserSession.isValid()) {
|
1622 | return callback.onFailure(new Error('User is not authenticated'));
|
1623 | }
|
1624 |
|
1625 | this.client.request('ForgetDevice', {
|
1626 | AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),
|
1627 | DeviceKey: deviceKey
|
1628 | }, function (err) {
|
1629 | if (err) {
|
1630 | return callback.onFailure(err);
|
1631 | }
|
1632 |
|
1633 | return callback.onSuccess('SUCCESS');
|
1634 | });
|
1635 | return undefined;
|
1636 | }
|
1637 | |
1638 |
|
1639 |
|
1640 |
|
1641 |
|
1642 |
|
1643 |
|
1644 | ;
|
1645 |
|
1646 | _proto.forgetDevice = function forgetDevice(callback) {
|
1647 | var _this12 = this;
|
1648 |
|
1649 | this.forgetSpecificDevice(this.deviceKey, {
|
1650 | onFailure: callback.onFailure,
|
1651 | onSuccess: function onSuccess(result) {
|
1652 | _this12.deviceKey = null;
|
1653 | _this12.deviceGroupKey = null;
|
1654 | _this12.randomPassword = null;
|
1655 |
|
1656 | _this12.clearCachedDeviceKeyAndPassword();
|
1657 |
|
1658 | return callback.onSuccess(result);
|
1659 | }
|
1660 | });
|
1661 | }
|
1662 | |
1663 |
|
1664 |
|
1665 |
|
1666 |
|
1667 |
|
1668 |
|
1669 | ;
|
1670 |
|
1671 | _proto.setDeviceStatusRemembered = function setDeviceStatusRemembered(callback) {
|
1672 | if (this.signInUserSession == null || !this.signInUserSession.isValid()) {
|
1673 | return callback.onFailure(new Error('User is not authenticated'));
|
1674 | }
|
1675 |
|
1676 | this.client.request('UpdateDeviceStatus', {
|
1677 | AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),
|
1678 | DeviceKey: this.deviceKey,
|
1679 | DeviceRememberedStatus: 'remembered'
|
1680 | }, function (err) {
|
1681 | if (err) {
|
1682 | return callback.onFailure(err);
|
1683 | }
|
1684 |
|
1685 | return callback.onSuccess('SUCCESS');
|
1686 | });
|
1687 | return undefined;
|
1688 | }
|
1689 | |
1690 |
|
1691 |
|
1692 |
|
1693 |
|
1694 |
|
1695 |
|
1696 | ;
|
1697 |
|
1698 | _proto.setDeviceStatusNotRemembered = function setDeviceStatusNotRemembered(callback) {
|
1699 | if (this.signInUserSession == null || !this.signInUserSession.isValid()) {
|
1700 | return callback.onFailure(new Error('User is not authenticated'));
|
1701 | }
|
1702 |
|
1703 | this.client.request('UpdateDeviceStatus', {
|
1704 | AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),
|
1705 | DeviceKey: this.deviceKey,
|
1706 | DeviceRememberedStatus: 'not_remembered'
|
1707 | }, function (err) {
|
1708 | if (err) {
|
1709 | return callback.onFailure(err);
|
1710 | }
|
1711 |
|
1712 | return callback.onSuccess('SUCCESS');
|
1713 | });
|
1714 | return undefined;
|
1715 | }
|
1716 | |
1717 |
|
1718 |
|
1719 |
|
1720 |
|
1721 |
|
1722 |
|
1723 |
|
1724 |
|
1725 |
|
1726 | ;
|
1727 |
|
1728 | _proto.listDevices = function listDevices(limit, paginationToken, callback) {
|
1729 | if (this.signInUserSession == null || !this.signInUserSession.isValid()) {
|
1730 | return callback.onFailure(new Error('User is not authenticated'));
|
1731 | }
|
1732 |
|
1733 | this.client.request('ListDevices', {
|
1734 | AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),
|
1735 | Limit: limit,
|
1736 | PaginationToken: paginationToken
|
1737 | }, function (err, data) {
|
1738 | if (err) {
|
1739 | return callback.onFailure(err);
|
1740 | }
|
1741 |
|
1742 | return callback.onSuccess(data);
|
1743 | });
|
1744 | return undefined;
|
1745 | }
|
1746 | |
1747 |
|
1748 |
|
1749 |
|
1750 |
|
1751 |
|
1752 |
|
1753 | ;
|
1754 |
|
1755 | _proto.globalSignOut = function globalSignOut(callback) {
|
1756 | var _this13 = this;
|
1757 |
|
1758 | if (this.signInUserSession == null || !this.signInUserSession.isValid()) {
|
1759 | return callback.onFailure(new Error('User is not authenticated'));
|
1760 | }
|
1761 |
|
1762 | this.client.request('GlobalSignOut', {
|
1763 | AccessToken: this.signInUserSession.getAccessToken().getJwtToken()
|
1764 | }, function (err) {
|
1765 | if (err) {
|
1766 | return callback.onFailure(err);
|
1767 | }
|
1768 |
|
1769 | _this13.clearCachedUser();
|
1770 |
|
1771 | return callback.onSuccess('SUCCESS');
|
1772 | });
|
1773 | return undefined;
|
1774 | }
|
1775 | |
1776 |
|
1777 |
|
1778 |
|
1779 | ;
|
1780 |
|
1781 | _proto.signOut = function signOut() {
|
1782 | this.signInUserSession = null;
|
1783 | this.clearCachedUser();
|
1784 | }
|
1785 | |
1786 |
|
1787 |
|
1788 |
|
1789 |
|
1790 |
|
1791 | ;
|
1792 |
|
1793 | _proto.sendMFASelectionAnswer = function sendMFASelectionAnswer(answerChallenge, callback) {
|
1794 | var _this14 = this;
|
1795 |
|
1796 | var challengeResponses = {};
|
1797 | challengeResponses.USERNAME = this.username;
|
1798 | challengeResponses.ANSWER = answerChallenge;
|
1799 | var jsonReq = {
|
1800 | ChallengeName: 'SELECT_MFA_TYPE',
|
1801 | ChallengeResponses: challengeResponses,
|
1802 | ClientId: this.pool.getClientId(),
|
1803 | Session: this.Session
|
1804 | };
|
1805 |
|
1806 | if (this.getUserContextData()) {
|
1807 | jsonReq.UserContextData = this.getUserContextData();
|
1808 | }
|
1809 |
|
1810 | this.client.request('RespondToAuthChallenge', jsonReq, function (err, data) {
|
1811 | if (err) {
|
1812 | return callback.onFailure(err);
|
1813 | }
|
1814 |
|
1815 | _this14.Session = data.Session;
|
1816 |
|
1817 | if (answerChallenge === 'SMS_MFA') {
|
1818 | return callback.mfaRequired(data.challengeName, data.challengeParameters);
|
1819 | }
|
1820 |
|
1821 | if (answerChallenge === 'SOFTWARE_TOKEN_MFA') {
|
1822 | return callback.totpRequired(data.challengeName, data.challengeParameters);
|
1823 | }
|
1824 |
|
1825 | return undefined;
|
1826 | });
|
1827 | }
|
1828 | |
1829 |
|
1830 |
|
1831 |
|
1832 | ;
|
1833 |
|
1834 | _proto.getUserContextData = function getUserContextData() {
|
1835 | var pool = this.pool;
|
1836 | return pool.getUserContextData(this.username);
|
1837 | }
|
1838 | |
1839 |
|
1840 |
|
1841 |
|
1842 |
|
1843 | ;
|
1844 |
|
1845 | _proto.associateSoftwareToken = function associateSoftwareToken(callback) {
|
1846 | var _this15 = this;
|
1847 |
|
1848 | if (!(this.signInUserSession != null && this.signInUserSession.isValid())) {
|
1849 | this.client.request('AssociateSoftwareToken', {
|
1850 | Session: this.Session
|
1851 | }, function (err, data) {
|
1852 | if (err) {
|
1853 | return callback.onFailure(err);
|
1854 | }
|
1855 |
|
1856 | _this15.Session = data.Session;
|
1857 | return callback.associateSecretCode(data.SecretCode);
|
1858 | });
|
1859 | } else {
|
1860 | this.client.request('AssociateSoftwareToken', {
|
1861 | AccessToken: this.signInUserSession.getAccessToken().getJwtToken()
|
1862 | }, function (err, data) {
|
1863 | if (err) {
|
1864 | return callback.onFailure(err);
|
1865 | }
|
1866 |
|
1867 | return callback.associateSecretCode(data.SecretCode);
|
1868 | });
|
1869 | }
|
1870 | }
|
1871 | |
1872 |
|
1873 |
|
1874 |
|
1875 |
|
1876 |
|
1877 |
|
1878 | ;
|
1879 |
|
1880 | _proto.verifySoftwareToken = function verifySoftwareToken(totpCode, friendlyDeviceName, callback) {
|
1881 | var _this16 = this;
|
1882 |
|
1883 | if (!(this.signInUserSession != null && this.signInUserSession.isValid())) {
|
1884 | this.client.request('VerifySoftwareToken', {
|
1885 | Session: this.Session,
|
1886 | UserCode: totpCode,
|
1887 | FriendlyDeviceName: friendlyDeviceName
|
1888 | }, function (err, data) {
|
1889 | if (err) {
|
1890 | return callback.onFailure(err);
|
1891 | }
|
1892 |
|
1893 | _this16.Session = data.Session;
|
1894 | var challengeResponses = {};
|
1895 | challengeResponses.USERNAME = _this16.username;
|
1896 | var jsonReq = {
|
1897 | ChallengeName: 'MFA_SETUP',
|
1898 | ClientId: _this16.pool.getClientId(),
|
1899 | ChallengeResponses: challengeResponses,
|
1900 | Session: _this16.Session
|
1901 | };
|
1902 |
|
1903 | if (_this16.getUserContextData()) {
|
1904 | jsonReq.UserContextData = _this16.getUserContextData();
|
1905 | }
|
1906 |
|
1907 | _this16.client.request('RespondToAuthChallenge', jsonReq, function (errRespond, dataRespond) {
|
1908 | if (errRespond) {
|
1909 | return callback.onFailure(errRespond);
|
1910 | }
|
1911 |
|
1912 | _this16.signInUserSession = _this16.getCognitoUserSession(dataRespond.AuthenticationResult);
|
1913 |
|
1914 | _this16.cacheTokens();
|
1915 |
|
1916 | return callback.onSuccess(_this16.signInUserSession);
|
1917 | });
|
1918 |
|
1919 | return undefined;
|
1920 | });
|
1921 | } else {
|
1922 | this.client.request('VerifySoftwareToken', {
|
1923 | AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),
|
1924 | UserCode: totpCode,
|
1925 | FriendlyDeviceName: friendlyDeviceName
|
1926 | }, function (err, data) {
|
1927 | if (err) {
|
1928 | return callback.onFailure(err);
|
1929 | }
|
1930 |
|
1931 | return callback.onSuccess(data);
|
1932 | });
|
1933 | }
|
1934 | };
|
1935 |
|
1936 | return CognitoUser;
|
1937 | }();
|
1938 |
|
1939 | exports["default"] = CognitoUser; |
\ | No newline at end of file |