@vardario/cognito-client 5.0.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/browser.js CHANGED
@@ -26,15 +26,15 @@ var COMMON_EXCEPTIONS = [
26
26
  "ThrottlingException" /* ThrottlingException */,
27
27
  "ValidationError" /* ValidationError */
28
28
  ];
29
- var AssociateSoftwareTokenException = /* @__PURE__ */ ((AssociateSoftwareTokenException2) => {
30
- AssociateSoftwareTokenException2["ConcurrentModificationException"] = "ConcurrentModificationException";
31
- AssociateSoftwareTokenException2["ForbiddenException"] = "ForbiddenException";
32
- AssociateSoftwareTokenException2["InternalErrorException"] = "InternalErrorException";
33
- AssociateSoftwareTokenException2["InvalidParameterException"] = "InvalidParameterException";
34
- AssociateSoftwareTokenException2["NotAuthorizedException"] = "NotAuthorizedException";
35
- AssociateSoftwareTokenException2["ResourceNotFoundException"] = "ResourceNotFoundException";
36
- AssociateSoftwareTokenException2["SoftwareTokenMFANotFoundException"] = "SoftwareTokenMFANotFoundException";
37
- return AssociateSoftwareTokenException2;
29
+ var AssociateSoftwareTokenException = /* @__PURE__ */ ((AssociateSoftwareTokenException3) => {
30
+ AssociateSoftwareTokenException3["ConcurrentModificationException"] = "ConcurrentModificationException";
31
+ AssociateSoftwareTokenException3["ForbiddenException"] = "ForbiddenException";
32
+ AssociateSoftwareTokenException3["InternalErrorException"] = "InternalErrorException";
33
+ AssociateSoftwareTokenException3["InvalidParameterException"] = "InvalidParameterException";
34
+ AssociateSoftwareTokenException3["NotAuthorizedException"] = "NotAuthorizedException";
35
+ AssociateSoftwareTokenException3["ResourceNotFoundException"] = "ResourceNotFoundException";
36
+ AssociateSoftwareTokenException3["SoftwareTokenMFANotFoundException"] = "SoftwareTokenMFANotFoundException";
37
+ return AssociateSoftwareTokenException3;
38
38
  })(AssociateSoftwareTokenException || {});
39
39
  var ChangePasswordException = /* @__PURE__ */ ((ChangePasswordException3) => {
40
40
  ChangePasswordException3["ForbiddenException"] = "ForbiddenException";
@@ -158,17 +158,17 @@ var ForgotPasswordException = /* @__PURE__ */ ((ForgotPasswordException3) => {
158
158
  ForgotPasswordException3["UserNotFoundException"] = "UserNotFoundException";
159
159
  return ForgotPasswordException3;
160
160
  })(ForgotPasswordException || {});
161
- var GetUserException = /* @__PURE__ */ ((GetUserException2) => {
162
- GetUserException2["ForbiddenException"] = "ForbiddenException";
163
- GetUserException2["InternalErrorException"] = "InternalErrorException";
164
- GetUserException2["InvalidParameterException"] = "InvalidParameterException";
165
- GetUserException2["NotAuthorizedException"] = "NotAuthorizedException";
166
- GetUserException2["PasswordResetRequiredException"] = "PasswordResetRequiredException";
167
- GetUserException2["ResourceNotFoundException"] = "ResourceNotFoundException";
168
- GetUserException2["TooManyRequestsException"] = "TooManyRequestsException";
169
- GetUserException2["UserNotConfirmedException"] = "UserNotConfirmedException";
170
- GetUserException2["UserNotFoundException"] = "UserNotFoundException";
171
- return GetUserException2;
161
+ var GetUserException = /* @__PURE__ */ ((GetUserException3) => {
162
+ GetUserException3["ForbiddenException"] = "ForbiddenException";
163
+ GetUserException3["InternalErrorException"] = "InternalErrorException";
164
+ GetUserException3["InvalidParameterException"] = "InvalidParameterException";
165
+ GetUserException3["NotAuthorizedException"] = "NotAuthorizedException";
166
+ GetUserException3["PasswordResetRequiredException"] = "PasswordResetRequiredException";
167
+ GetUserException3["ResourceNotFoundException"] = "ResourceNotFoundException";
168
+ GetUserException3["TooManyRequestsException"] = "TooManyRequestsException";
169
+ GetUserException3["UserNotConfirmedException"] = "UserNotConfirmedException";
170
+ GetUserException3["UserNotFoundException"] = "UserNotFoundException";
171
+ return GetUserException3;
172
172
  })(GetUserException || {});
173
173
  var GetIdException = /* @__PURE__ */ ((GetIdException2) => {
174
174
  GetIdException2["ExternalServiceException"] = "ExternalServiceException";
@@ -283,16 +283,16 @@ var RespondToAuthChallengeException = /* @__PURE__ */ ((RespondToAuthChallengeEx
283
283
  RespondToAuthChallengeException3["UserNotFoundException"] = "UserNotFoundException";
284
284
  return RespondToAuthChallengeException3;
285
285
  })(RespondToAuthChallengeException || {});
286
- var SetUserMFAPreferenceException = /* @__PURE__ */ ((SetUserMFAPreferenceException2) => {
287
- SetUserMFAPreferenceException2["ForbiddenException"] = "ForbiddenException";
288
- SetUserMFAPreferenceException2["InternalErrorException"] = "InternalErrorException";
289
- SetUserMFAPreferenceException2["InvalidParameterException"] = "InvalidParameterException";
290
- SetUserMFAPreferenceException2["NotAuthorizedException"] = "NotAuthorizedException";
291
- SetUserMFAPreferenceException2["PasswordResetRequiredException"] = "PasswordResetRequiredException";
292
- SetUserMFAPreferenceException2["ResourceNotFoundException"] = "ResourceNotFoundException";
293
- SetUserMFAPreferenceException2["UserNotConfirmedException"] = "UserNotConfirmedException";
294
- SetUserMFAPreferenceException2["UserNotFoundException"] = "UserNotFoundException";
295
- return SetUserMFAPreferenceException2;
286
+ var SetUserMFAPreferenceException = /* @__PURE__ */ ((SetUserMFAPreferenceException3) => {
287
+ SetUserMFAPreferenceException3["ForbiddenException"] = "ForbiddenException";
288
+ SetUserMFAPreferenceException3["InternalErrorException"] = "InternalErrorException";
289
+ SetUserMFAPreferenceException3["InvalidParameterException"] = "InvalidParameterException";
290
+ SetUserMFAPreferenceException3["NotAuthorizedException"] = "NotAuthorizedException";
291
+ SetUserMFAPreferenceException3["PasswordResetRequiredException"] = "PasswordResetRequiredException";
292
+ SetUserMFAPreferenceException3["ResourceNotFoundException"] = "ResourceNotFoundException";
293
+ SetUserMFAPreferenceException3["UserNotConfirmedException"] = "UserNotConfirmedException";
294
+ SetUserMFAPreferenceException3["UserNotFoundException"] = "UserNotFoundException";
295
+ return SetUserMFAPreferenceException3;
296
296
  })(SetUserMFAPreferenceException || {});
297
297
  var SignUpException = /* @__PURE__ */ ((SignUpException3) => {
298
298
  SignUpException3["CodeDeliveryFailureException"] = "CodeDeliveryFailureException";
@@ -378,18 +378,18 @@ var UpdateDeviceStatusException = /* @__PURE__ */ ((UpdateDeviceStatusException2
378
378
  UpdateDeviceStatusException2["UserNotFoundException"] = "UserNotFoundException";
379
379
  return UpdateDeviceStatusException2;
380
380
  })(UpdateDeviceStatusException || {});
381
- var ListDevicesException = /* @__PURE__ */ ((ListDevicesException2) => {
382
- ListDevicesException2["ForbiddenException"] = "ForbiddenException";
383
- ListDevicesException2["InternalErrorException"] = "InternalErrorException";
384
- ListDevicesException2["InvalidParameterException"] = "InvalidParameterException";
385
- ListDevicesException2["InvalidUserPoolConfigurationException"] = "InvalidUserPoolConfigurationException";
386
- ListDevicesException2["NotAuthorizedException"] = "NotAuthorizedException";
387
- ListDevicesException2["PasswordResetRequiredException"] = "PasswordResetRequiredException";
388
- ListDevicesException2["ResourceNotFoundException"] = "ResourceNotFoundException";
389
- ListDevicesException2["TooManyRequestsException"] = "TooManyRequestsException";
390
- ListDevicesException2["UserNotConfirmedException"] = "UserNotConfirmedException";
391
- ListDevicesException2["UserNotFoundException"] = "UserNotFoundException";
392
- return ListDevicesException2;
381
+ var ListDevicesException = /* @__PURE__ */ ((ListDevicesException3) => {
382
+ ListDevicesException3["ForbiddenException"] = "ForbiddenException";
383
+ ListDevicesException3["InternalErrorException"] = "InternalErrorException";
384
+ ListDevicesException3["InvalidParameterException"] = "InvalidParameterException";
385
+ ListDevicesException3["InvalidUserPoolConfigurationException"] = "InvalidUserPoolConfigurationException";
386
+ ListDevicesException3["NotAuthorizedException"] = "NotAuthorizedException";
387
+ ListDevicesException3["PasswordResetRequiredException"] = "PasswordResetRequiredException";
388
+ ListDevicesException3["ResourceNotFoundException"] = "ResourceNotFoundException";
389
+ ListDevicesException3["TooManyRequestsException"] = "TooManyRequestsException";
390
+ ListDevicesException3["UserNotConfirmedException"] = "UserNotConfirmedException";
391
+ ListDevicesException3["UserNotFoundException"] = "UserNotFoundException";
392
+ return ListDevicesException3;
393
393
  })(ListDevicesException || {});
394
394
  var RevokeTokenException = /* @__PURE__ */ ((RevokeTokenException3) => {
395
395
  RevokeTokenException3["ForbiddenException"] = "ForbiddenException";
@@ -498,6 +498,24 @@ var AssociateSoftwareTokenError = class extends CognitoError {
498
498
  this.cognitoException = cognitoException;
499
499
  }
500
500
  };
501
+ var SetUserMFAPreferenceError = class extends CognitoError {
502
+ constructor(message, cognitoException) {
503
+ super(message, "SetUserMFAPreferenceError", cognitoException);
504
+ this.cognitoException = cognitoException;
505
+ }
506
+ };
507
+ var ListDevicesError = class extends CognitoError {
508
+ constructor(message, cognitoException) {
509
+ super(message, "ListDevicesError", cognitoException);
510
+ this.cognitoException = cognitoException;
511
+ }
512
+ };
513
+ var GetUserError = class extends CognitoError {
514
+ constructor(message, cognitoException) {
515
+ super(message, "GetUserError", cognitoException);
516
+ this.cognitoException = cognitoException;
517
+ }
518
+ };
501
519
 
502
520
  // src/bigint-math.ts
503
521
  var abs = (n) => n < 0n ? -n : n;
@@ -790,8 +808,16 @@ async function cognitoRequest(body, serviceTarget, cognitoEndpoint) {
790
808
  throw new VerifyUserAttributeError(errorMessage, cognitoException);
791
809
  case "GlobalSignOut" /* GlobalSignOut */:
792
810
  throw new GlobalSignOutError(errorMessage, cognitoException);
811
+ case "AssociateSoftwareToken" /* AssociateSoftwareToken */:
812
+ throw new AssociateSoftwareTokenError(errorMessage, cognitoException);
793
813
  case "VerifySoftwareToken" /* VerifySoftwareToken */:
794
814
  throw new VerifySoftwareTokenError(errorMessage, cognitoException);
815
+ case "SetUserMFAPreference" /* SetUserMFAPreference */:
816
+ throw new SetUserMFAPreferenceError(errorMessage, cognitoException);
817
+ case "ListDevices" /* ListDevices */:
818
+ throw new ListDevicesError(errorMessage, cognitoException);
819
+ case "GetUser" /* GetUser */:
820
+ throw new GetUserError(errorMessage, cognitoException);
795
821
  }
796
822
  }
797
823
  var CognitoClient = class {
@@ -1265,12 +1291,14 @@ export {
1265
1291
  GetCredentialsForIdentityException,
1266
1292
  GetIdException,
1267
1293
  GetUserAttributeVerificationException,
1294
+ GetUserError,
1268
1295
  GetUserException,
1269
1296
  GlobalSignOutError,
1270
1297
  GlobalSignOutException,
1271
1298
  IdentityProvider,
1272
1299
  InitAuthError,
1273
1300
  InitiateAuthException,
1301
+ ListDevicesError,
1274
1302
  ListDevicesException,
1275
1303
  ResendConfirmationCodeError,
1276
1304
  ResendConfirmationException,
@@ -1279,6 +1307,7 @@ export {
1279
1307
  RevokeTokenError,
1280
1308
  RevokeTokenException,
1281
1309
  ServiceTarget,
1310
+ SetUserMFAPreferenceError,
1282
1311
  SetUserMFAPreferenceException,
1283
1312
  SignUpError,
1284
1313
  SignUpException,
@@ -1,4 +1,4 @@
1
- import { ChangePasswordError, ConfirmForgotPasswordError, ConfirmSignUpError, ForgotPasswordError, GlobalSignOutError, InitAuthError, ResendConfirmationCodeError, RespondToAuthChallengeError, RevokeTokenError, SignUpError, UpdateUserAttributesError, VerifyUserAttributeError, InitiateAuthException, COMMON_EXCEPTIONS, CommonError, VerifySoftwareTokenError } from './error.js';
1
+ import { ChangePasswordError, ConfirmForgotPasswordError, ConfirmSignUpError, ForgotPasswordError, GlobalSignOutError, InitAuthError, ResendConfirmationCodeError, RespondToAuthChallengeError, RevokeTokenError, SignUpError, UpdateUserAttributesError, VerifyUserAttributeError, InitiateAuthException, COMMON_EXCEPTIONS, CommonError, VerifySoftwareTokenError, AssociateSoftwareTokenError, SetUserMFAPreferenceError, ListDevicesError, GetUserError } from './error.js';
2
2
  import { calculateSecretHash, calculateSignature, calculateU, decodeJwt, digest, generateA, generateSmallA, getPasswordAuthenticationKey, randomBytes, uint8ArrayFromString, uint8ArrayToBase64String } from './utils.js';
3
3
  /**
4
4
  * List of used and supported Cognito API calls.
@@ -103,8 +103,16 @@ export async function cognitoRequest(body, serviceTarget, cognitoEndpoint) {
103
103
  throw new VerifyUserAttributeError(errorMessage, cognitoException);
104
104
  case ServiceTarget.GlobalSignOut:
105
105
  throw new GlobalSignOutError(errorMessage, cognitoException);
106
+ case ServiceTarget.AssociateSoftwareToken:
107
+ throw new AssociateSoftwareTokenError(errorMessage, cognitoException);
106
108
  case ServiceTarget.VerifySoftwareToken:
107
109
  throw new VerifySoftwareTokenError(errorMessage, cognitoException);
110
+ case ServiceTarget.SetUserMFAPreference:
111
+ throw new SetUserMFAPreferenceError(errorMessage, cognitoException);
112
+ case ServiceTarget.ListDevices:
113
+ throw new ListDevicesError(errorMessage, cognitoException);
114
+ case ServiceTarget.GetUser:
115
+ throw new GetUserError(errorMessage, cognitoException);
108
116
  }
109
117
  }
110
118
  /**
package/lib/error.d.ts CHANGED
@@ -362,11 +362,11 @@ export declare enum RevokeTokenException {
362
362
  UnsupportedOperationException = "UnsupportedOperationException",
363
363
  UnsupportedTokenTypeException = "UnsupportedTokenTypeException"
364
364
  }
365
- export type CognitoErrorType = 'CommonError' | 'InitAuthError' | 'RespondToAuthChallengeError' | 'SignUpError' | 'ConfirmSignUpError' | 'VerifySoftwareTokenError' | 'ChangePasswordError' | 'RevokeTokenError' | 'ForgotPasswordError' | 'ConfirmForgotPasswordError' | 'ResendConfirmationCodeError' | 'UpdateUserAttributesError' | 'VerifyUserAttributeError' | 'AssociateSoftwareTokenError' | 'GlobalSignOutError';
365
+ export type CognitoErrorType = 'CommonError' | 'InitAuthError' | 'RespondToAuthChallengeError' | 'SignUpError' | 'ConfirmSignUpError' | 'VerifySoftwareTokenError' | 'ChangePasswordError' | 'RevokeTokenError' | 'ForgotPasswordError' | 'ConfirmForgotPasswordError' | 'ResendConfirmationCodeError' | 'UpdateUserAttributesError' | 'VerifyUserAttributeError' | 'AssociateSoftwareTokenError' | 'GlobalSignOutError' | 'SetUserMFAPreferenceError' | 'GetUserError' | 'ListDevicesError';
366
366
  export declare class CognitoError extends Error {
367
367
  readonly errorType: CognitoErrorType;
368
- readonly cognitoException: CommonException | InitiateAuthException | RespondToAuthChallengeException | SignUpException | ConfirmSignUpException | ChangePasswordException | RevokeTokenException | ForgotPasswordException | ConfirmForgotPasswordException | ResendConfirmationException | UpdateUserAttributesException | VerifyUserAttributeException | GlobalSignOutException | VerifySoftwareTokenException | AssociateSoftwareTokenException;
369
- constructor(message: string, errorType: CognitoErrorType, cognitoException: CommonException | InitiateAuthException | RespondToAuthChallengeException | SignUpException | ConfirmSignUpException | ChangePasswordException | RevokeTokenException | ForgotPasswordException | ConfirmForgotPasswordException | ResendConfirmationException | UpdateUserAttributesException | VerifyUserAttributeException | GlobalSignOutException | VerifySoftwareTokenException | AssociateSoftwareTokenException);
368
+ readonly cognitoException: CommonException | InitiateAuthException | RespondToAuthChallengeException | SignUpException | ConfirmSignUpException | ChangePasswordException | RevokeTokenException | ForgotPasswordException | ConfirmForgotPasswordException | ResendConfirmationException | UpdateUserAttributesException | VerifyUserAttributeException | GlobalSignOutException | VerifySoftwareTokenException | AssociateSoftwareTokenException | SetUserMFAPreferenceException | ListDevicesException | GetUserException;
369
+ constructor(message: string, errorType: CognitoErrorType, cognitoException: CommonException | InitiateAuthException | RespondToAuthChallengeException | SignUpException | ConfirmSignUpException | ChangePasswordException | RevokeTokenException | ForgotPasswordException | ConfirmForgotPasswordException | ResendConfirmationException | UpdateUserAttributesException | VerifyUserAttributeException | GlobalSignOutException | VerifySoftwareTokenException | AssociateSoftwareTokenException | SetUserMFAPreferenceException | ListDevicesException | GetUserException);
370
370
  }
371
371
  export declare class CommonError extends CognitoError {
372
372
  readonly cognitoException: CommonException;
@@ -428,3 +428,15 @@ export declare class AssociateSoftwareTokenError extends CognitoError {
428
428
  readonly cognitoException: AssociateSoftwareTokenException;
429
429
  constructor(message: string, cognitoException: AssociateSoftwareTokenException);
430
430
  }
431
+ export declare class SetUserMFAPreferenceError extends CognitoError {
432
+ readonly cognitoException: SetUserMFAPreferenceException;
433
+ constructor(message: string, cognitoException: SetUserMFAPreferenceException);
434
+ }
435
+ export declare class ListDevicesError extends CognitoError {
436
+ readonly cognitoException: ListDevicesException;
437
+ constructor(message: string, cognitoException: ListDevicesException);
438
+ }
439
+ export declare class GetUserError extends CognitoError {
440
+ readonly cognitoException: GetUserException;
441
+ constructor(message: string, cognitoException: GetUserException);
442
+ }
package/lib/error.js CHANGED
@@ -497,3 +497,21 @@ export class AssociateSoftwareTokenError extends CognitoError {
497
497
  this.cognitoException = cognitoException;
498
498
  }
499
499
  }
500
+ export class SetUserMFAPreferenceError extends CognitoError {
501
+ constructor(message, cognitoException) {
502
+ super(message, 'SetUserMFAPreferenceError', cognitoException);
503
+ this.cognitoException = cognitoException;
504
+ }
505
+ }
506
+ export class ListDevicesError extends CognitoError {
507
+ constructor(message, cognitoException) {
508
+ super(message, 'ListDevicesError', cognitoException);
509
+ this.cognitoException = cognitoException;
510
+ }
511
+ }
512
+ export class GetUserError extends CognitoError {
513
+ constructor(message, cognitoException) {
514
+ super(message, 'GetUserError', cognitoException);
515
+ this.cognitoException = cognitoException;
516
+ }
517
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vardario/cognito-client",
3
- "version": "5.0.0",
3
+ "version": "5.1.0",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "author": "Sahin Vardar",