@stack-spot/auth-react 2.13.0 → 2.14.1-beta.1

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/src/dictionary.ts CHANGED
@@ -1,48 +1,48 @@
1
- import { Dictionary, useTranslate } from '@stack-spot/portal-translate'
2
-
3
- const dictionary = {
4
- en: {
5
- welcome: 'Welcome to StackSpot AI',
6
- loginWithEmail: 'Log in with your email.',
7
- loginWithSocialAccount1: 'Sign up or access your ',
8
- loginWithSocialAccount2: ' freemium account ',
9
- loginWithSocialAccount3: ' with a social login',
10
- label: 'Corporate email',
11
- placeholder: 'email@company.com',
12
- continue: 'Continue',
13
- or: 'Or',
14
- loginWith: 'Continue with $0',
15
- emailNotAllowedTitle: 'Your email is linked to an Enterprise account.',
16
- emailNotAllowedSubtitle: "Please log in with your corporate email.",
17
- socialLogin: 'Login or register with a social account',
18
- corporateLoginTitle: 'Already have a StackSpot Enterprise account?',
19
- corporateLoginButton: 'Enter Enterprise account',
20
- socialLoginTitle: 'Do you want to access another way?',
21
- emailNotFoundError: 'We couldn\'t find an account for this email.',
22
- errorMobileDesktop: "It looks like you are using a mobile device in desktop mode. We recommend adjusting this setting before continuing for a complete experience.",
23
- loginTemporarilyUnavailable: 'Login temporarily unavailable.'
24
- },
25
- pt: {
26
- welcome: 'Boas vindas à StackSpot AI',
27
- loginWithEmail: 'Faça login com seu e-mail.',
28
- loginWithSocialAccount1: 'Cadastre-se ou acesse sua ',
29
- loginWithSocialAccount2: ' conta freemium ',
30
- loginWithSocialAccount3: ' com uma conta social',
31
- label: 'Email corporativo',
32
- placeholder: 'email@empresa.com',
33
- continue: 'Continuar',
34
- or: 'Ou',
35
- loginWith: 'Continuar com $0',
36
- emailNotAllowedTitle: '"Este e-mail está vinculado a uma conta Enterprise.',
37
- emailNotAllowedSubtitle: "Faça login com seu email corporativo.",
38
- socialLogin: 'Entre ou cadastre-se com uma conta social',
39
- corporateLoginTitle: 'Já possui uma conta StackSpot Enterprise?',
40
- corporateLoginButton: 'Entrar na conta Enterprise',
41
- socialLoginTitle: 'Você quer entrar de outro jeito?',
42
- emailNotFoundError: 'Não encontramos uma conta para este e-mail.',
43
- errorMobileDesktop: "Parece que você está utilizando um dispositivo móvel na versão desktop. Recomendamos ajustar essa configuração antes de continuar para uma experiência completa.",
44
- loginTemporarilyUnavailable: 'Login indisponível temporariamente.'
45
- },
46
- } satisfies Dictionary
47
-
48
- export const useTranslation = () => useTranslate(dictionary)
1
+ import { Dictionary, useTranslate } from '@stack-spot/portal-translate'
2
+
3
+ const dictionary = {
4
+ en: {
5
+ welcome: 'Welcome to StackSpot AI',
6
+ loginWithEmail: 'Log in with your email.',
7
+ loginWithSocialAccount1: 'Sign up or access your ',
8
+ loginWithSocialAccount2: ' freemium account ',
9
+ loginWithSocialAccount3: ' with a social login',
10
+ label: 'Corporate email',
11
+ placeholder: 'email@company.com',
12
+ continue: 'Continue',
13
+ or: 'Or',
14
+ loginWith: 'Continue with $0',
15
+ emailNotAllowedTitle: 'Your email is linked to an Enterprise account.',
16
+ emailNotAllowedSubtitle: "Please log in with your corporate email.",
17
+ socialLogin: 'Login or register with a social account',
18
+ corporateLoginTitle: 'Already have a StackSpot Enterprise account?',
19
+ corporateLoginButton: 'Enter Enterprise account',
20
+ socialLoginTitle: 'Do you want to access another way?',
21
+ emailNotFoundError: 'We couldn\'t find an account for this email.',
22
+ errorMobileDesktop: "It looks like you are using a mobile device in desktop mode. We recommend adjusting this setting before continuing for a complete experience.",
23
+ loginTemporarilyUnavailable: 'Login temporarily unavailable.'
24
+ },
25
+ pt: {
26
+ welcome: 'Boas vindas à StackSpot AI',
27
+ loginWithEmail: 'Faça login com seu e-mail.',
28
+ loginWithSocialAccount1: 'Cadastre-se ou acesse sua ',
29
+ loginWithSocialAccount2: ' conta freemium ',
30
+ loginWithSocialAccount3: ' com uma conta social',
31
+ label: 'Email corporativo',
32
+ placeholder: 'email@empresa.com',
33
+ continue: 'Continuar',
34
+ or: 'Ou',
35
+ loginWith: 'Continuar com $0',
36
+ emailNotAllowedTitle: '"Este e-mail está vinculado a uma conta Enterprise.',
37
+ emailNotAllowedSubtitle: "Faça login com seu email corporativo.",
38
+ socialLogin: 'Entre ou cadastre-se com uma conta social',
39
+ corporateLoginTitle: 'Já possui uma conta StackSpot Enterprise?',
40
+ corporateLoginButton: 'Entrar na conta Enterprise',
41
+ socialLoginTitle: 'Você quer entrar de outro jeito?',
42
+ emailNotFoundError: 'Não encontramos uma conta para este e-mail.',
43
+ errorMobileDesktop: "Parece que você está utilizando um dispositivo móvel na versão desktop. Recomendamos ajustar essa configuração antes de continuar para uma experiência completa.",
44
+ loginTemporarilyUnavailable: 'Login indisponível temporariamente.'
45
+ },
46
+ } satisfies Dictionary
47
+
48
+ export const useTranslation = () => useTranslate(dictionary)
package/src/hooks.ts CHANGED
@@ -1,34 +1,34 @@
1
- import { Session } from '@stack-spot/auth'
2
- import { useEffect, useState } from 'react'
3
- import { SessionManager } from './SessionManager'
4
-
5
- export function useSession() {
6
- const manager = SessionManager.instance
7
- const [session, setSession] = useState<Session | undefined>(manager?.hasSession() ? manager.getSession() : undefined)
8
- useEffect(() => {
9
- return manager?.onChange(setSession)
10
- }, [])
11
- return session
12
- }
13
-
14
- export type Provider = 'google' | 'github' | 'microsoft'
15
- export const useTrialProviders = ({ enabled = true }): [Provider[], boolean] => {
16
- const [isLoadingTrialProviders, setIsLoadingTrialProviders] = useState<boolean>(enabled)
17
- const [trialProviders, setTrialProviders] = useState<Provider[]>([])
18
-
19
- useEffect(() => {
20
- (async () => {
21
- if (!SessionManager.instance || !enabled) return
22
- try {
23
- const providers = (await SessionManager.instance.getTrialEnabledProviders()) as Provider[]
24
- setTrialProviders(providers)
25
- setIsLoadingTrialProviders(false)
26
- } catch (error) {
27
- console.error(error)
28
- setIsLoadingTrialProviders(false)
29
- }
30
- })()
31
- }, [SessionManager.instance])
32
-
33
- return [trialProviders, isLoadingTrialProviders]
34
- }
1
+ import { Session } from '@stack-spot/auth'
2
+ import { useEffect, useState } from 'react'
3
+ import { SessionManager } from './SessionManager'
4
+
5
+ export function useSession() {
6
+ const manager = SessionManager.instance
7
+ const [session, setSession] = useState<Session | undefined>(manager?.hasSession() ? manager.getSession() : undefined)
8
+ useEffect(() => {
9
+ return manager?.onChange(setSession)
10
+ }, [])
11
+ return session
12
+ }
13
+
14
+ export type Provider = 'google' | 'github' | 'microsoft'
15
+ export const useTrialProviders = ({ enabled = true }): [Provider[], boolean] => {
16
+ const [isLoadingTrialProviders, setIsLoadingTrialProviders] = useState<boolean>(enabled)
17
+ const [trialProviders, setTrialProviders] = useState<Provider[]>([])
18
+
19
+ useEffect(() => {
20
+ (async () => {
21
+ if (!SessionManager.instance || !enabled) return
22
+ try {
23
+ const providers = (await SessionManager.instance.getTrialEnabledProviders()) as Provider[]
24
+ setTrialProviders(providers)
25
+ setIsLoadingTrialProviders(false)
26
+ } catch (error) {
27
+ console.error(error)
28
+ setIsLoadingTrialProviders(false)
29
+ }
30
+ })()
31
+ }, [SessionManager.instance])
32
+
33
+ return [trialProviders, isLoadingTrialProviders]
34
+ }
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { Authenticated } from './Authenticated'
2
- export { useSession } from './hooks'
3
- export { Login } from './Login'
4
- export { SessionManager } from './SessionManager'
5
-
1
+ export { Authenticated } from './Authenticated'
2
+ export { useSession } from './hooks'
3
+ export { Login } from './Login'
4
+ export { SessionManager } from './SessionManager'
5
+
@@ -1,20 +1,20 @@
1
- import { getCookie } from '@stack-spot/portal-components'
2
- import { LoginType } from './types'
3
-
4
- const lastLoginTypeKey = 'lastLoginType'
5
- const fallbackKeys = ['guided-tour', '@stack-spot/opa:user', 'CHAT_AGENTS', 'RATED_US_IN']
6
-
7
- export function getLastLoginType(): LoginType {
8
- const type = localStorage.getItem(lastLoginTypeKey)
9
- if (type === 'idp' || type === 'sso') return type
10
- // for now, the user won't have the variable "lastLoginType" set. So, we check for tother variables that may indicate this is an enterprise user
11
- if (getCookie('stk-session.stackspot.com')) return 'sso'
12
- for (const key of fallbackKeys) {
13
- if (localStorage.getItem(key)) return 'sso'
14
- }
15
- return 'idp'
16
- }
17
-
18
- export function setLastLoginType(type: LoginType) {
19
- localStorage.setItem(lastLoginTypeKey, type)
20
- }
1
+ import { getCookie } from '@stack-spot/portal-components'
2
+ import { LoginType } from './types'
3
+
4
+ const lastLoginTypeKey = 'lastLoginType'
5
+ const fallbackKeys = ['guided-tour', '@stack-spot/opa:user', 'CHAT_AGENTS', 'RATED_US_IN']
6
+
7
+ export function getLastLoginType(): LoginType {
8
+ const type = localStorage.getItem(lastLoginTypeKey)
9
+ if (type === 'idp' || type === 'sso') return type
10
+ // for now, the user won't have the variable "lastLoginType" set. So, we check for tother variables that may indicate this is an enterprise user
11
+ if (getCookie('stk-session.stackspot.com')) return 'sso'
12
+ for (const key of fallbackKeys) {
13
+ if (localStorage.getItem(key)) return 'sso'
14
+ }
15
+ return 'idp'
16
+ }
17
+
18
+ export function setLastLoginType(type: LoginType) {
19
+ localStorage.setItem(lastLoginTypeKey, type)
20
+ }
@@ -1,21 +1,21 @@
1
- import { forwardRef, Ref, SVGProps } from 'react'
2
-
3
- export const Github = forwardRef((props: SVGProps<SVGSVGElement>, ref: Ref<SVGSVGElement>) => (
4
- <svg ref={ref} {...props} width="25" height="25" viewBox="0 0 25 25" xmlns="http://www.w3.org/2000/svg">
5
- <g clip-path="url(#clip0_1215_2072)">
6
- <path fill-rule="evenodd" clip-rule="evenodd" d="M12.0011 4.38525C10.1019 4.38624 8.26498 5.05889 6.81881 6.28294C5.37263 7.50698 4.4115 9.20259 4.10726 11.0666C3.80302 12.9306 4.17551 14.8414 5.15814 16.4574C6.14077 18.0733 7.66946 19.2891 9.47085 19.8872C9.86827 19.961 10.018 19.7147 10.018 19.5053C10.018 19.2958 10.01 18.6886 10.0074 18.0247C7.78183 18.5055 7.31155 17.0856 7.31155 17.0856C6.94858 16.1635 6.42399 15.9212 6.42399 15.9212C5.69804 15.4286 6.4783 15.4378 6.4783 15.4378C7.28241 15.4944 7.705 16.2584 7.705 16.2584C8.4177 17.4741 9.57683 17.1225 10.0325 16.917C10.1041 16.402 10.312 16.0516 10.5412 15.8527C8.76345 15.6525 6.89559 14.9702 6.89559 11.9222C6.88457 11.1317 7.17958 10.3673 7.71957 9.78704C7.63744 9.58683 7.36321 8.77808 7.79772 7.67954C7.79772 7.67954 8.46936 7.46616 9.99809 8.49488C11.3093 8.13834 12.6928 8.13834 14.0041 8.49488C15.5315 7.46616 16.2018 7.67954 16.2018 7.67954C16.6376 8.77544 16.3634 9.58419 16.2813 9.78704C16.823 10.3674 17.1186 11.1332 17.1066 11.9248C17.1066 14.9794 15.2347 15.6525 13.4543 15.8487C13.7404 16.0964 13.9961 16.5798 13.9961 17.3227C13.9961 18.387 13.9868 19.2431 13.9868 19.5053C13.9868 19.7173 14.1312 19.9649 14.5366 19.8872C16.3382 19.289 17.867 18.0731 18.8496 16.4568C19.8323 14.8406 20.2046 12.9295 19.9 11.0653C19.5954 9.20112 18.6338 7.50549 17.1871 6.28166C15.7405 5.05782 13.9031 4.38561 12.0037 4.38525H12.0011Z" fill="white" />
7
- <path d="M9.35091 17.3684C9.35091 17.4329 9.27673 17.4882 9.18135 17.4896C9.08597 17.4909 9.00781 17.4382 9.00781 17.3736C9.00781 17.3091 9.08199 17.2538 9.17737 17.2525C9.27275 17.2511 9.35091 17.3025 9.35091 17.3684Z" fill="white" />
8
- <path d="M9.96094 17.2672C9.97286 17.3317 9.90662 17.3989 9.81124 17.4147C9.71586 17.4305 9.63241 17.3923 9.62048 17.3291C9.60856 17.2659 9.67745 17.1974 9.77018 17.1803C9.86291 17.1631 9.94902 17.2027 9.96094 17.2672Z" fill="white" />
9
- <path d="M8.6968 17.324C8.67693 17.3859 8.58685 17.4136 8.49676 17.3872C8.40668 17.3609 8.34707 17.2871 8.36429 17.2239C8.38151 17.1607 8.47292 17.1317 8.56433 17.1607C8.65573 17.1897 8.71402 17.2595 8.6968 17.324Z" fill="white" />
10
- <path d="M8.09774 17.0658C8.05402 17.1145 7.96527 17.1013 7.89241 17.0355C7.81955 16.9696 7.80232 16.88 7.84604 16.8326C7.88975 16.7852 7.97851 16.7984 8.05402 16.8629C8.12953 16.9274 8.1441 17.0183 8.09774 17.0658V17.0658Z" fill="white" />
11
- <path d="M7.6686 16.6231C7.61959 16.6574 7.53612 16.6231 7.48976 16.5546C7.47694 16.5423 7.46674 16.5276 7.45978 16.5113C7.45281 16.495 7.44922 16.4775 7.44922 16.4598C7.44922 16.4421 7.45281 16.4246 7.45978 16.4083C7.46674 16.392 7.47694 16.3772 7.48976 16.3649C7.53877 16.332 7.62224 16.3649 7.6686 16.4321C7.71497 16.4993 7.71629 16.5889 7.6686 16.6231V16.6231Z" fill="white" />
12
- <path d="M7.3535 16.1662C7.32607 16.1799 7.29468 16.1838 7.26472 16.177C7.23475 16.1703 7.20807 16.1534 7.18924 16.1293C7.13757 16.074 7.12697 15.9976 7.16671 15.9633C7.20645 15.9291 7.27799 15.9449 7.32966 16.0002C7.38132 16.0555 7.39324 16.1319 7.3535 16.1662Z" fill="white" />
13
- <path d="M7.02905 15.8062C7.01183 15.8457 6.94825 15.8576 6.89658 15.8299C6.84492 15.8022 6.8065 15.7509 6.82505 15.71C6.8436 15.6692 6.90586 15.6587 6.95752 15.6863C7.00919 15.714 7.04893 15.7667 7.02905 15.8062Z" fill="white" />
14
- </g>
15
- <defs>
16
- <clipPath id="clip0_1215_2072">
17
- <rect width="16" height="16" fill="white" transform="translate(4 4.05176)" />
18
- </clipPath>
19
- </defs>
20
- </svg>
21
- ))
1
+ import { forwardRef, Ref, SVGProps } from 'react'
2
+
3
+ export const Github = forwardRef((props: SVGProps<SVGSVGElement>, ref: Ref<SVGSVGElement>) => (
4
+ <svg ref={ref} {...props} width="25" height="25" viewBox="0 0 25 25" xmlns="http://www.w3.org/2000/svg">
5
+ <g clip-path="url(#clip0_1215_2072)">
6
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M12.0011 4.38525C10.1019 4.38624 8.26498 5.05889 6.81881 6.28294C5.37263 7.50698 4.4115 9.20259 4.10726 11.0666C3.80302 12.9306 4.17551 14.8414 5.15814 16.4574C6.14077 18.0733 7.66946 19.2891 9.47085 19.8872C9.86827 19.961 10.018 19.7147 10.018 19.5053C10.018 19.2958 10.01 18.6886 10.0074 18.0247C7.78183 18.5055 7.31155 17.0856 7.31155 17.0856C6.94858 16.1635 6.42399 15.9212 6.42399 15.9212C5.69804 15.4286 6.4783 15.4378 6.4783 15.4378C7.28241 15.4944 7.705 16.2584 7.705 16.2584C8.4177 17.4741 9.57683 17.1225 10.0325 16.917C10.1041 16.402 10.312 16.0516 10.5412 15.8527C8.76345 15.6525 6.89559 14.9702 6.89559 11.9222C6.88457 11.1317 7.17958 10.3673 7.71957 9.78704C7.63744 9.58683 7.36321 8.77808 7.79772 7.67954C7.79772 7.67954 8.46936 7.46616 9.99809 8.49488C11.3093 8.13834 12.6928 8.13834 14.0041 8.49488C15.5315 7.46616 16.2018 7.67954 16.2018 7.67954C16.6376 8.77544 16.3634 9.58419 16.2813 9.78704C16.823 10.3674 17.1186 11.1332 17.1066 11.9248C17.1066 14.9794 15.2347 15.6525 13.4543 15.8487C13.7404 16.0964 13.9961 16.5798 13.9961 17.3227C13.9961 18.387 13.9868 19.2431 13.9868 19.5053C13.9868 19.7173 14.1312 19.9649 14.5366 19.8872C16.3382 19.289 17.867 18.0731 18.8496 16.4568C19.8323 14.8406 20.2046 12.9295 19.9 11.0653C19.5954 9.20112 18.6338 7.50549 17.1871 6.28166C15.7405 5.05782 13.9031 4.38561 12.0037 4.38525H12.0011Z" fill="white" />
7
+ <path d="M9.35091 17.3684C9.35091 17.4329 9.27673 17.4882 9.18135 17.4896C9.08597 17.4909 9.00781 17.4382 9.00781 17.3736C9.00781 17.3091 9.08199 17.2538 9.17737 17.2525C9.27275 17.2511 9.35091 17.3025 9.35091 17.3684Z" fill="white" />
8
+ <path d="M9.96094 17.2672C9.97286 17.3317 9.90662 17.3989 9.81124 17.4147C9.71586 17.4305 9.63241 17.3923 9.62048 17.3291C9.60856 17.2659 9.67745 17.1974 9.77018 17.1803C9.86291 17.1631 9.94902 17.2027 9.96094 17.2672Z" fill="white" />
9
+ <path d="M8.6968 17.324C8.67693 17.3859 8.58685 17.4136 8.49676 17.3872C8.40668 17.3609 8.34707 17.2871 8.36429 17.2239C8.38151 17.1607 8.47292 17.1317 8.56433 17.1607C8.65573 17.1897 8.71402 17.2595 8.6968 17.324Z" fill="white" />
10
+ <path d="M8.09774 17.0658C8.05402 17.1145 7.96527 17.1013 7.89241 17.0355C7.81955 16.9696 7.80232 16.88 7.84604 16.8326C7.88975 16.7852 7.97851 16.7984 8.05402 16.8629C8.12953 16.9274 8.1441 17.0183 8.09774 17.0658V17.0658Z" fill="white" />
11
+ <path d="M7.6686 16.6231C7.61959 16.6574 7.53612 16.6231 7.48976 16.5546C7.47694 16.5423 7.46674 16.5276 7.45978 16.5113C7.45281 16.495 7.44922 16.4775 7.44922 16.4598C7.44922 16.4421 7.45281 16.4246 7.45978 16.4083C7.46674 16.392 7.47694 16.3772 7.48976 16.3649C7.53877 16.332 7.62224 16.3649 7.6686 16.4321C7.71497 16.4993 7.71629 16.5889 7.6686 16.6231V16.6231Z" fill="white" />
12
+ <path d="M7.3535 16.1662C7.32607 16.1799 7.29468 16.1838 7.26472 16.177C7.23475 16.1703 7.20807 16.1534 7.18924 16.1293C7.13757 16.074 7.12697 15.9976 7.16671 15.9633C7.20645 15.9291 7.27799 15.9449 7.32966 16.0002C7.38132 16.0555 7.39324 16.1319 7.3535 16.1662Z" fill="white" />
13
+ <path d="M7.02905 15.8062C7.01183 15.8457 6.94825 15.8576 6.89658 15.8299C6.84492 15.8022 6.8065 15.7509 6.82505 15.71C6.8436 15.6692 6.90586 15.6587 6.95752 15.6863C7.00919 15.714 7.04893 15.7667 7.02905 15.8062Z" fill="white" />
14
+ </g>
15
+ <defs>
16
+ <clipPath id="clip0_1215_2072">
17
+ <rect width="16" height="16" fill="white" transform="translate(4 4.05176)" />
18
+ </clipPath>
19
+ </defs>
20
+ </svg>
21
+ ))
@@ -1,17 +1,17 @@
1
- import { forwardRef, Ref, SVGProps } from 'react'
2
-
3
- export const Google = forwardRef((props: SVGProps<SVGSVGElement>, ref: Ref<SVGSVGElement>) => (
4
- <svg ref={ref} {...props} width="25" height="25" viewBox="0 0 25 25" xmlns="http://www.w3.org/2000/svg">
5
- <g clip-path="url(#clip0_1215_2403)">
6
- <path d="M20.3442 12.2359C20.3442 11.6921 20.3001 11.1454 20.206 10.6104H12.6602V13.691H16.9813C16.802 14.6846 16.2258 15.5635 15.3822 16.122V18.1209H17.9602C19.4741 16.7276 20.3442 14.6699 20.3442 12.2359Z" fill="#4285F4" />
7
- <path d="M12.6607 20.0525C14.8184 20.0525 16.6379 19.344 17.9637 18.1212L15.3857 16.1223C14.6684 16.6103 13.7425 16.8866 12.6637 16.8866C10.5766 16.8866 8.80696 15.4785 8.17202 13.5854H5.51172V15.6461C6.86979 18.3475 9.63592 20.0525 12.6607 20.0525V20.0525Z" fill="#34A853" />
8
- <path d="M8.16852 13.5856C7.83341 12.592 7.83341 11.5161 8.16852 10.5225V8.46191H5.51116C4.37649 10.7224 4.37649 13.3857 5.51116 15.6462L8.16852 13.5856V13.5856Z" fill="#FBBC04" />
9
- <path d="M12.6607 7.2182C13.8013 7.20056 14.9036 7.62974 15.7296 8.41754L18.0136 6.1335C16.5674 4.77543 14.6479 4.02878 12.6607 4.0523C9.63592 4.0523 6.86979 5.75724 5.51172 8.46163L8.16908 10.5223C8.80108 8.62625 10.5736 7.2182 12.6607 7.2182V7.2182Z" fill="#EA4335" />
10
- </g>
11
- <defs>
12
- <clipPath id="clip0_1215_2403">
13
- <rect width="16" height="16" fill="white" transform="translate(4.5 4.05176)" />
14
- </clipPath>
15
- </defs>
16
- </svg>
17
- ))
1
+ import { forwardRef, Ref, SVGProps } from 'react'
2
+
3
+ export const Google = forwardRef((props: SVGProps<SVGSVGElement>, ref: Ref<SVGSVGElement>) => (
4
+ <svg ref={ref} {...props} width="25" height="25" viewBox="0 0 25 25" xmlns="http://www.w3.org/2000/svg">
5
+ <g clip-path="url(#clip0_1215_2403)">
6
+ <path d="M20.3442 12.2359C20.3442 11.6921 20.3001 11.1454 20.206 10.6104H12.6602V13.691H16.9813C16.802 14.6846 16.2258 15.5635 15.3822 16.122V18.1209H17.9602C19.4741 16.7276 20.3442 14.6699 20.3442 12.2359Z" fill="#4285F4" />
7
+ <path d="M12.6607 20.0525C14.8184 20.0525 16.6379 19.344 17.9637 18.1212L15.3857 16.1223C14.6684 16.6103 13.7425 16.8866 12.6637 16.8866C10.5766 16.8866 8.80696 15.4785 8.17202 13.5854H5.51172V15.6461C6.86979 18.3475 9.63592 20.0525 12.6607 20.0525V20.0525Z" fill="#34A853" />
8
+ <path d="M8.16852 13.5856C7.83341 12.592 7.83341 11.5161 8.16852 10.5225V8.46191H5.51116C4.37649 10.7224 4.37649 13.3857 5.51116 15.6462L8.16852 13.5856V13.5856Z" fill="#FBBC04" />
9
+ <path d="M12.6607 7.2182C13.8013 7.20056 14.9036 7.62974 15.7296 8.41754L18.0136 6.1335C16.5674 4.77543 14.6479 4.02878 12.6607 4.0523C9.63592 4.0523 6.86979 5.75724 5.51172 8.46163L8.16908 10.5223C8.80108 8.62625 10.5736 7.2182 12.6607 7.2182V7.2182Z" fill="#EA4335" />
10
+ </g>
11
+ <defs>
12
+ <clipPath id="clip0_1215_2403">
13
+ <rect width="16" height="16" fill="white" transform="translate(4.5 4.05176)" />
14
+ </clipPath>
15
+ </defs>
16
+ </svg>
17
+ ))
@@ -1,10 +1,10 @@
1
- import { forwardRef, Ref, SVGProps } from 'react'
2
-
3
- export const Microsoft = forwardRef((props: SVGProps<SVGSVGElement>, ref: Ref<SVGSVGElement>) => (
4
- <svg ref={ref} {...props} width="25" height="25" viewBox="0 0 25 25" xmlns="http://www.w3.org/2000/svg">
5
- <path d="M5.19531 4.74707H12.1518V11.7036H5.19531V4.74707Z" fill="#F35325" />
6
- <path d="M12.8477 4.74707H19.8042V11.7036H12.8477V4.74707Z" fill="#81BC06" />
7
- <path d="M5.19531 12.3994H12.1518V19.3559H5.19531V12.3994Z" fill="#05A6F0" />
8
- <path d="M12.8477 12.3994H19.8042V19.3559H12.8477V12.3994Z" fill="#FFBA08" />
9
- </svg>
10
- ))
1
+ import { forwardRef, Ref, SVGProps } from 'react'
2
+
3
+ export const Microsoft = forwardRef((props: SVGProps<SVGSVGElement>, ref: Ref<SVGSVGElement>) => (
4
+ <svg ref={ref} {...props} width="25" height="25" viewBox="0 0 25 25" xmlns="http://www.w3.org/2000/svg">
5
+ <path d="M5.19531 4.74707H12.1518V11.7036H5.19531V4.74707Z" fill="#F35325" />
6
+ <path d="M12.8477 4.74707H19.8042V11.7036H12.8477V4.74707Z" fill="#81BC06" />
7
+ <path d="M5.19531 12.3994H12.1518V19.3559H5.19531V12.3994Z" fill="#05A6F0" />
8
+ <path d="M12.8477 12.3994H19.8042V19.3559H12.8477V12.3994Z" fill="#FFBA08" />
9
+ </svg>
10
+ ))
package/src/types.ts CHANGED
@@ -1,29 +1,29 @@
1
- export type LoginType = 'sso' | 'idp'
2
-
3
- interface BaseData {
4
- type: LoginType,
5
- }
6
-
7
- interface SSOData extends BaseData {
8
- type: 'sso',
9
- email: string,
10
- }
11
-
12
- interface IDPData extends BaseData {
13
- type: 'idp',
14
- provider: 'external-idp:github' | 'external-idp:google' | 'external-idp:microsoft',
15
- }
16
-
17
- export type LoginData = SSOData | IDPData
18
-
19
- export type LoginProps = {
20
- initialValue?: string,
21
- onSubmit: (data: LoginData) => Promise<void>,
22
- welcomeText?: string,
23
- removeLoadingOnSuccess?: boolean,
24
- className?: string,
25
- style?: React.CSSProperties,
26
- banner?: React.ReactNode,
27
- showLogin?: boolean,
28
- loginTypes?: LoginType[],
29
- }
1
+ export type LoginType = 'sso' | 'idp'
2
+
3
+ interface BaseData {
4
+ type: LoginType,
5
+ }
6
+
7
+ interface SSOData extends BaseData {
8
+ type: 'sso',
9
+ email: string,
10
+ }
11
+
12
+ interface IDPData extends BaseData {
13
+ type: 'idp',
14
+ provider: 'external-idp:github' | 'external-idp:google' | 'external-idp:microsoft',
15
+ }
16
+
17
+ export type LoginData = SSOData | IDPData
18
+
19
+ export type LoginProps = {
20
+ initialValue?: string,
21
+ onSubmit: (data: LoginData) => Promise<void>,
22
+ welcomeText?: string,
23
+ removeLoadingOnSuccess?: boolean,
24
+ className?: string,
25
+ style?: React.CSSProperties,
26
+ banner?: React.ReactNode,
27
+ showLogin?: boolean,
28
+ loginTypes?: LoginType[],
29
+ }
@@ -1,24 +1,24 @@
1
- import { ThirdPartyLoginParams } from '@stack-spot/auth'
2
- import { getCookie, getCookieDomain, removeCookie, setCookie } from '@stack-spot/portal-components'
3
-
4
- const sessionKey = `stk-session${getCookieDomain()}`
5
-
6
- type SessionCookie = ThirdPartyLoginParams & { sub: string, tenant: string }
7
-
8
- export const sessionCookie = Object.freeze({
9
- /**
10
- * Sets the user's session cookie
11
- * @param data session to be saved in the cookie
12
- * @param customAttributes Accepted values: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#attributes.
13
- */
14
- set: (data: SessionCookie, customAttributes: Record<string, any> = {}) => setCookie(sessionKey, JSON.stringify(data), customAttributes),
15
- get: (): SessionCookie | undefined => {
16
- try {
17
- const cookie = getCookie(sessionKey)
18
- return cookie ? JSON.parse(cookie) : undefined
19
- } catch (error) {
20
- console.error(error)
21
- }
22
- },
23
- delete: () => removeCookie(sessionKey)
24
- })
1
+ import { ThirdPartyLoginParams } from '@stack-spot/auth'
2
+ import { getCookie, getCookieDomain, removeCookie, setCookie } from '@stack-spot/portal-components'
3
+
4
+ const sessionKey = `stk-session${getCookieDomain()}`
5
+
6
+ type SessionCookie = ThirdPartyLoginParams & { sub: string, tenant: string }
7
+
8
+ export const sessionCookie = Object.freeze({
9
+ /**
10
+ * Sets the user's session cookie
11
+ * @param data session to be saved in the cookie
12
+ * @param customAttributes Accepted values: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#attributes.
13
+ */
14
+ set: (data: SessionCookie, customAttributes: Record<string, any> = {}) => setCookie(sessionKey, JSON.stringify(data), customAttributes),
15
+ get: (): SessionCookie | undefined => {
16
+ try {
17
+ const cookie = getCookie(sessionKey)
18
+ return cookie ? JSON.parse(cookie) : undefined
19
+ } catch (error) {
20
+ console.error(error)
21
+ }
22
+ },
23
+ delete: () => removeCookie(sessionKey)
24
+ })
@@ -1,21 +1,21 @@
1
- import { getCookieDomain } from '@stack-spot/portal-components'
2
-
3
- const isValidDomain = (url: string) => {
4
- const portalDomainRegex = new RegExp(`^https?:\/\/[a-zA-Z0-9.-]*${getCookieDomain().replaceAll('.', '\.')}(:[0-9]{2,4})*.*$`, 'g')
5
- const platformDomainRegex = new RegExp(/^https:\/\/[a-zA-Z0-9.-]+\.stackspot\.com.*$/, 'g')
6
- const result = portalDomainRegex.test(url) || platformDomainRegex.test(url)
7
- return result
8
- }
9
-
10
- export const redirect = async (url: string) => {
11
-
12
- if (!isValidDomain(url)) throw new Error('Redirect URL invalid domain')
13
-
14
- window.location.href = url
15
- /**
16
- * This is intentional. The promise bellow will never be fulfilled.
17
- * Once the set href is not instantaneous, this will guarantee no further code is executed until the user is really redirected.
18
- * Particularly useful to prevent flickering page renders on scenarios with redirects.
19
- */
20
- await new Promise(() => '')
1
+ import { getCookieDomain } from '@stack-spot/portal-components'
2
+
3
+ const isValidDomain = (url: string) => {
4
+ const portalDomainRegex = new RegExp(`^https?:\/\/[a-zA-Z0-9.-]*${getCookieDomain().replaceAll('.', '\.')}(:[0-9]{2,4})*.*$`, 'g')
5
+ const platformDomainRegex = new RegExp(/^https:\/\/[a-zA-Z0-9.-]+\.stackspot\.com.*$/, 'g')
6
+ const result = portalDomainRegex.test(url) || platformDomainRegex.test(url)
7
+ return result
8
+ }
9
+
10
+ export const redirect = async (url: string) => {
11
+
12
+ if (!isValidDomain(url)) throw new Error('Redirect URL invalid domain')
13
+
14
+ window.location.href = url
15
+ /**
16
+ * This is intentional. The promise bellow will never be fulfilled.
17
+ * Once the set href is not instantaneous, this will guarantee no further code is executed until the user is really redirected.
18
+ * Particularly useful to prevent flickering page renders on scenarios with redirects.
19
+ */
20
+ await new Promise(() => '')
21
21
  }
package/tsconfig.json CHANGED
@@ -1,12 +1,12 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "module": "ESNext",
5
- "jsx": "react-jsx",
6
- "rootDir": "src",
7
- "moduleResolution": "Bundler"
8
- },
9
- "include": [
10
- "src"
11
- ]
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "module": "ESNext",
5
+ "jsx": "react-jsx",
6
+ "rootDir": "src",
7
+ "moduleResolution": "Bundler",
8
+ },
9
+ "include": [
10
+ "src"
11
+ ]
12
12
  }