@ctx-core/auth0-ui 12.2.228 → 12.2.229
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/CHANGELOG.md +11 -0
- package/lib/src/ui/Auth0_c.d.ts +6 -6
- package/lib/ui/Auth0.svelte +8 -8
- package/lib/ui/Auth0_Change_Password_Form.svelte +2 -2
- package/lib/ui/Auth0_Forgot_Password_Form.svelte +4 -4
- package/lib/ui/Auth0_Login_Form.svelte +5 -5
- package/lib/ui/Auth0_Signup_Form.svelte +4 -4
- package/lib/ui/Auth0_c.js +29 -29
- package/lib/ui/Auth0_c.js.map +1 -1
- package/package.json +6 -6
- package/src/ui/Auth0.svelte +8 -8
- package/src/ui/Auth0_Change_Password_Form.svelte +2 -2
- package/src/ui/Auth0_Forgot_Password_Form.svelte +4 -4
- package/src/ui/Auth0_Login_Form.svelte +5 -5
- package/src/ui/Auth0_Signup_Form.svelte +4 -4
- package/src/ui/Auth0_c.ts +69 -69
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @ctx-core/auth0-ui
|
|
2
2
|
|
|
3
|
+
## 12.2.229
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @ctx-core/auth0-management: ^9.0.154 -> ^9.1.0
|
|
8
|
+
- @ctx-core/error: ^11.5.18 -> ^11.6.0
|
|
9
|
+
- @ctx-core/auth0: ^35.0.97 -> ^35.1.0
|
|
10
|
+
- @ctx-core/jwt: ^10.1.55 -> ^10.2.0
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @ctx-core/fetch-undici@2.3.72
|
|
13
|
+
|
|
3
14
|
## 12.2.228
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/lib/src/ui/Auth0_c.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { auth0__client_id__body_T, auth0__grant_type__body_T, auth0__login_data_T, password_realm__body_T, auth0__oauth_token__fetch__body_T, auth0__passwordless_start__fetch__body_T, auth0__signup_data_T } from '@ctx-core/auth0';
|
|
2
2
|
import { noop } from '@ctx-core/function';
|
|
3
3
|
import type { Ctx } from '@ctx-core/object';
|
|
4
4
|
export declare class Auth0_c {
|
|
@@ -11,10 +11,10 @@ export declare class Auth0_c {
|
|
|
11
11
|
readonly auth0_opened_class: import("@ctx-core/nanostores").ReadableAtom_<import("@ctx-core/auth0").auth0_opened_T>;
|
|
12
12
|
readonly auth0_token_json_: import("@ctx-core/nanostores").WritableAtom_<string | import("@ctx-core/function").nullish>;
|
|
13
13
|
readonly auth0_token_error_: import("@ctx-core/nanostores").WritableAtom_<import("@ctx-core/auth0").auth0_token_error_T>;
|
|
14
|
-
readonly
|
|
14
|
+
readonly auth0__close: () => void;
|
|
15
15
|
readonly onMount: (root: HTMLElement) => Promise<void>;
|
|
16
|
-
readonly login: (data:
|
|
17
|
-
readonly signup: (data:
|
|
16
|
+
readonly login: (data: auth0__login_data_T, schedule_forms_clear?: () => void) => Promise<void>;
|
|
17
|
+
readonly signup: (data: auth0__signup_data_T, schedule_forms_clear?: () => void) => Promise<void>;
|
|
18
18
|
readonly change_password: (form: {
|
|
19
19
|
password: string;
|
|
20
20
|
}, schedule_forms_clear?: () => void) => Promise<void>;
|
|
@@ -26,9 +26,9 @@ export declare class Auth0_c {
|
|
|
26
26
|
readonly onsubmit_change_password: (event: Event, ctx: onsubmit_change_password_Ctx, schedule_forms_clear?: typeof noop) => Promise<void>;
|
|
27
27
|
readonly onclose: (event: MouseEvent) => Promise<void>;
|
|
28
28
|
}
|
|
29
|
-
export interface signup_data_password_realm_body_I extends
|
|
29
|
+
export interface signup_data_password_realm_body_I extends auth0__signup_data_T, auth0__client_id__body_T, auth0__passwordless_start__fetch__body_T, password_realm__body_T, auth0__grant_type__body_T, auth0__oauth_token__fetch__body_T {
|
|
30
30
|
}
|
|
31
|
-
export interface login_data_password_realm_body_I extends
|
|
31
|
+
export interface login_data_password_realm_body_I extends auth0__login_data_T, auth0__client_id__body_T, auth0__passwordless_start__fetch__body_T, password_realm__body_T, auth0__grant_type__body_T, auth0__oauth_token__fetch__body_T {
|
|
32
32
|
}
|
|
33
33
|
export interface onsubmit_change_password_Ctx {
|
|
34
34
|
password_input: HTMLInputElement;
|
package/lib/ui/Auth0.svelte
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { setContext } from 'svelte'
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
auth0__forgot_password__opened__, auth0__opened__class__, auth0__login__opened__, auth0__signup__opened__,
|
|
5
|
+
auth0__forgot_password__check_email__opened__, auth0__change_password__opened__
|
|
6
6
|
} from '@ctx-core/auth0'
|
|
7
7
|
import { ctx_ } from '@ctx-core/object'
|
|
8
8
|
import { auth0_ui_ctx_key } from '../auth0_ui_ctx_key.js'
|
|
@@ -15,12 +15,12 @@ import Auth0_Login_Form from './Auth0_Login_Form.svelte'
|
|
|
15
15
|
import Auth0_Signup_Form from './Auth0_Signup_Form.svelte'
|
|
16
16
|
export let ctx = ctx_(), dialog = false
|
|
17
17
|
setContext(auth0_ui_ctx_key, ctx)
|
|
18
|
-
const auth0_change_password_opened_ =
|
|
19
|
-
const auth0_opened_class_ =
|
|
20
|
-
const auth0_forgot_password_check_email_opened_ =
|
|
21
|
-
const auth0_forgot_password_opened_ =
|
|
22
|
-
const auth0_login_opened_ =
|
|
23
|
-
const auth0_signup_opened_ =
|
|
18
|
+
const auth0_change_password_opened_ = auth0__change_password__opened__(ctx)
|
|
19
|
+
const auth0_opened_class_ = auth0__opened__class__(ctx)
|
|
20
|
+
const auth0_forgot_password_check_email_opened_ = auth0__forgot_password__check_email__opened__(ctx)
|
|
21
|
+
const auth0_forgot_password_opened_ = auth0__forgot_password__opened__(ctx)
|
|
22
|
+
const auth0_login_opened_ = auth0__login__opened__(ctx)
|
|
23
|
+
const auth0_signup_opened_ = auth0__signup__opened__(ctx)
|
|
24
24
|
const _ = new Auth0_c(ctx)
|
|
25
25
|
</script>
|
|
26
26
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { createEventDispatcher } from 'svelte'
|
|
3
|
-
import { AUTH0_DOMAIN__,
|
|
3
|
+
import { AUTH0_DOMAIN__, auth0__token__error__ } from '@ctx-core/auth0'
|
|
4
4
|
import { getContext_auth0_ui_ctx } from '../getContext_auth0_ui_ctx.js'
|
|
5
5
|
import { Auth0_c } from './Auth0_c.js'
|
|
6
6
|
import Auth0_Dialog_Close from './Auth0_Dialog_Close.svelte'
|
|
@@ -8,7 +8,7 @@ const ctx = getContext_auth0_ui_ctx()
|
|
|
8
8
|
const dispatch = createEventDispatcher()
|
|
9
9
|
export let error_class = '', input_class = '', button_class = '', label_class = '.js'
|
|
10
10
|
const AUTH0_DOMAIN_ = AUTH0_DOMAIN__(ctx)
|
|
11
|
-
const auth0_token_error_ =
|
|
11
|
+
const auth0_token_error_ = auth0__token__error__(ctx)
|
|
12
12
|
const _ = new Auth0_c(ctx)
|
|
13
13
|
let root:HTMLDivElement
|
|
14
14
|
let password_input:HTMLInputElement
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { AUTH0_DOMAIN__,
|
|
2
|
+
import { AUTH0_DOMAIN__, auth0__token__error__, auth0__login__open, auth0__signup__open } from '@ctx-core/auth0'
|
|
3
3
|
import { getContext_auth0_ui_ctx } from '../getContext_auth0_ui_ctx.js'
|
|
4
4
|
import { Auth0_c } from './Auth0_c.js'
|
|
5
5
|
import Auth0_Dialog_Close from './Auth0_Dialog_Close.svelte'
|
|
6
6
|
export let error_class = '', input_class = '', button_class = '', label_class = '.js'
|
|
7
7
|
const ctx = getContext_auth0_ui_ctx()
|
|
8
8
|
const AUTH0_DOMAIN_ = AUTH0_DOMAIN__(ctx)
|
|
9
|
-
const auth0_token_error_ =
|
|
9
|
+
const auth0_token_error_ = auth0__token__error__(ctx)
|
|
10
10
|
const _ = new Auth0_c(ctx)
|
|
11
11
|
let email_input:HTMLInputElement, error:typeof $auth0_token_error_?.error
|
|
12
12
|
$: error = $auth0_token_error_?.error
|
|
@@ -50,11 +50,11 @@ $: error = $auth0_token_error_?.error
|
|
|
50
50
|
/>
|
|
51
51
|
<label
|
|
52
52
|
class="auth_navigation {label_class}"
|
|
53
|
-
on:click={()=>
|
|
53
|
+
on:click={()=>auth0__login__open(ctx)}
|
|
54
54
|
>Have an account? Log in…</label>
|
|
55
55
|
<label
|
|
56
56
|
class="auth_navigation {label_class}"
|
|
57
|
-
on:click={()=>
|
|
57
|
+
on:click={()=>auth0__signup__open(ctx)}
|
|
58
58
|
>Don't have an account? Signup…</label>
|
|
59
59
|
</footer>
|
|
60
60
|
</form>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import {
|
|
3
|
-
AUTH0_DOMAIN__,
|
|
3
|
+
AUTH0_DOMAIN__, auth0__token__error__, auth0__token__error_txt__, auth0__forgot_password__open, auth0__signup__open
|
|
4
4
|
} from '@ctx-core/auth0'
|
|
5
5
|
import { type Ctx } from '@ctx-core/object'
|
|
6
6
|
import { Auth0_c } from './Auth0_c.js'
|
|
7
7
|
import Auth0_Dialog_Close from './Auth0_Dialog_Close.svelte'
|
|
8
8
|
export let ctx:Ctx, error_class = '', input_class = '', button_class = '', label_class = '.js'
|
|
9
|
-
const auth0_token_error_ =
|
|
10
|
-
const auth0_token_error_txt_ =
|
|
9
|
+
const auth0_token_error_ = auth0__token__error__(ctx)
|
|
10
|
+
const auth0_token_error_txt_ = auth0__token__error_txt__(ctx)
|
|
11
11
|
const AUTH0_DOMAIN = AUTH0_DOMAIN__(ctx)
|
|
12
12
|
const _ = new Auth0_c(ctx)
|
|
13
13
|
let root:HTMLDivElement
|
|
@@ -72,11 +72,11 @@ $: error_password = $auth0_token_error_?.password //endregion
|
|
|
72
72
|
/>
|
|
73
73
|
<label
|
|
74
74
|
class="auth_navigation {label_class}"
|
|
75
|
-
on:click={()=>
|
|
75
|
+
on:click={()=>auth0__signup__open(ctx)}
|
|
76
76
|
>Don't have an account? Signup…</label>
|
|
77
77
|
<label
|
|
78
78
|
class="auth_navigation {label_class}"
|
|
79
|
-
on:click={()=>
|
|
79
|
+
on:click={()=>auth0__forgot_password__open(ctx)}
|
|
80
80
|
>Forgot Password?</label>
|
|
81
81
|
</footer>
|
|
82
82
|
</form>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import {
|
|
3
|
-
AUTH0_DOMAIN__,
|
|
3
|
+
AUTH0_DOMAIN__, auth0__token__error__, auth0__forgot_password__open, auth0__login__open,
|
|
4
4
|
} from '@ctx-core/auth0'
|
|
5
5
|
import { getContext_auth0_ui_ctx } from '../getContext_auth0_ui_ctx.js'
|
|
6
6
|
import { Auth0_c } from './Auth0_c.js'
|
|
@@ -8,7 +8,7 @@ import Auth0_Dialog_Close from './Auth0_Dialog_Close.svelte'
|
|
|
8
8
|
export let error_class = '', input_class = '', button_class = '', label_class = '.js'
|
|
9
9
|
const ctx = getContext_auth0_ui_ctx()
|
|
10
10
|
const AUTH0_DOMAIN_ = AUTH0_DOMAIN__(ctx)
|
|
11
|
-
const auth0_token_error_ =
|
|
11
|
+
const auth0_token_error_ = auth0__token__error__(ctx)
|
|
12
12
|
const _ = new Auth0_c(ctx)
|
|
13
13
|
let root, signup_email_input, signup_password_input, signup_password_confirmation_input
|
|
14
14
|
let error_username:string|undefined //region
|
|
@@ -106,11 +106,11 @@ $: {
|
|
|
106
106
|
/>
|
|
107
107
|
<label
|
|
108
108
|
class="auth_navigation {label_class}"
|
|
109
|
-
on:click={()=>
|
|
109
|
+
on:click={()=>auth0__login__open(ctx)}
|
|
110
110
|
>Have an account? Log in…</label>
|
|
111
111
|
<label
|
|
112
112
|
class="auth_navigation {label_class}"
|
|
113
|
-
on:click={()=>
|
|
113
|
+
on:click={()=>auth0__forgot_password__open(ctx)}
|
|
114
114
|
>Forgot Password?</label>
|
|
115
115
|
</footer>
|
|
116
116
|
</form>
|
package/lib/ui/Auth0_c.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { auth0__body_, auth0__opened__class__, auth0__token__error__, auth0__token__json__, auth0__token__error__clear, auth0__close, auth0__token__error__logout, auth0__forgot_password__check_email__open, auth0__login__open, password_realm__body_, auth0__change_password__fetch, auth0__dbconnections_signup__fetch_get, auth0__oauth_token__fetch_get, auth0__passwordless_start__fetch_get, auth0__change_password__validate, auth0__forgot_password__validate, auth0__signup__validate } from '@ctx-core/auth0';
|
|
2
2
|
import { dom_a_, has_dom } from '@ctx-core/dom';
|
|
3
3
|
import { noop } from '@ctx-core/function';
|
|
4
4
|
import { onDestroy } from 'svelte';
|
|
5
5
|
export class Auth0_c {
|
|
6
6
|
constructor(ctx){
|
|
7
7
|
this.ctx = ctx;
|
|
8
|
-
this.login_auth0_body_ = (data)=>
|
|
9
|
-
this.login_password_realm_body_ = (data)=>
|
|
10
|
-
this.signup_auth0_body_ = (data)=>
|
|
11
|
-
this.signup_password_realm_body_ = (data)=>
|
|
12
|
-
this.auth0_opened_class =
|
|
13
|
-
this.auth0_token_json_ =
|
|
14
|
-
this.auth0_token_error_ =
|
|
15
|
-
this.
|
|
8
|
+
this.login_auth0_body_ = (data)=>auth0__body_(this.ctx, data);
|
|
9
|
+
this.login_password_realm_body_ = (data)=>password_realm__body_(this.ctx, this.login_auth0_body_(data));
|
|
10
|
+
this.signup_auth0_body_ = (data)=>auth0__body_(this.ctx, data);
|
|
11
|
+
this.signup_password_realm_body_ = (data)=>password_realm__body_(this.ctx, this.signup_auth0_body_(data));
|
|
12
|
+
this.auth0_opened_class = auth0__opened__class__(this.ctx);
|
|
13
|
+
this.auth0_token_json_ = auth0__token__json__(this.ctx);
|
|
14
|
+
this.auth0_token_error_ = auth0__token__error__(this.ctx);
|
|
15
|
+
this.auth0__close = ()=>auth0__close(this.ctx);
|
|
16
16
|
this.onMount = async (root)=>{
|
|
17
17
|
if (has_dom) {
|
|
18
18
|
const unsubscribe = this.auth0_opened_class.subscribe(()=>this.schedule_forms_clear(root));
|
|
@@ -20,20 +20,20 @@ export class Auth0_c {
|
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
this.login = async (data, schedule_forms_clear = ()=>{})=>{
|
|
23
|
-
const [auth0_token, response] = await
|
|
23
|
+
const [auth0_token, response] = await auth0__oauth_token__fetch_get(this.ctx, this.login_password_realm_body_(data));
|
|
24
24
|
if (response.ok) {
|
|
25
25
|
const auth0_token_json = JSON.stringify(auth0_token);
|
|
26
26
|
this.auth0_token_json_.$ = auth0_token_json;
|
|
27
27
|
schedule_forms_clear();
|
|
28
|
-
this.
|
|
28
|
+
this.auth0__close();
|
|
29
29
|
} else {
|
|
30
30
|
const auth_token_error = auth0_token;
|
|
31
31
|
this.auth0_token_error_.$ = auth_token_error;
|
|
32
|
-
|
|
32
|
+
auth0__token__error__logout(this.ctx, auth_token_error);
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
this.signup = async (data, schedule_forms_clear = ()=>{})=>{
|
|
36
|
-
const [auth0_userinfo] = await
|
|
36
|
+
const [auth0_userinfo] = await auth0__dbconnections_signup__fetch_get(this.ctx, this.signup_password_realm_body_(data));
|
|
37
37
|
const auth0_userinfo_Auth0Error = auth0_userinfo;
|
|
38
38
|
const { statusCode } = auth0_userinfo_Auth0Error;
|
|
39
39
|
if (statusCode) {
|
|
@@ -42,7 +42,7 @@ export class Auth0_c {
|
|
|
42
42
|
const auth0_token_error = {
|
|
43
43
|
email
|
|
44
44
|
};
|
|
45
|
-
|
|
45
|
+
auth0__token__error__logout(this.ctx, auth0_token_error);
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
48
|
schedule_forms_clear();
|
|
@@ -55,14 +55,14 @@ export class Auth0_c {
|
|
|
55
55
|
const { password } = form;
|
|
56
56
|
let error;
|
|
57
57
|
try {
|
|
58
|
-
const [response_json, response] = await
|
|
58
|
+
const [response_json, response] = await auth0__change_password__fetch(this.ctx, password);
|
|
59
59
|
if (!response.ok) {
|
|
60
60
|
if (response.status == 401) {
|
|
61
|
-
|
|
61
|
+
auth0__login__open(this.ctx);
|
|
62
62
|
const auth0_token_error = {
|
|
63
63
|
username: 'Authentication Error - Log in'
|
|
64
64
|
};
|
|
65
|
-
|
|
65
|
+
auth0__token__error__logout(this.ctx, auth0_token_error);
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
68
|
error = response_json.error || 'Error changing Password';
|
|
@@ -75,18 +75,18 @@ export class Auth0_c {
|
|
|
75
75
|
const auth0_token_error = {
|
|
76
76
|
password: error
|
|
77
77
|
};
|
|
78
|
-
|
|
78
|
+
auth0__token__error__logout(this.ctx, auth0_token_error);
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
81
|
schedule_forms_clear();
|
|
82
|
-
this.
|
|
82
|
+
this.auth0__close();
|
|
83
83
|
};
|
|
84
84
|
this.schedule_forms_clear_ = (root)=>{
|
|
85
85
|
return ()=>this.schedule_forms_clear(root);
|
|
86
86
|
};
|
|
87
87
|
this.schedule_forms_clear = (root)=>{
|
|
88
88
|
setTimeout(()=>{
|
|
89
|
-
|
|
89
|
+
auth0__token__error__clear(this.ctx);
|
|
90
90
|
clear_inputs(dom_a_('input[type=text]', root));
|
|
91
91
|
clear_inputs(dom_a_('input[type=password]', root));
|
|
92
92
|
}, 100);
|
|
@@ -97,13 +97,13 @@ export class Auth0_c {
|
|
|
97
97
|
const email = email_input.value;
|
|
98
98
|
const password = password_input.value;
|
|
99
99
|
const password_confirmation = password_confirmation_input.value;
|
|
100
|
-
const auth0_token_error =
|
|
100
|
+
const auth0_token_error = auth0__signup__validate({
|
|
101
101
|
email,
|
|
102
102
|
password,
|
|
103
103
|
password_confirmation
|
|
104
104
|
});
|
|
105
105
|
if (auth0_token_error) {
|
|
106
|
-
|
|
106
|
+
auth0__token__error__logout(this.ctx, auth0_token_error);
|
|
107
107
|
return false;
|
|
108
108
|
}
|
|
109
109
|
await this.signup({
|
|
@@ -131,25 +131,25 @@ export class Auth0_c {
|
|
|
131
131
|
send: 'link',
|
|
132
132
|
email
|
|
133
133
|
};
|
|
134
|
-
const auth0_token_error =
|
|
134
|
+
const auth0_token_error = auth0__forgot_password__validate(data);
|
|
135
135
|
if (auth0_token_error) {
|
|
136
|
-
|
|
136
|
+
auth0__token__error__logout(this.ctx, auth0_token_error);
|
|
137
137
|
return;
|
|
138
138
|
}
|
|
139
|
-
await
|
|
140
|
-
|
|
139
|
+
await auth0__passwordless_start__fetch_get(this.ctx, this.login_auth0_body_(data));
|
|
140
|
+
auth0__forgot_password__check_email__open(this.ctx);
|
|
141
141
|
};
|
|
142
142
|
this.onsubmit_change_password = async (event, ctx, schedule_forms_clear = noop)=>{
|
|
143
143
|
event.preventDefault();
|
|
144
144
|
const { password_input , password_confirmation_input } = ctx;
|
|
145
145
|
const password = password_input.value;
|
|
146
146
|
const password_confirmation = password_confirmation_input.value;
|
|
147
|
-
const auth0_token_error =
|
|
147
|
+
const auth0_token_error = auth0__change_password__validate({
|
|
148
148
|
password,
|
|
149
149
|
password_confirmation
|
|
150
150
|
});
|
|
151
151
|
if (auth0_token_error) {
|
|
152
|
-
|
|
152
|
+
auth0__token__error__logout(this.ctx, auth0_token_error);
|
|
153
153
|
throw auth0_token_error;
|
|
154
154
|
}
|
|
155
155
|
return await this.change_password({
|
|
@@ -158,7 +158,7 @@ export class Auth0_c {
|
|
|
158
158
|
};
|
|
159
159
|
this.onclose = async (event)=>{
|
|
160
160
|
event.preventDefault();
|
|
161
|
-
this.
|
|
161
|
+
this.auth0__close();
|
|
162
162
|
};
|
|
163
163
|
}
|
|
164
164
|
}
|
package/lib/ui/Auth0_c.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ui/Auth0_c.ts"],"sourcesContent":["import type {\n\tauth0_client_id_body_I,\n\tauth0_grant_type_body_I,\n\tlogin_data_I,\n\tpassword_realm_body_T,\n\tpost_auth0_oauth_token_body_I,\n\tpost_auth0_passwordless_start_body_T,\n\tpost_auth0_passwordless_start_optional_body_T,\n\tsignup_data_I\n} from '@ctx-core/auth0'\nimport {\n\tauth0_body_,\n\tauth0_opened_class__,\n\tauth0_token_error__,\n\tauth0_token_json__,\n\tclear_auth0_token_error,\n\tclose_auth0,\n\tlogout_auth0_token_error,\n\topen_auth0_forgot_password_check_email,\n\topen_auth0_login,\n\tpassword_realm_body_,\n\tpost_auth0_auth_change_password,\n\tpost_auth0_dbconnections_signup,\n\tpost_auth0_oauth_token,\n\tpost_auth0_passwordless_start,\n\tvalidate_auth0_change_password,\n\tvalidate_auth0_forgot_password,\n\tvalidate_auth0_signup\n} from '@ctx-core/auth0'\nimport { dom_a_, has_dom } from '@ctx-core/dom'\nimport { noop } from '@ctx-core/function'\nimport type { Ctx } from '@ctx-core/object'\nimport type { Auth0Error } from 'auth0-js'\nimport { onDestroy } from 'svelte'\nexport class Auth0_c {\n\tconstructor(protected ctx:Ctx) {}\n\treadonly login_auth0_body_ = (data:any)=>\n\t\tauth0_body_<login_data_password_realm_body_I>(\n\t\t\tthis.ctx, data\n\t\t)\n\treadonly login_password_realm_body_ = (data:any)=>\n\t\tpassword_realm_body_<login_data_password_realm_body_I>(\n\t\t\tthis.ctx,\n\t\t\tthis.login_auth0_body_(data)\n\t\t)\n\treadonly signup_auth0_body_ = (data:any)=>\n\t\tauth0_body_<signup_data_password_realm_body_I>(this.ctx, data) as signup_data_password_realm_body_I\n\treadonly signup_password_realm_body_ = (data:any)=>\n\t\tpassword_realm_body_<signup_data_password_realm_body_I>(this.ctx, this.signup_auth0_body_(data))\n\treadonly auth0_opened_class = auth0_opened_class__(this.ctx)\n\treadonly auth0_token_json_ = auth0_token_json__(this.ctx)\n\treadonly auth0_token_error_ = auth0_token_error__(this.ctx)\n\treadonly close_auth0 = ()=>close_auth0(this.ctx)\n\treadonly onMount = async (root:HTMLElement)=>{\n\t\tif (has_dom) {\n\t\t\tconst unsubscribe =\n\t\t\t\tthis.auth0_opened_class.subscribe(()=>this.schedule_forms_clear(root))\n\t\t\tonDestroy(unsubscribe)\n\t\t}\n\t}\n\treadonly login = async (data:login_data_I, schedule_forms_clear = ()=>{})=>{\n\t\tconst [auth0_token, response] = await post_auth0_oauth_token(\n\t\t\tthis.ctx, this.login_password_realm_body_(data)\n\t\t)\n\t\tif (response.ok) {\n\t\t\tconst auth0_token_json = JSON.stringify(auth0_token)\n\t\t\tthis.auth0_token_json_.$ = auth0_token_json\n\t\t\tschedule_forms_clear()\n\t\t\tthis.close_auth0()\n\t\t} else {\n\t\t\tconst auth_token_error = auth0_token as Auth0Error\n\t\t\tthis.auth0_token_error_.$ = auth_token_error\n\t\t\tlogout_auth0_token_error(this.ctx, auth_token_error)\n\t\t}\n\t}\n\treadonly signup = async (data:signup_data_I, schedule_forms_clear = ()=>{})=>{\n\t\tconst [auth0_userinfo] = await post_auth0_dbconnections_signup(\n\t\t\tthis.ctx,\n\t\t\tthis.signup_password_realm_body_(data))\n\t\tconst auth0_userinfo_Auth0Error = auth0_userinfo as Auth0Error\n\t\tconst { statusCode } = auth0_userinfo_Auth0Error\n\t\tif (statusCode) {\n\t\t\tconst {\n\t\t\t\tcode,\n\t\t\t\tdescription\n\t\t\t} = auth0_userinfo_Auth0Error\n\t\t\tconst email =\n\t\t\t\tcode === 'user_exists'\n\t\t\t\t? 'This Email is already signed up'\n\t\t\t\t: description || ''\n\t\t\tconst auth0_token_error = { email }\n\t\t\tlogout_auth0_token_error(this.ctx, auth0_token_error)\n\t\t\treturn\n\t\t}\n\t\tschedule_forms_clear()\n\t\tawait this.login({\n\t\t\tusername: data.email,\n\t\t\tpassword: data.password,\n\t\t}, schedule_forms_clear)\n\t}\n\treadonly change_password = async (form:{ password:string }, schedule_forms_clear = ()=>{})=>{\n\t\tconst { password } = form\n\t\tlet error\n\t\ttry {\n\t\t\tconst [response_json, response] = await post_auth0_auth_change_password(this.ctx, password)\n\t\t\tif (!response.ok) {\n\t\t\t\tif (response.status == 401) {\n\t\t\t\t\topen_auth0_login(this.ctx)\n\t\t\t\t\tconst auth0_token_error = { username: 'Authentication Error - Log in' }\n\t\t\t\t\tlogout_auth0_token_error(this.ctx, auth0_token_error)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\terror = response_json.error || 'Error changing Password'\n\t\t\t}\n\t\t} catch (e:any) {\n\t\t\tconsole.warn(e)\n\t\t\terror = e.message\n\t\t}\n\t\tif (error) {\n\t\t\tconst auth0_token_error = { password: error }\n\t\t\tlogout_auth0_token_error(this.ctx, auth0_token_error)\n\t\t\treturn\n\t\t}\n\t\tschedule_forms_clear()\n\t\tthis.close_auth0()\n\t}\n\treadonly schedule_forms_clear_:(root:HTMLElement)=>void = (root:HTMLElement)=>{\n\t\treturn ()=>this.schedule_forms_clear(root)\n\t}\n\treadonly schedule_forms_clear = (root:HTMLElement)=>{\n\t\tsetTimeout(()=>{\n\t\t\tclear_auth0_token_error(this.ctx)\n\t\t\tclear_inputs(dom_a_('input[type=text]', root))\n\t\t\tclear_inputs(dom_a_('input[type=password]', root))\n\t\t}, 100)\n\t}\n\treadonly onsubmit_signup = async (event:Event, ctx:onsubmit_signup_Ctx, schedule_forms_clear = ()=>{})=>{\n\t\tevent.preventDefault()\n\t\tconst {\n\t\t\temail_input,\n\t\t\tpassword_input,\n\t\t\tpassword_confirmation_input,\n\t\t} = ctx\n\t\tconst email = email_input.value\n\t\tconst password = password_input.value\n\t\tconst password_confirmation = password_confirmation_input.value\n\t\tconst auth0_token_error =\n\t\t\tvalidate_auth0_signup({\n\t\t\t\temail,\n\t\t\t\tpassword,\n\t\t\t\tpassword_confirmation\n\t\t\t})\n\t\tif (auth0_token_error) {\n\t\t\tlogout_auth0_token_error(this.ctx, auth0_token_error)\n\t\t\treturn false\n\t\t}\n\t\tawait this.signup({\n\t\t\temail,\n\t\t\tpassword\n\t\t}, schedule_forms_clear)\n\t\treturn\n\t}\n\treadonly onsubmit_login = async (event:Event, ctx:onsubmit_login_Ctx, schedule_forms_clear = ()=>{})=>{\n\t\tevent.preventDefault()\n\t\tconst { username_login_input, password_login_input } = ctx\n\t\tconst username = username_login_input.value\n\t\tconst password = password_login_input.value\n\t\tawait this.login({ username, password }, schedule_forms_clear)\n\t}\n\treadonly onsubmit_forgot_password = async (event:Event, ctx:onsubmit_forgot_password_Ctx)=>{\n\t\tevent.preventDefault()\n\t\tconst { email_input } = ctx\n\t\tconst email = email_input.value\n\t\tconst data:post_auth0_passwordless_start_optional_body_T = {\n\t\t\tconnection: 'email',\n\t\t\tsend: 'link',\n\t\t\temail\n\t\t}\n\t\tconst auth0_token_error = validate_auth0_forgot_password(data)\n\t\tif (auth0_token_error) {\n\t\t\tlogout_auth0_token_error(this.ctx, auth0_token_error)\n\t\t\treturn\n\t\t}\n\t\tawait post_auth0_passwordless_start(\n\t\t\tthis.ctx, this.login_auth0_body_(data) as post_auth0_passwordless_start_body_T\n\t\t)\n\t\topen_auth0_forgot_password_check_email(this.ctx)\n\t}\n\treadonly onsubmit_change_password = async (\n\t\tevent:Event, ctx:onsubmit_change_password_Ctx, schedule_forms_clear = noop\n\t)=>{\n\t\tevent.preventDefault()\n\t\tconst {\n\t\t\tpassword_input,\n\t\t\tpassword_confirmation_input,\n\t\t} = ctx\n\t\tconst password = password_input.value\n\t\tconst password_confirmation = password_confirmation_input.value\n\t\tconst auth0_token_error =\n\t\t\tvalidate_auth0_change_password(\n\t\t\t\t{\n\t\t\t\t\tpassword,\n\t\t\t\t\tpassword_confirmation\n\t\t\t\t})\n\t\tif (auth0_token_error) {\n\t\t\tlogout_auth0_token_error(this.ctx, auth0_token_error)\n\t\t\tthrow auth0_token_error\n\t\t}\n\t\treturn await this.change_password({ password }, schedule_forms_clear)\n\t}\n\treadonly onclose = async (event:MouseEvent)=>{\n\t\tevent.preventDefault()\n\t\tthis.close_auth0()\n\t}\n}\nfunction clear_inputs(inputs:NodeList) {\n\tfor (let i = 0; i < inputs.length; i++) {\n\t\tconst input = inputs[i] as HTMLInputElement\n\t\tinput.value = ''\n\t}\n}\nexport interface signup_data_password_realm_body_I\n\textends signup_data_I,\n\t\tauth0_client_id_body_I,\n\t\tpost_auth0_passwordless_start_body_T,\n\t\tpassword_realm_body_T,\n\t\tauth0_grant_type_body_I,\n\t\tpost_auth0_oauth_token_body_I {}\nexport interface login_data_password_realm_body_I\n\textends login_data_I,\n\t\tauth0_client_id_body_I,\n\t\tpost_auth0_passwordless_start_body_T,\n\t\tpassword_realm_body_T,\n\t\tauth0_grant_type_body_I,\n\t\tpost_auth0_oauth_token_body_I {}\nexport interface onsubmit_change_password_Ctx {\n\tpassword_input:HTMLInputElement\n\tpassword_confirmation_input:HTMLInputElement\n}\nexport interface onsubmit_forgot_password_Ctx {\n\temail_input:HTMLInputElement\n}\nexport interface onsubmit_login_Ctx {\n\tusername_login_input:HTMLInputElement\n\tpassword_login_input:HTMLInputElement\n}\nexport interface onsubmit_signup_Ctx {\n\temail_input:HTMLInputElement\n\tpassword_input:HTMLInputElement\n\tpassword_confirmation_input:HTMLInputElement\n}\n"],"names":["auth0_body_","auth0_opened_class__","auth0_token_error__","auth0_token_json__","clear_auth0_token_error","close_auth0","logout_auth0_token_error","open_auth0_forgot_password_check_email","open_auth0_login","password_realm_body_","post_auth0_auth_change_password","post_auth0_dbconnections_signup","post_auth0_oauth_token","post_auth0_passwordless_start","validate_auth0_change_password","validate_auth0_forgot_password","validate_auth0_signup","dom_a_","has_dom","noop","onDestroy","Auth0_c","constructor","ctx","login_auth0_body_","data","login_password_realm_body_","signup_auth0_body_","signup_password_realm_body_","auth0_opened_class","auth0_token_json_","auth0_token_error_","onMount","root","unsubscribe","subscribe","schedule_forms_clear","login","auth0_token","response","ok","auth0_token_json","JSON","stringify","$","auth_token_error","signup","auth0_userinfo","auth0_userinfo_Auth0Error","statusCode","code","description","email","auth0_token_error","username","password","change_password","form","error","response_json","status","e","console","warn","message","schedule_forms_clear_","setTimeout","clear_inputs","onsubmit_signup","event","preventDefault","email_input","password_input","password_confirmation_input","value","password_confirmation","onsubmit_login","username_login_input","password_login_input","onsubmit_forgot_password","connection","send","onsubmit_change_password","onclose","inputs","i","length","input"],"mappings":"AAUA,SACCA,WAAW,EACXC,oBAAoB,EACpBC,mBAAmB,EACnBC,kBAAkB,EAClBC,uBAAuB,EACvBC,WAAW,EACXC,wBAAwB,EACxBC,sCAAsC,EACtCC,gBAAgB,EAChBC,oBAAoB,EACpBC,+BAA+B,EAC/BC,+BAA+B,EAC/BC,sBAAsB,EACtBC,6BAA6B,EAC7BC,8BAA8B,EAC9BC,8BAA8B,EAC9BC,qBAAqB,QACf,kBAAiB;AACxB,SAASC,MAAM,EAAEC,OAAO,QAAQ,gBAAe;AAC/C,SAASC,IAAI,QAAQ,qBAAoB;AAGzC,SAASC,SAAS,QAAQ,SAAQ;AAClC,OAAO,MAAMC;IACZC,YAAsBC,IAAS;mBAATA;aACbC,oBAAoB,CAACC,OAC7BzB,YACC,IAAI,CAACuB,GAAG,EAAEE;aAEHC,6BAA6B,CAACD,OACtChB,qBACC,IAAI,CAACc,GAAG,EACR,IAAI,CAACC,iBAAiB,CAACC;aAEhBE,qBAAqB,CAACF,OAC9BzB,YAA+C,IAAI,CAACuB,GAAG,EAAEE;aACjDG,8BAA8B,CAACH,OACvChB,qBAAwD,IAAI,CAACc,GAAG,EAAE,IAAI,CAACI,kBAAkB,CAACF;aAClFI,qBAAqB5B,qBAAqB,IAAI,CAACsB,GAAG;aAClDO,oBAAoB3B,mBAAmB,IAAI,CAACoB,GAAG;aAC/CQ,qBAAqB7B,oBAAoB,IAAI,CAACqB,GAAG;aACjDlB,cAAc,IAAIA,YAAY,IAAI,CAACkB,GAAG;aACtCS,UAAU,OAAOC,OAAmB;YAC5C,IAAIf,SAAS;gBACZ,MAAMgB,cACL,IAAI,CAACL,kBAAkB,CAACM,SAAS,CAAC,IAAI,IAAI,CAACC,oBAAoB,CAACH;gBACjEb,UA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AAC;gBAAED;YAAS,GAAGnB;QACjD;aACS+C,UAAU,OAAOd,QAAmB;YAC5CA,MAAMC,cAAc;YACpB,IAAI,CAACjE,WAAW;QACjB;IAlLgC;AAmLjC,CAAC;AACD,SAAS8D,aAAaiB,MAAe,EAAE;IACtC,IAAK,IAAIC,IAAI,GAAGA,IAAID,OAAOE,MAAM,EAAED,IAAK;QACvC,MAAME,QAAQH,MAAM,CAACC,EAAE;QACvBE,MAAMb,KAAK,GAAG;IACf;AACD"}
|
|
1
|
+
{"version":3,"sources":["../../src/ui/Auth0_c.ts"],"sourcesContent":["import type {\n\tauth0__client_id__body_T,\n\tauth0__grant_type__body_T,\n\tauth0__login_data_T,\n\tpassword_realm__body_T,\n\tauth0__oauth_token__fetch__body_T,\n\tauth0__passwordless_start__fetch__body_T,\n\tauth0__passwordless_start__fetch__optional_body_T,\n\tauth0__signup_data_T\n} from '@ctx-core/auth0'\nimport {\n\tauth0__body_,\n\tauth0__opened__class__,\n\tauth0__token__error__,\n\tauth0__token__json__,\n\tauth0__token__error__clear,\n\tauth0__close,\n\tauth0__token__error__logout,\n\tauth0__forgot_password__check_email__open,\n\tauth0__login__open,\n\tpassword_realm__body_,\n\tauth0__change_password__fetch,\n\tauth0__dbconnections_signup__fetch_get,\n\tauth0__oauth_token__fetch_get,\n\tauth0__passwordless_start__fetch_get,\n\tauth0__change_password__validate,\n\tauth0__forgot_password__validate,\n\tauth0__signup__validate\n} from '@ctx-core/auth0'\nimport { dom_a_, has_dom } from '@ctx-core/dom'\nimport { noop } from '@ctx-core/function'\nimport type { Ctx } from '@ctx-core/object'\nimport type { Auth0Error } from 'auth0-js'\nimport { onDestroy } from 'svelte'\nexport class Auth0_c {\n\tconstructor(protected ctx:Ctx) {}\n\treadonly login_auth0_body_ = (data:any)=>\n\t\tauth0__body_<login_data_password_realm_body_I>(\n\t\t\tthis.ctx, data\n\t\t)\n\treadonly login_password_realm_body_ = (data:any)=>\n\t\tpassword_realm__body_<login_data_password_realm_body_I>(\n\t\t\tthis.ctx,\n\t\t\tthis.login_auth0_body_(data)\n\t\t)\n\treadonly signup_auth0_body_ = (data:any)=>\n\t\tauth0__body_<signup_data_password_realm_body_I>(this.ctx, data) as signup_data_password_realm_body_I\n\treadonly signup_password_realm_body_ = (data:any)=>\n\t\tpassword_realm__body_<signup_data_password_realm_body_I>(this.ctx, this.signup_auth0_body_(data))\n\treadonly auth0_opened_class = auth0__opened__class__(this.ctx)\n\treadonly auth0_token_json_ = auth0__token__json__(this.ctx)\n\treadonly auth0_token_error_ = auth0__token__error__(this.ctx)\n\treadonly auth0__close = ()=>auth0__close(this.ctx)\n\treadonly onMount = async (root:HTMLElement)=>{\n\t\tif (has_dom) {\n\t\t\tconst unsubscribe =\n\t\t\t\tthis.auth0_opened_class.subscribe(()=>this.schedule_forms_clear(root))\n\t\t\tonDestroy(unsubscribe)\n\t\t}\n\t}\n\treadonly login = async (data:auth0__login_data_T, schedule_forms_clear = ()=>{})=>{\n\t\tconst [auth0_token, response] = await auth0__oauth_token__fetch_get(\n\t\t\tthis.ctx, this.login_password_realm_body_(data)\n\t\t)\n\t\tif (response.ok) {\n\t\t\tconst auth0_token_json = JSON.stringify(auth0_token)\n\t\t\tthis.auth0_token_json_.$ = auth0_token_json\n\t\t\tschedule_forms_clear()\n\t\t\tthis.auth0__close()\n\t\t} else {\n\t\t\tconst auth_token_error = auth0_token as Auth0Error\n\t\t\tthis.auth0_token_error_.$ = auth_token_error\n\t\t\tauth0__token__error__logout(this.ctx, auth_token_error)\n\t\t}\n\t}\n\treadonly signup = async (data:auth0__signup_data_T, schedule_forms_clear = ()=>{})=>{\n\t\tconst [auth0_userinfo] = await auth0__dbconnections_signup__fetch_get(\n\t\t\tthis.ctx,\n\t\t\tthis.signup_password_realm_body_(data))\n\t\tconst auth0_userinfo_Auth0Error = auth0_userinfo as Auth0Error\n\t\tconst { statusCode } = auth0_userinfo_Auth0Error\n\t\tif (statusCode) {\n\t\t\tconst {\n\t\t\t\tcode,\n\t\t\t\tdescription\n\t\t\t} = auth0_userinfo_Auth0Error\n\t\t\tconst email =\n\t\t\t\tcode === 'user_exists'\n\t\t\t\t? 'This Email is already signed up'\n\t\t\t\t: description || ''\n\t\t\tconst auth0_token_error = { email }\n\t\t\tauth0__token__error__logout(this.ctx, auth0_token_error)\n\t\t\treturn\n\t\t}\n\t\tschedule_forms_clear()\n\t\tawait this.login({\n\t\t\tusername: data.email,\n\t\t\tpassword: data.password,\n\t\t}, schedule_forms_clear)\n\t}\n\treadonly change_password = async (form:{ password:string }, schedule_forms_clear = ()=>{})=>{\n\t\tconst { password } = form\n\t\tlet error\n\t\ttry {\n\t\t\tconst [response_json, response] = await auth0__change_password__fetch(this.ctx, password)\n\t\t\tif (!response.ok) {\n\t\t\t\tif (response.status == 401) {\n\t\t\t\t\tauth0__login__open(this.ctx)\n\t\t\t\t\tconst auth0_token_error = { username: 'Authentication Error - Log in' }\n\t\t\t\t\tauth0__token__error__logout(this.ctx, auth0_token_error)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\terror = response_json.error || 'Error changing Password'\n\t\t\t}\n\t\t} catch (e:any) {\n\t\t\tconsole.warn(e)\n\t\t\terror = e.message\n\t\t}\n\t\tif (error) {\n\t\t\tconst auth0_token_error = { password: error }\n\t\t\tauth0__token__error__logout(this.ctx, auth0_token_error)\n\t\t\treturn\n\t\t}\n\t\tschedule_forms_clear()\n\t\tthis.auth0__close()\n\t}\n\treadonly schedule_forms_clear_:(root:HTMLElement)=>void = (root:HTMLElement)=>{\n\t\treturn ()=>this.schedule_forms_clear(root)\n\t}\n\treadonly schedule_forms_clear = (root:HTMLElement)=>{\n\t\tsetTimeout(()=>{\n\t\t\tauth0__token__error__clear(this.ctx)\n\t\t\tclear_inputs(dom_a_('input[type=text]', root))\n\t\t\tclear_inputs(dom_a_('input[type=password]', root))\n\t\t}, 100)\n\t}\n\treadonly onsubmit_signup = async (event:Event, ctx:onsubmit_signup_Ctx, schedule_forms_clear = ()=>{})=>{\n\t\tevent.preventDefault()\n\t\tconst {\n\t\t\temail_input,\n\t\t\tpassword_input,\n\t\t\tpassword_confirmation_input,\n\t\t} = ctx\n\t\tconst email = email_input.value\n\t\tconst password = password_input.value\n\t\tconst password_confirmation = password_confirmation_input.value\n\t\tconst auth0_token_error =\n\t\t\tauth0__signup__validate({\n\t\t\t\temail,\n\t\t\t\tpassword,\n\t\t\t\tpassword_confirmation\n\t\t\t})\n\t\tif (auth0_token_error) {\n\t\t\tauth0__token__error__logout(this.ctx, auth0_token_error)\n\t\t\treturn false\n\t\t}\n\t\tawait this.signup({\n\t\t\temail,\n\t\t\tpassword\n\t\t}, schedule_forms_clear)\n\t\treturn\n\t}\n\treadonly onsubmit_login = async (event:Event, ctx:onsubmit_login_Ctx, schedule_forms_clear = ()=>{})=>{\n\t\tevent.preventDefault()\n\t\tconst { username_login_input, password_login_input } = ctx\n\t\tconst username = username_login_input.value\n\t\tconst password = password_login_input.value\n\t\tawait this.login({ username, password }, schedule_forms_clear)\n\t}\n\treadonly onsubmit_forgot_password = async (event:Event, ctx:onsubmit_forgot_password_Ctx)=>{\n\t\tevent.preventDefault()\n\t\tconst { email_input } = ctx\n\t\tconst email = email_input.value\n\t\tconst data:auth0__passwordless_start__fetch__optional_body_T = {\n\t\t\tconnection: 'email',\n\t\t\tsend: 'link',\n\t\t\temail\n\t\t}\n\t\tconst auth0_token_error = auth0__forgot_password__validate(data)\n\t\tif (auth0_token_error) {\n\t\t\tauth0__token__error__logout(this.ctx, auth0_token_error)\n\t\t\treturn\n\t\t}\n\t\tawait auth0__passwordless_start__fetch_get(\n\t\t\tthis.ctx, this.login_auth0_body_(data) as auth0__passwordless_start__fetch__body_T\n\t\t)\n\t\tauth0__forgot_password__check_email__open(this.ctx)\n\t}\n\treadonly onsubmit_change_password = async (\n\t\tevent:Event, ctx:onsubmit_change_password_Ctx, schedule_forms_clear = noop\n\t)=>{\n\t\tevent.preventDefault()\n\t\tconst {\n\t\t\tpassword_input,\n\t\t\tpassword_confirmation_input,\n\t\t} = ctx\n\t\tconst password = password_input.value\n\t\tconst password_confirmation = password_confirmation_input.value\n\t\tconst auth0_token_error =\n\t\t\tauth0__change_password__validate(\n\t\t\t\t{\n\t\t\t\t\tpassword,\n\t\t\t\t\tpassword_confirmation\n\t\t\t\t})\n\t\tif (auth0_token_error) {\n\t\t\tauth0__token__error__logout(this.ctx, auth0_token_error)\n\t\t\tthrow auth0_token_error\n\t\t}\n\t\treturn await this.change_password({ password }, schedule_forms_clear)\n\t}\n\treadonly onclose = async (event:MouseEvent)=>{\n\t\tevent.preventDefault()\n\t\tthis.auth0__close()\n\t}\n}\nfunction clear_inputs(inputs:NodeList) {\n\tfor (let i = 0; i < inputs.length; i++) {\n\t\tconst input = inputs[i] as HTMLInputElement\n\t\tinput.value = ''\n\t}\n}\nexport interface signup_data_password_realm_body_I\n\textends auth0__signup_data_T,\n\t\tauth0__client_id__body_T,\n\t\tauth0__passwordless_start__fetch__body_T,\n\t\tpassword_realm__body_T,\n\t\tauth0__grant_type__body_T,\n\t\tauth0__oauth_token__fetch__body_T {}\nexport interface login_data_password_realm_body_I\n\textends auth0__login_data_T,\n\t\tauth0__client_id__body_T,\n\t\tauth0__passwordless_start__fetch__body_T,\n\t\tpassword_realm__body_T,\n\t\tauth0__grant_type__body_T,\n\t\tauth0__oauth_token__fetch__body_T {}\nexport interface onsubmit_change_password_Ctx {\n\tpassword_input:HTMLInputElement\n\tpassword_confirmation_input:HTMLInputElement\n}\nexport interface onsubmit_forgot_password_Ctx {\n\temail_input:HTMLInputElement\n}\nexport interface onsubmit_login_Ctx {\n\tusername_login_input:HTMLInputElement\n\tpassword_login_input:HTMLInputElement\n}\nexport interface onsubmit_signup_Ctx {\n\temail_input:HTMLInputElement\n\tpassword_input:HTMLInputElement\n\tpassword_confirmation_input:HTMLInputElement\n}\n"],"names":["auth0__body_","auth0__opened__class__","auth0__token__error__","auth0__token__json__","auth0__token__error__clear","auth0__close","auth0__token__error__logout","auth0__forgot_password__check_email__open","auth0__login__open","password_realm__body_","auth0__change_password__fetch","auth0__dbconnections_signup__fetch_get","auth0__oauth_token__fetch_get","auth0__passwordless_start__fetch_get","auth0__change_password__validate","auth0__forgot_password__validate","auth0__signup__validate","dom_a_","has_dom","noop","onDestroy","Auth0_c","constructor","ctx","login_auth0_body_","data","login_password_realm_body_","signup_auth0_body_","signup_password_realm_body_","auth0_opened_class","auth0_token_json_","auth0_token_error_","onMount","root","unsubscribe","subscribe","schedule_forms_clear","login","auth0_token","response","ok","auth0_token_json","JSON","stringify","$","auth_token_error","signup","auth0_userinfo","auth0_userinfo_Auth0Error","statusCode","code","description","email","auth0_token_error","username","password","change_password","form","error","response_json","status","e","console","warn","message","schedule_forms_clear_","setTimeout","clear_inputs","onsubmit_signup","event","preventDefault","email_input","password_input","password_confirmation_input","value","password_confirmation","onsubmit_login","username_login_input","password_login_input","onsubmit_forgot_password","connection","send","onsubmit_change_password","onclose","inputs","i","length","input"],"mappings":"AAUA,SACCA,YAAY,EACZC,sBAAsB,EACtBC,qBAAqB,EACrBC,oBAAoB,EACpBC,0BAA0B,EAC1BC,YAAY,EACZC,2BAA2B,EAC3BC,yCAAyC,EACzCC,kBAAkB,EAClBC,qBAAqB,EACrBC,6BAA6B,EAC7BC,sCAAsC,EACtCC,6BAA6B,EAC7BC,oCAAoC,EACpCC,gCAAgC,EAChCC,gCAAgC,EAChCC,uBAAuB,QACjB,kBAAiB;AACxB,SAASC,MAAM,EAAEC,OAAO,QAAQ,gBAAe;AAC/C,SAASC,IAAI,QAAQ,qBAAoB;AAGzC,SAASC,SAAS,QAAQ,SAAQ;AAClC,OAAO,MAAMC;IACZC,YAAsBC,IAAS;mBAATA;aACbC,oBAAoB,CAACC,OAC7BzB,aACC,IAAI,CAACuB,GAAG,EAAEE;aAEHC,6BAA6B,CAACD,OACtChB,sBACC,IAAI,CAACc,GAAG,EACR,IAAI,CAACC,iBAAiB,CAACC;aAEhBE,qBAAqB,CAACF,OAC9BzB,aAAgD,IAA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AACC;YAElClB,0CAA0C,IAAI,CAACgB,GAAG;QACnD;aACS2D,2BAA2B,OACnCb,OAAa9C,KAAkCa,uBAAuBjB,IAAI,GACxE;YACFkD,MAAMC,cAAc;YACpB,MAAM,EACLE,eAAc,EACdC,4BAA2B,EAC3B,GAAGlD;YACJ,MAAMgC,WAAWiB,eAAeE,KAAK;YACrC,MAAMC,wBAAwBF,4BAA4BC,KAAK;YAC/D,MAAMrB,oBACLvC,iCACC;gBACCyC;gBACAoB;YACD;YACF,IAAItB,mBAAmB;gBACtB/C,4BAA4B,IAAI,CAACiB,GAAG,EAAE8B;gBACtC,MAAMA,kBAAiB;YACxB,CAAC;YACD,OAAO,MAAM,IAAI,CAACG,eAAe,CAAC;gBAAED;YAAS,GAAGnB;QACjD;aACS+C,UAAU,OAAOd,QAAmB;YAC5CA,MAAMC,cAAc;YACpB,IAAI,CAACjE,YAAY;QAClB;IAlLgC;AAmLjC,CAAC;AACD,SAAS8D,aAAaiB,MAAe,EAAE;IACtC,IAAK,IAAIC,IAAI,GAAGA,IAAID,OAAOE,MAAM,EAAED,IAAK;QACvC,MAAME,QAAQH,MAAM,CAACC,EAAE;QACvBE,MAAMb,KAAK,GAAG;IACf;AACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ctx-core/auth0-ui",
|
|
3
|
-
"version": "12.2.
|
|
3
|
+
"version": "12.2.229",
|
|
4
4
|
"description": "ctx-core auth0 ui component & express endpoints",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ctx-core",
|
|
@@ -24,16 +24,16 @@
|
|
|
24
24
|
"./package.json": "./package.json"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@ctx-core/auth0": "^35.0
|
|
28
|
-
"@ctx-core/auth0-management": "^9.0
|
|
27
|
+
"@ctx-core/auth0": "^35.1.0",
|
|
28
|
+
"@ctx-core/auth0-management": "^9.1.0",
|
|
29
29
|
"@ctx-core/dialog": "^20.1.35",
|
|
30
30
|
"@ctx-core/dialog-ui-svelte": "^1.0.46",
|
|
31
31
|
"@ctx-core/dom": "^11.2.33",
|
|
32
|
-
"@ctx-core/error": "^11.
|
|
33
|
-
"@ctx-core/fetch-undici": "^2.3.
|
|
32
|
+
"@ctx-core/error": "^11.6.0",
|
|
33
|
+
"@ctx-core/fetch-undici": "^2.3.72",
|
|
34
34
|
"@ctx-core/function": "^21.6.1",
|
|
35
35
|
"@ctx-core/http": "^9.1.2",
|
|
36
|
-
"@ctx-core/jwt": "^10.
|
|
36
|
+
"@ctx-core/jwt": "^10.2.0",
|
|
37
37
|
"@ctx-core/logger": "^9.0.49",
|
|
38
38
|
"@ctx-core/object": "^24.1.4",
|
|
39
39
|
"@ctx-core/svelte": "^13.4.24",
|
package/src/ui/Auth0.svelte
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { setContext } from 'svelte'
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
auth0__forgot_password__opened__, auth0__opened__class__, auth0__login__opened__, auth0__signup__opened__,
|
|
5
|
+
auth0__forgot_password__check_email__opened__, auth0__change_password__opened__
|
|
6
6
|
} from '@ctx-core/auth0'
|
|
7
7
|
import { ctx_ } from '@ctx-core/object'
|
|
8
8
|
import { auth0_ui_ctx_key } from '../auth0_ui_ctx_key.js'
|
|
@@ -15,12 +15,12 @@ import Auth0_Login_Form from './Auth0_Login_Form.svelte'
|
|
|
15
15
|
import Auth0_Signup_Form from './Auth0_Signup_Form.svelte'
|
|
16
16
|
export let ctx = ctx_(), dialog = false
|
|
17
17
|
setContext(auth0_ui_ctx_key, ctx)
|
|
18
|
-
const auth0_change_password_opened_ =
|
|
19
|
-
const auth0_opened_class_ =
|
|
20
|
-
const auth0_forgot_password_check_email_opened_ =
|
|
21
|
-
const auth0_forgot_password_opened_ =
|
|
22
|
-
const auth0_login_opened_ =
|
|
23
|
-
const auth0_signup_opened_ =
|
|
18
|
+
const auth0_change_password_opened_ = auth0__change_password__opened__(ctx)
|
|
19
|
+
const auth0_opened_class_ = auth0__opened__class__(ctx)
|
|
20
|
+
const auth0_forgot_password_check_email_opened_ = auth0__forgot_password__check_email__opened__(ctx)
|
|
21
|
+
const auth0_forgot_password_opened_ = auth0__forgot_password__opened__(ctx)
|
|
22
|
+
const auth0_login_opened_ = auth0__login__opened__(ctx)
|
|
23
|
+
const auth0_signup_opened_ = auth0__signup__opened__(ctx)
|
|
24
24
|
const _ = new Auth0_c(ctx)
|
|
25
25
|
</script>
|
|
26
26
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { createEventDispatcher } from 'svelte'
|
|
3
|
-
import { AUTH0_DOMAIN__,
|
|
3
|
+
import { AUTH0_DOMAIN__, auth0__token__error__ } from '@ctx-core/auth0'
|
|
4
4
|
import { getContext_auth0_ui_ctx } from '../getContext_auth0_ui_ctx.js'
|
|
5
5
|
import { Auth0_c } from './Auth0_c.js'
|
|
6
6
|
import Auth0_Dialog_Close from './Auth0_Dialog_Close.svelte'
|
|
@@ -8,7 +8,7 @@ const ctx = getContext_auth0_ui_ctx()
|
|
|
8
8
|
const dispatch = createEventDispatcher()
|
|
9
9
|
export let error_class = '', input_class = '', button_class = '', label_class = '.js'
|
|
10
10
|
const AUTH0_DOMAIN_ = AUTH0_DOMAIN__(ctx)
|
|
11
|
-
const auth0_token_error_ =
|
|
11
|
+
const auth0_token_error_ = auth0__token__error__(ctx)
|
|
12
12
|
const _ = new Auth0_c(ctx)
|
|
13
13
|
let root:HTMLDivElement
|
|
14
14
|
let password_input:HTMLInputElement
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { AUTH0_DOMAIN__,
|
|
2
|
+
import { AUTH0_DOMAIN__, auth0__token__error__, auth0__login__open, auth0__signup__open } from '@ctx-core/auth0'
|
|
3
3
|
import { getContext_auth0_ui_ctx } from '../getContext_auth0_ui_ctx.js'
|
|
4
4
|
import { Auth0_c } from './Auth0_c.js'
|
|
5
5
|
import Auth0_Dialog_Close from './Auth0_Dialog_Close.svelte'
|
|
6
6
|
export let error_class = '', input_class = '', button_class = '', label_class = '.js'
|
|
7
7
|
const ctx = getContext_auth0_ui_ctx()
|
|
8
8
|
const AUTH0_DOMAIN_ = AUTH0_DOMAIN__(ctx)
|
|
9
|
-
const auth0_token_error_ =
|
|
9
|
+
const auth0_token_error_ = auth0__token__error__(ctx)
|
|
10
10
|
const _ = new Auth0_c(ctx)
|
|
11
11
|
let email_input:HTMLInputElement, error:typeof $auth0_token_error_?.error
|
|
12
12
|
$: error = $auth0_token_error_?.error
|
|
@@ -50,11 +50,11 @@ $: error = $auth0_token_error_?.error
|
|
|
50
50
|
/>
|
|
51
51
|
<label
|
|
52
52
|
class="auth_navigation {label_class}"
|
|
53
|
-
on:click={()=>
|
|
53
|
+
on:click={()=>auth0__login__open(ctx)}
|
|
54
54
|
>Have an account? Log in…</label>
|
|
55
55
|
<label
|
|
56
56
|
class="auth_navigation {label_class}"
|
|
57
|
-
on:click={()=>
|
|
57
|
+
on:click={()=>auth0__signup__open(ctx)}
|
|
58
58
|
>Don't have an account? Signup…</label>
|
|
59
59
|
</footer>
|
|
60
60
|
</form>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import {
|
|
3
|
-
AUTH0_DOMAIN__,
|
|
3
|
+
AUTH0_DOMAIN__, auth0__token__error__, auth0__token__error_txt__, auth0__forgot_password__open, auth0__signup__open
|
|
4
4
|
} from '@ctx-core/auth0'
|
|
5
5
|
import { type Ctx } from '@ctx-core/object'
|
|
6
6
|
import { Auth0_c } from './Auth0_c.js'
|
|
7
7
|
import Auth0_Dialog_Close from './Auth0_Dialog_Close.svelte'
|
|
8
8
|
export let ctx:Ctx, error_class = '', input_class = '', button_class = '', label_class = '.js'
|
|
9
|
-
const auth0_token_error_ =
|
|
10
|
-
const auth0_token_error_txt_ =
|
|
9
|
+
const auth0_token_error_ = auth0__token__error__(ctx)
|
|
10
|
+
const auth0_token_error_txt_ = auth0__token__error_txt__(ctx)
|
|
11
11
|
const AUTH0_DOMAIN = AUTH0_DOMAIN__(ctx)
|
|
12
12
|
const _ = new Auth0_c(ctx)
|
|
13
13
|
let root:HTMLDivElement
|
|
@@ -72,11 +72,11 @@ $: error_password = $auth0_token_error_?.password //endregion
|
|
|
72
72
|
/>
|
|
73
73
|
<label
|
|
74
74
|
class="auth_navigation {label_class}"
|
|
75
|
-
on:click={()=>
|
|
75
|
+
on:click={()=>auth0__signup__open(ctx)}
|
|
76
76
|
>Don't have an account? Signup…</label>
|
|
77
77
|
<label
|
|
78
78
|
class="auth_navigation {label_class}"
|
|
79
|
-
on:click={()=>
|
|
79
|
+
on:click={()=>auth0__forgot_password__open(ctx)}
|
|
80
80
|
>Forgot Password?</label>
|
|
81
81
|
</footer>
|
|
82
82
|
</form>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import {
|
|
3
|
-
AUTH0_DOMAIN__,
|
|
3
|
+
AUTH0_DOMAIN__, auth0__token__error__, auth0__forgot_password__open, auth0__login__open,
|
|
4
4
|
} from '@ctx-core/auth0'
|
|
5
5
|
import { getContext_auth0_ui_ctx } from '../getContext_auth0_ui_ctx.js'
|
|
6
6
|
import { Auth0_c } from './Auth0_c.js'
|
|
@@ -8,7 +8,7 @@ import Auth0_Dialog_Close from './Auth0_Dialog_Close.svelte'
|
|
|
8
8
|
export let error_class = '', input_class = '', button_class = '', label_class = '.js'
|
|
9
9
|
const ctx = getContext_auth0_ui_ctx()
|
|
10
10
|
const AUTH0_DOMAIN_ = AUTH0_DOMAIN__(ctx)
|
|
11
|
-
const auth0_token_error_ =
|
|
11
|
+
const auth0_token_error_ = auth0__token__error__(ctx)
|
|
12
12
|
const _ = new Auth0_c(ctx)
|
|
13
13
|
let root, signup_email_input, signup_password_input, signup_password_confirmation_input
|
|
14
14
|
let error_username:string|undefined //region
|
|
@@ -106,11 +106,11 @@ $: {
|
|
|
106
106
|
/>
|
|
107
107
|
<label
|
|
108
108
|
class="auth_navigation {label_class}"
|
|
109
|
-
on:click={()=>
|
|
109
|
+
on:click={()=>auth0__login__open(ctx)}
|
|
110
110
|
>Have an account? Log in…</label>
|
|
111
111
|
<label
|
|
112
112
|
class="auth_navigation {label_class}"
|
|
113
|
-
on:click={()=>
|
|
113
|
+
on:click={()=>auth0__forgot_password__open(ctx)}
|
|
114
114
|
>Forgot Password?</label>
|
|
115
115
|
</footer>
|
|
116
116
|
</form>
|
package/src/ui/Auth0_c.ts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
auth0__client_id__body_T,
|
|
3
|
+
auth0__grant_type__body_T,
|
|
4
|
+
auth0__login_data_T,
|
|
5
|
+
password_realm__body_T,
|
|
6
|
+
auth0__oauth_token__fetch__body_T,
|
|
7
|
+
auth0__passwordless_start__fetch__body_T,
|
|
8
|
+
auth0__passwordless_start__fetch__optional_body_T,
|
|
9
|
+
auth0__signup_data_T
|
|
10
10
|
} from '@ctx-core/auth0'
|
|
11
11
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
12
|
+
auth0__body_,
|
|
13
|
+
auth0__opened__class__,
|
|
14
|
+
auth0__token__error__,
|
|
15
|
+
auth0__token__json__,
|
|
16
|
+
auth0__token__error__clear,
|
|
17
|
+
auth0__close,
|
|
18
|
+
auth0__token__error__logout,
|
|
19
|
+
auth0__forgot_password__check_email__open,
|
|
20
|
+
auth0__login__open,
|
|
21
|
+
password_realm__body_,
|
|
22
|
+
auth0__change_password__fetch,
|
|
23
|
+
auth0__dbconnections_signup__fetch_get,
|
|
24
|
+
auth0__oauth_token__fetch_get,
|
|
25
|
+
auth0__passwordless_start__fetch_get,
|
|
26
|
+
auth0__change_password__validate,
|
|
27
|
+
auth0__forgot_password__validate,
|
|
28
|
+
auth0__signup__validate
|
|
29
29
|
} from '@ctx-core/auth0'
|
|
30
30
|
import { dom_a_, has_dom } from '@ctx-core/dom'
|
|
31
31
|
import { noop } from '@ctx-core/function'
|
|
@@ -35,22 +35,22 @@ import { onDestroy } from 'svelte'
|
|
|
35
35
|
export class Auth0_c {
|
|
36
36
|
constructor(protected ctx:Ctx) {}
|
|
37
37
|
readonly login_auth0_body_ = (data:any)=>
|
|
38
|
-
|
|
38
|
+
auth0__body_<login_data_password_realm_body_I>(
|
|
39
39
|
this.ctx, data
|
|
40
40
|
)
|
|
41
41
|
readonly login_password_realm_body_ = (data:any)=>
|
|
42
|
-
|
|
42
|
+
password_realm__body_<login_data_password_realm_body_I>(
|
|
43
43
|
this.ctx,
|
|
44
44
|
this.login_auth0_body_(data)
|
|
45
45
|
)
|
|
46
46
|
readonly signup_auth0_body_ = (data:any)=>
|
|
47
|
-
|
|
47
|
+
auth0__body_<signup_data_password_realm_body_I>(this.ctx, data) as signup_data_password_realm_body_I
|
|
48
48
|
readonly signup_password_realm_body_ = (data:any)=>
|
|
49
|
-
|
|
50
|
-
readonly auth0_opened_class =
|
|
51
|
-
readonly auth0_token_json_ =
|
|
52
|
-
readonly auth0_token_error_ =
|
|
53
|
-
readonly
|
|
49
|
+
password_realm__body_<signup_data_password_realm_body_I>(this.ctx, this.signup_auth0_body_(data))
|
|
50
|
+
readonly auth0_opened_class = auth0__opened__class__(this.ctx)
|
|
51
|
+
readonly auth0_token_json_ = auth0__token__json__(this.ctx)
|
|
52
|
+
readonly auth0_token_error_ = auth0__token__error__(this.ctx)
|
|
53
|
+
readonly auth0__close = ()=>auth0__close(this.ctx)
|
|
54
54
|
readonly onMount = async (root:HTMLElement)=>{
|
|
55
55
|
if (has_dom) {
|
|
56
56
|
const unsubscribe =
|
|
@@ -58,23 +58,23 @@ export class Auth0_c {
|
|
|
58
58
|
onDestroy(unsubscribe)
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
readonly login = async (data:
|
|
62
|
-
const [auth0_token, response] = await
|
|
61
|
+
readonly login = async (data:auth0__login_data_T, schedule_forms_clear = ()=>{})=>{
|
|
62
|
+
const [auth0_token, response] = await auth0__oauth_token__fetch_get(
|
|
63
63
|
this.ctx, this.login_password_realm_body_(data)
|
|
64
64
|
)
|
|
65
65
|
if (response.ok) {
|
|
66
66
|
const auth0_token_json = JSON.stringify(auth0_token)
|
|
67
67
|
this.auth0_token_json_.$ = auth0_token_json
|
|
68
68
|
schedule_forms_clear()
|
|
69
|
-
this.
|
|
69
|
+
this.auth0__close()
|
|
70
70
|
} else {
|
|
71
71
|
const auth_token_error = auth0_token as Auth0Error
|
|
72
72
|
this.auth0_token_error_.$ = auth_token_error
|
|
73
|
-
|
|
73
|
+
auth0__token__error__logout(this.ctx, auth_token_error)
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
readonly signup = async (data:
|
|
77
|
-
const [auth0_userinfo] = await
|
|
76
|
+
readonly signup = async (data:auth0__signup_data_T, schedule_forms_clear = ()=>{})=>{
|
|
77
|
+
const [auth0_userinfo] = await auth0__dbconnections_signup__fetch_get(
|
|
78
78
|
this.ctx,
|
|
79
79
|
this.signup_password_realm_body_(data))
|
|
80
80
|
const auth0_userinfo_Auth0Error = auth0_userinfo as Auth0Error
|
|
@@ -89,7 +89,7 @@ export class Auth0_c {
|
|
|
89
89
|
? 'This Email is already signed up'
|
|
90
90
|
: description || ''
|
|
91
91
|
const auth0_token_error = { email }
|
|
92
|
-
|
|
92
|
+
auth0__token__error__logout(this.ctx, auth0_token_error)
|
|
93
93
|
return
|
|
94
94
|
}
|
|
95
95
|
schedule_forms_clear()
|
|
@@ -102,12 +102,12 @@ export class Auth0_c {
|
|
|
102
102
|
const { password } = form
|
|
103
103
|
let error
|
|
104
104
|
try {
|
|
105
|
-
const [response_json, response] = await
|
|
105
|
+
const [response_json, response] = await auth0__change_password__fetch(this.ctx, password)
|
|
106
106
|
if (!response.ok) {
|
|
107
107
|
if (response.status == 401) {
|
|
108
|
-
|
|
108
|
+
auth0__login__open(this.ctx)
|
|
109
109
|
const auth0_token_error = { username: 'Authentication Error - Log in' }
|
|
110
|
-
|
|
110
|
+
auth0__token__error__logout(this.ctx, auth0_token_error)
|
|
111
111
|
return
|
|
112
112
|
}
|
|
113
113
|
error = response_json.error || 'Error changing Password'
|
|
@@ -118,18 +118,18 @@ export class Auth0_c {
|
|
|
118
118
|
}
|
|
119
119
|
if (error) {
|
|
120
120
|
const auth0_token_error = { password: error }
|
|
121
|
-
|
|
121
|
+
auth0__token__error__logout(this.ctx, auth0_token_error)
|
|
122
122
|
return
|
|
123
123
|
}
|
|
124
124
|
schedule_forms_clear()
|
|
125
|
-
this.
|
|
125
|
+
this.auth0__close()
|
|
126
126
|
}
|
|
127
127
|
readonly schedule_forms_clear_:(root:HTMLElement)=>void = (root:HTMLElement)=>{
|
|
128
128
|
return ()=>this.schedule_forms_clear(root)
|
|
129
129
|
}
|
|
130
130
|
readonly schedule_forms_clear = (root:HTMLElement)=>{
|
|
131
131
|
setTimeout(()=>{
|
|
132
|
-
|
|
132
|
+
auth0__token__error__clear(this.ctx)
|
|
133
133
|
clear_inputs(dom_a_('input[type=text]', root))
|
|
134
134
|
clear_inputs(dom_a_('input[type=password]', root))
|
|
135
135
|
}, 100)
|
|
@@ -145,13 +145,13 @@ export class Auth0_c {
|
|
|
145
145
|
const password = password_input.value
|
|
146
146
|
const password_confirmation = password_confirmation_input.value
|
|
147
147
|
const auth0_token_error =
|
|
148
|
-
|
|
148
|
+
auth0__signup__validate({
|
|
149
149
|
email,
|
|
150
150
|
password,
|
|
151
151
|
password_confirmation
|
|
152
152
|
})
|
|
153
153
|
if (auth0_token_error) {
|
|
154
|
-
|
|
154
|
+
auth0__token__error__logout(this.ctx, auth0_token_error)
|
|
155
155
|
return false
|
|
156
156
|
}
|
|
157
157
|
await this.signup({
|
|
@@ -171,20 +171,20 @@ export class Auth0_c {
|
|
|
171
171
|
event.preventDefault()
|
|
172
172
|
const { email_input } = ctx
|
|
173
173
|
const email = email_input.value
|
|
174
|
-
const data:
|
|
174
|
+
const data:auth0__passwordless_start__fetch__optional_body_T = {
|
|
175
175
|
connection: 'email',
|
|
176
176
|
send: 'link',
|
|
177
177
|
email
|
|
178
178
|
}
|
|
179
|
-
const auth0_token_error =
|
|
179
|
+
const auth0_token_error = auth0__forgot_password__validate(data)
|
|
180
180
|
if (auth0_token_error) {
|
|
181
|
-
|
|
181
|
+
auth0__token__error__logout(this.ctx, auth0_token_error)
|
|
182
182
|
return
|
|
183
183
|
}
|
|
184
|
-
await
|
|
185
|
-
this.ctx, this.login_auth0_body_(data) as
|
|
184
|
+
await auth0__passwordless_start__fetch_get(
|
|
185
|
+
this.ctx, this.login_auth0_body_(data) as auth0__passwordless_start__fetch__body_T
|
|
186
186
|
)
|
|
187
|
-
|
|
187
|
+
auth0__forgot_password__check_email__open(this.ctx)
|
|
188
188
|
}
|
|
189
189
|
readonly onsubmit_change_password = async (
|
|
190
190
|
event:Event, ctx:onsubmit_change_password_Ctx, schedule_forms_clear = noop
|
|
@@ -197,20 +197,20 @@ export class Auth0_c {
|
|
|
197
197
|
const password = password_input.value
|
|
198
198
|
const password_confirmation = password_confirmation_input.value
|
|
199
199
|
const auth0_token_error =
|
|
200
|
-
|
|
200
|
+
auth0__change_password__validate(
|
|
201
201
|
{
|
|
202
202
|
password,
|
|
203
203
|
password_confirmation
|
|
204
204
|
})
|
|
205
205
|
if (auth0_token_error) {
|
|
206
|
-
|
|
206
|
+
auth0__token__error__logout(this.ctx, auth0_token_error)
|
|
207
207
|
throw auth0_token_error
|
|
208
208
|
}
|
|
209
209
|
return await this.change_password({ password }, schedule_forms_clear)
|
|
210
210
|
}
|
|
211
211
|
readonly onclose = async (event:MouseEvent)=>{
|
|
212
212
|
event.preventDefault()
|
|
213
|
-
this.
|
|
213
|
+
this.auth0__close()
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
function clear_inputs(inputs:NodeList) {
|
|
@@ -220,19 +220,19 @@ function clear_inputs(inputs:NodeList) {
|
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
export interface signup_data_password_realm_body_I
|
|
223
|
-
extends
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
223
|
+
extends auth0__signup_data_T,
|
|
224
|
+
auth0__client_id__body_T,
|
|
225
|
+
auth0__passwordless_start__fetch__body_T,
|
|
226
|
+
password_realm__body_T,
|
|
227
|
+
auth0__grant_type__body_T,
|
|
228
|
+
auth0__oauth_token__fetch__body_T {}
|
|
229
229
|
export interface login_data_password_realm_body_I
|
|
230
|
-
extends
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
230
|
+
extends auth0__login_data_T,
|
|
231
|
+
auth0__client_id__body_T,
|
|
232
|
+
auth0__passwordless_start__fetch__body_T,
|
|
233
|
+
password_realm__body_T,
|
|
234
|
+
auth0__grant_type__body_T,
|
|
235
|
+
auth0__oauth_token__fetch__body_T {}
|
|
236
236
|
export interface onsubmit_change_password_Ctx {
|
|
237
237
|
password_input:HTMLInputElement
|
|
238
238
|
password_confirmation_input:HTMLInputElement
|