@linked.cm/capacitor 0.0.0-stage → 0.1.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.
- package/.changeset/README.md +20 -0
- package/.changeset/config.json +14 -0
- package/.github/workflows/pr.yml +27 -0
- package/.github/workflows/publish.yml +32 -0
- package/CHANGELOG.md +26 -0
- package/lib/esm/auth/SocialLoginClient.d.ts +40 -0
- package/lib/esm/auth/SocialLoginClient.js +240 -0
- package/lib/esm/auth/SocialLoginClient.js.map +1 -0
- package/lib/esm/backend.d.ts +26 -0
- package/lib/esm/backend.js +302 -0
- package/lib/esm/backend.js.map +1 -0
- package/lib/esm/components/LocationEnabler.d.ts +6 -0
- package/lib/esm/components/LocationEnabler.js +48 -0
- package/lib/esm/components/LocationEnabler.js.map +1 -0
- package/lib/esm/components/LocationEnabler.module.css +6 -0
- package/lib/esm/components/SafeAreaContainer.d.ts +10 -0
- package/lib/esm/components/SafeAreaContainer.js +36 -0
- package/lib/esm/components/SafeAreaContainer.js.map +1 -0
- package/lib/esm/components/SafeAreaContainer.module.css +39 -0
- package/lib/esm/components/SignInWithWhatsapp.d.ts +9 -0
- package/lib/esm/components/SignInWithWhatsapp.js +86 -0
- package/lib/esm/components/SignInWithWhatsapp.js.map +1 -0
- package/lib/esm/components/SignInWithWhatsapp.module.css +92 -0
- package/lib/esm/components/SigninWithAppleButton.d.ts +13 -0
- package/lib/esm/components/SigninWithAppleButton.js +45 -0
- package/lib/esm/components/SigninWithAppleButton.js.map +1 -0
- package/lib/esm/components/SigninWithAppleButton.module.css +22 -0
- package/lib/esm/components/SigninWithFacebookButton.d.ts +13 -0
- package/lib/esm/components/SigninWithFacebookButton.js +46 -0
- package/lib/esm/components/SigninWithFacebookButton.js.map +1 -0
- package/lib/esm/components/SigninWithFacebookButton.module.css +22 -0
- package/lib/esm/components/SigninWithGoogleButton.d.ts +13 -0
- package/lib/esm/components/SigninWithGoogleButton.js +47 -0
- package/lib/esm/components/SigninWithGoogleButton.js.map +1 -0
- package/lib/esm/components/SigninWithGoogleButton.module.css +22 -0
- package/lib/esm/data/lincd-capacitor.json +20 -0
- package/lib/esm/hooks/useAutomaticUpdates.d.ts +22 -0
- package/lib/esm/hooks/useAutomaticUpdates.js +270 -0
- package/lib/esm/hooks/useAutomaticUpdates.js.map +1 -0
- package/lib/esm/hooks/useCapacitor.d.ts +12 -0
- package/lib/esm/hooks/useCapacitor.js +68 -0
- package/lib/esm/hooks/useCapacitor.js.map +1 -0
- package/lib/esm/hooks/useNativeAppUpdate.d.ts +3 -0
- package/lib/esm/hooks/useNativeAppUpdate.js +68 -0
- package/lib/esm/hooks/useNativeAppUpdate.js.map +1 -0
- package/lib/esm/index.d.ts +13 -0
- package/lib/esm/index.js +16 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/ontologies/lincd-capacitor.d.ts +30 -0
- package/lib/esm/ontologies/lincd-capacitor.js +28 -0
- package/lib/esm/ontologies/lincd-capacitor.js.map +1 -0
- package/lib/esm/ontologies/lincd-capacitor.register.d.ts +1 -0
- package/lib/esm/ontologies/lincd-capacitor.register.js +15 -0
- package/lib/esm/ontologies/lincd-capacitor.register.js.map +1 -0
- package/lib/esm/package.d.ts +10 -0
- package/lib/esm/package.js +6 -0
- package/lib/esm/package.js.map +1 -0
- package/lib/esm/shapes/LocationUpdateAction.d.ts +11 -0
- package/lib/esm/shapes/LocationUpdateAction.js +34 -0
- package/lib/esm/shapes/LocationUpdateAction.js.map +1 -0
- package/lib/esm/shapes/index.d.ts +2 -0
- package/lib/esm/shapes/index.js +5 -0
- package/lib/esm/shapes/index.js.map +1 -0
- package/lib/esm/types.d.ts +12 -0
- package/lib/esm/types.js +1 -0
- package/lib/esm/types.js.map +1 -0
- package/lib/esm/utils/helper.d.ts +14 -0
- package/lib/esm/utils/helper.js +39 -0
- package/lib/esm/utils/helper.js.map +1 -0
- package/package.json +102 -4
- package/readme.md +50 -0
- package/tests/social-login-client.test.mjs +99 -0
- package/tsconfig-esm.json +9 -0
- package/README.md +0 -3
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
display: flex;
|
|
3
|
+
width: 100%;
|
|
4
|
+
gap: 1rem;
|
|
5
|
+
height: 43px !important;
|
|
6
|
+
border-radius: 8px !important;
|
|
7
|
+
font-size: 14px !important;
|
|
8
|
+
font-weight: 400 !important;
|
|
9
|
+
color: #032265 !important;
|
|
10
|
+
border: 1px solid #032265 !important;
|
|
11
|
+
background: #fff !important;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.root:hover {
|
|
15
|
+
color: #032265 !important;
|
|
16
|
+
background: #f4f6fb !important;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.WhatsappIcon {
|
|
20
|
+
width: 25px;
|
|
21
|
+
height: 25px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.phoneStep {
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-direction: column;
|
|
27
|
+
width: 100%;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.phoneRow {
|
|
31
|
+
position: relative;
|
|
32
|
+
width: 100%;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.phoneInput {
|
|
36
|
+
--react-international-phone-height: 43px;
|
|
37
|
+
--react-international-phone-border-radius: 8px;
|
|
38
|
+
--react-international-phone-border-color: #032265;
|
|
39
|
+
--react-international-phone-font-size: 14px;
|
|
40
|
+
--react-international-phone-text-color: #032265;
|
|
41
|
+
width: 100%;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.phoneInput button,
|
|
45
|
+
.phoneInput input {
|
|
46
|
+
height: 43px !important;
|
|
47
|
+
box-sizing: border-box;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.phoneInput button {
|
|
51
|
+
border-radius: 8px 0 0 8px !important;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.phoneInput input {
|
|
55
|
+
width: 100%;
|
|
56
|
+
border-radius: 0 8px 8px 0 !important;
|
|
57
|
+
padding-right: 44px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.signButton {
|
|
61
|
+
position: absolute;
|
|
62
|
+
top: 50%;
|
|
63
|
+
right: 6px;
|
|
64
|
+
transform: translateY(-50%);
|
|
65
|
+
display: flex;
|
|
66
|
+
align-items: center;
|
|
67
|
+
justify-content: center;
|
|
68
|
+
width: 32px !important;
|
|
69
|
+
height: 32px !important;
|
|
70
|
+
padding: 0;
|
|
71
|
+
border: 0 !important;
|
|
72
|
+
border-radius: 0 !important;
|
|
73
|
+
background: transparent !important;
|
|
74
|
+
cursor: pointer;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.signButton img {
|
|
78
|
+
width: 32px;
|
|
79
|
+
height: 32px;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.phoneError {
|
|
83
|
+
color: #ff8a80;
|
|
84
|
+
font-size: 14px;
|
|
85
|
+
margin-top: 6px;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.loading {
|
|
89
|
+
width: 32px;
|
|
90
|
+
height: 32px;
|
|
91
|
+
margin: 0 auto;
|
|
92
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button } from '@_linked/primitives/components/Button';
|
|
3
|
+
import type { AuthenticationResult } from '@_linked/auth/types/auth';
|
|
4
|
+
interface SigninWithAppleButtonProps extends Omit<React.ComponentProps<typeof Button>, 'onClick' | 'children'> {
|
|
5
|
+
label?: string;
|
|
6
|
+
scopes?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
onCallback: (data: AuthenticationResult) => void;
|
|
9
|
+
restProps?: any;
|
|
10
|
+
onLoadingChange?: (loading: boolean) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const SigninWithAppleButton: ({ label, scopes, className, onCallback, onLoadingChange, restProps, disabled: disabledByCaller, ...buttonProps }: SigninWithAppleButtonProps) => React.JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React, { useRef, useState } from 'react';
|
|
2
|
+
import style from './SigninWithAppleButton.module.css';
|
|
3
|
+
import { Button } from '@_linked/primitives/components/Button';
|
|
4
|
+
import { cl } from '@_linked/react/utils/ClassNames';
|
|
5
|
+
import { useAuth } from '@_linked/auth/hooks/useAuth';
|
|
6
|
+
import { classifySocialLoginError, isAppleLoginSupported, loginWithApple, } from '../auth/SocialLoginClient.js';
|
|
7
|
+
export const SigninWithAppleButton = ({ label = 'Sign in with Apple', scopes = 'email name', className, onCallback, onLoadingChange, restProps, disabled: disabledByCaller = false, ...buttonProps }) => {
|
|
8
|
+
const [loading, setLoading] = useState(false);
|
|
9
|
+
const auth = useAuth();
|
|
10
|
+
const loginInFlight = useRef(false);
|
|
11
|
+
const isSupportedPlatform = isAppleLoginSupported();
|
|
12
|
+
const signInWithApple = async () => {
|
|
13
|
+
if (loginInFlight.current)
|
|
14
|
+
return;
|
|
15
|
+
loginInFlight.current = true;
|
|
16
|
+
setLoading(true);
|
|
17
|
+
let result;
|
|
18
|
+
try {
|
|
19
|
+
onLoadingChange === null || onLoadingChange === void 0 ? void 0 : onLoadingChange(true);
|
|
20
|
+
const payload = await loginWithApple(scopes.split(/\s+/).filter(Boolean));
|
|
21
|
+
result = await auth.signinOAuth('apple', payload);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
const loginError = classifySocialLoginError(error);
|
|
25
|
+
if (loginError.kind !== 'cancelled') {
|
|
26
|
+
result = { error: loginError.message };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
finally {
|
|
30
|
+
loginInFlight.current = false;
|
|
31
|
+
setLoading(false);
|
|
32
|
+
onLoadingChange === null || onLoadingChange === void 0 ? void 0 : onLoadingChange(false);
|
|
33
|
+
}
|
|
34
|
+
if (result)
|
|
35
|
+
onCallback(result);
|
|
36
|
+
};
|
|
37
|
+
if (!isSupportedPlatform) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return (React.createElement(Button, { type: "button", className: cl(style.root, className), variant: "outline", ...restProps, ...buttonProps, onClick: signInWithApple, disabled: loading || disabledByCaller || (restProps === null || restProps === void 0 ? void 0 : restProps.disabled) },
|
|
41
|
+
React.createElement("svg", { className: style.icon, viewBox: "-1.5 0 20 20" },
|
|
42
|
+
React.createElement("path", { d: "M11.570887 3.19296C12.29996 2.34797 12.791401 1.17098 12.656912 0c-1.050633.04-2.321706.67099-3.075048 1.51498-.67649.74899-1.267029 1.94597-1.10827 3.09396 1.171976.08699 2.36822-.57 3.097293-1.41598m2.6281 7.43189C14.22831 13.65181 16.969663 14.65879 17 14.67179c-.022246.071-.437848 1.43498-1.443988 2.84496-.87064 1.21799-1.773639 2.43097-3.196392 2.45697-1.397473.025-1.847455-.79399-3.446157-.79399-1.59769 0-2.09722.76799-3.419865.81899-1.373205.049-2.419793-1.31798-3.2965-2.53196C.403236 14.98379-.966935 10.44985.873442 7.3899c.914121-1.51898 2.547203-2.48197 4.320842-2.50597 1.347924-.025 2.62102.86899 3.445145.86899s2.371256-1.07499 3.99726-.91699c.680534.027 2.591695.263 3.818276 1.98397-.099097.059-2.280247 1.27499-2.255979 3.80495", fill: "#000", fillRule: "evenodd" })),
|
|
43
|
+
label));
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=SigninWithAppleButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SigninWithAppleButton.js","sourceRoot":"","sources":["../../../src/components/SigninWithAppleButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,KAAK,MAAM,oCAAoC,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAC/D,OAAO,EAAE,EAAE,EAAE,MAAM,iCAAiC,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAA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gBAAS,CAAC;YACT,aAAa,CAAC,OAAO,GAAG,KAAK,CAAC;YAC9B,UAAU,CAAC,KAAK,CAAC,CAAC;YAClB,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAG,KAAK,CAAC,CAAC;QAC3B,CAAC;QACD,IAAI,MAAM;YAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC,CAAC;IAEF,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,oBAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,EACpC,OAAO,EAAC,SAAS,KACb,SAAS,KACT,WAAW,EACf,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,OAAO,IAAI,gBAAgB,KAAI,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,CAAA;QAE5D,6BAAK,SAAS,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAC,cAAc;YAC9C,8BACE,CAAC,EAAC,+uBAA+uB,EACjvB,IAAI,EAAC,MAAM,EACX,QAAQ,EAAC,SAAS,GAClB,CACA;QACL,KAAK,CACC,CACV,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React, { useRef, useState } from 'react';\nimport style from './SigninWithAppleButton.module.css';\nimport { Button } from '@_linked/primitives/components/Button';\nimport { cl } from '@_linked/react/utils/ClassNames';\nimport { useAuth } from '@_linked/auth/hooks/useAuth';\nimport type { AuthenticationResult } from '@_linked/auth/types/auth';\nimport {\n classifySocialLoginError,\n isAppleLoginSupported,\n loginWithApple,\n} from '../auth/SocialLoginClient.js';\n\ninterface SigninWithAppleButtonProps\n extends Omit<React.ComponentProps<typeof Button>, 'onClick' | 'children'> {\n label?: string;\n scopes?: string;\n className?: string;\n onCallback: (data: AuthenticationResult) => void;\n restProps?: any;\n onLoadingChange?: (loading: boolean) => void;\n}\nexport const SigninWithAppleButton = ({\n label = 'Sign in with Apple',\n scopes = 'email name',\n className,\n onCallback,\n onLoadingChange,\n restProps,\n disabled: disabledByCaller = false,\n ...buttonProps\n}: SigninWithAppleButtonProps) => {\n const [loading, setLoading] = useState(false);\n\n const auth = useAuth();\n const loginInFlight = useRef(false);\n const isSupportedPlatform = isAppleLoginSupported();\n\n const signInWithApple = async () => {\n if (loginInFlight.current) return;\n loginInFlight.current = true;\n setLoading(true);\n let result: AuthenticationResult | undefined;\n try {\n onLoadingChange?.(true);\n const payload = await loginWithApple(scopes.split(/\\s+/).filter(Boolean));\n result = await auth.signinOAuth('apple', payload);\n } catch (error) {\n const loginError = classifySocialLoginError(error);\n if (loginError.kind !== 'cancelled') {\n result = { error: loginError.message };\n }\n } finally {\n loginInFlight.current = false;\n setLoading(false);\n onLoadingChange?.(false);\n }\n if (result) onCallback(result);\n };\n\n if (!isSupportedPlatform) {\n return null;\n }\n\n return (\n <Button\n type=\"button\"\n className={cl(style.root, className)}\n variant=\"outline\"\n {...restProps}\n {...buttonProps}\n onClick={signInWithApple}\n disabled={loading || disabledByCaller || restProps?.disabled}\n >\n <svg className={style.icon} viewBox=\"-1.5 0 20 20\">\n <path\n d=\"M11.570887 3.19296C12.29996 2.34797 12.791401 1.17098 12.656912 0c-1.050633.04-2.321706.67099-3.075048 1.51498-.67649.74899-1.267029 1.94597-1.10827 3.09396 1.171976.08699 2.36822-.57 3.097293-1.41598m2.6281 7.43189C14.22831 13.65181 16.969663 14.65879 17 14.67179c-.022246.071-.437848 1.43498-1.443988 2.84496-.87064 1.21799-1.773639 2.43097-3.196392 2.45697-1.397473.025-1.847455-.79399-3.446157-.79399-1.59769 0-2.09722.76799-3.419865.81899-1.373205.049-2.419793-1.31798-3.2965-2.53196C.403236 14.98379-.966935 10.44985.873442 7.3899c.914121-1.51898 2.547203-2.48197 4.320842-2.50597 1.347924-.025 2.62102.86899 3.445145.86899s2.371256-1.07499 3.99726-.91699c.680534.027 2.591695.263 3.818276 1.98397-.099097.059-2.280247 1.27499-2.255979 3.80495\"\n fill=\"#000\"\n fillRule=\"evenodd\"\n />\n </svg>\n {label}\n </Button>\n );\n};\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
display: flex;
|
|
3
|
+
width: 100%;
|
|
4
|
+
gap: 1rem;
|
|
5
|
+
height: 43px !important;
|
|
6
|
+
border-radius: 8px !important;
|
|
7
|
+
font-size: 14px !important;
|
|
8
|
+
font-weight: 400 !important;
|
|
9
|
+
color: #032265 !important;
|
|
10
|
+
border: 1px solid #032265 !important;
|
|
11
|
+
background: #fff !important;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.root:hover {
|
|
15
|
+
color: #032265 !important;
|
|
16
|
+
background: #f4f6fb !important;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.icon {
|
|
20
|
+
width: 25px;
|
|
21
|
+
height: 25px;
|
|
22
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button } from '@_linked/primitives/components/Button';
|
|
3
|
+
import type { AuthenticationResult } from '@_linked/auth/types/auth';
|
|
4
|
+
interface SigninWithFacebookButtonProps extends Omit<React.ComponentProps<typeof Button>, 'onClick' | 'children'> {
|
|
5
|
+
label?: string;
|
|
6
|
+
scopes?: string[];
|
|
7
|
+
className?: string;
|
|
8
|
+
onCallback: (data: AuthenticationResult) => void;
|
|
9
|
+
onLoadingChange?: (loading: boolean) => void;
|
|
10
|
+
restProps?: any;
|
|
11
|
+
}
|
|
12
|
+
export declare const SigninWithFacebookButton: ({ label, scopes, className, onCallback, onLoadingChange, restProps, disabled: disabledByCaller, ...buttonProps }: SigninWithFacebookButtonProps) => React.JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { useRef, useState } from 'react';
|
|
2
|
+
import style from './SigninWithFacebookButton.module.css';
|
|
3
|
+
import { Button } from '@_linked/primitives/components/Button';
|
|
4
|
+
import { cl } from '@_linked/react/utils/ClassNames';
|
|
5
|
+
import { useAuth } from '@_linked/auth/hooks/useAuth';
|
|
6
|
+
import { classifySocialLoginError, loginWithFacebook, } from '../auth/SocialLoginClient.js';
|
|
7
|
+
export const SigninWithFacebookButton = ({ label = 'Sign in with Facebook', scopes = ['email'], className, onCallback, onLoadingChange, restProps, disabled: disabledByCaller = false, ...buttonProps }) => {
|
|
8
|
+
const [loading, setLoading] = useState(false);
|
|
9
|
+
const auth = useAuth();
|
|
10
|
+
const loginInFlight = useRef(false);
|
|
11
|
+
const onSignin = async () => {
|
|
12
|
+
if (loginInFlight.current)
|
|
13
|
+
return;
|
|
14
|
+
loginInFlight.current = true;
|
|
15
|
+
setLoading(true);
|
|
16
|
+
let result;
|
|
17
|
+
try {
|
|
18
|
+
onLoadingChange === null || onLoadingChange === void 0 ? void 0 : onLoadingChange(true);
|
|
19
|
+
const payload = await loginWithFacebook(scopes);
|
|
20
|
+
result = await auth.signinOAuth('facebook', payload);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
const loginError = classifySocialLoginError(error);
|
|
24
|
+
if (loginError.kind !== 'cancelled') {
|
|
25
|
+
result = { error: loginError.message };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
29
|
+
loginInFlight.current = false;
|
|
30
|
+
setLoading(false);
|
|
31
|
+
onLoadingChange === null || onLoadingChange === void 0 ? void 0 : onLoadingChange(false);
|
|
32
|
+
}
|
|
33
|
+
if (result)
|
|
34
|
+
onCallback(result);
|
|
35
|
+
};
|
|
36
|
+
return (React.createElement(Button, { type: "button", className: cl(style.root, className), variant: "outline", ...restProps, ...buttonProps, onClick: onSignin, disabled: loading || disabledByCaller || (restProps === null || restProps === void 0 ? void 0 : restProps.disabled) },
|
|
37
|
+
React.createElement("svg", { className: style.icon, width: "24", height: "24", fill: "none" },
|
|
38
|
+
React.createElement("g", { clipPath: "url(#a)" },
|
|
39
|
+
React.createElement("path", { d: "M24 12c0-6.62742-5.3726-12-12-12C5.37258 0 0 5.37258 0 12c0 5.9895 4.3882 10.954 10.125 11.8542v-8.3854H7.07812V12H10.125V9.35625c0-3.0075 1.7916-4.66875 4.5326-4.66875 1.3125 0 2.6862.23438 2.6862.23438V7.875h-1.5132c-1.4906 0-1.9556.92508-1.9556 1.875V12h3.3281l-.532 3.4688H13.875v8.3854C19.6118 22.954 24 17.9895 24 12Z", fill: "#1877F2" }),
|
|
40
|
+
React.createElement("path", { d: "M16.6711 15.4688 17.2031 12H13.875V9.75c0-.94898.465-1.875 1.9556-1.875h1.5132V4.92188s-1.3733-.23438-2.6862-.23438c-2.741 0-4.5326 1.66125-4.5326 4.66875V12H7.07812v3.4688H10.125v8.3854c1.2424.1944 2.5076.1944 3.75 0v-8.3854h2.7961Z", fill: "#fff" })),
|
|
41
|
+
React.createElement("defs", null,
|
|
42
|
+
React.createElement("clipPath", { id: "a" },
|
|
43
|
+
React.createElement("path", { fill: "#fff", d: "M0 0h24v24H0z" })))),
|
|
44
|
+
label));
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=SigninWithFacebookButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SigninWithFacebookButton.js","sourceRoot":"","sources":["../../../src/components/SigninWithFacebookButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,KAAK,MAAM,uCAAuC,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAC/D,OAAO,EAAE,EAAE,EAAE,MAAM,iCAAiC,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAEtD,OAAO,EACL,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,8BAA8B,CAAC;AAYtC,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,EACvC,KAAK,G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CAAC;IAEF,OAAO,CACL,oBAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,EACpC,OAAO,EAAC,SAAS,KACb,SAAS,KACT,WAAW,EACf,OAAO,EAAE,QAAQ,EACjB,QAAQ,EAAE,OAAO,IAAI,gBAAgB,KAAI,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,CAAA;QAE5D,6BAAK,SAAS,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,IAAI,EAAC,MAAM;YAC1D,2BAAG,QAAQ,EAAC,SAAS;gBACnB,8BACE,CAAC,EAAC,qUAAqU,EACvU,IAAI,EAAC,SAAS,GACd;gBACF,8BACE,CAAC,EAAC,2OAA2O,EAC7O,IAAI,EAAC,MAAM,GACX,CACA;YACJ;gBACE,kCAAU,EAAE,EAAC,GAAG;oBACd,8BAAM,IAAI,EAAC,MAAM,EAAC,CAAC,EAAC,eAAe,GAAG,CAC7B,CACN,CACL;QACL,KAAK,CACC,CACV,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React, { useRef, useState } from 'react';\nimport style from './SigninWithFacebookButton.module.css';\nimport { Button } from '@_linked/primitives/components/Button';\nimport { cl } from '@_linked/react/utils/ClassNames';\nimport { useAuth } from '@_linked/auth/hooks/useAuth';\nimport type { AuthenticationResult } from '@_linked/auth/types/auth';\nimport {\n classifySocialLoginError,\n loginWithFacebook,\n} from '../auth/SocialLoginClient.js';\n\ninterface SigninWithFacebookButtonProps\n extends Omit<React.ComponentProps<typeof Button>, 'onClick' | 'children'> {\n label?: string;\n scopes?: string[];\n className?: string;\n onCallback: (data: AuthenticationResult) => void;\n onLoadingChange?: (loading: boolean) => void;\n restProps?: any;\n}\n\nexport const SigninWithFacebookButton = ({\n label = 'Sign in with Facebook',\n scopes = ['email'],\n className,\n onCallback,\n onLoadingChange,\n restProps,\n disabled: disabledByCaller = false,\n ...buttonProps\n}: SigninWithFacebookButtonProps) => {\n const [loading, setLoading] = useState(false);\n\n const auth = useAuth();\n const loginInFlight = useRef(false);\n\n const onSignin = async () => {\n if (loginInFlight.current) return;\n loginInFlight.current = true;\n setLoading(true);\n let result: AuthenticationResult | undefined;\n try {\n onLoadingChange?.(true);\n const payload = await loginWithFacebook(scopes);\n result = await auth.signinOAuth('facebook', payload);\n } catch (error) {\n const loginError = classifySocialLoginError(error);\n if (loginError.kind !== 'cancelled') {\n result = { error: loginError.message };\n }\n } finally {\n loginInFlight.current = false;\n setLoading(false);\n onLoadingChange?.(false);\n }\n if (result) onCallback(result);\n };\n\n return (\n <Button\n type=\"button\"\n className={cl(style.root, className)}\n variant=\"outline\"\n {...restProps}\n {...buttonProps}\n onClick={onSignin}\n disabled={loading || disabledByCaller || restProps?.disabled}\n >\n <svg className={style.icon} width=\"24\" height=\"24\" fill=\"none\">\n <g clipPath=\"url(#a)\">\n <path\n d=\"M24 12c0-6.62742-5.3726-12-12-12C5.37258 0 0 5.37258 0 12c0 5.9895 4.3882 10.954 10.125 11.8542v-8.3854H7.07812V12H10.125V9.35625c0-3.0075 1.7916-4.66875 4.5326-4.66875 1.3125 0 2.6862.23438 2.6862.23438V7.875h-1.5132c-1.4906 0-1.9556.92508-1.9556 1.875V12h3.3281l-.532 3.4688H13.875v8.3854C19.6118 22.954 24 17.9895 24 12Z\"\n fill=\"#1877F2\"\n />\n <path\n d=\"M16.6711 15.4688 17.2031 12H13.875V9.75c0-.94898.465-1.875 1.9556-1.875h1.5132V4.92188s-1.3733-.23438-2.6862-.23438c-2.741 0-4.5326 1.66125-4.5326 4.66875V12H7.07812v3.4688H10.125v8.3854c1.2424.1944 2.5076.1944 3.75 0v-8.3854h2.7961Z\"\n fill=\"#fff\"\n />\n </g>\n <defs>\n <clipPath id=\"a\">\n <path fill=\"#fff\" d=\"M0 0h24v24H0z\" />\n </clipPath>\n </defs>\n </svg>\n {label}\n </Button>\n );\n};\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
display: flex;
|
|
3
|
+
width: 100%;
|
|
4
|
+
gap: 1rem;
|
|
5
|
+
height: 43px !important;
|
|
6
|
+
border-radius: 8px !important;
|
|
7
|
+
font-size: 14px !important;
|
|
8
|
+
font-weight: 400 !important;
|
|
9
|
+
color: #032265 !important;
|
|
10
|
+
border: 1px solid #032265 !important;
|
|
11
|
+
background: #fff !important;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.root:hover {
|
|
15
|
+
color: #032265 !important;
|
|
16
|
+
background: #f4f6fb !important;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.icon {
|
|
20
|
+
width: 25px;
|
|
21
|
+
height: 25px;
|
|
22
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button } from '@_linked/primitives/components/Button';
|
|
3
|
+
import type { AuthenticationResult } from '@_linked/auth/types/auth';
|
|
4
|
+
interface SigninWithGoogleButtonProps extends Omit<React.ComponentProps<typeof Button>, 'onClick' | 'children'> {
|
|
5
|
+
label?: string;
|
|
6
|
+
scopes?: string[];
|
|
7
|
+
className?: string;
|
|
8
|
+
onCallback: (data: AuthenticationResult) => void;
|
|
9
|
+
onLoadingChange?: (loading: boolean) => void;
|
|
10
|
+
restProps?: any;
|
|
11
|
+
}
|
|
12
|
+
export declare const SigninWithGoogleButton: ({ label, scopes, className, onCallback, onLoadingChange, restProps, disabled: disabledByCaller, ...buttonProps }: SigninWithGoogleButtonProps) => React.JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React, { useRef, useState } from 'react';
|
|
2
|
+
import style from './SigninWithGoogleButton.module.css';
|
|
3
|
+
import { Button } from '@_linked/primitives/components/Button';
|
|
4
|
+
import { cl } from '@_linked/react/utils/ClassNames';
|
|
5
|
+
import { useAuth } from '@_linked/auth/hooks/useAuth';
|
|
6
|
+
import { useTranslate } from '@tolgee/react';
|
|
7
|
+
import { classifySocialLoginError, loginWithGoogle, } from '../auth/SocialLoginClient.js';
|
|
8
|
+
export const SigninWithGoogleButton = ({ label = 'Sign in with Google', scopes = ['profile', 'email'], className, onCallback, onLoadingChange, restProps, disabled: disabledByCaller = false, ...buttonProps }) => {
|
|
9
|
+
const auth = useAuth();
|
|
10
|
+
const { t } = useTranslate();
|
|
11
|
+
let prefix = 'signIn';
|
|
12
|
+
const [loading, setLoading] = useState(false);
|
|
13
|
+
const loginInFlight = useRef(false);
|
|
14
|
+
const signInWithGoogle = async () => {
|
|
15
|
+
if (loginInFlight.current)
|
|
16
|
+
return;
|
|
17
|
+
loginInFlight.current = true;
|
|
18
|
+
setLoading(true);
|
|
19
|
+
let result;
|
|
20
|
+
try {
|
|
21
|
+
onLoadingChange === null || onLoadingChange === void 0 ? void 0 : onLoadingChange(true);
|
|
22
|
+
const payload = await loginWithGoogle(scopes);
|
|
23
|
+
result = await auth.signinOAuth('google', payload);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
const loginError = classifySocialLoginError(error);
|
|
27
|
+
if (loginError.kind !== 'cancelled') {
|
|
28
|
+
result = { error: loginError.message };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
loginInFlight.current = false;
|
|
33
|
+
setLoading(false);
|
|
34
|
+
onLoadingChange === null || onLoadingChange === void 0 ? void 0 : onLoadingChange(false);
|
|
35
|
+
}
|
|
36
|
+
if (result)
|
|
37
|
+
onCallback(result);
|
|
38
|
+
};
|
|
39
|
+
return (React.createElement(Button, { type: "button", className: cl(style.root, className), variant: "outline", ...restProps, ...buttonProps, onClick: signInWithGoogle, disabled: loading || disabledByCaller || (restProps === null || restProps === void 0 ? void 0 : restProps.disabled) },
|
|
40
|
+
React.createElement("svg", { className: style.icon, preserveAspectRatio: "xMidYMid", viewBox: "0 0 256 262" },
|
|
41
|
+
React.createElement("path", { fill: "#4285F4", d: "M255.878 133.451c0-10.734-.871-18.567-2.756-26.69H130.55v48.448h71.947c-1.45 12.04-9.283 30.172-26.69 42.356l-.244 1.622 38.755 30.023 2.685.268c24.659-22.774 38.875-56.282 38.875-96.027" }),
|
|
42
|
+
React.createElement("path", { fill: "#34A853", d: "M130.55 261.1c35.248 0 64.839-11.605 86.453-31.622l-41.196-31.913c-11.024 7.688-25.82 13.055-45.257 13.055-34.523 0-63.824-22.773-74.269-54.25l-1.531.13-40.298 31.187-.527 1.465C35.393 231.798 79.49 261.1 130.55 261.1" }),
|
|
43
|
+
React.createElement("path", { fill: "#FBBC05", d: "M56.281 156.37c-2.756-8.123-4.351-16.827-4.351-25.82 0-8.994 1.595-17.697 4.206-25.82l-.073-1.73L15.26 71.312l-1.335.635C5.077 89.644 0 109.517 0 130.55s5.077 40.905 13.925 58.602l42.356-32.782" }),
|
|
44
|
+
React.createElement("path", { fill: "#EB4335", d: "M130.55 50.479c24.514 0 41.05 10.589 50.479 19.438l36.844-35.974C195.245 12.91 165.798 0 130.55 0 79.49 0 35.393 29.301 13.925 71.947l42.211 32.783c10.59-31.477 39.891-54.251 74.414-54.251" })),
|
|
45
|
+
t(prefix + '.google', label)));
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=SigninWithGoogleButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SigninWithGoogleButton.js","sourceRoot":"","sources":["../../../src/components/SigninWithGoogleButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,KAAK,MAAM,qCAAqC,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAC/D,OAAO,EAAE,EAAE,EAAE,MAAM,iCAAiC,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MA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AC;QACH,CAAC;gBAAS,CAAC;YACT,aAAa,CAAC,OAAO,GAAG,KAAK,CAAC;YAC9B,UAAU,CAAC,KAAK,CAAC,CAAC;YAClB,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAG,KAAK,CAAC,CAAC;QAC3B,CAAC;QACD,IAAI,MAAM;YAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC,CAAC;IAEF,OAAO,CACL,oBAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,EACpC,OAAO,EAAC,SAAS,KACb,SAAS,KACT,WAAW,EACf,OAAO,EAAE,gBAAgB,EACzB,QAAQ,EAAE,OAAO,IAAI,gBAAgB,KAAI,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,CAAA;QAE5D,6BACE,SAAS,EAAE,KAAK,CAAC,IAAI,EACrB,mBAAmB,EAAC,UAAU,EAC9B,OAAO,EAAC,aAAa;YAEnB,8BACE,IAAI,EAAC,SAAS,EACd,CAAC,EAAC,4LAA4L,GAC9L;YACF,8BACE,IAAI,EAAC,SAAS,EACd,CAAC,EAAC,2NAA2N,GAC7N;YACF,8BACE,IAAI,EAAC,SAAS,EACd,CAAC,EAAC,mMAAmM,GACrM;YACF,8BACE,IAAI,EAAC,SAAS,EACd,CAAC,EAAC,8LAA8L,GAChM,CACA;QACL,CAAC,CAAC,MAAM,GAAG,SAAS,EAAE,KAAK,CAAC,CACtB,CACV,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React, { useRef, useState } from 'react';\nimport style from './SigninWithGoogleButton.module.css';\nimport { Button } from '@_linked/primitives/components/Button';\nimport { cl } from '@_linked/react/utils/ClassNames';\nimport { useAuth } from '@_linked/auth/hooks/useAuth';\nimport type { AuthenticationResult } from '@_linked/auth/types/auth';\nimport { useTranslate } from '@tolgee/react';\nimport {\n classifySocialLoginError,\n loginWithGoogle,\n} from '../auth/SocialLoginClient.js';\ninterface SigninWithGoogleButtonProps\n extends Omit<React.ComponentProps<typeof Button>, 'onClick' | 'children'> {\n label?: string;\n scopes?: string[];\n className?: string;\n onCallback: (data: AuthenticationResult) => void;\n onLoadingChange?: (loading: boolean) => void;\n restProps?: any;\n}\nexport const SigninWithGoogleButton = ({\n label = 'Sign in with Google',\n scopes = ['profile', 'email'],\n className,\n onCallback,\n onLoadingChange,\n restProps,\n disabled: disabledByCaller = false,\n ...buttonProps\n}: SigninWithGoogleButtonProps) => {\n const auth = useAuth();\n const { t } = useTranslate();\n let prefix = 'signIn';\n\n const [loading, setLoading] = useState(false);\n const loginInFlight = useRef(false);\n\n const signInWithGoogle = async () => {\n if (loginInFlight.current) return;\n loginInFlight.current = true;\n setLoading(true);\n let result: AuthenticationResult | undefined;\n try {\n onLoadingChange?.(true);\n const payload = await loginWithGoogle(scopes);\n result = await auth.signinOAuth('google', payload);\n } catch (error) {\n const loginError = classifySocialLoginError(error);\n if (loginError.kind !== 'cancelled') {\n result = { error: loginError.message };\n }\n } finally {\n loginInFlight.current = false;\n setLoading(false);\n onLoadingChange?.(false);\n }\n if (result) onCallback(result);\n };\n\n return (\n <Button\n type=\"button\"\n className={cl(style.root, className)}\n variant=\"outline\"\n {...restProps}\n {...buttonProps}\n onClick={signInWithGoogle}\n disabled={loading || disabledByCaller || restProps?.disabled}\n >\n <svg\n className={style.icon}\n preserveAspectRatio=\"xMidYMid\"\n viewBox=\"0 0 256 262\"\n >\n <path\n fill=\"#4285F4\"\n d=\"M255.878 133.451c0-10.734-.871-18.567-2.756-26.69H130.55v48.448h71.947c-1.45 12.04-9.283 30.172-26.69 42.356l-.244 1.622 38.755 30.023 2.685.268c24.659-22.774 38.875-56.282 38.875-96.027\"\n />\n <path\n fill=\"#34A853\"\n d=\"M130.55 261.1c35.248 0 64.839-11.605 86.453-31.622l-41.196-31.913c-11.024 7.688-25.82 13.055-45.257 13.055-34.523 0-63.824-22.773-74.269-54.25l-1.531.13-40.298 31.187-.527 1.465C35.393 231.798 79.49 261.1 130.55 261.1\"\n />\n <path\n fill=\"#FBBC05\"\n d=\"M56.281 156.37c-2.756-8.123-4.351-16.827-4.351-25.82 0-8.994 1.595-17.697 4.206-25.82l-.073-1.73L15.26 71.312l-1.335.635C5.077 89.644 0 109.517 0 130.55s5.077 40.905 13.925 58.602l42.356-32.782\"\n />\n <path\n fill=\"#EB4335\"\n d=\"M130.55 50.479c24.514 0 41.05 10.589 50.479 19.438l36.844-35.974C195.245 12.91 165.798 0 130.55 0 79.49 0 35.393 29.301 13.925 71.947l42.211 32.783c10.59-31.477 39.891-54.251 74.414-54.251\"\n />\n </svg>\n {t(prefix + '.google', label)}\n </Button>\n );\n};\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
display: flex;
|
|
3
|
+
width: 100%;
|
|
4
|
+
gap: 1rem;
|
|
5
|
+
height: 43px !important;
|
|
6
|
+
border-radius: 8px !important;
|
|
7
|
+
font-size: 14px !important;
|
|
8
|
+
font-weight: 400 !important;
|
|
9
|
+
color: #032265 !important;
|
|
10
|
+
border: 1px solid #032265 !important;
|
|
11
|
+
background: #fff !important;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.root:hover {
|
|
15
|
+
color: #032265 !important;
|
|
16
|
+
background: #f4f6fb !important;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.icon {
|
|
20
|
+
width: 25px;
|
|
21
|
+
height: 25px;
|
|
22
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@context": {
|
|
3
|
+
"dc": "http://purl.org/dc/elements/1.1/",
|
|
4
|
+
"owl": "http://www.w3.org/2002/07/owl#",
|
|
5
|
+
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
|
|
6
|
+
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
|
|
7
|
+
"lincd-capacitor": "http://lincd.org/ont/lincd-capacitor/"
|
|
8
|
+
},
|
|
9
|
+
"@graph": [
|
|
10
|
+
{
|
|
11
|
+
"@id": "lincd-capacitor:ExampleClass",
|
|
12
|
+
"@type": "rdfs:Class",
|
|
13
|
+
"rdfs:comment": "This is an example class. You can remove or rename it",
|
|
14
|
+
"rdfs:isDefinedBy": {
|
|
15
|
+
"@id": "lincd-capacitor:"
|
|
16
|
+
},
|
|
17
|
+
"rdfs:label": "Example Class"
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useAutomaticUpdates
|
|
3
|
+
*
|
|
4
|
+
* Handles OTA (over-the-air) updates and maintenance mode detection for Capacitor apps.
|
|
5
|
+
* Only runs on native platforms (iOS/Android); skips on web.
|
|
6
|
+
*
|
|
7
|
+
* With autoUpdate: false in capacitor.config.ts, we have full manual control:
|
|
8
|
+
* 1. notifyAppReady → confirm current bundle (prevent rollback)
|
|
9
|
+
* 2. Check Capgo channel → switch to production if needed
|
|
10
|
+
* 3. Check native app version → if outdated, show store update and stop
|
|
11
|
+
* 4. Check maintenance (HEAD request to SITE_ROOT) → on start + every 1 min
|
|
12
|
+
* 5. If server up → getLatest() → download with progress → set + reload
|
|
13
|
+
*/
|
|
14
|
+
export type OTAStatus = 'idle' | 'downloading' | 'complete' | 'error';
|
|
15
|
+
export type UseAutomaticUpdatesState = {
|
|
16
|
+
otaStatus: OTAStatus;
|
|
17
|
+
otaProgress: number;
|
|
18
|
+
maintenanceMode: boolean;
|
|
19
|
+
retryOTA: () => void;
|
|
20
|
+
retryMaintenanceCheck: () => void;
|
|
21
|
+
};
|
|
22
|
+
export declare const useAutomaticUpdates: () => UseAutomaticUpdatesState;
|