@verdocs/web-sdk 4.2.12 → 4.2.24
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/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/verdocs-auth.cjs.entry.js +69 -90
- package/dist/cjs/verdocs-web-sdk.cjs.js +1 -1
- package/dist/collection/components/embeds/verdocs-auth/verdocs-auth.css +16 -1
- package/dist/collection/components/embeds/verdocs-auth/verdocs-auth.js +72 -95
- package/dist/components/verdocs-auth.js +73 -96
- package/dist/esm/loader.js +1 -1
- package/dist/esm/verdocs-auth.entry.js +70 -91
- package/dist/esm/verdocs-web-sdk.js +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/verdocs-auth.entry.js +1 -1
- package/dist/esm-es5/verdocs-web-sdk.js +1 -1
- package/dist/types/components/embeds/verdocs-auth/verdocs-auth.d.ts +8 -11
- package/dist/verdocs-web-sdk/p-12c81053.entry.js +1 -0
- package/dist/verdocs-web-sdk/p-322fa613.system.js +1 -1
- package/dist/verdocs-web-sdk/p-9a14fe42.system.entry.js +1 -0
- package/dist/verdocs-web-sdk/verdocs-web-sdk.esm.js +1 -1
- package/package.json +2 -2
- package/dist/custom-elements.json +0 -2086
- package/dist/verdocs-web-sdk/p-18363901.entry.js +0 -1
- package/dist/verdocs-web-sdk/p-f0299a13.system.entry.js +0 -1
@@ -1,8 +1,7 @@
|
|
1
|
-
import { VerdocsEndpoint, createProfile, authenticate,
|
1
|
+
import { VerdocsEndpoint, createProfile, authenticate, resendVerification, resetPassword, verifyEmail, getMyUser } from "@verdocs/js-sdk";
|
2
2
|
import { h } from "@stencil/core";
|
3
3
|
import { VerdocsToast } from "../../../utils/Toast";
|
4
4
|
import { SDKError } from "../../../utils/errors";
|
5
|
-
const RECHECK_INTERVAL = 5000;
|
6
5
|
/**
|
7
6
|
* Display an authentication dialog that allows the user to login or sign up. If the user is already authenticated
|
8
7
|
* with a valid session, this component will hide itself and fire the success callback immediately. It is up to the
|
@@ -20,9 +19,11 @@ const RECHECK_INTERVAL = 5000;
|
|
20
19
|
*/
|
21
20
|
export class VerdocsAuth {
|
22
21
|
constructor() {
|
23
|
-
this.recheckTimer = null;
|
24
22
|
this.resendDisabledTimer = null;
|
25
|
-
|
23
|
+
// We can't instantly log in on the default endpoint because other listeners might see
|
24
|
+
// its events and incorrectly trigger before we're done. So we manage our own temp
|
25
|
+
// endpoint and pass the final tokens to the default once we're ready.
|
26
|
+
this.tempAuthEndpoint = new VerdocsEndpoint();
|
26
27
|
this.endpoint = VerdocsEndpoint.getDefault();
|
27
28
|
this.visible = true;
|
28
29
|
this.logo = 'https://app.verdocs.com/assets/blue-logo.svg';
|
@@ -31,14 +32,12 @@ export class VerdocsAuth {
|
|
31
32
|
this.org_name = '';
|
32
33
|
this.first_name = '';
|
33
34
|
this.last_name = '';
|
34
|
-
this.
|
35
|
+
this.email = '';
|
36
|
+
this.verificationCode = '';
|
35
37
|
this.password = '';
|
36
38
|
this.submitting = false;
|
37
39
|
this.activeSession = null;
|
38
|
-
this.accountType = 'org';
|
39
|
-
this.signupStep = 1;
|
40
40
|
this.resendDisabled = false;
|
41
|
-
this.checkingOrg = false;
|
42
41
|
}
|
43
42
|
componentWillLoad() {
|
44
43
|
var _a, _b;
|
@@ -54,29 +53,6 @@ export class VerdocsAuth {
|
|
54
53
|
(_b = this.authenticated) === null || _b === void 0 ? void 0 : _b.emit({ authenticated: false, session: null });
|
55
54
|
}
|
56
55
|
}
|
57
|
-
disconnectedCallback() {
|
58
|
-
this.cancelRecheckTimer();
|
59
|
-
}
|
60
|
-
cancelRecheckTimer() {
|
61
|
-
if (this.recheckTimer) {
|
62
|
-
try {
|
63
|
-
clearTimeout(this.recheckTimer);
|
64
|
-
}
|
65
|
-
catch (e) {
|
66
|
-
// NOP
|
67
|
-
}
|
68
|
-
this.recheckTimer = null;
|
69
|
-
}
|
70
|
-
if (this.resendDisabledTimer) {
|
71
|
-
try {
|
72
|
-
clearTimeout(this.resendDisabledTimer);
|
73
|
-
}
|
74
|
-
catch (e) {
|
75
|
-
// NOP
|
76
|
-
}
|
77
|
-
this.resendDisabledTimer = null;
|
78
|
-
}
|
79
|
-
}
|
80
56
|
isPasswordComplex(password) {
|
81
57
|
const isUppercase = (ch) => /[A-Z]/.test(ch);
|
82
58
|
const isLowercase = (ch) => /[a-z]/.test(ch);
|
@@ -95,13 +71,13 @@ export class VerdocsAuth {
|
|
95
71
|
}
|
96
72
|
handleSignup() {
|
97
73
|
this.submitting = true;
|
98
|
-
this.
|
74
|
+
this.tempAuthEndpoint.clearSession();
|
99
75
|
if (!this.isPasswordComplex(this.password)) {
|
100
76
|
window.alert('Password must be at least 8 characters long and contain at least one uppercase, one lowercase, and one special character.');
|
101
77
|
return;
|
102
78
|
}
|
103
|
-
createProfile(this.
|
104
|
-
email: this.
|
79
|
+
createProfile(this.tempAuthEndpoint, {
|
80
|
+
email: this.email,
|
105
81
|
password: this.password,
|
106
82
|
first_name: this.first_name,
|
107
83
|
last_name: this.last_name,
|
@@ -109,7 +85,8 @@ export class VerdocsAuth {
|
|
109
85
|
})
|
110
86
|
.then(r => {
|
111
87
|
console.log('Profile creation result', r);
|
112
|
-
this.
|
88
|
+
this.tempAuthEndpoint.setToken(r.access_token);
|
89
|
+
this.displayMode = 'verify';
|
113
90
|
})
|
114
91
|
.catch(e => {
|
115
92
|
var _a, _b, _c, _d, _e, _f;
|
@@ -121,49 +98,55 @@ export class VerdocsAuth {
|
|
121
98
|
VerdocsToast('Signup failed: ' + ((_f = (_e = e.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.message) || 'Unknown Error', { style: 'error' });
|
122
99
|
});
|
123
100
|
}
|
124
|
-
|
101
|
+
async handleVerification() {
|
125
102
|
this.submitting = true;
|
126
|
-
|
127
|
-
authenticate(this.endpoint, { username: this.username, password: this.password, grant_type: 'password' })
|
128
|
-
.then(r => {
|
129
|
-
var _a;
|
130
|
-
this.cancelRecheckTimer();
|
103
|
+
try {
|
131
104
|
this.submitting = false;
|
132
|
-
const
|
133
|
-
console.log('
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
105
|
+
const verificationResult = await verifyEmail(this.endpoint, { email: this.email, token: this.verificationCode });
|
106
|
+
console.log('Verification result', verificationResult);
|
107
|
+
this.completeLogin(verificationResult);
|
108
|
+
}
|
109
|
+
catch (e) {
|
110
|
+
this.submitting = false;
|
111
|
+
console.log('Verification error', e);
|
112
|
+
VerdocsToast('Verification error, please check the code and try again.');
|
113
|
+
}
|
114
|
+
}
|
115
|
+
completeLogin(result) {
|
116
|
+
var _a;
|
117
|
+
this.endpoint.setToken(result.access_token);
|
118
|
+
this.activeSession = this.endpoint.session;
|
119
|
+
this.isAuthenticated = true;
|
120
|
+
(_a = this.authenticated) === null || _a === void 0 ? void 0 : _a.emit({ authenticated: true, session: this.endpoint.session });
|
121
|
+
}
|
122
|
+
async loginAndCheckVerification() {
|
123
|
+
this.submitting = true;
|
124
|
+
this.tempAuthEndpoint.clearSession();
|
125
|
+
try {
|
126
|
+
this.submitting = false;
|
127
|
+
const authResult = await authenticate(this.endpoint, { username: this.email, password: this.password, grant_type: 'password' });
|
128
|
+
console.log('[AUTH] Authenticated', authResult.access_token);
|
129
|
+
this.tempAuthEndpoint.setToken(authResult.access_token);
|
130
|
+
const user = await getMyUser(this.tempAuthEndpoint);
|
131
|
+
console.log('Got user', user);
|
132
|
+
if (!user.email_verified) {
|
144
133
|
console.log('[AUTH] Logged in, pending email address verification');
|
145
134
|
this.displayMode = 'verify';
|
146
|
-
this.accessTokenForVerification = r.access_token;
|
147
|
-
this.recheckTimer = setTimeout(this.loginAndCheckVerification, RECHECK_INTERVAL);
|
148
135
|
}
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
136
|
+
else {
|
137
|
+
console.log('[AUTH] Email address is verified, completing login');
|
138
|
+
this.completeLogin(authResult);
|
139
|
+
}
|
140
|
+
}
|
141
|
+
catch (e) {
|
155
142
|
this.submitting = false;
|
156
|
-
|
157
|
-
(_a = this.authenticated) === null || _a === void 0 ? void 0 : _a.emit({ authenticated: false, session: null });
|
158
|
-
(_b = this.sdkError) === null || _b === void 0 ? void 0 : _b.emit(new SDKError(e.message, (_c = e.response) === null || _c === void 0 ? void 0 : _c.status, (_d = e.response) === null || _d === void 0 ? void 0 : _d.data));
|
159
|
-
VerdocsToast('Login failed. Please check your username and password and try again.', { style: 'error' });
|
160
|
-
});
|
143
|
+
}
|
161
144
|
}
|
162
145
|
handleLogout() {
|
163
146
|
var _a;
|
164
147
|
this.endpoint.clearSession();
|
148
|
+
this.tempAuthEndpoint.clearSession();
|
165
149
|
this.isAuthenticated = false;
|
166
|
-
this.accessTokenForVerification = null;
|
167
150
|
(_a = this.authenticated) === null || _a === void 0 ? void 0 : _a.emit({ authenticated: false, session: null });
|
168
151
|
}
|
169
152
|
handleResend() {
|
@@ -174,7 +157,7 @@ export class VerdocsAuth {
|
|
174
157
|
this.resendDisabled = false;
|
175
158
|
this.resendDisabledTimer = null;
|
176
159
|
}, 30000);
|
177
|
-
resendVerification(this.
|
160
|
+
resendVerification(this.tempAuthEndpoint)
|
178
161
|
.then(r => {
|
179
162
|
console.log('[AUTH] Verification request resent', r);
|
180
163
|
VerdocsToast('Please check your email for a message with verification instructions.', { style: 'info' });
|
@@ -183,19 +166,20 @@ export class VerdocsAuth {
|
|
183
166
|
console.log('[AUTH] Unable to resend verification', e);
|
184
167
|
});
|
185
168
|
}
|
186
|
-
handleReset() {
|
169
|
+
async handleReset() {
|
187
170
|
this.submitting = true;
|
188
|
-
|
189
|
-
.
|
190
|
-
console.log('[AUTH] Reset sent',
|
171
|
+
try {
|
172
|
+
const result = await resetPassword(this.endpoint, { email: this.email });
|
173
|
+
console.log('[AUTH] Reset sent', result);
|
191
174
|
this.submitting = false;
|
192
175
|
this.displayMode = 'login';
|
193
176
|
VerdocsToast('If your email address is registered, you will receive instructions on resetting your password shortly.', { style: 'info' });
|
194
|
-
}
|
195
|
-
|
177
|
+
}
|
178
|
+
catch (e) {
|
196
179
|
console.log('[AUTH] Unable to reset password', e);
|
197
180
|
this.submitting = false;
|
198
|
-
|
181
|
+
VerdocsToast('Unable to reset password. Please check your email address and try again.', { style: 'error' });
|
182
|
+
}
|
199
183
|
}
|
200
184
|
render() {
|
201
185
|
if (!this.visible) {
|
@@ -205,26 +189,21 @@ export class VerdocsAuth {
|
|
205
189
|
return (h("verdocs-button", { label: "Sign Out", disabled: this.submitting, onClick: () => this.handleLogout(), style: { display: 'flex', justifyContent: 'center', margin: '30px auto 0' } }));
|
206
190
|
}
|
207
191
|
if (this.displayMode === 'signup') {
|
208
|
-
const
|
209
|
-
return (h("div", { class: "form" }, h("a", { href: "https://verdocs.com/en/" }, h("img", { src: this.logo, alt: "Verdocs Logo", class: "logo" })), h("h3", null, "Sign up for a free account"), h("
|
210
|
-
this.signupStep = 2;
|
211
|
-
}, style: { display: 'flex', justifyContent: 'center', margin: '30px auto 0' } }), h("verdocs-button", { label: "Go to Dashboard", disabled: true, onClick: () => this.handleSignup(), style: { display: 'flex', justifyContent: 'center', margin: '30px auto 0' } }))))));
|
212
|
-
}
|
213
|
-
if (this.displayMode === 'forgot') {
|
214
|
-
return (h("div", { class: "form" }, h("a", { href: "https://verdocs.com/en/" }, h("img", { src: this.logo, alt: "Verdocs Logo", class: "logo" })), h("h3", null, "Forgot your password?"), h("p", null, "Enter your e-mail address below, and reset instructions will be sent to your Inbox."), h("p", null, h("em", null, "Please allow up to 24 hours for delivery, and check your spam folder if you do not receive the message. ")), h("form", { onSubmit: () => this.handleSignup() }, h("verdocs-text-input", { label: "Email", autocomplete: "email", required: true, value: this.username, onInput: (e) => (this.username = e.target.value), disabled: this.submitting }), h("div", { style: { marginTop: '30px' } }), h("div", { class: "buttons" }, h("verdocs-button", { label: "Cancel", variant: "outline", disabled: this.submitting, onClick: () => (this.displayMode = 'login') }), h("verdocs-button", { label: "Reset", disabled: this.submitting, onClick: () => this.handleReset() })))));
|
192
|
+
const invalid = this.submitting || !this.first_name || !this.last_name || !this.email || !this.password || !this.org_name;
|
193
|
+
return (h("div", { class: "form" }, h("a", { href: "https://verdocs.com/en/" }, h("img", { src: this.logo, alt: "Verdocs Logo", class: "logo" })), h("h3", null, "Sign up for a free account"), h("h5", null, "Already have an account?", h("verdocs-button", { label: "Log In", variant: "text", onClick: () => (this.displayMode = 'login'), disabled: this.submitting })), h("form", { onSubmit: () => this.handleSignup() }, h("div", { style: { display: 'flex', flexDirection: 'row', columnGap: '20px' } }, h("verdocs-text-input", { label: "First Name", autocomplete: "first", required: true, value: this.first_name, onInput: (e) => (this.first_name = e.target.value), disabled: this.submitting }), h("verdocs-text-input", { label: "Last Name", autocomplete: "last", required: true, value: this.last_name, onInput: (e) => (this.last_name = e.target.value), disabled: this.submitting })), h("verdocs-text-input", { label: "Email Address", autocomplete: "email", required: true, value: this.email, onInput: (e) => (this.email = e.target.value), disabled: this.submitting }), h("verdocs-text-input", { label: "Password", type: "password", required: true, autocomplete: "current-password", value: this.password, onInput: (e) => (this.password = e.target.value), disabled: this.submitting }), h("verdocs-text-input", { label: "Organization Name", autocomplete: "org", required: true, value: this.org_name, onInput: (e) => (this.org_name = e.target.value), disabled: this.submitting, style: { flex: '1' } }), h("div", { style: { marginTop: '30px' } }), h("verdocs-button", { label: "Next", disabled: invalid, onClick: () => this.handleSignup(), style: { display: 'flex', justifyContent: 'center', margin: '30px auto 0' } }))));
|
215
194
|
}
|
216
195
|
if (this.displayMode === 'verify') {
|
217
|
-
return (h("
|
218
|
-
this.
|
196
|
+
return (h("form", { onSubmit: () => this.handleSignup() }, h("p", null, "Please check your e-mail inbox for a verification code and follow the instructions provided."), h("p", null, h("em", null, "Verification messages may take up to 1 hour to arrive. If you do not receive the invitation, ", h("a", { href: "#" }, "Click Here"), " to resend it. Be sure to check your spam folder.")), h("verdocs-text-input", { label: "Verification Code", required: true, value: this.verificationCode, onInput: (e) => (this.verificationCode = e.target.value), disabled: this.submitting }), h("div", { style: { display: 'flex', flexDirection: 'row', gap: '20px' } }, h("verdocs-button", { label: "Verify", disabled: this.submitting, onClick: () => this.handleVerification(), style: { display: 'flex', justifyContent: 'center', margin: '10px auto 0' } }), h("verdocs-button", { variant: "outline", label: "Resend Code", disabled: this.resendDisabled, onClick: () => this.handleResend() }), h("verdocs-button", { label: "Sign Out", variant: "text", disabled: this.submitting, onClick: () => {
|
197
|
+
this.tempAuthEndpoint.clearSession();
|
198
|
+
this.email = '';
|
219
199
|
this.password = '';
|
220
|
-
this.cancelRecheckTimer();
|
221
200
|
this.displayMode = 'login';
|
222
|
-
} })
|
201
|
+
} }))));
|
202
|
+
}
|
203
|
+
if (this.displayMode === 'forgot') {
|
204
|
+
return (h("div", { class: "form" }, h("a", { href: "https://verdocs.com/en/" }, h("img", { src: this.logo, alt: "Verdocs Logo", class: "logo" })), h("h3", null, "Forgot your password?"), h("p", null, "Enter your e-mail address below, and reset instructions will be sent to your Inbox. Please allow up to 15 minutes to arrive. Check your spam folder if you do not receive the message."), h("form", { onSubmit: () => this.handleSignup() }, h("verdocs-text-input", { label: "Email Address", autocomplete: "email", required: true, value: this.email, onInput: (e) => (this.email = e.target.value), disabled: this.submitting }), h("div", { style: { marginTop: '30px' } }), h("div", { class: "buttons" }, h("verdocs-button", { label: "Cancel", variant: "outline", disabled: this.submitting, onClick: () => (this.displayMode = 'login') }), h("verdocs-button", { label: "Reset", disabled: this.submitting, onClick: () => this.handleReset() })))));
|
223
205
|
}
|
224
|
-
return (h("div", { class: "form" }, h("a", { href: "https://verdocs.com/en/" }, h("img", { src: this.logo, alt: "Verdocs Logo", class: "logo" })), h("h3", null, "Log in to your account"), h("h4", null, "Don't have an account?", h("verdocs-button", { label: "Sign Up", variant: "text", onClick: () => {
|
225
|
-
this.displayMode = 'signup';
|
226
|
-
this.signupStep = 1;
|
227
|
-
}, disabled: this.submitting })), h("form", { onSubmit: () => this.loginAndCheckVerification() }, h("verdocs-text-input", { label: "Email", autocomplete: "username", value: this.username, onInput: (e) => (this.username = e.target.value), disabled: this.submitting }), h("verdocs-text-input", { label: "Password", type: "password", autocomplete: "current-password", value: this.password, onInput: (e) => (this.password = e.target.value), disabled: this.submitting }), h("verdocs-button", { label: "Forgot Your Password?", variant: "text", onClick: () => (this.displayMode = 'forgot'), disabled: this.submitting, style: { display: 'flex', justifyContent: 'center', margin: '10px auto 20px' } }), h("verdocs-button", { label: "Login", disabled: this.submitting, onClick: () => this.loginAndCheckVerification(), style: { display: 'flex', justifyContent: 'center', margin: '10px auto 0' } }))));
|
206
|
+
return (h("div", { class: "form" }, h("a", { href: "https://verdocs.com/en/" }, h("img", { src: this.logo, alt: "Verdocs Logo", class: "logo" })), h("h3", null, "Log in to your account"), h("h4", null, "Don't have an account?", h("verdocs-button", { label: "Sign Up", variant: "text", onClick: () => (this.displayMode = 'signup'), disabled: this.submitting })), h("form", { onSubmit: () => this.loginAndCheckVerification() }, h("verdocs-text-input", { label: "Email", autocomplete: "username", value: this.email, onInput: (e) => (this.email = e.target.value), disabled: this.submitting }), h("verdocs-text-input", { label: "Password", type: "password", autocomplete: "current-password", value: this.password, onInput: (e) => (this.password = e.target.value), disabled: this.submitting }), h("verdocs-button", { label: "Forgot Your Password?", variant: "text", onClick: () => (this.displayMode = 'forgot'), disabled: this.submitting, style: { display: 'flex', justifyContent: 'center', margin: '10px auto 20px' } }), h("verdocs-button", { label: "Login", disabled: this.submitting, onClick: () => this.loginAndCheckVerification(), style: { display: 'flex', justifyContent: 'center', margin: '10px auto 0' } }))));
|
228
207
|
}
|
229
208
|
static get is() { return "verdocs-auth"; }
|
230
209
|
static get originalStyleUrls() {
|
@@ -306,14 +285,12 @@ export class VerdocsAuth {
|
|
306
285
|
"org_name": {},
|
307
286
|
"first_name": {},
|
308
287
|
"last_name": {},
|
309
|
-
"
|
288
|
+
"email": {},
|
289
|
+
"verificationCode": {},
|
310
290
|
"password": {},
|
311
291
|
"submitting": {},
|
312
292
|
"activeSession": {},
|
313
|
-
"
|
314
|
-
"signupStep": {},
|
315
|
-
"resendDisabled": {},
|
316
|
-
"checkingOrg": {}
|
293
|
+
"resendDisabled": {}
|
317
294
|
};
|
318
295
|
}
|
319
296
|
static get events() {
|
@@ -1,24 +1,25 @@
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
2
|
-
import { VerdocsEndpoint, createProfile, authenticate,
|
2
|
+
import { VerdocsEndpoint, createProfile, verifyEmail, authenticate, getMyUser, resendVerification, resetPassword } from '@verdocs/js-sdk';
|
3
3
|
import { V as VerdocsToast } from './Toast.js';
|
4
4
|
import { S as SDKError } from './errors.js';
|
5
5
|
import { d as defineCustomElement$4 } from './verdocs-button2.js';
|
6
6
|
import { d as defineCustomElement$3 } from './verdocs-help-icon2.js';
|
7
7
|
import { d as defineCustomElement$2 } from './verdocs-text-input2.js';
|
8
8
|
|
9
|
-
const verdocsAuthCss = "@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}verdocs-auth{font-family:\"Inter\", -apple-system, \"Segoe UI\", \"Roboto\", \"Helvetica Neue\", sans-serif;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center}verdocs-auth .form{background:#ffffff;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;-ms-flex-direction:column;flex-direction:column;display:-ms-flexbox;display:flex;padding:20px;width:
|
9
|
+
const verdocsAuthCss = "@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}verdocs-auth{font-family:\"Inter\", -apple-system, \"Segoe UI\", \"Roboto\", \"Helvetica Neue\", sans-serif;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center}verdocs-auth .form{background:#ffffff;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;-ms-flex-direction:column;flex-direction:column;display:-ms-flexbox;display:flex;padding:20px;width:320px;max-width:100%}verdocs-auth .logo{margin:20px 0 30px;width:128px;max-width:100%}verdocs-auth h3{text-align:center;font-weight:400;font-size:16px;line-height:1.75;margin:0}verdocs-auth h4{text-align:center;font-weight:400;font-size:14px;line-height:1.43;margin:0}verdocs-auth h4 verdocs-button button.normal .button-label{padding:0}verdocs-auth h6{text-align:center;font-weight:500;font-size:16px;line-height:1.75;margin:0 0 20px 0}verdocs-auth em{font-size:14px;margin:15px 0}verdocs-auth .buttons{gap:20px;margin:20px 0 0 0;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:center;justify-content:center}verdocs-auth .status-result{display:none}verdocs-auth .status-result.debug{white-space:pre-wrap;font-size:14px;background:#fff;padding:10px;display:block;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:center;justify-content:center}verdocs-auth form{width:100%}verdocs-auth verdocs-text-input{margin-bottom:10px}verdocs-auth .account-option{gap:8px;margin:20px 0 8px 0;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row}verdocs-auth p{margin:1em 0 0}verdocs-auth p+p{margin-top:0}verdocs-auth verdocs-help-icon{margin-top:18px;display:-ms-flexbox;display:flex;width:32px;height:32px;-ms-flex:0 0 32px;flex:0 0 32px}";
|
10
10
|
const VerdocsAuthStyle0 = verdocsAuthCss;
|
11
11
|
|
12
|
-
const RECHECK_INTERVAL = 5000;
|
13
12
|
const VerdocsAuth$1 = /*@__PURE__*/ proxyCustomElement(class VerdocsAuth extends HTMLElement {
|
14
13
|
constructor() {
|
15
14
|
super();
|
16
15
|
this.__registerHost();
|
17
16
|
this.authenticated = createEvent(this, "authenticated", 7);
|
18
17
|
this.sdkError = createEvent(this, "sdkError", 7);
|
19
|
-
this.recheckTimer = null;
|
20
18
|
this.resendDisabledTimer = null;
|
21
|
-
|
19
|
+
// We can't instantly log in on the default endpoint because other listeners might see
|
20
|
+
// its events and incorrectly trigger before we're done. So we manage our own temp
|
21
|
+
// endpoint and pass the final tokens to the default once we're ready.
|
22
|
+
this.tempAuthEndpoint = new VerdocsEndpoint();
|
22
23
|
this.endpoint = VerdocsEndpoint.getDefault();
|
23
24
|
this.visible = true;
|
24
25
|
this.logo = 'https://app.verdocs.com/assets/blue-logo.svg';
|
@@ -27,14 +28,12 @@ const VerdocsAuth$1 = /*@__PURE__*/ proxyCustomElement(class VerdocsAuth extends
|
|
27
28
|
this.org_name = '';
|
28
29
|
this.first_name = '';
|
29
30
|
this.last_name = '';
|
30
|
-
this.
|
31
|
+
this.email = '';
|
32
|
+
this.verificationCode = '';
|
31
33
|
this.password = '';
|
32
34
|
this.submitting = false;
|
33
35
|
this.activeSession = null;
|
34
|
-
this.accountType = 'org';
|
35
|
-
this.signupStep = 1;
|
36
36
|
this.resendDisabled = false;
|
37
|
-
this.checkingOrg = false;
|
38
37
|
}
|
39
38
|
componentWillLoad() {
|
40
39
|
var _a, _b;
|
@@ -50,29 +49,6 @@ const VerdocsAuth$1 = /*@__PURE__*/ proxyCustomElement(class VerdocsAuth extends
|
|
50
49
|
(_b = this.authenticated) === null || _b === void 0 ? void 0 : _b.emit({ authenticated: false, session: null });
|
51
50
|
}
|
52
51
|
}
|
53
|
-
disconnectedCallback() {
|
54
|
-
this.cancelRecheckTimer();
|
55
|
-
}
|
56
|
-
cancelRecheckTimer() {
|
57
|
-
if (this.recheckTimer) {
|
58
|
-
try {
|
59
|
-
clearTimeout(this.recheckTimer);
|
60
|
-
}
|
61
|
-
catch (e) {
|
62
|
-
// NOP
|
63
|
-
}
|
64
|
-
this.recheckTimer = null;
|
65
|
-
}
|
66
|
-
if (this.resendDisabledTimer) {
|
67
|
-
try {
|
68
|
-
clearTimeout(this.resendDisabledTimer);
|
69
|
-
}
|
70
|
-
catch (e) {
|
71
|
-
// NOP
|
72
|
-
}
|
73
|
-
this.resendDisabledTimer = null;
|
74
|
-
}
|
75
|
-
}
|
76
52
|
isPasswordComplex(password) {
|
77
53
|
const isUppercase = (ch) => /[A-Z]/.test(ch);
|
78
54
|
const isLowercase = (ch) => /[a-z]/.test(ch);
|
@@ -91,13 +67,13 @@ const VerdocsAuth$1 = /*@__PURE__*/ proxyCustomElement(class VerdocsAuth extends
|
|
91
67
|
}
|
92
68
|
handleSignup() {
|
93
69
|
this.submitting = true;
|
94
|
-
this.
|
70
|
+
this.tempAuthEndpoint.clearSession();
|
95
71
|
if (!this.isPasswordComplex(this.password)) {
|
96
72
|
window.alert('Password must be at least 8 characters long and contain at least one uppercase, one lowercase, and one special character.');
|
97
73
|
return;
|
98
74
|
}
|
99
|
-
createProfile(this.
|
100
|
-
email: this.
|
75
|
+
createProfile(this.tempAuthEndpoint, {
|
76
|
+
email: this.email,
|
101
77
|
password: this.password,
|
102
78
|
first_name: this.first_name,
|
103
79
|
last_name: this.last_name,
|
@@ -105,7 +81,8 @@ const VerdocsAuth$1 = /*@__PURE__*/ proxyCustomElement(class VerdocsAuth extends
|
|
105
81
|
})
|
106
82
|
.then(r => {
|
107
83
|
console.log('Profile creation result', r);
|
108
|
-
this.
|
84
|
+
this.tempAuthEndpoint.setToken(r.access_token);
|
85
|
+
this.displayMode = 'verify';
|
109
86
|
})
|
110
87
|
.catch(e => {
|
111
88
|
var _a, _b, _c, _d, _e, _f;
|
@@ -117,49 +94,55 @@ const VerdocsAuth$1 = /*@__PURE__*/ proxyCustomElement(class VerdocsAuth extends
|
|
117
94
|
VerdocsToast('Signup failed: ' + ((_f = (_e = e.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.message) || 'Unknown Error', { style: 'error' });
|
118
95
|
});
|
119
96
|
}
|
120
|
-
|
97
|
+
async handleVerification() {
|
121
98
|
this.submitting = true;
|
122
|
-
|
123
|
-
authenticate(this.endpoint, { username: this.username, password: this.password, grant_type: 'password' })
|
124
|
-
.then(r => {
|
125
|
-
var _a;
|
126
|
-
this.cancelRecheckTimer();
|
99
|
+
try {
|
127
100
|
this.submitting = false;
|
128
|
-
const
|
129
|
-
console.log('
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
101
|
+
const verificationResult = await verifyEmail(this.endpoint, { email: this.email, token: this.verificationCode });
|
102
|
+
console.log('Verification result', verificationResult);
|
103
|
+
this.completeLogin(verificationResult);
|
104
|
+
}
|
105
|
+
catch (e) {
|
106
|
+
this.submitting = false;
|
107
|
+
console.log('Verification error', e);
|
108
|
+
VerdocsToast('Verification error, please check the code and try again.');
|
109
|
+
}
|
110
|
+
}
|
111
|
+
completeLogin(result) {
|
112
|
+
var _a;
|
113
|
+
this.endpoint.setToken(result.access_token);
|
114
|
+
this.activeSession = this.endpoint.session;
|
115
|
+
this.isAuthenticated = true;
|
116
|
+
(_a = this.authenticated) === null || _a === void 0 ? void 0 : _a.emit({ authenticated: true, session: this.endpoint.session });
|
117
|
+
}
|
118
|
+
async loginAndCheckVerification() {
|
119
|
+
this.submitting = true;
|
120
|
+
this.tempAuthEndpoint.clearSession();
|
121
|
+
try {
|
122
|
+
this.submitting = false;
|
123
|
+
const authResult = await authenticate(this.endpoint, { username: this.email, password: this.password, grant_type: 'password' });
|
124
|
+
console.log('[AUTH] Authenticated', authResult.access_token);
|
125
|
+
this.tempAuthEndpoint.setToken(authResult.access_token);
|
126
|
+
const user = await getMyUser(this.tempAuthEndpoint);
|
127
|
+
console.log('Got user', user);
|
128
|
+
if (!user.email_verified) {
|
140
129
|
console.log('[AUTH] Logged in, pending email address verification');
|
141
130
|
this.displayMode = 'verify';
|
142
|
-
this.accessTokenForVerification = r.access_token;
|
143
|
-
this.recheckTimer = setTimeout(this.loginAndCheckVerification, RECHECK_INTERVAL);
|
144
131
|
}
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
132
|
+
else {
|
133
|
+
console.log('[AUTH] Email address is verified, completing login');
|
134
|
+
this.completeLogin(authResult);
|
135
|
+
}
|
136
|
+
}
|
137
|
+
catch (e) {
|
151
138
|
this.submitting = false;
|
152
|
-
|
153
|
-
(_a = this.authenticated) === null || _a === void 0 ? void 0 : _a.emit({ authenticated: false, session: null });
|
154
|
-
(_b = this.sdkError) === null || _b === void 0 ? void 0 : _b.emit(new SDKError(e.message, (_c = e.response) === null || _c === void 0 ? void 0 : _c.status, (_d = e.response) === null || _d === void 0 ? void 0 : _d.data));
|
155
|
-
VerdocsToast('Login failed. Please check your username and password and try again.', { style: 'error' });
|
156
|
-
});
|
139
|
+
}
|
157
140
|
}
|
158
141
|
handleLogout() {
|
159
142
|
var _a;
|
160
143
|
this.endpoint.clearSession();
|
144
|
+
this.tempAuthEndpoint.clearSession();
|
161
145
|
this.isAuthenticated = false;
|
162
|
-
this.accessTokenForVerification = null;
|
163
146
|
(_a = this.authenticated) === null || _a === void 0 ? void 0 : _a.emit({ authenticated: false, session: null });
|
164
147
|
}
|
165
148
|
handleResend() {
|
@@ -170,7 +153,7 @@ const VerdocsAuth$1 = /*@__PURE__*/ proxyCustomElement(class VerdocsAuth extends
|
|
170
153
|
this.resendDisabled = false;
|
171
154
|
this.resendDisabledTimer = null;
|
172
155
|
}, 30000);
|
173
|
-
resendVerification(this.
|
156
|
+
resendVerification(this.tempAuthEndpoint)
|
174
157
|
.then(r => {
|
175
158
|
console.log('[AUTH] Verification request resent', r);
|
176
159
|
VerdocsToast('Please check your email for a message with verification instructions.', { style: 'info' });
|
@@ -179,19 +162,20 @@ const VerdocsAuth$1 = /*@__PURE__*/ proxyCustomElement(class VerdocsAuth extends
|
|
179
162
|
console.log('[AUTH] Unable to resend verification', e);
|
180
163
|
});
|
181
164
|
}
|
182
|
-
handleReset() {
|
165
|
+
async handleReset() {
|
183
166
|
this.submitting = true;
|
184
|
-
|
185
|
-
.
|
186
|
-
console.log('[AUTH] Reset sent',
|
167
|
+
try {
|
168
|
+
const result = await resetPassword(this.endpoint, { email: this.email });
|
169
|
+
console.log('[AUTH] Reset sent', result);
|
187
170
|
this.submitting = false;
|
188
171
|
this.displayMode = 'login';
|
189
172
|
VerdocsToast('If your email address is registered, you will receive instructions on resetting your password shortly.', { style: 'info' });
|
190
|
-
}
|
191
|
-
|
173
|
+
}
|
174
|
+
catch (e) {
|
192
175
|
console.log('[AUTH] Unable to reset password', e);
|
193
176
|
this.submitting = false;
|
194
|
-
|
177
|
+
VerdocsToast('Unable to reset password. Please check your email address and try again.', { style: 'error' });
|
178
|
+
}
|
195
179
|
}
|
196
180
|
render() {
|
197
181
|
if (!this.visible) {
|
@@ -201,26 +185,21 @@ const VerdocsAuth$1 = /*@__PURE__*/ proxyCustomElement(class VerdocsAuth extends
|
|
201
185
|
return (h("verdocs-button", { label: "Sign Out", disabled: this.submitting, onClick: () => this.handleLogout(), style: { display: 'flex', justifyContent: 'center', margin: '30px auto 0' } }));
|
202
186
|
}
|
203
187
|
if (this.displayMode === 'signup') {
|
204
|
-
const
|
205
|
-
return (h("div", { class: "form" }, h("a", { href: "https://verdocs.com/en/" }, h("img", { src: this.logo, alt: "Verdocs Logo", class: "logo" })), h("h3", null, "Sign up for a free account"), h("
|
206
|
-
this.signupStep = 2;
|
207
|
-
}, style: { display: 'flex', justifyContent: 'center', margin: '30px auto 0' } }), h("verdocs-button", { label: "Go to Dashboard", disabled: true, onClick: () => this.handleSignup(), style: { display: 'flex', justifyContent: 'center', margin: '30px auto 0' } }))))));
|
208
|
-
}
|
209
|
-
if (this.displayMode === 'forgot') {
|
210
|
-
return (h("div", { class: "form" }, h("a", { href: "https://verdocs.com/en/" }, h("img", { src: this.logo, alt: "Verdocs Logo", class: "logo" })), h("h3", null, "Forgot your password?"), h("p", null, "Enter your e-mail address below, and reset instructions will be sent to your Inbox."), h("p", null, h("em", null, "Please allow up to 24 hours for delivery, and check your spam folder if you do not receive the message. ")), h("form", { onSubmit: () => this.handleSignup() }, h("verdocs-text-input", { label: "Email", autocomplete: "email", required: true, value: this.username, onInput: (e) => (this.username = e.target.value), disabled: this.submitting }), h("div", { style: { marginTop: '30px' } }), h("div", { class: "buttons" }, h("verdocs-button", { label: "Cancel", variant: "outline", disabled: this.submitting, onClick: () => (this.displayMode = 'login') }), h("verdocs-button", { label: "Reset", disabled: this.submitting, onClick: () => this.handleReset() })))));
|
188
|
+
const invalid = this.submitting || !this.first_name || !this.last_name || !this.email || !this.password || !this.org_name;
|
189
|
+
return (h("div", { class: "form" }, h("a", { href: "https://verdocs.com/en/" }, h("img", { src: this.logo, alt: "Verdocs Logo", class: "logo" })), h("h3", null, "Sign up for a free account"), h("h5", null, "Already have an account?", h("verdocs-button", { label: "Log In", variant: "text", onClick: () => (this.displayMode = 'login'), disabled: this.submitting })), h("form", { onSubmit: () => this.handleSignup() }, h("div", { style: { display: 'flex', flexDirection: 'row', columnGap: '20px' } }, h("verdocs-text-input", { label: "First Name", autocomplete: "first", required: true, value: this.first_name, onInput: (e) => (this.first_name = e.target.value), disabled: this.submitting }), h("verdocs-text-input", { label: "Last Name", autocomplete: "last", required: true, value: this.last_name, onInput: (e) => (this.last_name = e.target.value), disabled: this.submitting })), h("verdocs-text-input", { label: "Email Address", autocomplete: "email", required: true, value: this.email, onInput: (e) => (this.email = e.target.value), disabled: this.submitting }), h("verdocs-text-input", { label: "Password", type: "password", required: true, autocomplete: "current-password", value: this.password, onInput: (e) => (this.password = e.target.value), disabled: this.submitting }), h("verdocs-text-input", { label: "Organization Name", autocomplete: "org", required: true, value: this.org_name, onInput: (e) => (this.org_name = e.target.value), disabled: this.submitting, style: { flex: '1' } }), h("div", { style: { marginTop: '30px' } }), h("verdocs-button", { label: "Next", disabled: invalid, onClick: () => this.handleSignup(), style: { display: 'flex', justifyContent: 'center', margin: '30px auto 0' } }))));
|
211
190
|
}
|
212
191
|
if (this.displayMode === 'verify') {
|
213
|
-
return (h("
|
214
|
-
this.
|
192
|
+
return (h("form", { onSubmit: () => this.handleSignup() }, h("p", null, "Please check your e-mail inbox for a verification code and follow the instructions provided."), h("p", null, h("em", null, "Verification messages may take up to 1 hour to arrive. If you do not receive the invitation, ", h("a", { href: "#" }, "Click Here"), " to resend it. Be sure to check your spam folder.")), h("verdocs-text-input", { label: "Verification Code", required: true, value: this.verificationCode, onInput: (e) => (this.verificationCode = e.target.value), disabled: this.submitting }), h("div", { style: { display: 'flex', flexDirection: 'row', gap: '20px' } }, h("verdocs-button", { label: "Verify", disabled: this.submitting, onClick: () => this.handleVerification(), style: { display: 'flex', justifyContent: 'center', margin: '10px auto 0' } }), h("verdocs-button", { variant: "outline", label: "Resend Code", disabled: this.resendDisabled, onClick: () => this.handleResend() }), h("verdocs-button", { label: "Sign Out", variant: "text", disabled: this.submitting, onClick: () => {
|
193
|
+
this.tempAuthEndpoint.clearSession();
|
194
|
+
this.email = '';
|
215
195
|
this.password = '';
|
216
|
-
this.cancelRecheckTimer();
|
217
196
|
this.displayMode = 'login';
|
218
|
-
} })
|
197
|
+
} }))));
|
198
|
+
}
|
199
|
+
if (this.displayMode === 'forgot') {
|
200
|
+
return (h("div", { class: "form" }, h("a", { href: "https://verdocs.com/en/" }, h("img", { src: this.logo, alt: "Verdocs Logo", class: "logo" })), h("h3", null, "Forgot your password?"), h("p", null, "Enter your e-mail address below, and reset instructions will be sent to your Inbox. Please allow up to 15 minutes to arrive. Check your spam folder if you do not receive the message."), h("form", { onSubmit: () => this.handleSignup() }, h("verdocs-text-input", { label: "Email Address", autocomplete: "email", required: true, value: this.email, onInput: (e) => (this.email = e.target.value), disabled: this.submitting }), h("div", { style: { marginTop: '30px' } }), h("div", { class: "buttons" }, h("verdocs-button", { label: "Cancel", variant: "outline", disabled: this.submitting, onClick: () => (this.displayMode = 'login') }), h("verdocs-button", { label: "Reset", disabled: this.submitting, onClick: () => this.handleReset() })))));
|
219
201
|
}
|
220
|
-
return (h("div", { class: "form" }, h("a", { href: "https://verdocs.com/en/" }, h("img", { src: this.logo, alt: "Verdocs Logo", class: "logo" })), h("h3", null, "Log in to your account"), h("h4", null, "Don't have an account?", h("verdocs-button", { label: "Sign Up", variant: "text", onClick: () => {
|
221
|
-
this.displayMode = 'signup';
|
222
|
-
this.signupStep = 1;
|
223
|
-
}, disabled: this.submitting })), h("form", { onSubmit: () => this.loginAndCheckVerification() }, h("verdocs-text-input", { label: "Email", autocomplete: "username", value: this.username, onInput: (e) => (this.username = e.target.value), disabled: this.submitting }), h("verdocs-text-input", { label: "Password", type: "password", autocomplete: "current-password", value: this.password, onInput: (e) => (this.password = e.target.value), disabled: this.submitting }), h("verdocs-button", { label: "Forgot Your Password?", variant: "text", onClick: () => (this.displayMode = 'forgot'), disabled: this.submitting, style: { display: 'flex', justifyContent: 'center', margin: '10px auto 20px' } }), h("verdocs-button", { label: "Login", disabled: this.submitting, onClick: () => this.loginAndCheckVerification(), style: { display: 'flex', justifyContent: 'center', margin: '10px auto 0' } }))));
|
202
|
+
return (h("div", { class: "form" }, h("a", { href: "https://verdocs.com/en/" }, h("img", { src: this.logo, alt: "Verdocs Logo", class: "logo" })), h("h3", null, "Log in to your account"), h("h4", null, "Don't have an account?", h("verdocs-button", { label: "Sign Up", variant: "text", onClick: () => (this.displayMode = 'signup'), disabled: this.submitting })), h("form", { onSubmit: () => this.loginAndCheckVerification() }, h("verdocs-text-input", { label: "Email", autocomplete: "username", value: this.email, onInput: (e) => (this.email = e.target.value), disabled: this.submitting }), h("verdocs-text-input", { label: "Password", type: "password", autocomplete: "current-password", value: this.password, onInput: (e) => (this.password = e.target.value), disabled: this.submitting }), h("verdocs-button", { label: "Forgot Your Password?", variant: "text", onClick: () => (this.displayMode = 'forgot'), disabled: this.submitting, style: { display: 'flex', justifyContent: 'center', margin: '10px auto 20px' } }), h("verdocs-button", { label: "Login", disabled: this.submitting, onClick: () => this.loginAndCheckVerification(), style: { display: 'flex', justifyContent: 'center', margin: '10px auto 0' } }))));
|
224
203
|
}
|
225
204
|
static get style() { return VerdocsAuthStyle0; }
|
226
205
|
}, [0, "verdocs-auth", {
|
@@ -232,14 +211,12 @@ const VerdocsAuth$1 = /*@__PURE__*/ proxyCustomElement(class VerdocsAuth extends
|
|
232
211
|
"org_name": [32],
|
233
212
|
"first_name": [32],
|
234
213
|
"last_name": [32],
|
235
|
-
"
|
214
|
+
"email": [32],
|
215
|
+
"verificationCode": [32],
|
236
216
|
"password": [32],
|
237
217
|
"submitting": [32],
|
238
218
|
"activeSession": [32],
|
239
|
-
"
|
240
|
-
"signupStep": [32],
|
241
|
-
"resendDisabled": [32],
|
242
|
-
"checkingOrg": [32]
|
219
|
+
"resendDisabled": [32]
|
243
220
|
}]);
|
244
221
|
function defineCustomElement$1() {
|
245
222
|
if (typeof customElements === "undefined") {
|