@ttoss/react-auth 1.7.29 → 1.7.31
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/dist/esm/index.js +1 -294
- package/package.json +15 -15
package/dist/esm/index.js
CHANGED
|
@@ -351,300 +351,8 @@ import { Button as Button3 } from "@ttoss/ui";
|
|
|
351
351
|
import { Form as Form3, FormFieldInput as FormFieldInput3, FormFieldPassword, useForm as useForm3, yup as yup3, yupResolver as yupResolver3 } from "@ttoss/forms";
|
|
352
352
|
import { NotificationsBox as NotificationsBox2 } from "@ttoss/react-notifications";
|
|
353
353
|
|
|
354
|
-
// ../cloud-auth/
|
|
354
|
+
// ../cloud-auth/src/config.ts
|
|
355
355
|
var PASSWORD_MINIMUM_LENGTH = 8;
|
|
356
|
-
var CognitoUserPoolLogicalId = "CognitoUserPool";
|
|
357
|
-
var CognitoUserPoolClientLogicalId = "CognitoUserPoolClient";
|
|
358
|
-
var CognitoIdentityPoolLogicalId = "CognitoIdentityPool";
|
|
359
|
-
var IdentityPoolAuthenticatedIAMRoleLogicalId = "IdentityPoolAuthenticatedIAMRole";
|
|
360
|
-
var IdentityPoolUnauthenticatedIAMRoleLogicalId = "IdentityPoolUnauthenticatedIAMRole";
|
|
361
|
-
var DenyStatement = {
|
|
362
|
-
Effect: "Deny",
|
|
363
|
-
Action: ["*"],
|
|
364
|
-
Resource: ["*"]
|
|
365
|
-
};
|
|
366
|
-
var defaultPrincipalTags = {
|
|
367
|
-
appClientId: "aud",
|
|
368
|
-
userId: "sub"
|
|
369
|
-
};
|
|
370
|
-
var createAuthTemplate = ({
|
|
371
|
-
autoVerifiedAttributes = ["email"],
|
|
372
|
-
identityPool,
|
|
373
|
-
schema,
|
|
374
|
-
usernameAttributes = ["email"]
|
|
375
|
-
} = {}) => {
|
|
376
|
-
const AutoVerifiedAttributes = Array.isArray(autoVerifiedAttributes) && autoVerifiedAttributes.length > 0 ? autoVerifiedAttributes : [];
|
|
377
|
-
const template = {
|
|
378
|
-
AWSTemplateFormatVersion: "2010-09-09",
|
|
379
|
-
Resources: {
|
|
380
|
-
[CognitoUserPoolLogicalId]: {
|
|
381
|
-
/**
|
|
382
|
-
* https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cognito-userpool.html
|
|
383
|
-
*/
|
|
384
|
-
Type: "AWS::Cognito::UserPool",
|
|
385
|
-
Properties: {
|
|
386
|
-
AutoVerifiedAttributes,
|
|
387
|
-
Policies: {
|
|
388
|
-
PasswordPolicy: {
|
|
389
|
-
MinimumLength: PASSWORD_MINIMUM_LENGTH,
|
|
390
|
-
RequireLowercase: false,
|
|
391
|
-
RequireNumbers: false,
|
|
392
|
-
RequireSymbols: false,
|
|
393
|
-
RequireUppercase: false,
|
|
394
|
-
TemporaryPasswordValidityDays: 30
|
|
395
|
-
}
|
|
396
|
-
},
|
|
397
|
-
UsernameAttributes: usernameAttributes,
|
|
398
|
-
UsernameConfiguration: {
|
|
399
|
-
CaseSensitive: false
|
|
400
|
-
},
|
|
401
|
-
UserPoolName: {
|
|
402
|
-
Ref: "AWS::StackName"
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
},
|
|
406
|
-
[CognitoUserPoolClientLogicalId]: {
|
|
407
|
-
/**
|
|
408
|
-
* https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cognito-userpoolclient.html
|
|
409
|
-
*/
|
|
410
|
-
Type: "AWS::Cognito::UserPoolClient",
|
|
411
|
-
Properties: {
|
|
412
|
-
SupportedIdentityProviders: ["COGNITO"],
|
|
413
|
-
UserPoolId: {
|
|
414
|
-
Ref: "CognitoUserPool"
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
},
|
|
419
|
-
Outputs: {
|
|
420
|
-
Region: {
|
|
421
|
-
Description: "You use this value on Amplify Auth `region`.",
|
|
422
|
-
Value: {
|
|
423
|
-
Ref: "AWS::Region"
|
|
424
|
-
},
|
|
425
|
-
Export: {
|
|
426
|
-
Name: {
|
|
427
|
-
"Fn::Join": [":", [{
|
|
428
|
-
Ref: "AWS::StackName"
|
|
429
|
-
}, "Region"]]
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
},
|
|
433
|
-
UserPoolId: {
|
|
434
|
-
Description: "You use this value on Amplify Auth `userPoolId`.",
|
|
435
|
-
Value: {
|
|
436
|
-
Ref: CognitoUserPoolLogicalId
|
|
437
|
-
},
|
|
438
|
-
Export: {
|
|
439
|
-
Name: {
|
|
440
|
-
"Fn::Join": [":", [{
|
|
441
|
-
Ref: "AWS::StackName"
|
|
442
|
-
}, "UserPoolId"]]
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
},
|
|
446
|
-
AppClientId: {
|
|
447
|
-
Description: "You use this value on Amplify Auth `userPoolWebClientId`.",
|
|
448
|
-
Value: {
|
|
449
|
-
Ref: CognitoUserPoolClientLogicalId
|
|
450
|
-
},
|
|
451
|
-
Export: {
|
|
452
|
-
Name: {
|
|
453
|
-
"Fn::Join": [":", [{
|
|
454
|
-
Ref: "AWS::StackName"
|
|
455
|
-
}, "AppClientId"]]
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
};
|
|
461
|
-
if (schema) {
|
|
462
|
-
const Schema = schema.map(attribute => {
|
|
463
|
-
let NumberAttributeConstraints = void 0;
|
|
464
|
-
if (attribute.numberAttributeConstraints) {
|
|
465
|
-
NumberAttributeConstraints = {
|
|
466
|
-
MaxValue: attribute.numberAttributeConstraints?.maxValue,
|
|
467
|
-
MinValue: attribute.numberAttributeConstraints?.minValue
|
|
468
|
-
};
|
|
469
|
-
}
|
|
470
|
-
let StringAttributeConstraints = void 0;
|
|
471
|
-
if (attribute.stringAttributeConstraints) {
|
|
472
|
-
StringAttributeConstraints = {
|
|
473
|
-
MaxLength: attribute.stringAttributeConstraints?.maxLength,
|
|
474
|
-
MinLength: attribute.stringAttributeConstraints?.minLength
|
|
475
|
-
};
|
|
476
|
-
}
|
|
477
|
-
return {
|
|
478
|
-
AttributeDataType: attribute.attributeDataType,
|
|
479
|
-
DeveloperOnlyAttribute: attribute.developerOnlyAttribute,
|
|
480
|
-
Mutable: attribute.mutable,
|
|
481
|
-
Name: attribute.name,
|
|
482
|
-
NumberAttributeConstraints,
|
|
483
|
-
Required: attribute.required,
|
|
484
|
-
StringAttributeConstraints
|
|
485
|
-
};
|
|
486
|
-
});
|
|
487
|
-
template.Resources[CognitoUserPoolLogicalId].Properties.Schema = Schema;
|
|
488
|
-
}
|
|
489
|
-
if (identityPool?.enabled) {
|
|
490
|
-
template.Resources[CognitoIdentityPoolLogicalId] = {
|
|
491
|
-
/**
|
|
492
|
-
* https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cognito-identitypool.html
|
|
493
|
-
*/
|
|
494
|
-
Type: "AWS::Cognito::IdentityPool",
|
|
495
|
-
Properties: {
|
|
496
|
-
AllowUnauthenticatedIdentities: identityPool.allowUnauthenticatedIdentities || false,
|
|
497
|
-
CognitoIdentityProviders: [{
|
|
498
|
-
ClientId: {
|
|
499
|
-
Ref: CognitoUserPoolClientLogicalId
|
|
500
|
-
},
|
|
501
|
-
ProviderName: {
|
|
502
|
-
"Fn::GetAtt": [CognitoUserPoolLogicalId, "ProviderName"]
|
|
503
|
-
}
|
|
504
|
-
}]
|
|
505
|
-
}
|
|
506
|
-
};
|
|
507
|
-
if (identityPool.name) {
|
|
508
|
-
template.Resources[CognitoIdentityPoolLogicalId].Properties.IdentityPoolName = identityPool.name;
|
|
509
|
-
}
|
|
510
|
-
template.Resources.CognitoIdentityPoolRoleAttachment = {
|
|
511
|
-
/**
|
|
512
|
-
* https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cognito-identitypoolroleattachment.html
|
|
513
|
-
*/
|
|
514
|
-
Type: "AWS::Cognito::IdentityPoolRoleAttachment",
|
|
515
|
-
Properties: {
|
|
516
|
-
IdentityPoolId: {
|
|
517
|
-
Ref: CognitoIdentityPoolLogicalId
|
|
518
|
-
},
|
|
519
|
-
Roles: {}
|
|
520
|
-
}
|
|
521
|
-
};
|
|
522
|
-
if (!identityPool.authenticatedRoleArn) {
|
|
523
|
-
template.Resources[IdentityPoolAuthenticatedIAMRoleLogicalId] = {
|
|
524
|
-
Type: "AWS::IAM::Role",
|
|
525
|
-
Properties: {
|
|
526
|
-
AssumeRolePolicyDocument: {
|
|
527
|
-
Version: "2012-10-17",
|
|
528
|
-
Statement: [{
|
|
529
|
-
Effect: "Allow",
|
|
530
|
-
Principal: {
|
|
531
|
-
Federated: "cognito-identity.amazonaws.com"
|
|
532
|
-
},
|
|
533
|
-
Action: ["sts:AssumeRoleWithWebIdentity", "sts:TagSession"],
|
|
534
|
-
Condition: {
|
|
535
|
-
StringEquals: {
|
|
536
|
-
"cognito-identity.amazonaws.com:aud": {
|
|
537
|
-
Ref: CognitoIdentityPoolLogicalId
|
|
538
|
-
}
|
|
539
|
-
},
|
|
540
|
-
"ForAnyValue:StringLike": {
|
|
541
|
-
"cognito-identity.amazonaws.com:amr": "authenticated"
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
}]
|
|
545
|
-
},
|
|
546
|
-
Policies: identityPool.authenticatedPolicies || [{
|
|
547
|
-
PolicyName: "IdentityPoolAuthenticatedIAMRolePolicyName",
|
|
548
|
-
PolicyDocument: {
|
|
549
|
-
Version: "2012-10-17",
|
|
550
|
-
Statement: [DenyStatement]
|
|
551
|
-
}
|
|
552
|
-
}]
|
|
553
|
-
}
|
|
554
|
-
};
|
|
555
|
-
template.Resources.CognitoIdentityPoolRoleAttachment.Properties.Roles.authenticated = {
|
|
556
|
-
"Fn::GetAtt": [IdentityPoolAuthenticatedIAMRoleLogicalId, "Arn"]
|
|
557
|
-
};
|
|
558
|
-
} else {
|
|
559
|
-
template.Resources.CognitoIdentityPoolRoleAttachment.Properties.Roles.authenticated = identityPool.authenticatedRoleArn;
|
|
560
|
-
}
|
|
561
|
-
if (!identityPool.unauthenticatedRoleArn) {
|
|
562
|
-
template.Resources[IdentityPoolUnauthenticatedIAMRoleLogicalId] = {
|
|
563
|
-
Type: "AWS::IAM::Role",
|
|
564
|
-
Properties: {
|
|
565
|
-
AssumeRolePolicyDocument: {
|
|
566
|
-
Version: "2012-10-17",
|
|
567
|
-
Statement: [{
|
|
568
|
-
Effect: "Allow",
|
|
569
|
-
Principal: {
|
|
570
|
-
Federated: "cognito-identity.amazonaws.com"
|
|
571
|
-
},
|
|
572
|
-
Action: "sts:AssumeRoleWithWebIdentity",
|
|
573
|
-
Condition: {
|
|
574
|
-
StringEquals: {
|
|
575
|
-
"cognito-identity.amazonaws.com:aud": {
|
|
576
|
-
Ref: CognitoIdentityPoolLogicalId
|
|
577
|
-
}
|
|
578
|
-
},
|
|
579
|
-
"ForAnyValue:StringLike": {
|
|
580
|
-
"cognito-identity.amazonaws.com:amr": "unauthenticated"
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
}]
|
|
584
|
-
},
|
|
585
|
-
Policies: identityPool.authenticatedPolicies || [{
|
|
586
|
-
PolicyName: "IdentityPoolUnauthenticatedIAMRolePolicyName",
|
|
587
|
-
PolicyDocument: {
|
|
588
|
-
Version: "2012-10-17",
|
|
589
|
-
Statement: [DenyStatement]
|
|
590
|
-
}
|
|
591
|
-
}]
|
|
592
|
-
}
|
|
593
|
-
};
|
|
594
|
-
template.Resources.CognitoIdentityPoolRoleAttachment.Properties.Roles.unauthenticated = {
|
|
595
|
-
"Fn::GetAtt": [IdentityPoolUnauthenticatedIAMRoleLogicalId, "Arn"]
|
|
596
|
-
};
|
|
597
|
-
} else {
|
|
598
|
-
template.Resources.CognitoIdentityPoolRoleAttachment.Properties.Roles.unauthenticated = identityPool.unauthenticatedRoleArn;
|
|
599
|
-
}
|
|
600
|
-
if (identityPool.principalTags || identityPool.principalTags === void 0) {
|
|
601
|
-
const PrincipalTags = (() => {
|
|
602
|
-
if (typeof identityPool.principalTags === "boolean") {
|
|
603
|
-
return defaultPrincipalTags;
|
|
604
|
-
}
|
|
605
|
-
if (identityPool.principalTags === void 0) {
|
|
606
|
-
return defaultPrincipalTags;
|
|
607
|
-
}
|
|
608
|
-
return identityPool.principalTags;
|
|
609
|
-
})();
|
|
610
|
-
template.Resources.CognitoIdentityPoolPrincipalTag = {
|
|
611
|
-
Type: "AWS::Cognito::IdentityPoolPrincipalTag",
|
|
612
|
-
Properties: {
|
|
613
|
-
IdentityPoolId: {
|
|
614
|
-
Ref: CognitoIdentityPoolLogicalId
|
|
615
|
-
},
|
|
616
|
-
IdentityProviderName: {
|
|
617
|
-
"Fn::GetAtt": [CognitoUserPoolLogicalId, "ProviderName"]
|
|
618
|
-
},
|
|
619
|
-
PrincipalTags,
|
|
620
|
-
UseDefaults: false
|
|
621
|
-
}
|
|
622
|
-
};
|
|
623
|
-
}
|
|
624
|
-
if (!template.Outputs) {
|
|
625
|
-
template.Outputs = {};
|
|
626
|
-
}
|
|
627
|
-
template.Outputs.IdentityPoolId = {
|
|
628
|
-
Description: "You use this value on Amplify Auth `identityPoolId`.",
|
|
629
|
-
Value: {
|
|
630
|
-
Ref: CognitoIdentityPoolLogicalId
|
|
631
|
-
},
|
|
632
|
-
Export: {
|
|
633
|
-
Name: {
|
|
634
|
-
"Fn::Join": [":", [{
|
|
635
|
-
Ref: "AWS::StackName"
|
|
636
|
-
}, "CognitoIdentityPoolId"]]
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
};
|
|
640
|
-
}
|
|
641
|
-
return template;
|
|
642
|
-
};
|
|
643
|
-
createAuthTemplate.CognitoUserPoolLogicalId = CognitoUserPoolLogicalId;
|
|
644
|
-
createAuthTemplate.CognitoUserPoolClientLogicalId = CognitoUserPoolClientLogicalId;
|
|
645
|
-
createAuthTemplate.CognitoIdentityPoolLogicalId = CognitoIdentityPoolLogicalId;
|
|
646
|
-
createAuthTemplate.IdentityPoolAuthenticatedIAMRoleLogicalId = IdentityPoolAuthenticatedIAMRoleLogicalId;
|
|
647
|
-
createAuthTemplate.IdentityPoolUnauthenticatedIAMRoleLogicalId = IdentityPoolUnauthenticatedIAMRoleLogicalId;
|
|
648
356
|
|
|
649
357
|
// src/AuthForgotPasswordResetPassword.tsx
|
|
650
358
|
import { useI18n as useI18n3 } from "@ttoss/react-i18n";
|
|
@@ -878,7 +586,6 @@ var AuthSignIn = ({
|
|
|
878
586
|
})).trim()
|
|
879
587
|
// remember: yup.boolean(),
|
|
880
588
|
});
|
|
881
|
-
|
|
882
589
|
const formMethods = useForm4({
|
|
883
590
|
defaultValues,
|
|
884
591
|
mode: "onBlur",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/react-auth",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.31",
|
|
4
4
|
"description": "ttoss authentication module for React apps.",
|
|
5
5
|
"author": "ttoss",
|
|
6
6
|
"contributors": [
|
|
@@ -27,28 +27,28 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@xstate/react": "^3.2.2",
|
|
29
29
|
"xstate": "^4.38.3",
|
|
30
|
-
"@ttoss/forms": "^0.22.
|
|
30
|
+
"@ttoss/forms": "^0.22.5"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"aws-amplify": "^6.0.0",
|
|
34
34
|
"react": ">=16.8.0",
|
|
35
|
-
"@ttoss/react-i18n": "^1.26.
|
|
36
|
-
"@ttoss/react-notifications": "^1.24.
|
|
37
|
-
"@ttoss/ui": "^4.1.
|
|
35
|
+
"@ttoss/react-i18n": "^1.26.1",
|
|
36
|
+
"@ttoss/react-notifications": "^1.24.29",
|
|
37
|
+
"@ttoss/ui": "^4.1.3"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@jest/globals": "^29.7.0",
|
|
41
|
-
"@types/react": "^18.2.
|
|
41
|
+
"@types/react": "^18.2.58",
|
|
42
42
|
"aws-amplify": "^6.0.12",
|
|
43
43
|
"jest": "^29.7.0",
|
|
44
|
-
"tsup": "^8.0.
|
|
45
|
-
"@ttoss/
|
|
46
|
-
"@ttoss/
|
|
47
|
-
"@ttoss/react-
|
|
48
|
-
"@ttoss/i18n-cli": "^0.7.
|
|
49
|
-
"@ttoss/
|
|
50
|
-
"@ttoss/test-utils": "^2.1.
|
|
51
|
-
"@ttoss/ui": "^4.1.
|
|
44
|
+
"tsup": "^8.0.2",
|
|
45
|
+
"@ttoss/cloud-auth": "^0.12.2",
|
|
46
|
+
"@ttoss/react-i18n": "^1.26.1",
|
|
47
|
+
"@ttoss/react-notifications": "^1.24.29",
|
|
48
|
+
"@ttoss/i18n-cli": "^0.7.6",
|
|
49
|
+
"@ttoss/config": "^1.31.5",
|
|
50
|
+
"@ttoss/test-utils": "^2.1.1",
|
|
51
|
+
"@ttoss/ui": "^4.1.3"
|
|
52
52
|
},
|
|
53
53
|
"keywords": [
|
|
54
54
|
"React",
|
|
@@ -64,6 +64,6 @@
|
|
|
64
64
|
"scripts": {
|
|
65
65
|
"build": "tsup",
|
|
66
66
|
"i18n": "ttoss-i18n",
|
|
67
|
-
"test": "
|
|
67
|
+
"test": "jest"
|
|
68
68
|
}
|
|
69
69
|
}
|