Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
135 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Amplify } from "aws-amplify"; | ||
|
||
import { Config } from "."; | ||
|
||
export type CognitoParams = { | ||
region?: string; | ||
userPoolId?: string; | ||
userPoolWebClientId?: string; | ||
oauthScope?: string; | ||
oauthDomain?: string; | ||
oauthRedirectSignIn?: string; | ||
oauthRedirectSignOut?: string; | ||
oauthResponseType?: string; | ||
}; | ||
|
||
export const configureCognito = (config: Config) => { | ||
const cognitoConfig = config.cognito; | ||
const authProvider = config.authProvider; | ||
|
||
if (cognitoConfig && authProvider === "cognito") { | ||
const cognitoRegion = cognitoConfig?.region; | ||
const cognitoUserPoolId = cognitoConfig?.userPoolId; | ||
const cognitoUserPoolWebClientId = cognitoConfig?.userPoolWebClientId; | ||
const cognitoOauthScope = cognitoConfig?.oauthScope?.split(", "); | ||
const cognitoOauthDomain = cognitoConfig?.oauthDomain; | ||
const cognitoOauthRedirectSignIn = cognitoConfig?.oauthRedirectSignIn; | ||
const cognitoOauthRedirectSignOut = cognitoConfig?.oauthRedirectSignOut; | ||
const cognitoOauthResponseType = cognitoConfig?.oauthResponseType; | ||
|
||
const config = { | ||
Auth: { | ||
region: cognitoRegion, | ||
userPoolId: cognitoUserPoolId, | ||
userPoolWebClientId: cognitoUserPoolWebClientId, | ||
oauth: { | ||
scope: cognitoOauthScope, | ||
domain: cognitoOauthDomain, | ||
redirectSignIn: cognitoOauthRedirectSignIn, | ||
redirectSignOut: cognitoOauthRedirectSignOut, | ||
responseType: cognitoOauthResponseType, | ||
}, | ||
}, | ||
}; | ||
|
||
Amplify.configure(config); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { Config } from "."; | ||
|
||
export const defaultConfig: Config = { | ||
api: "/api", | ||
plugins: "/plugins", | ||
published: window.origin + "/p/{}/", | ||
auth0Audience: "http://localhost:8080", | ||
auth0Domain: "http://localhost:8080", | ||
auth0ClientId: "reearth-authsrv-client-default", | ||
authProvider: "auth0", | ||
policy: { | ||
modalTitle: { | ||
en: "Re:Earth Cloud", | ||
ja: "Re:Earth Cloud", | ||
}, | ||
modalDescription: { | ||
en: "This is your currently subscribed to plan. If this plan stops meeting your needs, Re:Earth has other plans available. ", | ||
ja: "日本語版にほなsdflkjlksdjf", | ||
}, | ||
url: { | ||
en: "https://reearth.io/service/cloud", | ||
ja: "https://reearth.io/ja/service/cloud", | ||
}, | ||
limitNotifications: { | ||
asset: { | ||
en: "Your workspace has reached its plan's limit for assets. Please check reearth.io/service/cloud for details.", | ||
ja: "", | ||
}, | ||
createProject: { | ||
en: "Your workspace has reached its plan's limit for projects. Please check reearth.io/service/cloud for details.", | ||
ja: "", | ||
}, | ||
dataset: { | ||
en: "Your workspace has reached its plan's limit for dataset. Please check reearth.io/service/cloud for details.", | ||
ja: "", | ||
}, | ||
member: { | ||
en: "Your workspace has reached its plan's limit for new members. Please check reearth.io/service/cloud for details.", | ||
ja: "", | ||
}, | ||
layer: { | ||
en: "Your workspace has reached its plan's limit for layers. Please check reearth.io/service/cloud for details.", | ||
ja: "", | ||
}, | ||
publishProject: { | ||
en: "Your workspace has reached its plan's limit for publishing projects. Please check reearth.io/service/cloud for details.", | ||
ja: "", | ||
}, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export type PasswordPolicy = { | ||
tooShort?: RegExp; | ||
tooLong?: RegExp; | ||
whitespace?: RegExp; | ||
lowSecurity?: RegExp; | ||
medSecurity?: RegExp; | ||
highSecurity?: RegExp; | ||
}; | ||
|
||
export function convertPasswordPolicy(passwordPolicy?: { | ||
[key: string]: string; | ||
}): { [key: string]: RegExp | undefined } | undefined { | ||
if (!passwordPolicy) return; | ||
return Object.fromEntries( | ||
Object.entries(passwordPolicy) | ||
.map(([k, v]) => { | ||
if (typeof v !== "string") return [k, undefined]; | ||
try { | ||
return [k, new RegExp(v)]; | ||
} catch { | ||
return [k, undefined]; | ||
} | ||
}) | ||
.filter(i => !!i[1]), | ||
); | ||
} |