@webiny/cognito 6.4.4-beta.3 → 6.4.4-beta.4
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/Cognito.d.ts +51 -0
- package/Cognito.js +75 -4
- package/Cognito.js.map +1 -1
- package/admin/DefaultCognitoSignInConfig.d.ts +23 -0
- package/admin/DefaultCognitoSignInConfig.js +51 -0
- package/admin/DefaultCognitoSignInConfig.js.map +1 -0
- package/admin/Extension.js +3 -0
- package/admin/Extension.js.map +1 -1
- package/admin/index.d.ts +2 -0
- package/admin/index.js +2 -0
- package/admin/presentation/Cognito/CognitoLoginScreen.js +9 -0
- package/admin/presentation/Cognito/CognitoLoginScreen.js.map +1 -1
- package/admin/presentation/Cognito/CognitoPresenter.d.ts +25 -1
- package/admin/presentation/Cognito/CognitoPresenter.js +122 -10
- package/admin/presentation/Cognito/CognitoPresenter.js.map +1 -1
- package/admin/presentation/Cognito/CognitoSignInConfig.d.ts +31 -0
- package/admin/presentation/Cognito/CognitoSignInConfig.js +5 -0
- package/admin/presentation/Cognito/CognitoSignInConfig.js.map +1 -0
- package/admin/presentation/Cognito/abstractions.d.ts +20 -1
- package/admin/presentation/Cognito/abstractions.js.map +1 -1
- package/admin/presentation/Cognito/components/ConfirmTotpCode.d.ts +26 -0
- package/admin/presentation/Cognito/components/ConfirmTotpCode.js +45 -0
- package/admin/presentation/Cognito/components/ConfirmTotpCode.js.map +1 -0
- package/admin/presentation/Cognito/components/Divider.d.ts +19 -1
- package/admin/presentation/Cognito/components/Divider.js +3 -2
- package/admin/presentation/Cognito/components/Divider.js.map +1 -1
- package/admin/presentation/Cognito/components/FederatedLogin.d.ts +22 -5
- package/admin/presentation/Cognito/components/FederatedLogin.js +19 -6
- package/admin/presentation/Cognito/components/FederatedLogin.js.map +1 -1
- package/admin/presentation/Cognito/components/FooterSignIn.d.ts +20 -3
- package/admin/presentation/Cognito/components/FooterSignIn.js +3 -2
- package/admin/presentation/Cognito/components/FooterSignIn.js.map +1 -1
- package/admin/presentation/Cognito/components/PasswordResetCodeSent.d.ts +19 -1
- package/admin/presentation/Cognito/components/PasswordResetCodeSent.js +3 -2
- package/admin/presentation/Cognito/components/PasswordResetCodeSent.js.map +1 -1
- package/admin/presentation/Cognito/components/RequestPasswordResetCode.d.ts +19 -1
- package/admin/presentation/Cognito/components/RequestPasswordResetCode.js +3 -2
- package/admin/presentation/Cognito/components/RequestPasswordResetCode.js.map +1 -1
- package/admin/presentation/Cognito/components/RequireNewPassword.d.ts +19 -1
- package/admin/presentation/Cognito/components/RequireNewPassword.js +3 -2
- package/admin/presentation/Cognito/components/RequireNewPassword.js.map +1 -1
- package/admin/presentation/Cognito/components/SetNewPassword.d.ts +19 -1
- package/admin/presentation/Cognito/components/SetNewPassword.js +3 -2
- package/admin/presentation/Cognito/components/SetNewPassword.js.map +1 -1
- package/admin/presentation/Cognito/components/SetupTotp.d.ts +25 -0
- package/admin/presentation/Cognito/components/SetupTotp.js +60 -0
- package/admin/presentation/Cognito/components/SetupTotp.js.map +1 -0
- package/admin/presentation/Cognito/components/SignIn.d.ts +19 -3
- package/admin/presentation/Cognito/components/SignIn.js +14 -7
- package/admin/presentation/Cognito/components/SignIn.js.map +1 -1
- package/admin/presentation/Cognito/components/index.d.ts +292 -0
- package/admin/presentation/Cognito/components/index.js +29 -0
- package/admin/presentation/Cognito/components/index.js.map +1 -0
- package/admin/presentation/Cognito/signInFeature.d.ts +1 -0
- package/admin/presentation/Cognito/signInFeature.js +11 -0
- package/admin/presentation/Cognito/signInFeature.js.map +1 -0
- package/admin/ui/views/Users/UsersForm.js +21 -15
- package/admin/ui/views/Users/UsersForm.js.map +1 -1
- package/admin/ui/views/Users/hooks/useUserForm.js +3 -1
- package/admin/ui/views/Users/hooks/useUserForm.js.map +1 -1
- package/api/features/CognitoIdp/CognitoIdentityProvider.js +15 -11
- package/api/features/CognitoIdp/CognitoIdentityProvider.js.map +1 -1
- package/api/features/CognitoIdp/abstractions.d.ts +1 -1
- package/api/features/CognitoIdp/abstractions.js.map +1 -1
- package/api/index.d.ts +1 -0
- package/api/index.js +1 -0
- package/index.d.ts +0 -1
- package/index.js +0 -1
- package/infra/CognitoFederationPulumi.d.ts +8 -0
- package/infra/CognitoFederationPulumi.js +17 -0
- package/infra/CognitoFederationPulumi.js.map +1 -0
- package/package.json +19 -17
package/Cognito.d.ts
CHANGED
|
@@ -1,4 +1,55 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
declare const federationSchema: z.ZodObject<{
|
|
3
|
+
domain: z.ZodString;
|
|
4
|
+
callbackUrls: z.ZodArray<z.ZodString>;
|
|
5
|
+
logoutUrls: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
6
|
+
responseType: z.ZodDefault<z.ZodEnum<{
|
|
7
|
+
code: "code";
|
|
8
|
+
token: "token";
|
|
9
|
+
}>>;
|
|
10
|
+
allowCredentialsLogin: z.ZodDefault<z.ZodBoolean>;
|
|
11
|
+
identityProviders: z.ZodArray<z.ZodObject<{
|
|
12
|
+
type: z.ZodEnum<{
|
|
13
|
+
google: "google";
|
|
14
|
+
facebook: "facebook";
|
|
15
|
+
amazon: "amazon";
|
|
16
|
+
apple: "apple";
|
|
17
|
+
oidc: "oidc";
|
|
18
|
+
}>;
|
|
19
|
+
name: z.ZodOptional<z.ZodString>;
|
|
20
|
+
label: z.ZodString;
|
|
21
|
+
providerDetails: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
22
|
+
idpIdentifiers: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
23
|
+
attributeMapping: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
24
|
+
}, z.core.$strip>>;
|
|
25
|
+
}, z.core.$strip>;
|
|
2
26
|
export declare const Cognito: import("@webiny/project/defineExtension/defineExtension").ExtensionComponent<z.ZodObject<{
|
|
3
27
|
apiConfig: z.ZodOptional<z.ZodString>;
|
|
28
|
+
adminConfig: z.ZodOptional<z.ZodString>;
|
|
29
|
+
federation: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
30
|
+
domain: z.ZodString;
|
|
31
|
+
callbackUrls: z.ZodArray<z.ZodString>;
|
|
32
|
+
logoutUrls: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
33
|
+
responseType: z.ZodDefault<z.ZodEnum<{
|
|
34
|
+
code: "code";
|
|
35
|
+
token: "token";
|
|
36
|
+
}>>;
|
|
37
|
+
allowCredentialsLogin: z.ZodDefault<z.ZodBoolean>;
|
|
38
|
+
identityProviders: z.ZodArray<z.ZodObject<{
|
|
39
|
+
type: z.ZodEnum<{
|
|
40
|
+
google: "google";
|
|
41
|
+
facebook: "facebook";
|
|
42
|
+
amazon: "amazon";
|
|
43
|
+
apple: "apple";
|
|
44
|
+
oidc: "oidc";
|
|
45
|
+
}>;
|
|
46
|
+
name: z.ZodOptional<z.ZodString>;
|
|
47
|
+
label: z.ZodString;
|
|
48
|
+
providerDetails: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
49
|
+
idpIdentifiers: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
50
|
+
attributeMapping: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
51
|
+
}, z.core.$strip>>;
|
|
52
|
+
}, z.core.$strip>, z.ZodCustom<() => Promise<z.infer<typeof federationSchema>>, () => Promise<z.infer<typeof federationSchema>>>]>>;
|
|
53
|
+
mfa: z.ZodDefault<z.ZodBoolean>;
|
|
4
54
|
}, z.core.$strip>>;
|
|
55
|
+
export {};
|
package/Cognito.js
CHANGED
|
@@ -1,7 +1,33 @@
|
|
|
1
1
|
import react from "react";
|
|
2
2
|
import { defineExtension } from "@webiny/project/defineExtension/index.js";
|
|
3
3
|
import { Admin, Api, Infra } from "@webiny/project-aws";
|
|
4
|
+
import { Await } from "@webiny/react-properties";
|
|
4
5
|
import { z } from "zod";
|
|
6
|
+
const identityProviderSchema = z.object({
|
|
7
|
+
type: z["enum"]([
|
|
8
|
+
"google",
|
|
9
|
+
"facebook",
|
|
10
|
+
"amazon",
|
|
11
|
+
"apple",
|
|
12
|
+
"oidc"
|
|
13
|
+
]),
|
|
14
|
+
name: z.string().optional(),
|
|
15
|
+
label: z.string(),
|
|
16
|
+
providerDetails: z.record(z.string(), z.any()),
|
|
17
|
+
idpIdentifiers: z.array(z.string()).optional(),
|
|
18
|
+
attributeMapping: z.record(z.string(), z.string()).optional()
|
|
19
|
+
});
|
|
20
|
+
const federationSchema = z.object({
|
|
21
|
+
domain: z.string().describe("Cognito User Pool domain prefix."),
|
|
22
|
+
callbackUrls: z.array(z.string()).describe("OAuth callback URLs."),
|
|
23
|
+
logoutUrls: z.array(z.string()).optional(),
|
|
24
|
+
responseType: z["enum"]([
|
|
25
|
+
"code",
|
|
26
|
+
"token"
|
|
27
|
+
]).default("code"),
|
|
28
|
+
allowCredentialsLogin: z.boolean().default(true),
|
|
29
|
+
identityProviders: z.array(identityProviderSchema)
|
|
30
|
+
});
|
|
5
31
|
const Cognito = defineExtension({
|
|
6
32
|
type: "Project/Cognito",
|
|
7
33
|
tags: {
|
|
@@ -9,19 +35,64 @@ const Cognito = defineExtension({
|
|
|
9
35
|
},
|
|
10
36
|
description: "Enable and configure Cognito authentication.",
|
|
11
37
|
paramsSchema: z.object({
|
|
12
|
-
apiConfig: z.string().describe("Path to API configuration.").optional()
|
|
38
|
+
apiConfig: z.string().describe("Path to API configuration.").optional(),
|
|
39
|
+
adminConfig: z.string().describe("Path to Admin configuration.").optional(),
|
|
40
|
+
federation: z.union([
|
|
41
|
+
federationSchema,
|
|
42
|
+
z.custom((val)=>"function" == typeof val)
|
|
43
|
+
]).optional(),
|
|
44
|
+
mfa: z.boolean().describe("Enable TOTP MFA for all users.").default(false)
|
|
13
45
|
}),
|
|
14
|
-
render: (props)
|
|
46
|
+
render: (props)=>{
|
|
47
|
+
const federationProp = props.federation;
|
|
48
|
+
const federationFn = federationProp ? "function" == typeof federationProp ? federationProp : ()=>Promise.resolve(federationProp) : null;
|
|
49
|
+
return /*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(Infra.EnvVar, {
|
|
15
50
|
varName: "REACT_APP_IDP_TYPE",
|
|
16
51
|
value: "cognito"
|
|
17
|
-
}), /*#__PURE__*/ react.createElement(
|
|
52
|
+
}), props.mfa ? /*#__PURE__*/ react.createElement(Infra.EnvVar, {
|
|
53
|
+
varName: "COGNITO_MFA",
|
|
54
|
+
value: "true"
|
|
55
|
+
}) : null, /*#__PURE__*/ react.createElement(Api.Extension, {
|
|
18
56
|
src: import.meta.dirname + "/api/CognitoApiFeature.js",
|
|
19
57
|
exportName: "CognitoApiFeature"
|
|
20
58
|
}), props.apiConfig ? /*#__PURE__*/ react.createElement(Api.Extension, {
|
|
21
59
|
src: props.apiConfig
|
|
22
60
|
}) : null, /*#__PURE__*/ react.createElement(Admin.Extension, {
|
|
23
61
|
src: import.meta.dirname + "/admin/Extension.js"
|
|
24
|
-
})
|
|
62
|
+
}), props.adminConfig ? /*#__PURE__*/ react.createElement(Admin.Extension, {
|
|
63
|
+
src: props.adminConfig
|
|
64
|
+
}) : null, federationFn ? /*#__PURE__*/ react.createElement(Await, {
|
|
65
|
+
fn: federationFn
|
|
66
|
+
}, (federation)=>/*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(Infra.EnvVar, {
|
|
67
|
+
varName: "COGNITO_FEDERATION_INFRA_CONFIG",
|
|
68
|
+
value: JSON.stringify({
|
|
69
|
+
domain: federation.domain,
|
|
70
|
+
callbackUrls: federation.callbackUrls,
|
|
71
|
+
logoutUrls: federation.logoutUrls,
|
|
72
|
+
identityProviders: federation.identityProviders.map((idp)=>({
|
|
73
|
+
type: idp.type,
|
|
74
|
+
name: idp.name,
|
|
75
|
+
providerDetails: idp.providerDetails,
|
|
76
|
+
idpIdentifiers: idp.idpIdentifiers,
|
|
77
|
+
attributeMapping: idp.attributeMapping
|
|
78
|
+
}))
|
|
79
|
+
})
|
|
80
|
+
}), /*#__PURE__*/ react.createElement(Infra.Core.Pulumi, {
|
|
81
|
+
src: import.meta.dirname + "/infra/CognitoFederationPulumi.js"
|
|
82
|
+
}), /*#__PURE__*/ react.createElement(Admin.BuildParam, {
|
|
83
|
+
paramName: "cognitoFederation",
|
|
84
|
+
value: {
|
|
85
|
+
callbackUrls: federation.callbackUrls,
|
|
86
|
+
logoutUrls: federation.logoutUrls || federation.callbackUrls,
|
|
87
|
+
responseType: federation.responseType,
|
|
88
|
+
allowCredentialsLogin: federation.allowCredentialsLogin,
|
|
89
|
+
providers: federation.identityProviders.map((idp)=>({
|
|
90
|
+
name: idp.name || idp.type,
|
|
91
|
+
label: idp.label
|
|
92
|
+
}))
|
|
93
|
+
}
|
|
94
|
+
}))) : null);
|
|
95
|
+
}
|
|
25
96
|
});
|
|
26
97
|
export { Cognito };
|
|
27
98
|
|
package/Cognito.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cognito.js","sources":["../src/Cognito.tsx"],"sourcesContent":["import React from \"react\";\nimport { defineExtension } from \"@webiny/project/defineExtension/index.js\";\nimport { Api, Admin, Infra } from \"@webiny/project-aws\";\nimport { z } from \"zod\";\n\nexport const Cognito = defineExtension({\n type: \"Project/Cognito\",\n tags: { runtimeContext: \"project\" },\n description: \"Enable and configure Cognito authentication.\",\n paramsSchema: z.object({\n apiConfig: z.string().describe(\"Path to API configuration.\").optional()\n }),\n render: props => {\n return (\n <>\n <Infra.EnvVar varName={\"REACT_APP_IDP_TYPE\"} value={\"cognito\"} />\n {/* Api extensions */}\n <Api.Extension\n src={import.meta.dirname + \"/api/CognitoApiFeature.js\"}\n exportName={\"CognitoApiFeature\"}\n />\n {props.apiConfig ? <Api.Extension src={props.apiConfig} /> : null}\n {/* Admin extensions */}\n <Admin.Extension src={import.meta.dirname + \"/admin/Extension.js\"} />\n </>\n );\n }\n});\n"],"names":["Cognito","defineExtension","
|
|
1
|
+
{"version":3,"file":"Cognito.js","sources":["../src/Cognito.tsx"],"sourcesContent":["import React from \"react\";\nimport { defineExtension } from \"@webiny/project/defineExtension/index.js\";\nimport { Api, Admin, Infra } from \"@webiny/project-aws\";\nimport { Await } from \"@webiny/react-properties\";\nimport { z } from \"zod\";\n\nconst identityProviderSchema = z.object({\n type: z.enum([\"google\", \"facebook\", \"amazon\", \"apple\", \"oidc\"]),\n name: z.string().optional(),\n label: z.string(),\n providerDetails: z.record(z.string(), z.any()),\n idpIdentifiers: z.array(z.string()).optional(),\n attributeMapping: z.record(z.string(), z.string()).optional()\n});\n\nconst federationSchema = z.object({\n domain: z.string().describe(\"Cognito User Pool domain prefix.\"),\n callbackUrls: z.array(z.string()).describe(\"OAuth callback URLs.\"),\n logoutUrls: z.array(z.string()).optional(),\n responseType: z.enum([\"code\", \"token\"]).default(\"code\"),\n allowCredentialsLogin: z.boolean().default(true),\n identityProviders: z.array(identityProviderSchema)\n});\n\nexport const Cognito = defineExtension({\n type: \"Project/Cognito\",\n tags: { runtimeContext: \"project\" },\n description: \"Enable and configure Cognito authentication.\",\n paramsSchema: z.object({\n apiConfig: z.string().describe(\"Path to API configuration.\").optional(),\n adminConfig: z.string().describe(\"Path to Admin configuration.\").optional(),\n federation: z\n .union([\n federationSchema,\n z.custom<() => Promise<z.infer<typeof federationSchema>>>(\n val => typeof val === \"function\"\n )\n ])\n .optional(),\n mfa: z.boolean().describe(\"Enable TOTP MFA for all users.\").default(false)\n }),\n render: props => {\n const federationProp = props.federation;\n const federationFn = federationProp\n ? typeof federationProp === \"function\"\n ? federationProp\n : () => Promise.resolve(federationProp)\n : null;\n\n return (\n <>\n <Infra.EnvVar varName={\"REACT_APP_IDP_TYPE\"} value={\"cognito\"} />\n {props.mfa ? <Infra.EnvVar varName={\"COGNITO_MFA\"} value={\"true\"} /> : null}\n\n {/* Api extensions */}\n <Api.Extension\n src={import.meta.dirname + \"/api/CognitoApiFeature.js\"}\n exportName={\"CognitoApiFeature\"}\n />\n {props.apiConfig ? <Api.Extension src={props.apiConfig} /> : null}\n\n {/* Admin extensions */}\n <Admin.Extension src={import.meta.dirname + \"/admin/Extension.js\"} />\n {props.adminConfig ? <Admin.Extension src={props.adminConfig} /> : null}\n\n {/* Federation infra + admin config */}\n {federationFn ? (\n <Await fn={federationFn}>\n {federation => (\n <>\n <Infra.EnvVar\n varName={\"COGNITO_FEDERATION_INFRA_CONFIG\"}\n value={JSON.stringify({\n domain: federation.domain,\n callbackUrls: federation.callbackUrls,\n logoutUrls: federation.logoutUrls,\n identityProviders: federation.identityProviders.map(\n idp => ({\n type: idp.type,\n name: idp.name,\n providerDetails: idp.providerDetails,\n idpIdentifiers: idp.idpIdentifiers,\n attributeMapping: idp.attributeMapping\n })\n )\n })}\n />\n <Infra.Core.Pulumi\n src={import.meta.dirname + \"/infra/CognitoFederationPulumi.js\"}\n />\n <Admin.BuildParam\n paramName={\"cognitoFederation\"}\n value={{\n callbackUrls: federation.callbackUrls,\n logoutUrls:\n federation.logoutUrls || federation.callbackUrls,\n responseType: federation.responseType,\n allowCredentialsLogin: federation.allowCredentialsLogin,\n providers: federation.identityProviders.map(idp => ({\n name: idp.name || idp.type,\n label: idp.label\n }))\n }}\n />\n </>\n )}\n </Await>\n ) : null}\n </>\n );\n }\n});\n"],"names":["identityProviderSchema","z","federationSchema","Cognito","defineExtension","val","props","federationProp","federationFn","Promise","Infra","Api","Admin","Await","federation","JSON","idp"],"mappings":"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"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BuildParams } from "@webiny/app-admin/features/buildParams/index.js";
|
|
2
|
+
import { type ICognitoSignInConfig } from "./presentation/Cognito/CognitoSignInConfig.js";
|
|
3
|
+
declare class DefaultCognitoSignInConfigImpl implements ICognitoSignInConfig {
|
|
4
|
+
private buildParams;
|
|
5
|
+
constructor(buildParams: BuildParams.Interface);
|
|
6
|
+
getConfig(): Promise<{
|
|
7
|
+
oauth: {
|
|
8
|
+
scopes: string[];
|
|
9
|
+
redirectSignIn: string[];
|
|
10
|
+
redirectSignOut: string[];
|
|
11
|
+
responseType: "code" | "token";
|
|
12
|
+
};
|
|
13
|
+
allowCredentialsLogin: boolean;
|
|
14
|
+
providers: {
|
|
15
|
+
name: string;
|
|
16
|
+
label: string;
|
|
17
|
+
}[];
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
export declare const DefaultCognitoSignInConfig: typeof DefaultCognitoSignInConfigImpl & {
|
|
21
|
+
__abstraction: import("@webiny/di").Abstraction<ICognitoSignInConfig>;
|
|
22
|
+
};
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { BuildParams } from "@webiny/app-admin/features/buildParams/index.js";
|
|
2
|
+
import { CognitoSignInConfig } from "./presentation/Cognito/CognitoSignInConfig.js";
|
|
3
|
+
class DefaultCognitoSignInConfigImpl {
|
|
4
|
+
constructor(buildParams){
|
|
5
|
+
this.buildParams = buildParams;
|
|
6
|
+
}
|
|
7
|
+
async getConfig() {
|
|
8
|
+
const config = this.buildParams.get("cognitoFederation");
|
|
9
|
+
if (!config) return {
|
|
10
|
+
oauth: {
|
|
11
|
+
scopes: [
|
|
12
|
+
"profile",
|
|
13
|
+
"email",
|
|
14
|
+
"openid"
|
|
15
|
+
],
|
|
16
|
+
redirectSignIn: [
|
|
17
|
+
window.location.origin
|
|
18
|
+
],
|
|
19
|
+
redirectSignOut: [
|
|
20
|
+
window.location.origin
|
|
21
|
+
],
|
|
22
|
+
responseType: "code"
|
|
23
|
+
},
|
|
24
|
+
allowCredentialsLogin: true,
|
|
25
|
+
providers: []
|
|
26
|
+
};
|
|
27
|
+
return {
|
|
28
|
+
oauth: {
|
|
29
|
+
scopes: [
|
|
30
|
+
"profile",
|
|
31
|
+
"email",
|
|
32
|
+
"openid"
|
|
33
|
+
],
|
|
34
|
+
redirectSignIn: config.callbackUrls,
|
|
35
|
+
redirectSignOut: config.logoutUrls,
|
|
36
|
+
responseType: config.responseType
|
|
37
|
+
},
|
|
38
|
+
allowCredentialsLogin: config.allowCredentialsLogin,
|
|
39
|
+
providers: config.providers
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const DefaultCognitoSignInConfig = CognitoSignInConfig.createImplementation({
|
|
44
|
+
implementation: DefaultCognitoSignInConfigImpl,
|
|
45
|
+
dependencies: [
|
|
46
|
+
BuildParams
|
|
47
|
+
]
|
|
48
|
+
});
|
|
49
|
+
export { DefaultCognitoSignInConfig };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=DefaultCognitoSignInConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin/DefaultCognitoSignInConfig.js","sources":["../../src/admin/DefaultCognitoSignInConfig.ts"],"sourcesContent":["import { BuildParams } from \"@webiny/app-admin/features/buildParams/index.js\";\nimport {\n CognitoSignInConfig,\n type ICognitoSignInConfig\n} from \"./presentation/Cognito/CognitoSignInConfig.js\";\n\ninterface FederationBuildParam {\n callbackUrls: string[];\n logoutUrls: string[];\n responseType: \"code\" | \"token\";\n allowCredentialsLogin: boolean;\n providers: { name: string; label: string }[];\n}\n\nclass DefaultCognitoSignInConfigImpl implements ICognitoSignInConfig {\n constructor(private buildParams: BuildParams.Interface) {}\n\n async getConfig() {\n const config = this.buildParams.get<FederationBuildParam>(\"cognitoFederation\");\n\n if (!config) {\n return {\n oauth: {\n scopes: [\"profile\", \"email\", \"openid\"],\n redirectSignIn: [window.location.origin],\n redirectSignOut: [window.location.origin],\n responseType: \"code\" as const\n },\n allowCredentialsLogin: true,\n providers: []\n };\n }\n\n return {\n oauth: {\n scopes: [\"profile\", \"email\", \"openid\"],\n redirectSignIn: config.callbackUrls,\n redirectSignOut: config.logoutUrls,\n responseType: config.responseType\n },\n allowCredentialsLogin: config.allowCredentialsLogin,\n providers: config.providers\n };\n }\n}\n\nexport const DefaultCognitoSignInConfig = CognitoSignInConfig.createImplementation({\n implementation: DefaultCognitoSignInConfigImpl,\n dependencies: [BuildParams]\n});\n"],"names":["DefaultCognitoSignInConfigImpl","buildParams","config","window","DefaultCognitoSignInConfig","CognitoSignInConfig","BuildParams"],"mappings":";;AAcA,MAAMA;IACF,YAAoBC,WAAkC,CAAE;aAApCA,WAAW,GAAXA;IAAqC;IAEzD,MAAM,YAAY;QACd,MAAMC,SAAS,IAAI,CAAC,WAAW,CAAC,GAAG,CAAuB;QAE1D,IAAI,CAACA,QACD,OAAO;YACH,OAAO;gBACH,QAAQ;oBAAC;oBAAW;oBAAS;iBAAS;gBACtC,gBAAgB;oBAACC,OAAO,QAAQ,CAAC,MAAM;iBAAC;gBACxC,iBAAiB;oBAACA,OAAO,QAAQ,CAAC,MAAM;iBAAC;gBACzC,cAAc;YAClB;YACA,uBAAuB;YACvB,WAAW,EAAE;QACjB;QAGJ,OAAO;YACH,OAAO;gBACH,QAAQ;oBAAC;oBAAW;oBAAS;iBAAS;gBACtC,gBAAgBD,OAAO,YAAY;gBACnC,iBAAiBA,OAAO,UAAU;gBAClC,cAAcA,OAAO,YAAY;YACrC;YACA,uBAAuBA,OAAO,qBAAqB;YACnD,WAAWA,OAAO,SAAS;QAC/B;IACJ;AACJ;AAEO,MAAME,6BAA6BC,oBAAoB,oBAAoB,CAAC;IAC/E,gBAAgBL;IAChB,cAAc;QAACM;KAAY;AAC/B"}
|
package/admin/Extension.js
CHANGED
|
@@ -3,6 +3,7 @@ import { RegisterFeature } from "@webiny/app-admin";
|
|
|
3
3
|
import { CognitoFeature } from "./presentation/Cognito/feature.js";
|
|
4
4
|
import { CognitoAdmin } from "./Cognito.js";
|
|
5
5
|
import { CognitoPermissionsFeature } from "./features/permissions/feature.js";
|
|
6
|
+
import { CognitoSignInFeature } from "./presentation/Cognito/signInFeature.js";
|
|
6
7
|
const Extension = ()=>{
|
|
7
8
|
const region = process.env.REACT_APP_USER_POOL_REGION || "";
|
|
8
9
|
const userPoolId = process.env.REACT_APP_USER_POOL_ID || "";
|
|
@@ -11,6 +12,8 @@ const Extension = ()=>{
|
|
|
11
12
|
feature: CognitoFeature
|
|
12
13
|
}), /*#__PURE__*/ react.createElement(RegisterFeature, {
|
|
13
14
|
feature: CognitoPermissionsFeature
|
|
15
|
+
}), /*#__PURE__*/ react.createElement(RegisterFeature, {
|
|
16
|
+
feature: CognitoSignInFeature
|
|
14
17
|
}), /*#__PURE__*/ react.createElement(CognitoAdmin, {
|
|
15
18
|
login: {
|
|
16
19
|
region,
|
package/admin/Extension.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/Extension.js","sources":["../../src/admin/Extension.tsx"],"sourcesContent":["import React from \"react\";\nimport { RegisterFeature } from \"@webiny/app-admin\";\nimport { CognitoFeature } from \"./presentation/Cognito/feature.js\";\nimport { CognitoAdmin } from \"./Cognito.js\";\nimport { CognitoPermissionsFeature } from \"./features/permissions/feature.js\";\n\nexport const Extension = () => {\n const region = process.env.REACT_APP_USER_POOL_REGION || \"\";\n const userPoolId = process.env.REACT_APP_USER_POOL_ID || \"\";\n const clientId = process.env.REACT_APP_USER_POOL_WEB_CLIENT_ID || \"\";\n\n return (\n <>\n <RegisterFeature feature={CognitoFeature} />\n <RegisterFeature feature={CognitoPermissionsFeature} />\n <CognitoAdmin
|
|
1
|
+
{"version":3,"file":"admin/Extension.js","sources":["../../src/admin/Extension.tsx"],"sourcesContent":["import React from \"react\";\nimport { RegisterFeature } from \"@webiny/app-admin\";\nimport { CognitoFeature } from \"./presentation/Cognito/feature.js\";\nimport { CognitoAdmin } from \"./Cognito.js\";\nimport { CognitoPermissionsFeature } from \"./features/permissions/feature.js\";\nimport { CognitoSignInFeature } from \"./presentation/Cognito/signInFeature.js\";\n\nexport const Extension = () => {\n const region = process.env.REACT_APP_USER_POOL_REGION || \"\";\n const userPoolId = process.env.REACT_APP_USER_POOL_ID || \"\";\n const clientId = process.env.REACT_APP_USER_POOL_WEB_CLIENT_ID || \"\";\n\n return (\n <>\n <RegisterFeature feature={CognitoFeature} />\n <RegisterFeature feature={CognitoPermissionsFeature} />\n <RegisterFeature feature={CognitoSignInFeature} />\n <CognitoAdmin login={{ region, userPoolId, clientId }} />\n </>\n );\n};\n"],"names":["Extension","region","process","userPoolId","clientId","RegisterFeature","CognitoFeature","CognitoPermissionsFeature","CognitoSignInFeature","CognitoAdmin"],"mappings":";;;;;;AAOO,MAAMA,YAAY;IACrB,MAAMC,SAASC,QAAQ,GAAG,CAAC,0BAA0B,IAAI;IACzD,MAAMC,aAAaD,QAAQ,GAAG,CAAC,sBAAsB,IAAI;IACzD,MAAME,WAAWF,QAAQ,GAAG,CAAC,iCAAiC,IAAI;IAElE,OAAO,WAAP,GACI,wDACI,oBAACG,iBAAeA;QAAC,SAASC;sBAC1B,oBAACD,iBAAeA;QAAC,SAASE;sBAC1B,oBAACF,iBAAeA;QAAC,SAASG;sBAC1B,oBAACC,cAAYA;QAAC,OAAO;YAAER;YAAQE;YAAYC;QAAS;;AAGhE"}
|
package/admin/index.d.ts
ADDED
package/admin/index.js
ADDED
|
@@ -8,6 +8,8 @@ import { RequireNewPassword } from "./components/RequireNewPassword.js";
|
|
|
8
8
|
import { RequestPasswordResetCode } from "./components/RequestPasswordResetCode.js";
|
|
9
9
|
import { SetNewPassword } from "./components/SetNewPassword.js";
|
|
10
10
|
import { PasswordResetCodeSent } from "./components/PasswordResetCodeSent.js";
|
|
11
|
+
import { ConfirmTotpCode } from "./components/ConfirmTotpCode.js";
|
|
12
|
+
import { SetupTotp } from "./components/SetupTotp.js";
|
|
11
13
|
const CognitoLoginScreen = observer((props)=>{
|
|
12
14
|
const { presenter } = useFeature(CognitoFeature);
|
|
13
15
|
useEffect(()=>{
|
|
@@ -40,6 +42,13 @@ const CognitoLoginScreen = observer((props)=>{
|
|
|
40
42
|
vm: vm.setNewPassword,
|
|
41
43
|
onSetNewPassword: (code, password)=>presenter.confirmPasswordReset(code, password),
|
|
42
44
|
onCancel: ()=>presenter.showSignIn()
|
|
45
|
+
}), "confirmTotpCode" === vm.authState && /*#__PURE__*/ react.createElement(ConfirmTotpCode, {
|
|
46
|
+
vm: vm.confirmTotpCode,
|
|
47
|
+
onSubmit: (code)=>presenter.confirmTotpCode(code),
|
|
48
|
+
onCancel: ()=>presenter.showSignIn()
|
|
49
|
+
}), "setupTotp" === vm.authState && /*#__PURE__*/ react.createElement(SetupTotp, {
|
|
50
|
+
vm: vm.setupTotp,
|
|
51
|
+
onSubmit: (code)=>presenter.verifyTotpSetup(code)
|
|
43
52
|
}), ("signIn" === vm.authState || "signedOut" === vm.authState) && /*#__PURE__*/ react.createElement(SignIn, {
|
|
44
53
|
vm: vm.signIn,
|
|
45
54
|
onSubmit: (username, password)=>presenter.signIn(username, password),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/presentation/Cognito/CognitoLoginScreen.js","sources":["../../../../src/admin/presentation/Cognito/CognitoLoginScreen.tsx"],"sourcesContent":["import React, { useEffect } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { useFeature } from \"@webiny/app\";\nimport { OverlayLoader } from \"@webiny/admin-ui\";\nimport { CognitoFeature } from \"./feature.js\";\nimport { SignIn } from \"./components/SignIn.js\";\nimport { RequireNewPassword } from \"./components/RequireNewPassword.js\";\nimport { RequestPasswordResetCode } from \"./components/RequestPasswordResetCode.js\";\nimport { SetNewPassword } from \"./components/SetNewPassword.js\";\nimport { PasswordResetCodeSent } from \"~/admin/presentation/Cognito/components/PasswordResetCodeSent.js\";\n\nexport interface CognitoLoginScreenProps {\n region: string;\n userPoolId: string;\n clientId: string;\n children: React.ReactNode;\n}\n\nexport const CognitoLoginScreen = observer((props: CognitoLoginScreenProps) => {\n const { presenter } = useFeature(CognitoFeature);\n\n useEffect(() => {\n presenter.init({\n region: props.region,\n userPoolId: props.userPoolId,\n clientId: props.clientId\n });\n }, []);\n\n const vm = presenter.vm;\n\n if (vm.isAuthenticated) {\n return <>{props.children}</>;\n }\n\n return (\n <>\n {vm.isLoggingIn ? <OverlayLoader text={\"Signing in...\"} /> : null}\n {vm.checkingSession ? <OverlayLoader text={\"Checking session...\"} /> : null}\n\n {!vm.isLoggingIn && !vm.checkingSession ? (\n <>\n {vm.authState === \"requireNewPassword\" && (\n <RequireNewPassword\n vm={vm.requireNewPassword}\n onSubmit={(password, attributes) =>\n presenter.confirmNewPassword(password, attributes)\n }\n onCancel={() => presenter.showSignIn()}\n />\n )}\n\n {vm.authState === \"requestPasswordResetCode\" && (\n <RequestPasswordResetCode\n vm={vm.requestPasswordResetCode}\n onRequestCode={username => presenter.requestPasswordReset(username)}\n onCancel={() => presenter.showSignIn()}\n />\n )}\n\n {vm.authState === \"passwordResetCodeSent\" && (\n <PasswordResetCodeSent\n vm={vm.passwordResetCodeSent}\n onResendCode={() => presenter.resendPasswordResetCode()}\n onCodeAcquired={() => presenter.showSetNewPassword()}\n onCancel={() => presenter.showSignIn()}\n />\n )}\n\n {vm.authState === \"setNewPassword\" && (\n <SetNewPassword\n vm={vm.setNewPassword}\n onSetNewPassword={(code, password) =>\n presenter.confirmPasswordReset(code, password)\n }\n onCancel={() => presenter.showSignIn()}\n />\n )}\n\n {(vm.authState === \"signIn\" || vm.authState === \"signedOut\") && (\n <SignIn\n vm={vm.signIn}\n onSubmit={(username, password) => presenter.signIn(username, password)}\n onForgotPassword={() => presenter.showRequestPasswordResetCode()}\n />\n )}\n </>\n ) : null}\n </>\n );\n});\n"],"names":["CognitoLoginScreen","observer","props","presenter","useFeature","CognitoFeature","useEffect","vm","OverlayLoader","RequireNewPassword","password","attributes","RequestPasswordResetCode","username","PasswordResetCodeSent","SetNewPassword","code","SignIn"],"mappings":"
|
|
1
|
+
{"version":3,"file":"admin/presentation/Cognito/CognitoLoginScreen.js","sources":["../../../../src/admin/presentation/Cognito/CognitoLoginScreen.tsx"],"sourcesContent":["import React, { useEffect } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { useFeature } from \"@webiny/app\";\nimport { OverlayLoader } from \"@webiny/admin-ui\";\nimport { CognitoFeature } from \"./feature.js\";\nimport { SignIn } from \"./components/SignIn.js\";\nimport { RequireNewPassword } from \"./components/RequireNewPassword.js\";\nimport { RequestPasswordResetCode } from \"./components/RequestPasswordResetCode.js\";\nimport { SetNewPassword } from \"./components/SetNewPassword.js\";\nimport { PasswordResetCodeSent } from \"~/admin/presentation/Cognito/components/PasswordResetCodeSent.js\";\nimport { ConfirmTotpCode } from \"./components/ConfirmTotpCode.js\";\nimport { SetupTotp } from \"./components/SetupTotp.js\";\n\nexport interface CognitoLoginScreenProps {\n region: string;\n userPoolId: string;\n clientId: string;\n children: React.ReactNode;\n}\n\nexport const CognitoLoginScreen = observer((props: CognitoLoginScreenProps) => {\n const { presenter } = useFeature(CognitoFeature);\n\n useEffect(() => {\n presenter.init({\n region: props.region,\n userPoolId: props.userPoolId,\n clientId: props.clientId\n });\n }, []);\n\n const vm = presenter.vm;\n\n if (vm.isAuthenticated) {\n return <>{props.children}</>;\n }\n\n return (\n <>\n {vm.isLoggingIn ? <OverlayLoader text={\"Signing in...\"} /> : null}\n {vm.checkingSession ? <OverlayLoader text={\"Checking session...\"} /> : null}\n\n {!vm.isLoggingIn && !vm.checkingSession ? (\n <>\n {vm.authState === \"requireNewPassword\" && (\n <RequireNewPassword\n vm={vm.requireNewPassword}\n onSubmit={(password, attributes) =>\n presenter.confirmNewPassword(password, attributes)\n }\n onCancel={() => presenter.showSignIn()}\n />\n )}\n\n {vm.authState === \"requestPasswordResetCode\" && (\n <RequestPasswordResetCode\n vm={vm.requestPasswordResetCode}\n onRequestCode={username => presenter.requestPasswordReset(username)}\n onCancel={() => presenter.showSignIn()}\n />\n )}\n\n {vm.authState === \"passwordResetCodeSent\" && (\n <PasswordResetCodeSent\n vm={vm.passwordResetCodeSent}\n onResendCode={() => presenter.resendPasswordResetCode()}\n onCodeAcquired={() => presenter.showSetNewPassword()}\n onCancel={() => presenter.showSignIn()}\n />\n )}\n\n {vm.authState === \"setNewPassword\" && (\n <SetNewPassword\n vm={vm.setNewPassword}\n onSetNewPassword={(code, password) =>\n presenter.confirmPasswordReset(code, password)\n }\n onCancel={() => presenter.showSignIn()}\n />\n )}\n\n {vm.authState === \"confirmTotpCode\" && (\n <ConfirmTotpCode\n vm={vm.confirmTotpCode}\n onSubmit={code => presenter.confirmTotpCode(code)}\n onCancel={() => presenter.showSignIn()}\n />\n )}\n\n {vm.authState === \"setupTotp\" && (\n <SetupTotp\n vm={vm.setupTotp}\n onSubmit={code => presenter.verifyTotpSetup(code)}\n />\n )}\n\n {(vm.authState === \"signIn\" || vm.authState === \"signedOut\") && (\n <SignIn\n vm={vm.signIn}\n onSubmit={(username, password) => presenter.signIn(username, password)}\n onForgotPassword={() => presenter.showRequestPasswordResetCode()}\n />\n )}\n </>\n ) : null}\n </>\n );\n});\n"],"names":["CognitoLoginScreen","observer","props","presenter","useFeature","CognitoFeature","useEffect","vm","OverlayLoader","RequireNewPassword","password","attributes","RequestPasswordResetCode","username","PasswordResetCodeSent","SetNewPassword","code","ConfirmTotpCode","SetupTotp","SignIn"],"mappings":";;;;;;;;;;;;AAoBO,MAAMA,qBAAqBC,SAAS,CAACC;IACxC,MAAM,EAAEC,SAAS,EAAE,GAAGC,WAAWC;IAEjCC,UAAU;QACNH,UAAU,IAAI,CAAC;YACX,QAAQD,MAAM,MAAM;YACpB,YAAYA,MAAM,UAAU;YAC5B,UAAUA,MAAM,QAAQ;QAC5B;IACJ,GAAG,EAAE;IAEL,MAAMK,KAAKJ,UAAU,EAAE;IAEvB,IAAII,GAAG,eAAe,EAClB,OAAO,WAAP,GAAO,0CAAGL,MAAM,QAAQ;IAG5B,OAAO,WAAP,GACI,0CACKK,GAAG,WAAW,GAAG,WAAH,GAAG,oBAACC,eAAaA;QAAC,MAAM;SAAsB,MAC5DD,GAAG,eAAe,GAAG,WAAH,GAAG,oBAACC,eAAaA;QAAC,MAAM;SAA4B,MAEtE,AAACD,GAAG,WAAW,IAAKA,GAAG,eAAe,GA8DnC,OA9DsC,WAAH,GACnC,0CACKA,AAAiB,yBAAjBA,GAAG,SAAS,IAA6B,WAAxB,GACd,oBAACE,oBAAkBA;QACf,IAAIF,GAAG,kBAAkB;QACzB,UAAU,CAACG,UAAUC,aACjBR,UAAU,kBAAkB,CAACO,UAAUC;QAE3C,UAAU,IAAMR,UAAU,UAAU;QAI3CI,AAAiB,+BAAjBA,GAAG,SAAS,IAAmC,WAA9B,GACd,oBAACK,0BAAwBA;QACrB,IAAIL,GAAG,wBAAwB;QAC/B,eAAeM,CAAAA,WAAYV,UAAU,oBAAoB,CAACU;QAC1D,UAAU,IAAMV,UAAU,UAAU;QAI3CI,AAAiB,4BAAjBA,GAAG,SAAS,IAAgC,WAA3B,GACd,oBAACO,uBAAqBA;QAClB,IAAIP,GAAG,qBAAqB;QAC5B,cAAc,IAAMJ,UAAU,uBAAuB;QACrD,gBAAgB,IAAMA,UAAU,kBAAkB;QAClD,UAAU,IAAMA,UAAU,UAAU;QAI3CI,AAAiB,qBAAjBA,GAAG,SAAS,IAAyB,WAApB,GACd,oBAACQ,gBAAcA;QACX,IAAIR,GAAG,cAAc;QACrB,kBAAkB,CAACS,MAAMN,WACrBP,UAAU,oBAAoB,CAACa,MAAMN;QAEzC,UAAU,IAAMP,UAAU,UAAU;QAI3CI,AAAiB,sBAAjBA,GAAG,SAAS,IAA0B,WAArB,GACd,oBAACU,iBAAeA;QACZ,IAAIV,GAAG,eAAe;QACtB,UAAUS,CAAAA,OAAQb,UAAU,eAAe,CAACa;QAC5C,UAAU,IAAMb,UAAU,UAAU;QAI3CI,AAAiB,gBAAjBA,GAAG,SAAS,IAAoB,WAAf,GACd,oBAACW,WAASA;QACN,IAAIX,GAAG,SAAS;QAChB,UAAUS,CAAAA,OAAQb,UAAU,eAAe,CAACa;QAIlDT,AAAAA,CAAAA,AAAiB,aAAjBA,GAAG,SAAS,IAAiBA,AAAiB,gBAAjBA,GAAG,SAAS,AAAe,mBACtD,oBAACY,QAAMA;QACH,IAAIZ,GAAG,MAAM;QACb,UAAU,CAACM,UAAUH,WAAaP,UAAU,MAAM,CAACU,UAAUH;QAC7D,kBAAkB,IAAMP,UAAU,4BAA4B;;AAO1F"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { CognitoPresenter as CognitoPresenterAbstraction, AuthState, AuthMessage, ICognitoInitParams } from "./abstractions.js";
|
|
2
2
|
import { LogInUseCase } from "@webiny/app-admin/features/security/LogIn/index.js";
|
|
3
3
|
import { IdentityContext } from "@webiny/app-admin/features/security/IdentityContext/index.js";
|
|
4
|
+
import { CognitoSignInConfig } from "./CognitoSignInConfig.js";
|
|
4
5
|
declare class CognitoPresenterImpl implements CognitoPresenterAbstraction.Interface {
|
|
5
6
|
private identity;
|
|
6
7
|
private logInUseCase;
|
|
8
|
+
private signInConfig;
|
|
7
9
|
private authState;
|
|
8
10
|
private authData;
|
|
9
11
|
private message;
|
|
@@ -11,7 +13,13 @@ declare class CognitoPresenterImpl implements CognitoPresenterAbstraction.Interf
|
|
|
11
13
|
private isLoggingIn;
|
|
12
14
|
private formLoading;
|
|
13
15
|
private initialized;
|
|
14
|
-
|
|
16
|
+
private signInTitle;
|
|
17
|
+
private signInDescription;
|
|
18
|
+
private allowCredentialsLogin;
|
|
19
|
+
private federatedProviders;
|
|
20
|
+
private totpSharedSecret;
|
|
21
|
+
private totpQrCodeUri;
|
|
22
|
+
constructor(identity: IdentityContext.Interface, logInUseCase: LogInUseCase.Interface, signInConfig: CognitoSignInConfig.Interface | undefined);
|
|
15
23
|
get vm(): {
|
|
16
24
|
authState: AuthState;
|
|
17
25
|
checkingSession: boolean;
|
|
@@ -20,6 +28,10 @@ declare class CognitoPresenterImpl implements CognitoPresenterAbstraction.Interf
|
|
|
20
28
|
signIn: {
|
|
21
29
|
isLoading: boolean;
|
|
22
30
|
message: AuthMessage | null;
|
|
31
|
+
title: string;
|
|
32
|
+
description: string | undefined;
|
|
33
|
+
allowCredentialsLogin: boolean;
|
|
34
|
+
federatedProviders: import("./CognitoSignInConfig.js").IFederatedProvider[];
|
|
23
35
|
};
|
|
24
36
|
requestPasswordResetCode: {
|
|
25
37
|
isLoading: boolean;
|
|
@@ -37,6 +49,16 @@ declare class CognitoPresenterImpl implements CognitoPresenterAbstraction.Interf
|
|
|
37
49
|
isLoading: boolean;
|
|
38
50
|
requiredAttributes: string[];
|
|
39
51
|
};
|
|
52
|
+
confirmTotpCode: {
|
|
53
|
+
isLoading: boolean;
|
|
54
|
+
message: AuthMessage | null;
|
|
55
|
+
};
|
|
56
|
+
setupTotp: {
|
|
57
|
+
isLoading: boolean;
|
|
58
|
+
sharedSecret: string;
|
|
59
|
+
qrCodeUri: string;
|
|
60
|
+
message: AuthMessage | null;
|
|
61
|
+
};
|
|
40
62
|
};
|
|
41
63
|
init(params: ICognitoInitParams): Promise<void>;
|
|
42
64
|
signIn(username: string, password: string): Promise<void>;
|
|
@@ -44,6 +66,8 @@ declare class CognitoPresenterImpl implements CognitoPresenterAbstraction.Interf
|
|
|
44
66
|
requestPasswordReset(username: string): Promise<void>;
|
|
45
67
|
resendPasswordResetCode(): Promise<void>;
|
|
46
68
|
confirmPasswordReset(code: string, password: string): Promise<void>;
|
|
69
|
+
confirmTotpCode(code: string): Promise<void>;
|
|
70
|
+
verifyTotpSetup(code: string): Promise<void>;
|
|
47
71
|
showSignIn(): void;
|
|
48
72
|
showRequestPasswordResetCode(): void;
|
|
49
73
|
showSetNewPassword(): void;
|
|
@@ -4,10 +4,13 @@ import { confirmResetPassword, confirmSignIn, fetchAuthSession, resetPassword, s
|
|
|
4
4
|
import { CognitoPresenter } from "./abstractions.js";
|
|
5
5
|
import { LogInUseCase } from "@webiny/app-admin/features/security/LogIn/index.js";
|
|
6
6
|
import { IdentityContext } from "@webiny/app-admin/features/security/IdentityContext/index.js";
|
|
7
|
+
import { CognitoSignInConfig } from "./CognitoSignInConfig.js";
|
|
8
|
+
const federatedDescription = "You will be taken to an external service to complete the sign-in process.";
|
|
7
9
|
class CognitoPresenterImpl {
|
|
8
|
-
constructor(identity, logInUseCase){
|
|
10
|
+
constructor(identity, logInUseCase, signInConfig){
|
|
9
11
|
this.identity = identity;
|
|
10
12
|
this.logInUseCase = logInUseCase;
|
|
13
|
+
this.signInConfig = signInConfig;
|
|
11
14
|
this.authState = "signIn";
|
|
12
15
|
this.authData = null;
|
|
13
16
|
this.message = null;
|
|
@@ -15,6 +18,12 @@ class CognitoPresenterImpl {
|
|
|
15
18
|
this.isLoggingIn = false;
|
|
16
19
|
this.formLoading = false;
|
|
17
20
|
this.initialized = false;
|
|
21
|
+
this.signInTitle = "Sign in";
|
|
22
|
+
this.signInDescription = void 0;
|
|
23
|
+
this.allowCredentialsLogin = true;
|
|
24
|
+
this.federatedProviders = [];
|
|
25
|
+
this.totpSharedSecret = "";
|
|
26
|
+
this.totpQrCodeUri = "";
|
|
18
27
|
makeAutoObservable(this);
|
|
19
28
|
}
|
|
20
29
|
get vm() {
|
|
@@ -26,7 +35,11 @@ class CognitoPresenterImpl {
|
|
|
26
35
|
isAuthenticated: identity.isAuthenticated,
|
|
27
36
|
signIn: {
|
|
28
37
|
isLoading: this.formLoading,
|
|
29
|
-
message: this.message
|
|
38
|
+
message: this.message,
|
|
39
|
+
title: this.signInTitle,
|
|
40
|
+
description: this.signInDescription,
|
|
41
|
+
allowCredentialsLogin: this.allowCredentialsLogin,
|
|
42
|
+
federatedProviders: this.federatedProviders
|
|
30
43
|
},
|
|
31
44
|
requestPasswordResetCode: {
|
|
32
45
|
isLoading: this.formLoading,
|
|
@@ -43,13 +56,50 @@ class CognitoPresenterImpl {
|
|
|
43
56
|
requireNewPassword: {
|
|
44
57
|
isLoading: this.formLoading,
|
|
45
58
|
requiredAttributes: this.authData && this.authData.requiredAttributes || []
|
|
59
|
+
},
|
|
60
|
+
confirmTotpCode: {
|
|
61
|
+
isLoading: this.formLoading,
|
|
62
|
+
message: this.message
|
|
63
|
+
},
|
|
64
|
+
setupTotp: {
|
|
65
|
+
isLoading: this.formLoading,
|
|
66
|
+
sharedSecret: this.totpSharedSecret,
|
|
67
|
+
qrCodeUri: this.totpQrCodeUri,
|
|
68
|
+
message: this.message
|
|
46
69
|
}
|
|
47
70
|
};
|
|
48
71
|
}
|
|
49
72
|
async init(params) {
|
|
50
73
|
if (this.initialized) return;
|
|
74
|
+
let oauthConfig;
|
|
75
|
+
if (this.signInConfig) {
|
|
76
|
+
const config = await this.signInConfig.getConfig();
|
|
77
|
+
runInAction(()=>{
|
|
78
|
+
this.signInTitle = config.title ?? "Sign in";
|
|
79
|
+
this.signInDescription = config.description;
|
|
80
|
+
if (!config.description && !config.allowCredentialsLogin) this.signInDescription = federatedDescription;
|
|
81
|
+
this.allowCredentialsLogin = config.allowCredentialsLogin;
|
|
82
|
+
this.federatedProviders = config.providers;
|
|
83
|
+
});
|
|
84
|
+
const domain = process.env.REACT_APP_USER_POOL_DOMAIN;
|
|
85
|
+
if (domain) oauthConfig = {
|
|
86
|
+
Cognito: {
|
|
87
|
+
userPoolId: params.userPoolId,
|
|
88
|
+
userPoolClientId: params.clientId,
|
|
89
|
+
loginWith: {
|
|
90
|
+
oauth: {
|
|
91
|
+
domain,
|
|
92
|
+
redirectSignIn: config.oauth.redirectSignIn,
|
|
93
|
+
redirectSignOut: config.oauth.redirectSignOut,
|
|
94
|
+
scopes: config.oauth.scopes,
|
|
95
|
+
responseType: config.oauth.responseType
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
51
101
|
Amplify.configure({
|
|
52
|
-
Auth: {
|
|
102
|
+
Auth: oauthConfig ?? {
|
|
53
103
|
Cognito: {
|
|
54
104
|
userPoolId: params.userPoolId,
|
|
55
105
|
userPoolClientId: params.clientId
|
|
@@ -81,7 +131,20 @@ class CognitoPresenterImpl {
|
|
|
81
131
|
};
|
|
82
132
|
this.formLoading = false;
|
|
83
133
|
});
|
|
84
|
-
else {
|
|
134
|
+
else if ("CONFIRM_SIGN_IN_WITH_TOTP_CODE" === nextStep.signInStep) runInAction(()=>{
|
|
135
|
+
this.authState = "confirmTotpCode";
|
|
136
|
+
this.formLoading = false;
|
|
137
|
+
});
|
|
138
|
+
else if ("CONTINUE_SIGN_IN_WITH_TOTP_SETUP" === nextStep.signInStep) {
|
|
139
|
+
const totpSetup = nextStep.totpSetupDetails;
|
|
140
|
+
const uri = totpSetup.getSetupUri("Webiny").toString();
|
|
141
|
+
runInAction(()=>{
|
|
142
|
+
this.totpSharedSecret = totpSetup.sharedSecret;
|
|
143
|
+
this.totpQrCodeUri = uri;
|
|
144
|
+
this.authState = "setupTotp";
|
|
145
|
+
this.formLoading = false;
|
|
146
|
+
});
|
|
147
|
+
} else {
|
|
85
148
|
await this.handleSignedIn();
|
|
86
149
|
runInAction(()=>{
|
|
87
150
|
this.formLoading = false;
|
|
@@ -193,6 +256,54 @@ class CognitoPresenterImpl {
|
|
|
193
256
|
});
|
|
194
257
|
}
|
|
195
258
|
}
|
|
259
|
+
async confirmTotpCode(code) {
|
|
260
|
+
runInAction(()=>{
|
|
261
|
+
this.formLoading = true;
|
|
262
|
+
this.message = null;
|
|
263
|
+
});
|
|
264
|
+
try {
|
|
265
|
+
await confirmSignIn({
|
|
266
|
+
challengeResponse: code
|
|
267
|
+
});
|
|
268
|
+
await this.handleSignedIn();
|
|
269
|
+
} catch (error) {
|
|
270
|
+
runInAction(()=>{
|
|
271
|
+
this.message = {
|
|
272
|
+
title: "Verification Failed",
|
|
273
|
+
text: error.message,
|
|
274
|
+
type: "danger"
|
|
275
|
+
};
|
|
276
|
+
});
|
|
277
|
+
} finally{
|
|
278
|
+
runInAction(()=>{
|
|
279
|
+
this.formLoading = false;
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
async verifyTotpSetup(code) {
|
|
284
|
+
runInAction(()=>{
|
|
285
|
+
this.formLoading = true;
|
|
286
|
+
this.message = null;
|
|
287
|
+
});
|
|
288
|
+
try {
|
|
289
|
+
await confirmSignIn({
|
|
290
|
+
challengeResponse: code
|
|
291
|
+
});
|
|
292
|
+
await this.handleSignedIn();
|
|
293
|
+
} catch (error) {
|
|
294
|
+
runInAction(()=>{
|
|
295
|
+
this.message = {
|
|
296
|
+
title: "Setup Failed",
|
|
297
|
+
text: error.message,
|
|
298
|
+
type: "danger"
|
|
299
|
+
};
|
|
300
|
+
});
|
|
301
|
+
} finally{
|
|
302
|
+
runInAction(()=>{
|
|
303
|
+
this.formLoading = false;
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
}
|
|
196
307
|
showSignIn() {
|
|
197
308
|
this.authState = "signIn";
|
|
198
309
|
this.authData = null;
|
|
@@ -241,11 +352,6 @@ class CognitoPresenterImpl {
|
|
|
241
352
|
}
|
|
242
353
|
}
|
|
243
354
|
async checkUrl() {
|
|
244
|
-
const query = new URLSearchParams(window.location.search);
|
|
245
|
-
const queryData = {};
|
|
246
|
-
query.forEach((value, key)=>queryData[key] = value);
|
|
247
|
-
const { state } = queryData;
|
|
248
|
-
if (state) return;
|
|
249
355
|
return this.checkSession();
|
|
250
356
|
}
|
|
251
357
|
async checkSession() {
|
|
@@ -266,7 +372,13 @@ const CognitoPresenter_CognitoPresenter = CognitoPresenter.createImplementation(
|
|
|
266
372
|
implementation: CognitoPresenterImpl,
|
|
267
373
|
dependencies: [
|
|
268
374
|
IdentityContext,
|
|
269
|
-
LogInUseCase
|
|
375
|
+
LogInUseCase,
|
|
376
|
+
[
|
|
377
|
+
CognitoSignInConfig,
|
|
378
|
+
{
|
|
379
|
+
optional: true
|
|
380
|
+
}
|
|
381
|
+
]
|
|
270
382
|
]
|
|
271
383
|
});
|
|
272
384
|
export { CognitoPresenter_CognitoPresenter as CognitoPresenter };
|