@ttoss/cloud-auth 0.2.0 → 0.3.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.
@@ -8,10 +8,10 @@ $ tsup
8
8
  CLI Cleaning output folder
9
9
  CJS Build start
10
10
  ESM Build start
11
- CJS dist/index.js 1.19 KB
12
- CJS ⚡️ Build success in 90ms
13
- ESM dist/esm/index.js 170.00 B
14
- ESM ⚡️ Build success in 91ms
11
+ CJS dist/index.js 4.17 KB
12
+ CJS ⚡️ Build success in 103ms
13
+ ESM dist/esm/index.js 3.10 KB
14
+ ESM ⚡️ Build success in 107ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 13477ms
17
- DTS dist/index.d.ts 80.00 B
16
+ DTS ⚡️ Build success in 17579ms
17
+ DTS dist/index.d.ts 3.06 KB
package/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [0.3.0](https://github.com/ttoss/ttoss/compare/@ttoss/cloud-auth@0.2.0...@ttoss/cloud-auth@0.3.0) (2022-12-19)
7
+
8
+ ### Features
9
+
10
+ - add cloud auth ([#103](https://github.com/ttoss/ttoss/issues/103)) ([eba9df0](https://github.com/ttoss/ttoss/commit/eba9df065563c65db711e5615b54a08b28e645c1))
11
+
6
12
  # 0.2.0 (2022-12-18)
7
13
 
8
14
  ### Bug Fixes
package/dist/esm/index.js CHANGED
@@ -2,6 +2,116 @@
2
2
 
3
3
  // src/config.ts
4
4
  var PASSWORD_MINIMUM_LENGTH = 8;
5
+
6
+ // src/template.ts
7
+ var CognitoUserPoolLogicalId = "CognitoUserPool";
8
+ var CognitoUserPoolClientLogicalId = "CognitoUserPoolClient";
9
+ var CognitoIdentityPoolLogicalId = "CognitoIdentityPool";
10
+ var createAuthTemplate = () => {
11
+ const template = {
12
+ Resources: {
13
+ [CognitoUserPoolLogicalId]: {
14
+ Type: "AWS::Cognito::UserPool",
15
+ Properties: {
16
+ AutoVerifiedAttributes: ["email"],
17
+ Policies: {
18
+ PasswordPolicy: {
19
+ MinimumLength: PASSWORD_MINIMUM_LENGTH,
20
+ RequireLowercase: false,
21
+ RequireNumbers: false,
22
+ RequireSymbols: false,
23
+ RequireUppercase: false,
24
+ TemporaryPasswordValidityDays: 30
25
+ }
26
+ },
27
+ UsernameAttributes: ["email"],
28
+ UsernameConfiguration: {
29
+ CaseSensitive: false
30
+ },
31
+ UserPoolName: {
32
+ Ref: "AWS::StackName"
33
+ }
34
+ }
35
+ },
36
+ [CognitoUserPoolClientLogicalId]: {
37
+ Type: "AWS::Cognito::UserPoolClient",
38
+ Properties: {
39
+ SupportedIdentityProviders: ["COGNITO"],
40
+ UserPoolId: {
41
+ Ref: "CognitoUserPool"
42
+ }
43
+ }
44
+ },
45
+ [CognitoIdentityPoolLogicalId]: {
46
+ Type: "AWS::Cognito::IdentityPool",
47
+ Properties: {
48
+ AllowUnauthenticatedIdentities: true,
49
+ CognitoIdentityProviders: [
50
+ {
51
+ ClientId: {
52
+ Ref: CognitoUserPoolClientLogicalId
53
+ },
54
+ ProviderName: {
55
+ "Fn::GetAtt": [CognitoUserPoolLogicalId, "ProviderName"]
56
+ }
57
+ }
58
+ ]
59
+ }
60
+ }
61
+ },
62
+ Outputs: {
63
+ Region: {
64
+ Description: "You use this value on Amplify Auth `region`.",
65
+ Value: {
66
+ Ref: "AWS::Region"
67
+ },
68
+ Export: {
69
+ Name: {
70
+ "Fn::Join": [":", [{ Ref: "AWS::StackName" }, "Region"]]
71
+ }
72
+ }
73
+ },
74
+ UserPoolId: {
75
+ Description: "You use this value on Amplify Auth `userPoolId`.",
76
+ Value: {
77
+ Ref: CognitoUserPoolLogicalId
78
+ },
79
+ Export: {
80
+ Name: {
81
+ "Fn::Join": [":", [{ Ref: "AWS::StackName" }, "UserPoolId"]]
82
+ }
83
+ }
84
+ },
85
+ AppClientId: {
86
+ Description: "You use this value on Amplify Auth `userPoolWebClientId`.",
87
+ Value: {
88
+ Ref: CognitoUserPoolClientLogicalId
89
+ },
90
+ Export: {
91
+ Name: {
92
+ "Fn::Join": [":", [{ Ref: "AWS::StackName" }, "AppClientId"]]
93
+ }
94
+ }
95
+ },
96
+ IdentityPoolId: {
97
+ Description: "You use this value on Amplify Auth `identityPoolId`.",
98
+ Value: {
99
+ Ref: CognitoIdentityPoolLogicalId
100
+ },
101
+ Export: {
102
+ Name: {
103
+ "Fn::Join": [
104
+ ":",
105
+ [{ Ref: "AWS::StackName" }, "CognitoIdentityPoolId"]
106
+ ]
107
+ }
108
+ }
109
+ }
110
+ }
111
+ };
112
+ return template;
113
+ };
5
114
  export {
6
- PASSWORD_MINIMUM_LENGTH
115
+ PASSWORD_MINIMUM_LENGTH,
116
+ createAuthTemplate
7
117
  };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,111 @@
1
1
  declare const PASSWORD_MINIMUM_LENGTH = 8;
2
2
 
3
- export { PASSWORD_MINIMUM_LENGTH };
3
+ declare const createAuthTemplate: () => {
4
+ Resources: {
5
+ CognitoUserPool: {
6
+ Type: string;
7
+ Properties: {
8
+ AutoVerifiedAttributes: string[];
9
+ Policies: {
10
+ PasswordPolicy: {
11
+ MinimumLength: number;
12
+ RequireLowercase: boolean;
13
+ RequireNumbers: boolean;
14
+ RequireSymbols: boolean;
15
+ RequireUppercase: boolean;
16
+ TemporaryPasswordValidityDays: number;
17
+ };
18
+ };
19
+ UsernameAttributes: string[];
20
+ UsernameConfiguration: {
21
+ CaseSensitive: boolean;
22
+ };
23
+ UserPoolName: {
24
+ Ref: string;
25
+ };
26
+ };
27
+ };
28
+ CognitoUserPoolClient: {
29
+ Type: string;
30
+ Properties: {
31
+ SupportedIdentityProviders: string[];
32
+ UserPoolId: {
33
+ Ref: string;
34
+ };
35
+ };
36
+ };
37
+ /**
38
+ * https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cognito-identitypool.html
39
+ */
40
+ CognitoIdentityPool: {
41
+ Type: string;
42
+ Properties: {
43
+ AllowUnauthenticatedIdentities: boolean;
44
+ CognitoIdentityProviders: {
45
+ ClientId: {
46
+ Ref: string;
47
+ };
48
+ ProviderName: {
49
+ 'Fn::GetAtt': string[];
50
+ };
51
+ }[];
52
+ };
53
+ };
54
+ };
55
+ Outputs: {
56
+ Region: {
57
+ Description: string;
58
+ Value: {
59
+ Ref: string;
60
+ };
61
+ Export: {
62
+ Name: {
63
+ 'Fn::Join': (string | (string | {
64
+ Ref: string;
65
+ })[])[];
66
+ };
67
+ };
68
+ };
69
+ UserPoolId: {
70
+ Description: string;
71
+ Value: {
72
+ Ref: string;
73
+ };
74
+ Export: {
75
+ Name: {
76
+ 'Fn::Join': (string | (string | {
77
+ Ref: string;
78
+ })[])[];
79
+ };
80
+ };
81
+ };
82
+ AppClientId: {
83
+ Description: string;
84
+ Value: {
85
+ Ref: string;
86
+ };
87
+ Export: {
88
+ Name: {
89
+ 'Fn::Join': (string | (string | {
90
+ Ref: string;
91
+ })[])[];
92
+ };
93
+ };
94
+ };
95
+ IdentityPoolId: {
96
+ Description: string;
97
+ Value: {
98
+ Ref: string;
99
+ };
100
+ Export: {
101
+ Name: {
102
+ 'Fn::Join': (string | (string | {
103
+ Ref: string;
104
+ })[])[];
105
+ };
106
+ };
107
+ };
108
+ };
109
+ };
110
+
111
+ export { PASSWORD_MINIMUM_LENGTH, createAuthTemplate };
package/dist/index.js CHANGED
@@ -21,13 +21,124 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  // src/index.ts
22
22
  var src_exports = {};
23
23
  __export(src_exports, {
24
- PASSWORD_MINIMUM_LENGTH: () => PASSWORD_MINIMUM_LENGTH
24
+ PASSWORD_MINIMUM_LENGTH: () => PASSWORD_MINIMUM_LENGTH,
25
+ createAuthTemplate: () => createAuthTemplate
25
26
  });
26
27
  module.exports = __toCommonJS(src_exports);
27
28
 
28
29
  // src/config.ts
29
30
  var PASSWORD_MINIMUM_LENGTH = 8;
31
+
32
+ // src/template.ts
33
+ var CognitoUserPoolLogicalId = "CognitoUserPool";
34
+ var CognitoUserPoolClientLogicalId = "CognitoUserPoolClient";
35
+ var CognitoIdentityPoolLogicalId = "CognitoIdentityPool";
36
+ var createAuthTemplate = () => {
37
+ const template = {
38
+ Resources: {
39
+ [CognitoUserPoolLogicalId]: {
40
+ Type: "AWS::Cognito::UserPool",
41
+ Properties: {
42
+ AutoVerifiedAttributes: ["email"],
43
+ Policies: {
44
+ PasswordPolicy: {
45
+ MinimumLength: PASSWORD_MINIMUM_LENGTH,
46
+ RequireLowercase: false,
47
+ RequireNumbers: false,
48
+ RequireSymbols: false,
49
+ RequireUppercase: false,
50
+ TemporaryPasswordValidityDays: 30
51
+ }
52
+ },
53
+ UsernameAttributes: ["email"],
54
+ UsernameConfiguration: {
55
+ CaseSensitive: false
56
+ },
57
+ UserPoolName: {
58
+ Ref: "AWS::StackName"
59
+ }
60
+ }
61
+ },
62
+ [CognitoUserPoolClientLogicalId]: {
63
+ Type: "AWS::Cognito::UserPoolClient",
64
+ Properties: {
65
+ SupportedIdentityProviders: ["COGNITO"],
66
+ UserPoolId: {
67
+ Ref: "CognitoUserPool"
68
+ }
69
+ }
70
+ },
71
+ [CognitoIdentityPoolLogicalId]: {
72
+ Type: "AWS::Cognito::IdentityPool",
73
+ Properties: {
74
+ AllowUnauthenticatedIdentities: true,
75
+ CognitoIdentityProviders: [
76
+ {
77
+ ClientId: {
78
+ Ref: CognitoUserPoolClientLogicalId
79
+ },
80
+ ProviderName: {
81
+ "Fn::GetAtt": [CognitoUserPoolLogicalId, "ProviderName"]
82
+ }
83
+ }
84
+ ]
85
+ }
86
+ }
87
+ },
88
+ Outputs: {
89
+ Region: {
90
+ Description: "You use this value on Amplify Auth `region`.",
91
+ Value: {
92
+ Ref: "AWS::Region"
93
+ },
94
+ Export: {
95
+ Name: {
96
+ "Fn::Join": [":", [{ Ref: "AWS::StackName" }, "Region"]]
97
+ }
98
+ }
99
+ },
100
+ UserPoolId: {
101
+ Description: "You use this value on Amplify Auth `userPoolId`.",
102
+ Value: {
103
+ Ref: CognitoUserPoolLogicalId
104
+ },
105
+ Export: {
106
+ Name: {
107
+ "Fn::Join": [":", [{ Ref: "AWS::StackName" }, "UserPoolId"]]
108
+ }
109
+ }
110
+ },
111
+ AppClientId: {
112
+ Description: "You use this value on Amplify Auth `userPoolWebClientId`.",
113
+ Value: {
114
+ Ref: CognitoUserPoolClientLogicalId
115
+ },
116
+ Export: {
117
+ Name: {
118
+ "Fn::Join": [":", [{ Ref: "AWS::StackName" }, "AppClientId"]]
119
+ }
120
+ }
121
+ },
122
+ IdentityPoolId: {
123
+ Description: "You use this value on Amplify Auth `identityPoolId`.",
124
+ Value: {
125
+ Ref: CognitoIdentityPoolLogicalId
126
+ },
127
+ Export: {
128
+ Name: {
129
+ "Fn::Join": [
130
+ ":",
131
+ [{ Ref: "AWS::StackName" }, "CognitoIdentityPoolId"]
132
+ ]
133
+ }
134
+ }
135
+ }
136
+ }
137
+ };
138
+ return template;
139
+ };
30
140
  // Annotate the CommonJS export names for ESM import in node:
31
141
  0 && (module.exports = {
32
- PASSWORD_MINIMUM_LENGTH
142
+ PASSWORD_MINIMUM_LENGTH,
143
+ createAuthTemplate
33
144
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/cloud-auth",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/esm/index.js",
6
6
  "scripts": {
@@ -16,5 +16,5 @@
16
16
  "publishConfig": {
17
17
  "access": "public"
18
18
  },
19
- "gitHead": "01759d9c247bed2fe52ca580e87c0b21544cac49"
19
+ "gitHead": "b697061d84f3b079619befbfb150e587f455dd1c"
20
20
  }
package/src/index.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from './config';
2
+ export { createAuthTemplate } from './template';
@@ -0,0 +1,128 @@
1
+ import { PASSWORD_MINIMUM_LENGTH } from './config';
2
+
3
+ const CognitoUserPoolLogicalId = 'CognitoUserPool';
4
+
5
+ const CognitoUserPoolClientLogicalId = 'CognitoUserPoolClient';
6
+
7
+ const CognitoIdentityPoolLogicalId = 'CognitoIdentityPool';
8
+
9
+ export const createAuthTemplate = () => {
10
+ const template = {
11
+ Resources: {
12
+ [CognitoUserPoolLogicalId]: {
13
+ Type: 'AWS::Cognito::UserPool',
14
+ Properties: {
15
+ AutoVerifiedAttributes: ['email'],
16
+ Policies: {
17
+ PasswordPolicy: {
18
+ MinimumLength: PASSWORD_MINIMUM_LENGTH,
19
+ RequireLowercase: false,
20
+ RequireNumbers: false,
21
+ RequireSymbols: false,
22
+ RequireUppercase: false,
23
+ TemporaryPasswordValidityDays: 30,
24
+ },
25
+ },
26
+ UsernameAttributes: ['email'],
27
+ UsernameConfiguration: {
28
+ CaseSensitive: false,
29
+ },
30
+ UserPoolName: {
31
+ Ref: 'AWS::StackName',
32
+ },
33
+ },
34
+ },
35
+ [CognitoUserPoolClientLogicalId]: {
36
+ Type: 'AWS::Cognito::UserPoolClient',
37
+ Properties: {
38
+ SupportedIdentityProviders: ['COGNITO'],
39
+ UserPoolId: {
40
+ Ref: 'CognitoUserPool',
41
+ },
42
+ },
43
+ },
44
+ /**
45
+ * https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cognito-identitypool.html
46
+ */
47
+ [CognitoIdentityPoolLogicalId]: {
48
+ Type: 'AWS::Cognito::IdentityPool',
49
+ Properties: {
50
+ AllowUnauthenticatedIdentities: true,
51
+ CognitoIdentityProviders: [
52
+ {
53
+ ClientId: {
54
+ Ref: CognitoUserPoolClientLogicalId,
55
+ },
56
+ ProviderName: {
57
+ 'Fn::GetAtt': [CognitoUserPoolLogicalId, 'ProviderName'],
58
+ },
59
+ },
60
+ ],
61
+ },
62
+ },
63
+ /**
64
+ * https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cognito-identitypoolroleattachment.html
65
+ */
66
+ // CognitoIdentityPoolRoleAttachment: {
67
+ // Type: 'AWS::Cognito::IdentityPoolRoleAttachment',
68
+ // Properties: {
69
+ // IdentityPoolId: {
70
+ // Ref: CognitoIdentityPoolLogicalId,
71
+ // },
72
+ // },
73
+ // },
74
+ },
75
+ Outputs: {
76
+ Region: {
77
+ Description: 'You use this value on Amplify Auth `region`.',
78
+ Value: {
79
+ Ref: 'AWS::Region',
80
+ },
81
+ Export: {
82
+ Name: {
83
+ 'Fn::Join': [':', [{ Ref: 'AWS::StackName' }, 'Region']],
84
+ },
85
+ },
86
+ },
87
+ UserPoolId: {
88
+ Description: 'You use this value on Amplify Auth `userPoolId`.',
89
+ Value: {
90
+ Ref: CognitoUserPoolLogicalId,
91
+ },
92
+ Export: {
93
+ Name: {
94
+ 'Fn::Join': [':', [{ Ref: 'AWS::StackName' }, 'UserPoolId']],
95
+ },
96
+ },
97
+ },
98
+ AppClientId: {
99
+ Description:
100
+ 'You use this value on Amplify Auth `userPoolWebClientId`.',
101
+ Value: {
102
+ Ref: CognitoUserPoolClientLogicalId,
103
+ },
104
+ Export: {
105
+ Name: {
106
+ 'Fn::Join': [':', [{ Ref: 'AWS::StackName' }, 'AppClientId']],
107
+ },
108
+ },
109
+ },
110
+ IdentityPoolId: {
111
+ Description: 'You use this value on Amplify Auth `identityPoolId`.',
112
+ Value: {
113
+ Ref: CognitoIdentityPoolLogicalId,
114
+ },
115
+ Export: {
116
+ Name: {
117
+ 'Fn::Join': [
118
+ ':',
119
+ [{ Ref: 'AWS::StackName' }, 'CognitoIdentityPoolId'],
120
+ ],
121
+ },
122
+ },
123
+ },
124
+ },
125
+ };
126
+
127
+ return template;
128
+ };