@indobaseinc/auth-ui-svelte 1.0.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/README.md +24 -0
- package/dist/Auth/Auth.svelte +121 -0
- package/dist/Auth/Auth.svelte.d.ts +43 -0
- package/dist/Auth/Icons.svelte +322 -0
- package/dist/Auth/Icons.svelte.d.ts +17 -0
- package/dist/Auth/index.d.ts +2 -0
- package/dist/Auth/index.js +2 -0
- package/dist/Auth/interfaces/EmailAuth.svelte +165 -0
- package/dist/Auth/interfaces/EmailAuth.svelte.d.ts +33 -0
- package/dist/Auth/interfaces/ForgottenPassword.svelte +81 -0
- package/dist/Auth/interfaces/ForgottenPassword.svelte.d.ts +25 -0
- package/dist/Auth/interfaces/MagicLink.svelte +84 -0
- package/dist/Auth/interfaces/MagicLink.svelte.d.ts +25 -0
- package/dist/Auth/interfaces/SocialAuth.svelte +68 -0
- package/dist/Auth/interfaces/SocialAuth.svelte.d.ts +30 -0
- package/dist/Auth/interfaces/UpdatePassword.svelte +90 -0
- package/dist/Auth/interfaces/UpdatePassword.svelte.d.ts +24 -0
- package/dist/Auth/interfaces/VerifyOtp.svelte +117 -0
- package/dist/Auth/interfaces/VerifyOtp.svelte.d.ts +27 -0
- package/dist/Auth/interfaces/index.d.ts +6 -0
- package/dist/Auth/interfaces/index.js +6 -0
- package/dist/Auth/ui/ForgottenPassword.svelte +18 -0
- package/dist/Auth/ui/ForgottenPassword.svelte.d.ts +26 -0
- package/dist/Auth/ui/MagicLink.svelte +26 -0
- package/dist/Auth/ui/MagicLink.svelte.d.ts +32 -0
- package/dist/Auth/ui/SignIn.svelte +29 -0
- package/dist/Auth/ui/SignIn.svelte.d.ts +34 -0
- package/dist/Auth/ui/SignUp.svelte +35 -0
- package/dist/Auth/ui/SignUp.svelte.d.ts +40 -0
- package/dist/Auth/ui/SocialAuth.svelte +26 -0
- package/dist/Auth/ui/SocialAuth.svelte.d.ts +32 -0
- package/dist/Auth/ui/UpdatePassword.svelte +20 -0
- package/dist/Auth/ui/UpdatePassword.svelte.d.ts +27 -0
- package/dist/Auth/ui/VerifyOtp.svelte +18 -0
- package/dist/Auth/ui/VerifyOtp.svelte.d.ts +25 -0
- package/dist/Auth/ui/index.d.ts +7 -0
- package/dist/Auth/ui/index.js +7 -0
- package/dist/UI/Anchor.svelte +22 -0
- package/dist/UI/Anchor.svelte.d.ts +22 -0
- package/dist/UI/Button.svelte +47 -0
- package/dist/UI/Button.svelte.d.ts +23 -0
- package/dist/UI/Container.svelte +41 -0
- package/dist/UI/Container.svelte.d.ts +16 -0
- package/dist/UI/Divider.svelte +16 -0
- package/dist/UI/Divider.svelte.d.ts +16 -0
- package/dist/UI/Input.svelte +49 -0
- package/dist/UI/Input.svelte.d.ts +14 -0
- package/dist/UI/Label.svelte +16 -0
- package/dist/UI/Label.svelte.d.ts +16 -0
- package/dist/UI/Loader.svelte +30 -0
- package/dist/UI/Loader.svelte.d.ts +14 -0
- package/dist/UI/Message.svelte +34 -0
- package/dist/UI/Message.svelte.d.ts +16 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/types.d.ts +41 -0
- package/dist/types.js +1 -0
- package/package.json +79 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
<script>import Anchor from '../../UI/Anchor.svelte';
|
|
2
|
+
import Button from '../../UI/Button.svelte';
|
|
3
|
+
import Container from '../../UI/Container.svelte';
|
|
4
|
+
import Input from '../../UI/Input.svelte';
|
|
5
|
+
import Label from '../../UI/Label.svelte';
|
|
6
|
+
import Message from '../../UI/Message.svelte';
|
|
7
|
+
import { VIEWS } from '@indobaseinc/auth-ui-shared';
|
|
8
|
+
export let authView = 'sign_in';
|
|
9
|
+
export let email = '';
|
|
10
|
+
export let password = '';
|
|
11
|
+
export let supabaseClient;
|
|
12
|
+
export let redirectTo = undefined;
|
|
13
|
+
export let additionalData = undefined;
|
|
14
|
+
export let showLinks = false;
|
|
15
|
+
export let magicLink = true;
|
|
16
|
+
export let i18n;
|
|
17
|
+
export let passwordLimit = false;
|
|
18
|
+
export let appearance;
|
|
19
|
+
let message = '';
|
|
20
|
+
let error = '';
|
|
21
|
+
let loading = false;
|
|
22
|
+
let lngKey = authView === 'sign_in' ? 'sign_in' : 'sign_up';
|
|
23
|
+
async function handleSubmit() {
|
|
24
|
+
loading = true;
|
|
25
|
+
error = '';
|
|
26
|
+
message = '';
|
|
27
|
+
switch (authView) {
|
|
28
|
+
case VIEWS.SIGN_IN:
|
|
29
|
+
const { error: signInError } = await supabaseClient.auth.signInWithPassword({
|
|
30
|
+
email,
|
|
31
|
+
password
|
|
32
|
+
});
|
|
33
|
+
if (signInError)
|
|
34
|
+
error = signInError.message;
|
|
35
|
+
loading = false;
|
|
36
|
+
break;
|
|
37
|
+
case VIEWS.SIGN_UP:
|
|
38
|
+
if (passwordLimit && password.length > 72) {
|
|
39
|
+
error = 'Password exceeds maxmium length of 72 characters';
|
|
40
|
+
loading = false;
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
let options = {
|
|
44
|
+
emailRedirectTo: redirectTo
|
|
45
|
+
};
|
|
46
|
+
if (additionalData) {
|
|
47
|
+
options.data = additionalData;
|
|
48
|
+
}
|
|
49
|
+
const { data: { user: signUpUser, session: signUpSession }, error: signUpError } = await supabaseClient.auth.signUp({
|
|
50
|
+
email,
|
|
51
|
+
password,
|
|
52
|
+
options
|
|
53
|
+
});
|
|
54
|
+
if (signUpError)
|
|
55
|
+
error = signUpError.message;
|
|
56
|
+
// Check if session is null -> email confirmation setting is turned on
|
|
57
|
+
else if (signUpUser && !signUpSession)
|
|
58
|
+
message = i18n.sign_up?.confirmation_text;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
loading = false;
|
|
62
|
+
}
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
<form method="post" on:submit|preventDefault={handleSubmit}>
|
|
66
|
+
<Container direction="vertical" gap="large" {appearance}>
|
|
67
|
+
<Container direction="vertical" gap="large" {appearance}>
|
|
68
|
+
<div>
|
|
69
|
+
<Label for="email" {appearance}>{i18n?.[lngKey]?.email_label}</Label>
|
|
70
|
+
<Input
|
|
71
|
+
id="email"
|
|
72
|
+
type="email"
|
|
73
|
+
name="email"
|
|
74
|
+
autofocus
|
|
75
|
+
placeholder={i18n?.[lngKey]?.email_input_placeholder}
|
|
76
|
+
bind:value={email}
|
|
77
|
+
autocomplete="email"
|
|
78
|
+
{appearance}
|
|
79
|
+
/>
|
|
80
|
+
</div>
|
|
81
|
+
<div>
|
|
82
|
+
<Label for="password" {appearance}>{i18n?.[lngKey]?.password_label}</Label>
|
|
83
|
+
<Input
|
|
84
|
+
id="password"
|
|
85
|
+
type="password"
|
|
86
|
+
name="password"
|
|
87
|
+
placeholder={i18n?.[lngKey]?.password_input_placeholder}
|
|
88
|
+
bind:value={password}
|
|
89
|
+
autocomplete={authView === VIEWS.SIGN_IN ? 'current-password' : 'new-password'}
|
|
90
|
+
{appearance}
|
|
91
|
+
/>
|
|
92
|
+
</div>
|
|
93
|
+
<slot />
|
|
94
|
+
</Container>
|
|
95
|
+
<Button type="submit" color="primary" {loading} {appearance}
|
|
96
|
+
>{loading ? i18n?.[lngKey]?.loading_button_label : i18n?.[lngKey]?.button_label}
|
|
97
|
+
</Button>
|
|
98
|
+
|
|
99
|
+
{#if showLinks}
|
|
100
|
+
<Container direction="vertical" gap="small" {appearance}>
|
|
101
|
+
{#if authView === VIEWS.SIGN_IN && magicLink}
|
|
102
|
+
<Anchor
|
|
103
|
+
on:click={(e) => {
|
|
104
|
+
e.preventDefault();
|
|
105
|
+
authView = VIEWS.MAGIC_LINK;
|
|
106
|
+
}}
|
|
107
|
+
href="#auth-magic-link"
|
|
108
|
+
{appearance}
|
|
109
|
+
>{i18n?.magic_link?.link_text}
|
|
110
|
+
</Anchor>
|
|
111
|
+
{/if}
|
|
112
|
+
{#if authView === VIEWS.SIGN_IN}
|
|
113
|
+
<Anchor
|
|
114
|
+
on:click={(e) => {
|
|
115
|
+
e.preventDefault();
|
|
116
|
+
authView = VIEWS.FORGOTTEN_PASSWORD;
|
|
117
|
+
}}
|
|
118
|
+
href="#auth-forgot-password"
|
|
119
|
+
{appearance}
|
|
120
|
+
>
|
|
121
|
+
{i18n?.forgotten_password?.link_text}</Anchor
|
|
122
|
+
>
|
|
123
|
+
<Anchor
|
|
124
|
+
on:click={(e) => {
|
|
125
|
+
e.preventDefault();
|
|
126
|
+
authView = VIEWS.SIGN_UP;
|
|
127
|
+
}}
|
|
128
|
+
href="#auth-sign-up"
|
|
129
|
+
{appearance}
|
|
130
|
+
>
|
|
131
|
+
{i18n?.sign_up?.link_text}
|
|
132
|
+
</Anchor>
|
|
133
|
+
{:else}
|
|
134
|
+
<Anchor
|
|
135
|
+
on:click={(e) => {
|
|
136
|
+
e.preventDefault();
|
|
137
|
+
authView = VIEWS.SIGN_IN;
|
|
138
|
+
}}
|
|
139
|
+
href="#auth-sign-in"
|
|
140
|
+
{appearance}
|
|
141
|
+
>
|
|
142
|
+
{i18n?.sign_in?.link_text}
|
|
143
|
+
</Anchor>
|
|
144
|
+
{/if}
|
|
145
|
+
</Container>
|
|
146
|
+
{/if}
|
|
147
|
+
</Container>
|
|
148
|
+
|
|
149
|
+
{#if message}
|
|
150
|
+
<Message {appearance}>
|
|
151
|
+
{message}
|
|
152
|
+
</Message>
|
|
153
|
+
{/if}
|
|
154
|
+
{#if error}
|
|
155
|
+
<Message color="danger" {appearance}>
|
|
156
|
+
{error}
|
|
157
|
+
</Message>
|
|
158
|
+
{/if}
|
|
159
|
+
</form>
|
|
160
|
+
|
|
161
|
+
<style>
|
|
162
|
+
form {
|
|
163
|
+
width: 100%;
|
|
164
|
+
}
|
|
165
|
+
</style>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { IndobaseClient } from '@indobaseinc/indobase-js';
|
|
3
|
+
import { type I18nVariables, type ViewType, type RedirectTo } from '@indobaseinc/auth-ui-shared';
|
|
4
|
+
import type { Appearance } from '../../types';
|
|
5
|
+
declare const __propDef: {
|
|
6
|
+
props: {
|
|
7
|
+
authView?: ViewType | undefined;
|
|
8
|
+
email?: string | undefined;
|
|
9
|
+
password?: string | undefined;
|
|
10
|
+
supabaseClient: IndobaseClient;
|
|
11
|
+
redirectTo?: RedirectTo;
|
|
12
|
+
additionalData?: {
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
} | undefined;
|
|
15
|
+
showLinks?: boolean | undefined;
|
|
16
|
+
magicLink?: boolean | undefined;
|
|
17
|
+
i18n: I18nVariables;
|
|
18
|
+
passwordLimit?: boolean | undefined;
|
|
19
|
+
appearance: Appearance;
|
|
20
|
+
};
|
|
21
|
+
events: {
|
|
22
|
+
[evt: string]: CustomEvent<any>;
|
|
23
|
+
};
|
|
24
|
+
slots: {
|
|
25
|
+
default: {};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export type EmailAuthProps = typeof __propDef.props;
|
|
29
|
+
export type EmailAuthEvents = typeof __propDef.events;
|
|
30
|
+
export type EmailAuthSlots = typeof __propDef.slots;
|
|
31
|
+
export default class EmailAuth extends SvelteComponentTyped<EmailAuthProps, EmailAuthEvents, EmailAuthSlots> {
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<script>import Anchor from '../../UI/Anchor.svelte';
|
|
2
|
+
import Button from '../../UI/Button.svelte';
|
|
3
|
+
import Container from '../../UI/Container.svelte';
|
|
4
|
+
import Input from '../../UI/Input.svelte';
|
|
5
|
+
import Label from '../../UI/Label.svelte';
|
|
6
|
+
import Message from '../../UI/Message.svelte';
|
|
7
|
+
import { VIEWS } from '@indobaseinc/auth-ui-shared';
|
|
8
|
+
export let i18n;
|
|
9
|
+
export let supabaseClient;
|
|
10
|
+
export let authView;
|
|
11
|
+
export let redirectTo = undefined;
|
|
12
|
+
export let email = '';
|
|
13
|
+
export let showLinks = false;
|
|
14
|
+
export let appearance;
|
|
15
|
+
let message = '';
|
|
16
|
+
let error = '';
|
|
17
|
+
let loading = false;
|
|
18
|
+
async function handleSubmit() {
|
|
19
|
+
loading = true;
|
|
20
|
+
error = '';
|
|
21
|
+
message = '';
|
|
22
|
+
const { error: resetPasswordError } = await supabaseClient.auth.resetPasswordForEmail(email, {
|
|
23
|
+
redirectTo
|
|
24
|
+
});
|
|
25
|
+
if (resetPasswordError)
|
|
26
|
+
error = resetPasswordError.message;
|
|
27
|
+
else
|
|
28
|
+
message = i18n.forgotten_password?.confirmation_text;
|
|
29
|
+
loading = false;
|
|
30
|
+
}
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<form id="auth-forgot-password" method="post" on:submit|preventDefault={handleSubmit}>
|
|
34
|
+
<Container direction="vertical" gap="large" {appearance}>
|
|
35
|
+
<Container direction="vertical" gap="large" {appearance}>
|
|
36
|
+
<div>
|
|
37
|
+
<Label for="email" {appearance}>{i18n?.forgotten_password?.email_label}</Label>
|
|
38
|
+
<Input
|
|
39
|
+
id="email"
|
|
40
|
+
type="email"
|
|
41
|
+
name="email"
|
|
42
|
+
autofocus
|
|
43
|
+
placeholder={i18n?.forgotten_password?.email_input_placeholder}
|
|
44
|
+
bind:value={email}
|
|
45
|
+
autocomplete="email"
|
|
46
|
+
{appearance}
|
|
47
|
+
/>
|
|
48
|
+
</div>
|
|
49
|
+
<Button type="submit" color="primary" {loading} {appearance}>
|
|
50
|
+
{loading ? i18n?.forgotten_password?.loading_button_label : i18n?.forgotten_password?.button_label}
|
|
51
|
+
</Button>
|
|
52
|
+
</Container>
|
|
53
|
+
|
|
54
|
+
{#if showLinks}
|
|
55
|
+
<Anchor
|
|
56
|
+
on:click={(e) => {
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
authView = VIEWS.SIGN_IN;
|
|
59
|
+
}}
|
|
60
|
+
href="#auth-magic-link"
|
|
61
|
+
{appearance}>{i18n?.sign_in?.link_text}</Anchor
|
|
62
|
+
>
|
|
63
|
+
{/if}
|
|
64
|
+
{#if message}
|
|
65
|
+
<Message {appearance}>
|
|
66
|
+
{message}
|
|
67
|
+
</Message>
|
|
68
|
+
{/if}
|
|
69
|
+
{#if error}
|
|
70
|
+
<Message color="danger" {appearance}>
|
|
71
|
+
{error}
|
|
72
|
+
</Message>
|
|
73
|
+
{/if}
|
|
74
|
+
</Container>
|
|
75
|
+
</form>
|
|
76
|
+
|
|
77
|
+
<style>
|
|
78
|
+
form {
|
|
79
|
+
width: 100%;
|
|
80
|
+
}
|
|
81
|
+
</style>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { IndobaseClient } from '@indobaseinc/indobase-js';
|
|
3
|
+
import { type I18nVariables, type ViewType } from '@indobaseinc/auth-ui-shared';
|
|
4
|
+
import type { Appearance } from '../../types';
|
|
5
|
+
declare const __propDef: {
|
|
6
|
+
props: {
|
|
7
|
+
i18n: I18nVariables;
|
|
8
|
+
supabaseClient: IndobaseClient;
|
|
9
|
+
authView: ViewType;
|
|
10
|
+
redirectTo?: string | undefined;
|
|
11
|
+
email?: string | undefined;
|
|
12
|
+
showLinks?: boolean | undefined;
|
|
13
|
+
appearance: Appearance;
|
|
14
|
+
};
|
|
15
|
+
events: {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
};
|
|
18
|
+
slots: {};
|
|
19
|
+
};
|
|
20
|
+
export type ForgottenPasswordProps = typeof __propDef.props;
|
|
21
|
+
export type ForgottenPasswordEvents = typeof __propDef.events;
|
|
22
|
+
export type ForgottenPasswordSlots = typeof __propDef.slots;
|
|
23
|
+
export default class ForgottenPassword extends SvelteComponentTyped<ForgottenPasswordProps, ForgottenPasswordEvents, ForgottenPasswordSlots> {
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
<script>import Anchor from '../../UI/Anchor.svelte';
|
|
2
|
+
import Button from '../../UI/Button.svelte';
|
|
3
|
+
import Container from '../../UI/Container.svelte';
|
|
4
|
+
import Input from '../../UI/Input.svelte';
|
|
5
|
+
import Label from '../../UI/Label.svelte';
|
|
6
|
+
import Message from '../../UI/Message.svelte';
|
|
7
|
+
import { VIEWS } from '@indobaseinc/auth-ui-shared';
|
|
8
|
+
export let i18n;
|
|
9
|
+
export let supabaseClient;
|
|
10
|
+
export let authView;
|
|
11
|
+
export let redirectTo = undefined;
|
|
12
|
+
export let appearance;
|
|
13
|
+
export let showLinks = false;
|
|
14
|
+
export let email = '';
|
|
15
|
+
let message = '';
|
|
16
|
+
let error = '';
|
|
17
|
+
let loading = false;
|
|
18
|
+
async function handleSubmit() {
|
|
19
|
+
loading = true;
|
|
20
|
+
error = '';
|
|
21
|
+
message = '';
|
|
22
|
+
const { error: resetPasswordError } = await supabaseClient.auth.signInWithOtp({
|
|
23
|
+
email,
|
|
24
|
+
options: {
|
|
25
|
+
emailRedirectTo: redirectTo
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
if (resetPasswordError)
|
|
29
|
+
error = resetPasswordError.message;
|
|
30
|
+
else
|
|
31
|
+
message = i18n.magic_link?.confirmation_text;
|
|
32
|
+
loading = false;
|
|
33
|
+
}
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<form id="auth-magic-link" method="post" on:submit|preventDefault={handleSubmit}>
|
|
37
|
+
<Container direction="vertical" gap="large" {appearance}>
|
|
38
|
+
<Container direction="vertical" gap="large" {appearance}>
|
|
39
|
+
<div>
|
|
40
|
+
<Label for="email" {appearance}>{i18n?.magic_link?.email_input_label}</Label>
|
|
41
|
+
<Input
|
|
42
|
+
id="email"
|
|
43
|
+
type="email"
|
|
44
|
+
name="email"
|
|
45
|
+
autofocus
|
|
46
|
+
placeholder={i18n?.magic_link?.email_input_placeholder}
|
|
47
|
+
bind:value={email}
|
|
48
|
+
autocomplete="email"
|
|
49
|
+
{appearance}
|
|
50
|
+
/>
|
|
51
|
+
</div>
|
|
52
|
+
<Button type="submit" color="primary" {loading} {appearance}>
|
|
53
|
+
{loading ? i18n?.magic_link?.loading_button_label : i18n?.magic_link?.button_label}
|
|
54
|
+
</Button>
|
|
55
|
+
</Container>
|
|
56
|
+
|
|
57
|
+
{#if showLinks}
|
|
58
|
+
<Anchor
|
|
59
|
+
on:click={(e) => {
|
|
60
|
+
e.preventDefault();
|
|
61
|
+
authView = VIEWS.SIGN_IN;
|
|
62
|
+
}}
|
|
63
|
+
href="#auth-sign-in"
|
|
64
|
+
{appearance}>{i18n?.sign_in?.link_text}</Anchor
|
|
65
|
+
>
|
|
66
|
+
{/if}
|
|
67
|
+
{#if message}
|
|
68
|
+
<Message {appearance}>
|
|
69
|
+
{message}
|
|
70
|
+
</Message>
|
|
71
|
+
{/if}
|
|
72
|
+
{#if error}
|
|
73
|
+
<Message color="danger" {appearance}>
|
|
74
|
+
{error}
|
|
75
|
+
</Message>
|
|
76
|
+
{/if}
|
|
77
|
+
</Container>
|
|
78
|
+
</form>
|
|
79
|
+
|
|
80
|
+
<style>
|
|
81
|
+
form {
|
|
82
|
+
width: 100%;
|
|
83
|
+
}
|
|
84
|
+
</style>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { IndobaseClient } from '@indobaseinc/indobase-js';
|
|
3
|
+
import { type I18nVariables, type ViewType } from '@indobaseinc/auth-ui-shared';
|
|
4
|
+
import type { Appearance } from '../../types';
|
|
5
|
+
declare const __propDef: {
|
|
6
|
+
props: {
|
|
7
|
+
i18n: I18nVariables;
|
|
8
|
+
supabaseClient: IndobaseClient;
|
|
9
|
+
authView: ViewType;
|
|
10
|
+
redirectTo?: string | undefined;
|
|
11
|
+
appearance: Appearance;
|
|
12
|
+
showLinks?: boolean | undefined;
|
|
13
|
+
email?: string | undefined;
|
|
14
|
+
};
|
|
15
|
+
events: {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
};
|
|
18
|
+
slots: {};
|
|
19
|
+
};
|
|
20
|
+
export type MagicLinkProps = typeof __propDef.props;
|
|
21
|
+
export type MagicLinkEvents = typeof __propDef.events;
|
|
22
|
+
export type MagicLinkSlots = typeof __propDef.slots;
|
|
23
|
+
export default class MagicLink extends SvelteComponentTyped<MagicLinkProps, MagicLinkEvents, MagicLinkSlots> {
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<script>import { template } from '@indobaseinc/auth-ui-shared';
|
|
2
|
+
import Button from '../../UI/Button.svelte';
|
|
3
|
+
import Container from '../../UI/Container.svelte';
|
|
4
|
+
import Icons from '../Icons.svelte';
|
|
5
|
+
import Divider from '../../UI/Divider.svelte';
|
|
6
|
+
export let supabaseClient;
|
|
7
|
+
export let socialLayout;
|
|
8
|
+
export let redirectTo = undefined;
|
|
9
|
+
export let onlyThirdPartyProviders;
|
|
10
|
+
export let i18n;
|
|
11
|
+
export let providers = [];
|
|
12
|
+
export let providerScopes;
|
|
13
|
+
export let queryParams;
|
|
14
|
+
export let appearance;
|
|
15
|
+
let error = '';
|
|
16
|
+
let loading = false;
|
|
17
|
+
$: verticalSocialLayout = socialLayout === 'vertical' ? true : false;
|
|
18
|
+
async function handleProviderSignIn(provider) {
|
|
19
|
+
loading = true;
|
|
20
|
+
error = '';
|
|
21
|
+
const { error: providerSigninError } = await supabaseClient.auth.signInWithOAuth({
|
|
22
|
+
provider,
|
|
23
|
+
options: {
|
|
24
|
+
redirectTo,
|
|
25
|
+
scopes: providerScopes?.[provider],
|
|
26
|
+
queryParams
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
if (providerSigninError)
|
|
30
|
+
error = providerSigninError.message;
|
|
31
|
+
loading = false;
|
|
32
|
+
}
|
|
33
|
+
function capitalize(word) {
|
|
34
|
+
return word[0].toUpperCase() + word.slice(1).toLowerCase();
|
|
35
|
+
}
|
|
36
|
+
let iconTitle = (provider) => template(i18n['sign_in']?.social_provider_text, {
|
|
37
|
+
provider: capitalize(provider)
|
|
38
|
+
});
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
{#if providers.length}
|
|
42
|
+
<Container direction="vertical" gap="large" {appearance}>
|
|
43
|
+
<Container
|
|
44
|
+
direction={verticalSocialLayout ? 'vertical' : 'horizontal'}
|
|
45
|
+
gap={verticalSocialLayout ? 'small' : 'medium'}
|
|
46
|
+
{appearance}
|
|
47
|
+
>
|
|
48
|
+
{#each providers as provider}
|
|
49
|
+
<Button
|
|
50
|
+
aria-label={iconTitle(provider)}
|
|
51
|
+
on:click={() => handleProviderSignIn(provider)}
|
|
52
|
+
type="submit"
|
|
53
|
+
color="default"
|
|
54
|
+
{loading}
|
|
55
|
+
{appearance}
|
|
56
|
+
>
|
|
57
|
+
<Icons {provider} />
|
|
58
|
+
{#if verticalSocialLayout}
|
|
59
|
+
{iconTitle(provider)}
|
|
60
|
+
{/if}
|
|
61
|
+
</Button>
|
|
62
|
+
{/each}
|
|
63
|
+
</Container>
|
|
64
|
+
</Container>
|
|
65
|
+
{#if !onlyThirdPartyProviders}
|
|
66
|
+
<Divider {appearance} />
|
|
67
|
+
{/if}
|
|
68
|
+
{/if}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { Provider } from '@indobaseinc/auth-js';
|
|
3
|
+
import type { IndobaseClient } from '@indobaseinc/indobase-js';
|
|
4
|
+
import { type I18nVariables, type SocialLayout, type ProviderScopes } from '@indobaseinc/auth-ui-shared';
|
|
5
|
+
import type { Appearance } from '../../types';
|
|
6
|
+
declare const __propDef: {
|
|
7
|
+
props: {
|
|
8
|
+
supabaseClient: IndobaseClient;
|
|
9
|
+
socialLayout: SocialLayout;
|
|
10
|
+
redirectTo?: string | undefined;
|
|
11
|
+
onlyThirdPartyProviders: boolean;
|
|
12
|
+
i18n: I18nVariables;
|
|
13
|
+
providers?: Provider[] | undefined;
|
|
14
|
+
providerScopes: Partial<ProviderScopes> | undefined;
|
|
15
|
+
queryParams: {
|
|
16
|
+
[key: string]: string;
|
|
17
|
+
} | undefined;
|
|
18
|
+
appearance: Appearance;
|
|
19
|
+
};
|
|
20
|
+
events: {
|
|
21
|
+
[evt: string]: CustomEvent<any>;
|
|
22
|
+
};
|
|
23
|
+
slots: {};
|
|
24
|
+
};
|
|
25
|
+
export type SocialAuthProps = typeof __propDef.props;
|
|
26
|
+
export type SocialAuthEvents = typeof __propDef.events;
|
|
27
|
+
export type SocialAuthSlots = typeof __propDef.slots;
|
|
28
|
+
export default class SocialAuth extends SvelteComponentTyped<SocialAuthProps, SocialAuthEvents, SocialAuthSlots> {
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
<script>import Anchor from '../../UI/Anchor.svelte';
|
|
2
|
+
import Button from '../../UI/Button.svelte';
|
|
3
|
+
import Container from '../../UI/Container.svelte';
|
|
4
|
+
import Input from '../../UI/Input.svelte';
|
|
5
|
+
import Label from '../../UI/Label.svelte';
|
|
6
|
+
import Message from '../../UI/Message.svelte';
|
|
7
|
+
import { VIEWS } from '@indobaseinc/auth-ui-shared';
|
|
8
|
+
export let i18n;
|
|
9
|
+
export let supabaseClient;
|
|
10
|
+
export let authView;
|
|
11
|
+
export let appearance;
|
|
12
|
+
export let passwordLimit;
|
|
13
|
+
export let showLinks = false;
|
|
14
|
+
let password = '';
|
|
15
|
+
let message = '';
|
|
16
|
+
let error = '';
|
|
17
|
+
let loading = false;
|
|
18
|
+
async function handleSubmit() {
|
|
19
|
+
loading = true;
|
|
20
|
+
error = '';
|
|
21
|
+
message = '';
|
|
22
|
+
if (passwordLimit && password.length > 72) {
|
|
23
|
+
error = 'Password exceeds maxmium length of 72 characters';
|
|
24
|
+
loading = false;
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const { data, error: resetPasswordError } = await supabaseClient.auth.updateUser({
|
|
28
|
+
password
|
|
29
|
+
});
|
|
30
|
+
if (resetPasswordError)
|
|
31
|
+
error = resetPasswordError.message;
|
|
32
|
+
else
|
|
33
|
+
message = i18n.update_password?.confirmation_text;
|
|
34
|
+
loading = false;
|
|
35
|
+
}
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<form id="auth-update-password" method="post" on:submit|preventDefault={handleSubmit}>
|
|
39
|
+
<Container direction="vertical" gap="large" {appearance}>
|
|
40
|
+
<Container direction="vertical" gap="large" {appearance}>
|
|
41
|
+
<div>
|
|
42
|
+
<Label for="password" {appearance}>
|
|
43
|
+
{i18n?.update_password?.password_label}
|
|
44
|
+
</Label>
|
|
45
|
+
<Input
|
|
46
|
+
id="password"
|
|
47
|
+
type="password"
|
|
48
|
+
name="password"
|
|
49
|
+
autofocus
|
|
50
|
+
placeholder={i18n?.update_password?.password_input_placeholder}
|
|
51
|
+
bind:value={password}
|
|
52
|
+
autocomplete="password"
|
|
53
|
+
{appearance}
|
|
54
|
+
/>
|
|
55
|
+
</div>
|
|
56
|
+
<Button type="submit" color="primary" {loading} {appearance}>
|
|
57
|
+
{loading
|
|
58
|
+
? i18n?.update_password?.loading_button_label
|
|
59
|
+
: i18n?.update_password?.button_label}
|
|
60
|
+
</Button>
|
|
61
|
+
</Container>
|
|
62
|
+
|
|
63
|
+
{#if showLinks}
|
|
64
|
+
<Anchor
|
|
65
|
+
on:click={(e) => {
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
authView = VIEWS.SIGN_IN;
|
|
68
|
+
}}
|
|
69
|
+
href="#auth-magic-link"
|
|
70
|
+
{appearance}>{i18n?.sign_in?.link_text}</Anchor
|
|
71
|
+
>
|
|
72
|
+
{/if}
|
|
73
|
+
{#if message}
|
|
74
|
+
<Message {appearance}>
|
|
75
|
+
{message}
|
|
76
|
+
</Message>
|
|
77
|
+
{/if}
|
|
78
|
+
{#if error}
|
|
79
|
+
<Message color="danger" {appearance}>
|
|
80
|
+
{error}
|
|
81
|
+
</Message>
|
|
82
|
+
{/if}
|
|
83
|
+
</Container>
|
|
84
|
+
</form>
|
|
85
|
+
|
|
86
|
+
<style>
|
|
87
|
+
form {
|
|
88
|
+
width: 100%;
|
|
89
|
+
}
|
|
90
|
+
</style>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { IndobaseClient } from '@indobaseinc/indobase-js';
|
|
3
|
+
import { type I18nVariables, type ViewType } from '@indobaseinc/auth-ui-shared';
|
|
4
|
+
import type { Appearance } from '../../types';
|
|
5
|
+
declare const __propDef: {
|
|
6
|
+
props: {
|
|
7
|
+
i18n: I18nVariables;
|
|
8
|
+
supabaseClient: IndobaseClient;
|
|
9
|
+
authView: ViewType;
|
|
10
|
+
appearance: Appearance;
|
|
11
|
+
passwordLimit: boolean;
|
|
12
|
+
showLinks?: boolean | undefined;
|
|
13
|
+
};
|
|
14
|
+
events: {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
};
|
|
17
|
+
slots: {};
|
|
18
|
+
};
|
|
19
|
+
export type UpdatePasswordProps = typeof __propDef.props;
|
|
20
|
+
export type UpdatePasswordEvents = typeof __propDef.events;
|
|
21
|
+
export type UpdatePasswordSlots = typeof __propDef.slots;
|
|
22
|
+
export default class UpdatePassword extends SvelteComponentTyped<UpdatePasswordProps, UpdatePasswordEvents, UpdatePasswordSlots> {
|
|
23
|
+
}
|
|
24
|
+
export {};
|