@ttoss/react-auth 1.7.19 → 1.7.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/esm/index.js +94 -70
  2. package/package.json +12 -12
package/dist/esm/index.js CHANGED
@@ -369,6 +369,9 @@ var createAuthTemplate = ({
369
369
  AWSTemplateFormatVersion: "2010-09-09",
370
370
  Resources: {
371
371
  [CognitoUserPoolLogicalId]: {
372
+ /**
373
+ * https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cognito-userpool.html
374
+ */
372
375
  Type: "AWS::Cognito::UserPool",
373
376
  Properties: {
374
377
  AutoVerifiedAttributes,
@@ -392,6 +395,9 @@ var createAuthTemplate = ({
392
395
  }
393
396
  },
394
397
  [CognitoUserPoolClientLogicalId]: {
398
+ /**
399
+ * https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cognito-userpoolclient.html
400
+ */
395
401
  Type: "AWS::Cognito::UserPoolClient",
396
402
  Properties: {
397
403
  SupportedIdentityProviders: ["COGNITO"],
@@ -473,9 +479,12 @@ var createAuthTemplate = ({
473
479
  }
474
480
  if (identityPool?.enabled) {
475
481
  template.Resources[CognitoIdentityPoolLogicalId] = {
482
+ /**
483
+ * https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cognito-identitypool.html
484
+ */
476
485
  Type: "AWS::Cognito::IdentityPool",
477
486
  Properties: {
478
- AllowUnauthenticatedIdentities: true,
487
+ AllowUnauthenticatedIdentities: identityPool.allowUnauthenticatedIdentities || false,
479
488
  CognitoIdentityProviders: [{
480
489
  ClientId: {
481
490
  Ref: CognitoUserPoolClientLogicalId
@@ -486,86 +495,99 @@ var createAuthTemplate = ({
486
495
  }]
487
496
  }
488
497
  };
489
- template.Resources[IdentityPoolAuthenticatedIAMRoleLogicalId] = {
490
- Type: "AWS::IAM::Role",
498
+ if (identityPool.name) {
499
+ template.Resources[CognitoIdentityPoolLogicalId].Properties.IdentityPoolName = identityPool.name;
500
+ }
501
+ template.Resources.CognitoIdentityPoolRoleAttachment = {
502
+ /**
503
+ * https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cognito-identitypoolroleattachment.html
504
+ */
505
+ Type: "AWS::Cognito::IdentityPoolRoleAttachment",
491
506
  Properties: {
492
- AssumeRolePolicyDocument: {
493
- Version: "2012-10-17",
494
- Statement: [{
495
- Effect: "Allow",
496
- Principal: {
497
- Federated: "cognito-identity.amazonaws.com"
498
- },
499
- Action: ["sts:AssumeRoleWithWebIdentity", "sts:TagSession"],
500
- Condition: {
501
- StringEquals: {
502
- "cognito-identity.amazonaws.com:aud": {
503
- Ref: CognitoIdentityPoolLogicalId
504
- }
505
- },
506
- "ForAnyValue:StringLike": {
507
- "cognito-identity.amazonaws.com:amr": "authenticated"
508
- }
509
- }
510
- }]
507
+ IdentityPoolId: {
508
+ Ref: CognitoIdentityPoolLogicalId
511
509
  },
512
- Policies: identityPool.authenticatedPolicies || [{
513
- PolicyName: "IdentityPoolAuthenticatedIAMRolePolicyName",
514
- PolicyDocument: {
515
- Version: "2012-10-17",
516
- Statement: [DenyStatement]
517
- }
518
- }]
510
+ Roles: {}
519
511
  }
520
512
  };
521
- template.Resources[IdentityPoolUnauthenticatedIAMRoleLogicalId] = {
522
- Type: "AWS::IAM::Role",
523
- Properties: {
524
- AssumeRolePolicyDocument: {
525
- Version: "2012-10-17",
526
- Statement: [{
527
- Effect: "Allow",
528
- Principal: {
529
- Federated: "cognito-identity.amazonaws.com"
530
- },
531
- Action: "sts:AssumeRoleWithWebIdentity",
532
- Condition: {
533
- StringEquals: {
534
- "cognito-identity.amazonaws.com:aud": {
535
- Ref: CognitoIdentityPoolLogicalId
536
- }
513
+ if (!identityPool.authenticatedRoleArn) {
514
+ template.Resources[IdentityPoolAuthenticatedIAMRoleLogicalId] = {
515
+ Type: "AWS::IAM::Role",
516
+ Properties: {
517
+ AssumeRolePolicyDocument: {
518
+ Version: "2012-10-17",
519
+ Statement: [{
520
+ Effect: "Allow",
521
+ Principal: {
522
+ Federated: "cognito-identity.amazonaws.com"
537
523
  },
538
- "ForAnyValue:StringLike": {
539
- "cognito-identity.amazonaws.com:amr": "unauthenticated"
524
+ Action: ["sts:AssumeRoleWithWebIdentity", "sts:TagSession"],
525
+ Condition: {
526
+ StringEquals: {
527
+ "cognito-identity.amazonaws.com:aud": {
528
+ Ref: CognitoIdentityPoolLogicalId
529
+ }
530
+ },
531
+ "ForAnyValue:StringLike": {
532
+ "cognito-identity.amazonaws.com:amr": "authenticated"
533
+ }
540
534
  }
535
+ }]
536
+ },
537
+ Policies: identityPool.authenticatedPolicies || [{
538
+ PolicyName: "IdentityPoolAuthenticatedIAMRolePolicyName",
539
+ PolicyDocument: {
540
+ Version: "2012-10-17",
541
+ Statement: [DenyStatement]
541
542
  }
542
543
  }]
543
- },
544
- Policies: identityPool.authenticatedPolicies || [{
545
- PolicyName: "IdentityPoolUnauthenticatedIAMRolePolicyName",
546
- PolicyDocument: {
544
+ }
545
+ };
546
+ template.Resources.CognitoIdentityPoolRoleAttachment.Properties.Roles.authenticated = {
547
+ "Fn::GetAtt": [IdentityPoolAuthenticatedIAMRoleLogicalId, "Arn"]
548
+ };
549
+ } else {
550
+ template.Resources.CognitoIdentityPoolRoleAttachment.Properties.Roles.authenticated = identityPool.authenticatedRoleArn;
551
+ }
552
+ if (!identityPool.unauthenticatedRoleArn) {
553
+ template.Resources[IdentityPoolUnauthenticatedIAMRoleLogicalId] = {
554
+ Type: "AWS::IAM::Role",
555
+ Properties: {
556
+ AssumeRolePolicyDocument: {
547
557
  Version: "2012-10-17",
548
- Statement: [DenyStatement]
549
- }
550
- }]
551
- }
552
- };
553
- template.Resources.CognitoIdentityPoolRoleAttachment = {
554
- Type: "AWS::Cognito::IdentityPoolRoleAttachment",
555
- Properties: {
556
- IdentityPoolId: {
557
- Ref: CognitoIdentityPoolLogicalId
558
- },
559
- Roles: {
560
- authenticated: {
561
- "Fn::GetAtt": [IdentityPoolAuthenticatedIAMRoleLogicalId, "Arn"]
558
+ Statement: [{
559
+ Effect: "Allow",
560
+ Principal: {
561
+ Federated: "cognito-identity.amazonaws.com"
562
+ },
563
+ Action: "sts:AssumeRoleWithWebIdentity",
564
+ Condition: {
565
+ StringEquals: {
566
+ "cognito-identity.amazonaws.com:aud": {
567
+ Ref: CognitoIdentityPoolLogicalId
568
+ }
569
+ },
570
+ "ForAnyValue:StringLike": {
571
+ "cognito-identity.amazonaws.com:amr": "unauthenticated"
572
+ }
573
+ }
574
+ }]
562
575
  },
563
- unauthenticated: {
564
- "Fn::GetAtt": [IdentityPoolUnauthenticatedIAMRoleLogicalId, "Arn"]
565
- }
576
+ Policies: identityPool.authenticatedPolicies || [{
577
+ PolicyName: "IdentityPoolUnauthenticatedIAMRolePolicyName",
578
+ PolicyDocument: {
579
+ Version: "2012-10-17",
580
+ Statement: [DenyStatement]
581
+ }
582
+ }]
566
583
  }
567
- }
568
- };
584
+ };
585
+ template.Resources.CognitoIdentityPoolRoleAttachment.Properties.Roles.unauthenticated = {
586
+ "Fn::GetAtt": [IdentityPoolUnauthenticatedIAMRoleLogicalId, "Arn"]
587
+ };
588
+ } else {
589
+ template.Resources.CognitoIdentityPoolRoleAttachment.Properties.Roles.unauthenticated = identityPool.unauthenticatedRoleArn;
590
+ }
569
591
  if (!template.Outputs) {
570
592
  template.Outputs = {};
571
593
  }
@@ -588,6 +610,8 @@ var createAuthTemplate = ({
588
610
  createAuthTemplate.CognitoUserPoolLogicalId = CognitoUserPoolLogicalId;
589
611
  createAuthTemplate.CognitoUserPoolClientLogicalId = CognitoUserPoolClientLogicalId;
590
612
  createAuthTemplate.CognitoIdentityPoolLogicalId = CognitoIdentityPoolLogicalId;
613
+ createAuthTemplate.IdentityPoolAuthenticatedIAMRoleLogicalId = IdentityPoolAuthenticatedIAMRoleLogicalId;
614
+ createAuthTemplate.IdentityPoolUnauthenticatedIAMRoleLogicalId = IdentityPoolUnauthenticatedIAMRoleLogicalId;
591
615
 
592
616
  // src/AuthForgotPasswordResetPassword.tsx
593
617
  import { useI18n as useI18n3 } from "@ttoss/react-i18n";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/react-auth",
3
- "version": "1.7.19",
3
+ "version": "1.7.21",
4
4
  "description": "ttoss authentication module for React apps.",
5
5
  "author": "ttoss",
6
6
  "contributors": [
@@ -27,14 +27,14 @@
27
27
  "dependencies": {
28
28
  "@xstate/react": "^3.2.2",
29
29
  "xstate": "^4.38.3",
30
- "@ttoss/forms": "^0.21.8"
30
+ "@ttoss/forms": "^0.21.9"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "aws-amplify": "^5.0.0",
34
34
  "react": ">=16.8.0",
35
- "@ttoss/react-i18n": "^1.25.7",
36
- "@ttoss/react-notifications": "^1.24.21",
37
- "@ttoss/ui": "^4.0.6"
35
+ "@ttoss/react-i18n": "^1.25.8",
36
+ "@ttoss/react-notifications": "^1.24.22",
37
+ "@ttoss/ui": "^4.0.7"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@jest/globals": "^29.7.0",
@@ -42,13 +42,13 @@
42
42
  "aws-amplify": "^5.3.11",
43
43
  "jest": "^29.7.0",
44
44
  "tsup": "^8.0.1",
45
- "@ttoss/cloud-auth": "^0.10.6",
46
- "@ttoss/config": "^1.31.3",
47
- "@ttoss/i18n-cli": "^0.7.4",
48
- "@ttoss/react-i18n": "^1.25.7",
49
- "@ttoss/react-notifications": "^1.24.21",
50
- "@ttoss/test-utils": "^2.0.3",
51
- "@ttoss/ui": "^4.0.6"
45
+ "@ttoss/cloud-auth": "^0.11.0",
46
+ "@ttoss/config": "^1.31.4",
47
+ "@ttoss/i18n-cli": "^0.7.5",
48
+ "@ttoss/react-notifications": "^1.24.22",
49
+ "@ttoss/react-i18n": "^1.25.8",
50
+ "@ttoss/test-utils": "^2.0.4",
51
+ "@ttoss/ui": "^4.0.7"
52
52
  },
53
53
  "keywords": [
54
54
  "React",