pwa-auth 2.0.3 → 2.0.5

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.
Files changed (121) hide show
  1. package/CHANGELOG.md +36 -26
  2. package/README.md +101 -87
  3. package/demo/index.html +22 -126
  4. package/demo/pwa-styles.css +77 -0
  5. package/deploy/css/font.d.ts.map +1 -1
  6. package/deploy/css/form/button.d.ts.map +1 -1
  7. package/deploy/css/form/input.d.ts.map +1 -1
  8. package/deploy/css/form/label.d.ts.map +1 -1
  9. package/deploy/css/form/list.d.ts.map +1 -1
  10. package/deploy/css/svg.d.ts.map +1 -1
  11. package/deploy/css/toggle.d.ts.map +1 -1
  12. package/deploy/custom-elements/drawer/css/drawer.d.ts.map +1 -1
  13. package/deploy/custom-elements/drawer/css/exit.d.ts.map +1 -1
  14. package/deploy/custom-elements/drawer/css/link.d.ts.map +1 -1
  15. package/deploy/custom-elements/drawer/css/paragraph.d.ts.map +1 -1
  16. package/deploy/custom-elements/drawer/css/toggle.d.ts.map +1 -1
  17. package/deploy/custom-elements/drawer/drawer.d.ts.map +1 -1
  18. package/deploy/custom-elements/drawer/drawer.js +1 -1
  19. package/deploy/custom-elements/drawer/input/forgot.d.ts.map +1 -1
  20. package/deploy/custom-elements/drawer/input/forgot.js +1 -1
  21. package/deploy/custom-elements/drawer/input/login.d.ts.map +1 -1
  22. package/deploy/custom-elements/drawer/input/login.js +1 -1
  23. package/deploy/custom-elements/drawer/input/sign-up.d.ts.map +1 -1
  24. package/deploy/custom-elements/drawer/input/sign-up.js +1 -1
  25. package/deploy/custom-elements/icon/css/icon.d.ts.map +1 -1
  26. package/deploy/custom-elements/icon/css/icon.js +0 -1
  27. package/deploy/custom-elements/icon/icon.d.ts.map +1 -1
  28. package/deploy/custom-elements/settings/css/navigation.d.ts.map +1 -1
  29. package/deploy/custom-elements/settings/input/delete.d.ts.map +1 -1
  30. package/deploy/custom-elements/settings/input/delete.js +1 -1
  31. package/deploy/custom-elements/settings/input/email.d.ts.map +1 -1
  32. package/deploy/custom-elements/settings/input/email.js +1 -1
  33. package/deploy/custom-elements/settings/input/images.d.ts.map +1 -1
  34. package/deploy/custom-elements/settings/input/images.js +1 -1
  35. package/deploy/custom-elements/settings/input/name.d.ts.map +1 -1
  36. package/deploy/custom-elements/settings/input/name.js +1 -1
  37. package/deploy/custom-elements/settings/input/password.d.ts.map +1 -1
  38. package/deploy/custom-elements/settings/input/password.js +1 -1
  39. package/deploy/custom-elements/settings/input/uploader.d.ts +0 -2
  40. package/deploy/custom-elements/settings/input/uploader.d.ts.map +1 -1
  41. package/deploy/custom-elements/settings/input/uploader.js +11 -22
  42. package/deploy/custom-elements/settings/settings.d.ts.map +1 -1
  43. package/deploy/firebase/firebase-login.d.ts +21 -0
  44. package/deploy/firebase/firebase-login.d.ts.map +1 -0
  45. package/deploy/firebase/firebase-login.js +85 -0
  46. package/deploy/firebase/firebase.d.ts +20 -0
  47. package/deploy/firebase/firebase.d.ts.map +1 -0
  48. package/deploy/firebase/firebase.js +76 -0
  49. package/deploy/firebase/start.d.ts.map +1 -0
  50. package/deploy/{start.js → firebase/start.js} +5 -4
  51. package/deploy/lazy-loader.d.ts.map +1 -1
  52. package/deploy/redux/backend.d.ts.map +1 -1
  53. package/deploy/redux/drawer.d.ts.map +1 -1
  54. package/deploy/redux/frontend.d.ts.map +1 -1
  55. package/deploy/redux/object.d.ts.map +1 -1
  56. package/deploy/store.d.ts.map +1 -1
  57. package/npm/pwa-auth.js +1 -1
  58. package/npm/pwa-styles.css +66 -0
  59. package/package.json +4 -3
  60. package/source/css/font.ts +17 -0
  61. package/source/css/form/button.ts +55 -0
  62. package/source/css/form/input.ts +25 -0
  63. package/source/css/form/label.ts +25 -0
  64. package/source/css/form/list.ts +23 -0
  65. package/source/css/svg.ts +5 -0
  66. package/source/css/toggle.ts +9 -0
  67. package/source/custom-elements/drawer/css/drawer.ts +64 -0
  68. package/source/custom-elements/drawer/css/exit.ts +49 -0
  69. package/source/custom-elements/drawer/css/link.ts +15 -0
  70. package/source/custom-elements/drawer/css/paragraph.ts +11 -0
  71. package/source/custom-elements/drawer/css/toggle.ts +19 -0
  72. package/source/custom-elements/drawer/drawer.ts +120 -0
  73. package/source/custom-elements/drawer/input/forgot.ts +121 -0
  74. package/source/custom-elements/drawer/input/login.ts +135 -0
  75. package/source/custom-elements/drawer/input/sign-up.ts +158 -0
  76. package/source/custom-elements/icon/css/icon.ts +70 -0
  77. package/source/custom-elements/icon/icon.ts +87 -0
  78. package/source/custom-elements/settings/css/navigation.ts +92 -0
  79. package/source/custom-elements/settings/input/delete.ts +83 -0
  80. package/source/custom-elements/settings/input/email.ts +135 -0
  81. package/source/custom-elements/settings/input/images.ts +57 -0
  82. package/source/custom-elements/settings/input/name.ts +99 -0
  83. package/source/custom-elements/settings/input/password.ts +156 -0
  84. package/source/custom-elements/settings/input/uploader.ts +326 -0
  85. package/source/custom-elements/settings/settings.ts +202 -0
  86. package/source/firebase/firebase-login.ts +246 -0
  87. package/source/firebase/firebase.ts +214 -0
  88. package/source/firebase/start.ts +216 -0
  89. package/source/lazy-loader.ts +20 -0
  90. package/source/redux/backend.ts +94 -0
  91. package/source/redux/drawer.ts +37 -0
  92. package/source/redux/frontend.ts +134 -0
  93. package/source/redux/object.ts +31 -0
  94. package/source/store.ts +19 -0
  95. package/website/404.html +33 -0
  96. package/website/THIRD_PARTY_LICENSES.txt +303 -0
  97. package/website/css/pwa-styles.css +36 -0
  98. package/website/css/styles.css +67 -0
  99. package/website/images/empty.jpg +0 -0
  100. package/website/images/favicon.ico +0 -0
  101. package/website/images/manifest/logo-144.png +0 -0
  102. package/website/images/manifest/logo-192.png +0 -0
  103. package/website/images/manifest/logo-48.png +0 -0
  104. package/website/images/manifest/logo-512.png +0 -0
  105. package/website/images/manifest/logo-72.png +0 -0
  106. package/website/images/manifest/logo-96.png +0 -0
  107. package/website/images/manifest/maskable_icon_x128.png +0 -0
  108. package/website/images/manifest/maskable_icon_x192.png +0 -0
  109. package/website/images/manifest/maskable_icon_x384.png +0 -0
  110. package/website/images/manifest/maskable_icon_x48.png +0 -0
  111. package/website/images/manifest/maskable_icon_x512.png +0 -0
  112. package/website/images/manifest/maskable_icon_x72.png +0 -0
  113. package/website/images/manifest/maskable_icon_x96.png +0 -0
  114. package/website/index.html +64 -0
  115. package/website/js/pwa-auth.js +306 -0
  116. package/website/sitemap.xml +11 -0
  117. package/deploy/interface.d.ts +0 -36
  118. package/deploy/interface.d.ts.map +0 -1
  119. package/deploy/interface.js +0 -176
  120. package/deploy/start.d.ts.map +0 -1
  121. /package/deploy/{start.d.ts → firebase/start.d.ts} +0 -0
@@ -0,0 +1,135 @@
1
+ import { CSSResultArray, LitElement, css, html } from "lit";
2
+ import { property, state } from "lit/decorators.js";
3
+ import { connect } from "pwa-helpers";
4
+ import store, { AppState } from "../../../store";
5
+ import { auth } from "../../../firebase/start";
6
+ import { labelStyle } from "../../../css/form/label";
7
+ import { inputStyle } from "../../../css/form/input";
8
+ import { buttonStyle } from "../../../css/form/button";
9
+ import { updateEmail } from "firebase/auth";
10
+
11
+ export class ContactEmail extends connect(store)(LitElement) {
12
+
13
+ /** @attr email */
14
+ @property({ type: String, reflect: true}) email = '';
15
+
16
+ @state() private login : boolean = false;
17
+ @state() private mail : string = "";
18
+
19
+ constructor() { super(); }
20
+
21
+ stateChanged(state: AppState) {
22
+ this.login = state.frontend!.login;
23
+ this.mail = state.backend!.email ;
24
+ }
25
+
26
+ // Handle input changes to keep the password property in sync
27
+ private handleEmail(event: Event) {
28
+ const input = event.target as HTMLInputElement;
29
+ this.mail = input.value; // Update the property with the input value
30
+ }
31
+
32
+ static get styles(): CSSResultArray { return [
33
+ labelStyle,
34
+ inputStyle,
35
+ buttonStyle,
36
+ css`
37
+
38
+ :host {
39
+ display: grid;
40
+ }
41
+
42
+ form { display: grid; }
43
+
44
+ `
45
+ ]; }
46
+
47
+ render() {
48
+ return html`
49
+
50
+ <form
51
+ autocomplete="off"
52
+ @submit="${this.default}">
53
+
54
+ <label for="pwa-email" >E-mail:</label>
55
+
56
+ <input
57
+ id = "pwa-email"
58
+ name = "email"
59
+ type = "email"
60
+ class = "email"
61
+ data-label = "Account Email"
62
+ @input = "${this.handleEmail}"
63
+ .value = "${this.mail}"/>
64
+
65
+ <button
66
+ class = "action-button"
67
+ @click = "${this.saveEmail}"
68
+ ?disabled = "${this.login === false}">Update</button>
69
+
70
+ </form>
71
+
72
+ `;
73
+ }
74
+
75
+ /* Form Default */
76
+ private default = (e:Event) => {
77
+ e.preventDefault();
78
+ }
79
+
80
+ // Save Email
81
+ private saveEmail = async () => {
82
+ if ( auth.currentUser ) {
83
+
84
+ let contactMail :any = this.shadowRoot?.querySelector('#pwa-email')!;
85
+
86
+ // Change Email Firebase Function
87
+ await updateEmail( auth.currentUser, contactMail.value ).catch((error:Error) => { console.log(error); });
88
+
89
+ // Verify Email Custom Event
90
+ const emailChangedEvent = new CustomEvent("userEmailChanged", {
91
+ detail: { email: contactMail.value }
92
+ });
93
+
94
+ // Dispatch Custom Event
95
+ window.dispatchEvent(emailChangedEvent);
96
+
97
+ alert('Email Updated');
98
+
99
+ }
100
+
101
+ }
102
+
103
+ }
104
+
105
+ customElements.define('contact-email', ContactEmail);
106
+
107
+ declare global {
108
+ interface HTMLElementTagNameMap {
109
+ 'contact-email': ContactEmail;
110
+ }
111
+ }
112
+
113
+
114
+
115
+
116
+ // this.emailVerification();
117
+ // let document :any = doc( db, 'users', auth.currentUser.uid );
118
+ // .then(() => updateDoc( document, { "contractorEmail":contactMail.email } ).catch(e=>console.log(e)) )
119
+ // store.dispatch( businessEmail(contactMail.email) ); // Redux Account Update
120
+ // console.log('good');
121
+ /*
122
+ // Email Verification
123
+ private emailVerification() {
124
+
125
+ // const auth : any = getAuth();
126
+ console.log( 'auth.currentUser: ', auth.currentUser);
127
+
128
+ // Todo: Find Soruce of Dependency
129
+ sendEmailVerification(auth.currentUser)
130
+ .then(() => { console.log('success')
131
+ // Email verification sent!
132
+ }).catch( e => console.log(e) );
133
+
134
+ }
135
+ */
@@ -0,0 +1,57 @@
1
+ import { ref } from "@firebase/storage";
2
+ import { storage } from "../../../firebase/start";
3
+ /*
4
+ export const uploadIcon = (uploader, file) => {
5
+
6
+ const uploader = this.shadowRoot!.querySelector('#uploader');
7
+ const file = this.shadowRoot!.querySelector('#fileupload')!.files[0];
8
+
9
+ const now = storageRef.child('/images/' + file.name );
10
+
11
+ const task = now.put(file);
12
+
13
+ task.on('state_changed',
14
+ function progress(snapshot: object) { const percentage = ( snapshot.bytesTransferred / snapshot.totalBytes ) * 100; uploader.value = percentage },
15
+ // function error(error: object) { error },
16
+ // function complete() { }
17
+ )
18
+
19
+ this._imagePath = file.name;
20
+ console.log(this._imagePath);
21
+
22
+ }
23
+ */
24
+ // Reference the total number of existing documents
25
+ export const _listImages = () => {
26
+
27
+ // Create a reference under which you want to list
28
+ const storageRef:any = ref(storage);
29
+
30
+ // Reference to list
31
+ const listRef = storageRef
32
+ .child('images/'); // .child('images/'+this._userID+'/'+);
33
+
34
+ // Find all the prefixes and items.
35
+ listRef
36
+ .listAll()
37
+ .then( (res:any) => {
38
+
39
+ console.log('res:', res);
40
+
41
+ res
42
+ .prefixes
43
+ .forEach( (folderRef:any) => {
44
+ console.log('folderRef: ', folderRef);
45
+ }); // You may call listAll() recursively on them. // All the prefixes under listRef.
46
+
47
+ res
48
+ .items
49
+ .forEach( (itemRef:any) => {
50
+ console.log('itemRef: ', itemRef);
51
+ });
52
+
53
+ }).catch( (error:any) => { console.log("Could not get storage items: ", error)});
54
+ }
55
+
56
+
57
+
@@ -0,0 +1,99 @@
1
+ import { CSSResultArray, LitElement, css, html } from "lit";
2
+ import { property, state } from "lit/decorators.js";
3
+ import { connect } from "pwa-helpers";
4
+ import { store, AppState } from "../../../store";
5
+ import { updateProfile } from "firebase/auth";
6
+ import { accName } from "../../../redux/backend";
7
+ import { auth } from "../../../firebase/start";
8
+ import { labelStyle } from "../../../css/form/label";
9
+ import { inputStyle } from "../../../css/form/input";
10
+ import { buttonStyle } from "../../../css/form/button";
11
+
12
+ export class InputName extends connect(store)(LitElement) {
13
+
14
+ /** @attr value */
15
+ @property({ type: String, reflect: true}) public value = '';
16
+
17
+ @state() private login : boolean = false;
18
+
19
+ constructor() { super(); }
20
+
21
+ stateChanged(state: AppState) {
22
+ this.login = state.frontend!.login;
23
+ this.value = state.backend!.name; // user-name
24
+ }
25
+
26
+ static get styles(): CSSResultArray { return [
27
+ labelStyle,
28
+ inputStyle,
29
+ buttonStyle,
30
+ css`
31
+
32
+ :host, form { display: grid; }
33
+
34
+ ` ]; }
35
+
36
+ render() {
37
+ return html`
38
+
39
+ <form
40
+ @submit="${this.default}">
41
+
42
+ <label
43
+ for="pwa-name"><span>Name:</span></label>
44
+
45
+ <input
46
+ id = "pwa-name"
47
+ name = "username"
48
+ type = "text"
49
+ data-label = "Contact Name"
50
+ @input = "${ this.handleInput }"
51
+ .value = "${ this.value }" />
52
+
53
+ <!-- Save to Database -->
54
+ <button
55
+ class="action-button save"
56
+ @click="${this.alertProfile}"
57
+ ?disabled="${this.login === false}">Update</button>
58
+
59
+ </form>
60
+
61
+ `;
62
+ }
63
+
64
+ /* Form Default */
65
+ private default = (e:Event) => {
66
+ e.preventDefault();
67
+ }
68
+
69
+ // Handle input changes to keep the password property in sync
70
+ private handleInput(event: Event) {
71
+ const input = event.target as HTMLInputElement;
72
+ this.value = input.value; // Update the property with the input value
73
+ }
74
+
75
+ private alertProfile = async () => {
76
+
77
+ // Dispatch the Information to Firestore Function
78
+ if (auth.currentUser) {
79
+
80
+ await updateProfile(auth.currentUser, { displayName: this.value })
81
+ .then( () => { store.dispatch(accName(this.value)) })
82
+ .then( () => { alert('updated name:' + this.value); });
83
+
84
+ } else { alert('Please Login'); }
85
+
86
+ }
87
+
88
+
89
+ // Redux Dispatch Updated Information
90
+
91
+ }
92
+
93
+ customElements.define('input-name', InputName);
94
+
95
+ declare global {
96
+ interface HTMLElementTagNameMap {
97
+ 'input-name': InputName;
98
+ }
99
+ }
@@ -0,0 +1,156 @@
1
+
2
+ import { CSSResultArray, LitElement, css, html } from "lit";
3
+ import { state } from "lit/decorators.js";
4
+ import { connect } from "pwa-helpers";
5
+ import store, { AppState } from "../../../store";
6
+ import { auth } from "../../../firebase/start";
7
+ import { labelStyle } from "../../../css/form/label";
8
+ import { inputStyle } from "../../../css/form/input";
9
+ import { buttonStyle } from "../../../css/form/button";
10
+ import { updatePassword } from "firebase/auth";
11
+
12
+ export class InputPassword extends connect(store)(LitElement) {
13
+
14
+ @state() private message : string = '';
15
+ @state() private password : string = '';
16
+ @state() private login : boolean = false;
17
+
18
+ constructor() { super(); }
19
+
20
+ protected firstUpdated() {
21
+
22
+ this.shadowRoot!.querySelector('.pass')!.addEventListener('click',() => {
23
+ this.alertPassword();
24
+ } );
25
+
26
+ }
27
+
28
+ stateChanged(state: AppState) {
29
+ this.login = state.frontend!.login;
30
+ }
31
+
32
+ // Handle input changes to keep the password property in sync
33
+ private handleInputChange(event: Event) {
34
+ const input = event.target as HTMLInputElement;
35
+ this.password = input.value; // Update the property with the input value
36
+ }
37
+
38
+ static get styles(): CSSResultArray { return [
39
+ labelStyle,
40
+ inputStyle,
41
+ buttonStyle,
42
+ css`
43
+
44
+ :host{
45
+ display: grid;
46
+ }
47
+
48
+ form { display: grid; }
49
+
50
+ p.error { color: red; }
51
+
52
+ ` ]; }
53
+
54
+ render() {
55
+ return html`
56
+
57
+ <form
58
+ autocomplete="off"
59
+ @submit="${this.default}">
60
+
61
+ <!-- Input - 1 -->
62
+ <label for="pwa-new-password">New Password</label>
63
+
64
+ <input
65
+ id = "pwa-new-password"
66
+ name = "new_password"
67
+ type = "password"
68
+ .value = "${this.password}"
69
+ @input = "${this.handleInputChange}"
70
+ aria-describedby = "password-help">
71
+
72
+ <!-- Input - 2 -->
73
+ <label for="pwa-verify-password">Verify Password</label>
74
+
75
+ <input
76
+ id = "pwa-verify-password"
77
+ name = "verify_password"
78
+ type = "password">
79
+
80
+ <!-- Submit -->
81
+ <button
82
+ class="action-button pass"
83
+ ?disabled="${this.login === false}">Update</button>
84
+
85
+ ${this.message ? html`
86
+
87
+ <p
88
+ class=${this.message.includes('Password entered') ? '' : 'error'}
89
+ aria-live="polite">
90
+
91
+ ${this.message}
92
+
93
+ </p>
94
+
95
+ ` : ''
96
+ }
97
+
98
+ </form>
99
+
100
+ `;
101
+ }
102
+
103
+ /* Form Default */
104
+ private default = (e:Event) => {
105
+ e.preventDefault();
106
+ }
107
+
108
+ /* Update Password */
109
+ private alertPassword() {
110
+
111
+ if (!this.password) {
112
+ this.message = 'Please enter a password';
113
+ } else if (this.password.length < 8) {
114
+ this.message = 'Password must be at least 8 characters long';
115
+ } else {
116
+ this.message = `Password entered:`;
117
+
118
+ if (!/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/.test(this.password)) {
119
+ this.message = 'Password must include letters, numbers, and be 8+ characters';
120
+ } else {
121
+
122
+ if (auth.currentUser) { this.updatePass(this.password); }
123
+ else { alert('Please Login'); }
124
+
125
+ }
126
+
127
+ }
128
+
129
+ }
130
+
131
+ // Firebase Password Function
132
+ private updatePass = async (newPassword:any) => {
133
+
134
+ if (auth.currentUser) {
135
+
136
+ // Update new password
137
+ await updatePassword ( auth.currentUser, newPassword )
138
+ .then ( () => { console.log("Password successful!"); })
139
+ .catch ( (error) => { console.log("Problem: "+ error.messge) }); //alertPassword(error); });
140
+
141
+ } else { alert('Please Login'); }
142
+
143
+ }
144
+
145
+ }
146
+
147
+ customElements.define('input-password', InputPassword);
148
+
149
+ declare global {
150
+ interface HTMLElementTagNameMap {
151
+ 'input-password': InputPassword;
152
+ }
153
+ }
154
+
155
+
156
+ // grid-template-rows: auto auto auto auto auto;