@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 +71 -42
- package/lib/cognito-client.js +9 -1
- package/lib/error.d.ts +15 -3
- package/lib/error.js +18 -0
- package/package.json +1 -1
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__ */ ((
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return
|
|
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__ */ ((
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
return
|
|
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__ */ ((
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
return
|
|
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__ */ ((
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
return
|
|
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,
|
package/lib/cognito-client.js
CHANGED
|
@@ -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
|
+
}
|