pwa-auth 3.4.9 → 3.5.1

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 (235) hide show
  1. package/LICENSES.txt +18 -23
  2. package/README.md +547 -326
  3. package/base/api/drawer.d.ts +4 -0
  4. package/base/api/drawer.d.ts.map +1 -0
  5. package/base/api/drawer.js +12 -0
  6. package/base/api/drawer.js.map +1 -0
  7. package/base/api/user.d.ts +4 -0
  8. package/base/api/user.d.ts.map +1 -0
  9. package/base/api/user.js +25 -0
  10. package/base/api/user.js.map +1 -0
  11. package/base/api/verify.d.ts +4 -0
  12. package/base/api/verify.d.ts.map +1 -0
  13. package/base/api/verify.js +113 -0
  14. package/base/api/verify.js.map +1 -0
  15. package/base/deprecated/email-changed.d.ts +5 -0
  16. package/base/deprecated/email-changed.d.ts.map +1 -0
  17. package/base/deprecated/email-changed.js +9 -0
  18. package/base/deprecated/email-changed.js.map +1 -0
  19. package/base/events/emit.d.ts +12 -0
  20. package/base/events/emit.d.ts.map +1 -0
  21. package/base/events/emit.js +30 -0
  22. package/base/events/emit.js.map +1 -0
  23. package/base/events/names.d.ts +31 -0
  24. package/base/events/names.d.ts.map +1 -0
  25. package/base/events/names.js +31 -0
  26. package/base/events/names.js.map +1 -0
  27. package/base/events/types.d.ts +71 -0
  28. package/base/events/types.d.ts.map +1 -0
  29. package/base/events/types.js +2 -0
  30. package/base/events/types.js.map +1 -0
  31. package/base/export/pwa-auth.d.ts +17 -7
  32. package/base/export/pwa-auth.d.ts.map +1 -0
  33. package/base/export/pwa-auth.js +13 -7
  34. package/base/export/pwa-auth.js.map +1 -1
  35. package/base/firebase/attribute.d.ts +2 -0
  36. package/base/firebase/attribute.d.ts.map +1 -0
  37. package/base/firebase/attribute.js +17 -0
  38. package/base/firebase/attribute.js.map +1 -0
  39. package/base/firebase/authentication.d.ts +21 -10
  40. package/base/firebase/authentication.d.ts.map +1 -0
  41. package/base/firebase/authentication.js +65 -8
  42. package/base/firebase/authentication.js.map +1 -1
  43. package/base/firebase/interface.d.ts +7 -1
  44. package/base/firebase/interface.d.ts.map +1 -0
  45. package/base/firebase/interface.js +99 -68
  46. package/base/firebase/interface.js.map +1 -1
  47. package/base/firebase/message.d.ts +2 -0
  48. package/base/firebase/message.d.ts.map +1 -0
  49. package/base/firebase/message.js +34 -0
  50. package/base/firebase/message.js.map +1 -0
  51. package/base/firebase/password.d.ts +11 -0
  52. package/base/firebase/password.d.ts.map +1 -0
  53. package/base/firebase/password.js +16 -0
  54. package/base/firebase/password.js.map +1 -0
  55. package/base/lazyLoader.d.ts +1 -0
  56. package/base/lazyLoader.d.ts.map +1 -0
  57. package/base/redux/backend.d.ts +1 -0
  58. package/base/redux/backend.d.ts.map +1 -0
  59. package/base/redux/backend.js +1 -1
  60. package/base/redux/backend.js.map +1 -1
  61. package/base/redux/frontend.d.ts +16 -1
  62. package/base/redux/frontend.d.ts.map +1 -0
  63. package/base/redux/frontend.js +6 -3
  64. package/base/redux/frontend.js.map +1 -1
  65. package/base/store.d.ts +1 -6
  66. package/base/store.d.ts.map +1 -0
  67. package/base/store.js +2 -4
  68. package/base/store.js.map +1 -1
  69. package/base/webcomponents/css/animation.d.ts +1 -0
  70. package/base/webcomponents/css/animation.d.ts.map +1 -0
  71. package/base/webcomponents/css/animation.js +79 -67
  72. package/base/webcomponents/css/animation.js.map +1 -1
  73. package/base/webcomponents/css/svg.d.ts +1 -2
  74. package/base/webcomponents/css/svg.d.ts.map +1 -0
  75. package/base/webcomponents/css/svg.js +2 -4
  76. package/base/webcomponents/css/svg.js.map +1 -1
  77. package/base/webcomponents/css/tap.d.ts +3 -0
  78. package/base/webcomponents/css/tap.d.ts.map +1 -0
  79. package/base/webcomponents/css/tap.js +9 -0
  80. package/base/webcomponents/css/tap.js.map +1 -0
  81. package/base/webcomponents/css/toggle.d.ts +1 -0
  82. package/base/webcomponents/css/toggle.d.ts.map +1 -0
  83. package/base/webcomponents/css/toggle.js +5 -5
  84. package/base/webcomponents/drawer/css/drawer.d.ts +1 -0
  85. package/base/webcomponents/drawer/css/drawer.d.ts.map +1 -0
  86. package/base/webcomponents/drawer/css/drawer.js +101 -74
  87. package/base/webcomponents/drawer/css/drawer.js.map +1 -1
  88. package/base/webcomponents/drawer/css/exit.d.ts +1 -0
  89. package/base/webcomponents/drawer/css/exit.d.ts.map +1 -0
  90. package/base/webcomponents/drawer/css/exit.js +58 -52
  91. package/base/webcomponents/drawer/css/exit.js.map +1 -1
  92. package/base/webcomponents/drawer/css/link.d.ts +1 -0
  93. package/base/webcomponents/drawer/css/link.d.ts.map +1 -0
  94. package/base/webcomponents/drawer/css/link.js +9 -10
  95. package/base/webcomponents/drawer/css/link.js.map +1 -1
  96. package/base/webcomponents/drawer/css/paragraph.d.ts +1 -0
  97. package/base/webcomponents/drawer/css/paragraph.d.ts.map +1 -0
  98. package/base/webcomponents/drawer/css/paragraph.js +37 -20
  99. package/base/webcomponents/drawer/css/paragraph.js.map +1 -1
  100. package/base/webcomponents/drawer/drawer.d.ts +21 -7
  101. package/base/webcomponents/drawer/drawer.d.ts.map +1 -0
  102. package/base/webcomponents/drawer/drawer.js +292 -90
  103. package/base/webcomponents/drawer/drawer.js.map +1 -1
  104. package/base/webcomponents/drawer/keys.d.ts +4 -0
  105. package/base/webcomponents/drawer/keys.d.ts.map +1 -0
  106. package/base/webcomponents/drawer/keys.js +57 -0
  107. package/base/webcomponents/drawer/keys.js.map +1 -0
  108. package/base/webcomponents/form/css/button.d.ts +1 -0
  109. package/base/webcomponents/form/css/button.d.ts.map +1 -0
  110. package/base/webcomponents/form/css/button.js +69 -51
  111. package/base/webcomponents/form/css/button.js.map +1 -1
  112. package/base/webcomponents/form/css/input.d.ts +1 -0
  113. package/base/webcomponents/form/css/input.d.ts.map +1 -0
  114. package/base/webcomponents/form/css/input.js +22 -21
  115. package/base/webcomponents/form/css/input.js.map +1 -1
  116. package/base/webcomponents/form/css/label.d.ts +1 -0
  117. package/base/webcomponents/form/css/label.d.ts.map +1 -0
  118. package/base/webcomponents/form/css/label.js +22 -21
  119. package/base/webcomponents/form/css/label.js.map +1 -1
  120. package/base/webcomponents/form/css/list.d.ts +1 -0
  121. package/base/webcomponents/form/css/list.d.ts.map +1 -0
  122. package/base/webcomponents/form/css/list.js +19 -19
  123. package/base/webcomponents/form/css/notice.d.ts +3 -0
  124. package/base/webcomponents/form/css/notice.d.ts.map +1 -0
  125. package/base/webcomponents/form/css/notice.js +20 -0
  126. package/base/webcomponents/form/css/notice.js.map +1 -0
  127. package/base/webcomponents/form/css/status.d.ts +4 -0
  128. package/base/webcomponents/form/css/status.d.ts.map +1 -0
  129. package/base/webcomponents/form/css/status.js +44 -0
  130. package/base/webcomponents/form/css/status.js.map +1 -0
  131. package/base/webcomponents/form/css/toggle.d.ts +1 -0
  132. package/base/webcomponents/form/css/toggle.d.ts.map +1 -0
  133. package/base/webcomponents/form/css/toggle.js +43 -17
  134. package/base/webcomponents/form/css/toggle.js.map +1 -1
  135. package/base/webcomponents/form/draft.d.ts +5 -0
  136. package/base/webcomponents/form/draft.d.ts.map +1 -0
  137. package/base/webcomponents/form/draft.js +22 -0
  138. package/base/webcomponents/form/draft.js.map +1 -0
  139. package/base/webcomponents/form/forgot.d.ts +26 -3
  140. package/base/webcomponents/form/forgot.d.ts.map +1 -0
  141. package/base/webcomponents/form/forgot.js +297 -30
  142. package/base/webcomponents/form/forgot.js.map +1 -1
  143. package/base/webcomponents/form/letters.d.ts +3 -0
  144. package/base/webcomponents/form/letters.d.ts.map +1 -0
  145. package/base/webcomponents/form/letters.js +21 -0
  146. package/base/webcomponents/form/letters.js.map +1 -0
  147. package/base/webcomponents/form/login.d.ts +10 -0
  148. package/base/webcomponents/form/login.d.ts.map +1 -0
  149. package/base/webcomponents/form/login.js +221 -89
  150. package/base/webcomponents/form/login.js.map +1 -1
  151. package/base/webcomponents/form/notice.d.ts +4 -0
  152. package/base/webcomponents/form/notice.d.ts.map +1 -0
  153. package/base/webcomponents/form/notice.js +14 -0
  154. package/base/webcomponents/form/notice.js.map +1 -0
  155. package/base/webcomponents/form/reveal.d.ts +3 -0
  156. package/base/webcomponents/form/reveal.d.ts.map +1 -0
  157. package/base/webcomponents/form/reveal.js +14 -0
  158. package/base/webcomponents/form/reveal.js.map +1 -0
  159. package/base/webcomponents/form/signup.d.ts +8 -0
  160. package/base/webcomponents/form/signup.d.ts.map +1 -0
  161. package/base/webcomponents/form/signup.js +201 -100
  162. package/base/webcomponents/form/signup.js.map +1 -1
  163. package/base/webcomponents/form/verified.d.ts +3 -0
  164. package/base/webcomponents/form/verified.d.ts.map +1 -0
  165. package/base/webcomponents/form/verified.js +45 -0
  166. package/base/webcomponents/form/verified.js.map +1 -0
  167. package/base/webcomponents/icon/css/icon.d.ts +1 -0
  168. package/base/webcomponents/icon/css/icon.d.ts.map +1 -0
  169. package/base/webcomponents/icon/css/icon.js +63 -49
  170. package/base/webcomponents/icon/css/icon.js.map +1 -1
  171. package/base/webcomponents/icon/icon.d.ts +6 -4
  172. package/base/webcomponents/icon/icon.d.ts.map +1 -0
  173. package/base/webcomponents/icon/icon.js +48 -27
  174. package/base/webcomponents/icon/icon.js.map +1 -1
  175. package/base/webcomponents/login/css/auth.d.ts +1 -0
  176. package/base/webcomponents/login/css/auth.d.ts.map +1 -0
  177. package/base/webcomponents/login/css/auth.js +37 -36
  178. package/base/webcomponents/login/css/auth.js.map +1 -1
  179. package/base/webcomponents/login/css/link.d.ts +1 -0
  180. package/base/webcomponents/login/css/link.d.ts.map +1 -0
  181. package/base/webcomponents/login/css/link.js +9 -10
  182. package/base/webcomponents/login/css/link.js.map +1 -1
  183. package/base/webcomponents/login/css/paragraph.d.ts +1 -0
  184. package/base/webcomponents/login/css/paragraph.d.ts.map +1 -0
  185. package/base/webcomponents/login/css/paragraph.js +8 -8
  186. package/base/webcomponents/login/page.d.ts +10 -6
  187. package/base/webcomponents/login/page.d.ts.map +1 -0
  188. package/base/webcomponents/login/page.js +96 -55
  189. package/base/webcomponents/login/page.js.map +1 -1
  190. package/base/webcomponents/settings/css/navigation.d.ts +1 -0
  191. package/base/webcomponents/settings/css/navigation.d.ts.map +1 -0
  192. package/base/webcomponents/settings/css/navigation.js +78 -68
  193. package/base/webcomponents/settings/css/navigation.js.map +1 -1
  194. package/base/webcomponents/settings/input/delete.d.ts +7 -6
  195. package/base/webcomponents/settings/input/delete.d.ts.map +1 -0
  196. package/base/webcomponents/settings/input/delete.js +135 -48
  197. package/base/webcomponents/settings/input/delete.js.map +1 -1
  198. package/base/webcomponents/settings/input/email.d.ts +7 -5
  199. package/base/webcomponents/settings/input/email.d.ts.map +1 -0
  200. package/base/webcomponents/settings/input/email.js +155 -50
  201. package/base/webcomponents/settings/input/email.js.map +1 -1
  202. package/base/webcomponents/settings/input/name.d.ts +8 -5
  203. package/base/webcomponents/settings/input/name.d.ts.map +1 -0
  204. package/base/webcomponents/settings/input/name.js +116 -53
  205. package/base/webcomponents/settings/input/name.js.map +1 -1
  206. package/base/webcomponents/settings/input/password.d.ts +8 -5
  207. package/base/webcomponents/settings/input/password.d.ts.map +1 -0
  208. package/base/webcomponents/settings/input/password.js +200 -103
  209. package/base/webcomponents/settings/input/password.js.map +1 -1
  210. package/base/webcomponents/settings/input/uploader.d.ts +8 -6
  211. package/base/webcomponents/settings/input/uploader.d.ts.map +1 -0
  212. package/base/webcomponents/settings/input/uploader.js +209 -170
  213. package/base/webcomponents/settings/input/uploader.js.map +1 -1
  214. package/base/webcomponents/settings/input/verify.d.ts +64 -0
  215. package/base/webcomponents/settings/input/verify.d.ts.map +1 -0
  216. package/base/webcomponents/settings/input/verify.js +272 -0
  217. package/base/webcomponents/settings/input/verify.js.map +1 -0
  218. package/base/webcomponents/settings/settings.d.ts +15 -10
  219. package/base/webcomponents/settings/settings.d.ts.map +1 -0
  220. package/base/webcomponents/settings/settings.js +226 -147
  221. package/base/webcomponents/settings/settings.js.map +1 -1
  222. package/firebase.md +107 -0
  223. package/intro.md +19 -0
  224. package/license +21 -21
  225. package/package.json +116 -71
  226. package/source/pwa-auth.js +1098 -407
  227. package/source/pwa-styles.css +50 -68
  228. package/base/redux/drawer.d.ts +0 -17
  229. package/base/redux/drawer.js +0 -22
  230. package/base/redux/drawer.js.map +0 -1
  231. package/demonstration/index.html +0 -99
  232. package/demonstration/pwa-styles.css +0 -77
  233. package/demonstration/styles.css +0 -77
  234. package/notes.md +0 -11
  235. package/source/THIRD_PARTY_LICENSES.txt +0 -303
package/README.md CHANGED
@@ -1,326 +1,547 @@
1
- Progressive Website Application - Authentication
2
- ======================
3
- Jack's Publishing maintains Website Authentication Components where developers can focus on their User interface, rather than low-level API calls. Visit the [Live Demo](https://pwa-authentic.firebaseapp.com).
4
-
5
- pwa-auth.js is a bundle of 5 Custom HTML Elements for Firebase (IAM) Authenication using email and password, with the ability to change username, icon, email, password, or delete your own account and it's content all together.
6
-
7
- Quickly sign-up, log-in, log-out, modify, or delete your firebase account.
8
-
9
- Place 5 Custom HTML Tags, reference CSS, and Initialize a Firebase Instance. By either <b>Standard</b> or <b>Modular</b> ECMA Script.
10
-
11
- Continue reading to understand how to install this project:
12
-
13
- ## Prerequisites
14
- - Google
15
- - Analytics
16
- - Firebase Authentication
17
- - Email Login
18
- - Firebase Cloud Storage
19
- - Storage Bucket
20
-
21
- ## Outline
22
- - Register through Email and Password
23
- - Log-in
24
- - Log-out
25
- - Change Username
26
- - Change Email
27
- - Change Password
28
- - Upload Profile Picture
29
- - Delete Account
30
-
31
- ## Library
32
- - script-context
33
- - module-context
34
- ```javascript
35
- // Import ES Modules
36
- import 'pwa-auth';
37
-
38
- // Import Firebase Objects
39
- import {
40
- auth,
41
- db,
42
- user,
43
- storage,
44
- application,
45
- firebaseConfig
46
- } from "pwa-auth";
47
-
48
- // Import Functions
49
- import {
50
- logOut,
51
- logAccount,
52
- logAccountDelete,
53
- deleteDocument,
54
- pwaDrawerToggle
55
- } from "pwa-auth";
56
-
57
- // Optional - copy CoreJS files
58
- './npm/pwa-auth/source/**/*'
59
-
60
- // Global Login Object
61
- window.process = { env: { FIREBASE_CONFIG: JSON.stringify({
62
- apiKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
63
- authDomain: "xxxxxxx.xxxxxxx.xxx",
64
- databaseURL: "https://xxxxxxx.xxxxxxx.xxx",
65
- projectId: "xxxxxxx",
66
- storageBucket: "xxxxxxx.xxxxxxx.xxx",
67
- messagingSenderId: "xxxxxxxxxxx",
68
- appId: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
69
- measurementId: "xxxxxxxxxxx"
70
- })
71
- }};
72
-
73
- if (localhost) { window.process = { env: { FIREBASE_CONFIG: 'etc.' } } }
74
-
75
- ```
76
-
77
- ## Technical Summary
78
- - Type Strong with [TypeScript](https://www.typescriptlang.org)
79
- - Stylable with [CSS Custom Properties](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_cascading_variables/Using_CSS_custom_properties)
80
- - State Management with [ReduxJS](https://redux.js.org/)
81
- - Authentication with Google's [Firebase](https://www.firebase.com)
82
- - Firebase Initialization Object: `window.process = { env: { FIREBASE_CONFIG: `
83
-
84
- ## Atomic Engineering
85
- - Development (Server-side) Environment: [Node JavaScript](https://nodejs.org)
86
- - Backend: Google Cloud: [Firebase](https://firebase.google.com/)
87
- - Predicate State Behavior: [Redux](https://redux.js.org/)
88
- - Frontend (Client-side): [Lit](https://lit.dev)
89
-
90
- ## Enrichment
91
- - Development
92
- - Redux State Connection
93
- - Global Functions
94
- - Optional
95
- - Custom Properties
96
-
97
- ## Website Components
98
- - Button
99
- - `<user-icon>`
100
- - Email Log-in
101
- - Email Subscribe
102
- - Icon
103
- - Drop-down Drawer
104
- - `<user-drawer>`
105
- - Email Log-in
106
- - Email Subscribe
107
- - Menu with Log-out
108
- - Logged-in Menu Content `<slot>`'s
109
- - name: before
110
- - name: within
111
- - Pages
112
- - `<user-settings>`
113
- - Account Settings Page
114
- - `<user-login>`
115
- - Email Log-in Page
116
- - Email Subscribe Page
117
- - Logged-in Page Content `<slot>`'s
118
- - name: content
119
- - `<email-reset>`
120
- - Password Reset Page
121
-
122
- ## Observer Patterns
123
- - `<user-icon>`
124
- - property: subscribe: (Initial State): Subscribe
125
- - property: subscribe: else (Initial State): Login
126
- - property: empty: location of empty image
127
- - `<user-drawer>`
128
- - feature: Top-down drawer: 1.4 seconds
129
- - property: **url**: location of `<pwa-settings>` Tag
130
- - property: subscribe: (Initial State): Subscribe
131
- - property: subscribe: else (Initial State): Login
132
- - `<user-login>`
133
- - feature: regular visible page component
134
- - `<user-settings>`
135
- - 1 Photo Upload Feature, view uploaded bucket of photos, photo ediotr
136
- - empty property: location of empty image
137
- - Unavailable Photo
138
- - Update Username
139
- - Update Email / Verify
140
- - Update Password
141
- - Delete Account, Photos, Information
142
-
143
- ## Logical States
144
- - `<user-icon>`
145
- - Logged-out: txt: Login Button
146
- - Logged-out: txt: Subscribe Button
147
- - Logged-in, photo: Icon Button
148
- - `<user-drawer>`
149
- - logged-out: Sign-up by Email Addresses and Password
150
- - logged-out: Sign-in by Email Addresses and Password
151
- - logged-in: Settings Page Link, Log-out Button
152
- - `<user-login>`
153
- - logged-out: Sign-up by Email Addresses and Password
154
- - logged-out: Sign-in by Email Addresses and Password
155
- - logged-in, content: `<slot></slot>`
156
-
157
- ## Firebase Instance Configuration
158
- pwa-auth.js is built upon the Firebase SDK (Software Development Kit).
159
- The entire bundle is one instance of firebase that takes in the configuration information, internally.
160
-
161
- ## Boilerplate
162
- ```html
163
- <head>
164
-
165
- <!-- Optional - CSS Custom Variables-->
166
- <link type="stylesheet" href="./path_to/pwa-styles.css">
167
-
168
- <!-- Required - Configure Firebase Instance -->
169
- <script>
170
- window.process = { env: { FIREBASE_CONFIG: JSON.stringify({
171
- apiKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
172
- authDomain: "xxxxxxx.xxxxxxx.xxx",
173
- databaseURL: "https://xxxxxxx.xxxxxxx.xxx",
174
- projectId: "xxxxxxx",
175
- storageBucket: "xxxxxxx.xxxxxxx.xxx",
176
- messagingSenderId: "xxxxxxxxxxx",
177
- appId: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
178
- measurementId: "xxxxxxxxxxx"
179
- })
180
- }
181
- };
182
-
183
- if (lolalhost) { window.process = { env: { FIREBASE_CONFIG: 'etc.' } } }
184
- </script>
185
-
186
- <!-- Optional: Copy the Project Files from 'source' Folder -->
187
- <script type="module" src="./path_to/pwa-auth.js"></script>
188
-
189
- <!-- Optional: Custom CSS Properties -->
190
- <style>
191
-
192
- /* <user-icon> */
193
- :root {
194
- --pwa_icon_background_color: #6cc04a;
195
- --pwa_icon_radius: 6px;
196
- --pwa_icon_border: 2px solid black;
197
- --pwa_icon_padding: 0px 16px;
198
- --pwa_icon_hover_color: lightgrey;
199
- --pwa_icon_font: 'Arial', sans-serif;
200
- --pwa_icon_height: 32px; /* state: Logged-out (sync) */
201
- --pwa_icon_diameter: 32px; /* state: Logged-in (sync) */
202
- }
203
-
204
- /* <user-drawer> */
205
- :root {
206
- --pwa_drawer_background_color: #fff;
207
- --pwa_drawer_border-radius: 0px;
208
- --pwa_drawer_border: 3px #303030 solid;
209
- --pwa_drawer_z-index: 2;
210
- --pwa_drawer_text_color: #303030;
211
- --pwa_drawer_position: fixed;
212
- }
213
-
214
- /* <user-settings> */
215
- :root {
216
- --pwa_settings_background_color: grey;
217
-
218
- --pwa_nav_button_color: grey;
219
- --pwa_nav_highlight_color: black;
220
-
221
- --pwa_divider_color: grey;
222
- --pwa_header_color: black;
223
-
224
- --pwa_input_background_color: #E1E5EB;
225
-
226
- --pwa_label_text_color: black;
227
-
228
- --pwa_button_text_color: #fff;
229
- --pwa_button_background_color: #6cc04a;
230
- --pwa_button_border_color: #60b23e;
231
- }
232
-
233
- /* shared core elements */
234
- :root {
235
- --section_background_color: white;
236
- }
237
-
238
- </style>
239
-
240
- </head>
241
- ```
242
-
243
- ## Project Type: ECMA Script Modules
244
- Eports: classes and objects
245
- ```javascript
246
- // Custom HTML Element Classes
247
- import 'pwa-auth';
248
- `<user-icon>` // subscribe | empty= "./images/empty.jpg"
249
- `<user-drawer>` // subscribe | url= "./settings"
250
- `<user-settings>` // empty= "./images/empty.jpg"
251
- `<user-login>` // subscribe |
252
-
253
- // Firebase Objects
254
- import { db, storage, auth, user } from 'pwa-auth';
255
- // db - firestore database reference
256
- // storage - firebase storage reference
257
- // auth - user object reference
258
- // user - active user boolean reference
259
-
260
- // Firebase-Redux States
261
- import { store } from 'pwa-auth';
262
- // store.verified
263
- // store.userId
264
- // store.name
265
- // store.email
266
- // store.photoURL
267
-
268
- export { logOut, logAccount, logAccountDelete, deleteDocument } from "pwa-auth";
269
- // logOut() - Firebase Authentication: log user out
270
- // logAccount() - Google Analytics Signal: logEvent(analytics, 'create_account');
271
- // logAccountDelete() - Firebase Authentication: delete account
272
- // deleteDocument() - Firebase Storage and Firestore:
273
- ```
274
-
275
- ## Drawer Implementation
276
- ```html
277
- <body>
278
-
279
- <header>
280
- <user-icon subscribe empty="./images/empty.jpg"></user-icon>
281
- </header>
282
-
283
- <user-drawer subscribe url="./settings">
284
- <!-- before content slot -->
285
- <div slot="before">
286
- <a>Link Name</a>
287
- </div>
288
- <!-- default slot -->
289
- </user-drawer>
290
-
291
- <main>
292
- <user-settings empty="./images/empty.jpg"></user-settings>
293
- </main>
294
-
295
- </body>
296
- ```
297
-
298
- ## Page Implementation
299
- ```html
300
- <body>
301
-
302
- <header>
303
- <user-icon empty="./images/empty.jpg" subscribe ></user-icon>
304
- </header>
305
-
306
- <main>
307
-
308
- <user-login subscribe>
309
- <div slot="content">
310
- <p>Page Content</p>
311
- </div>
312
- </user-login>
313
-
314
- <user-settings empty="./images/empty.jpg"></user-settings>
315
-
316
- </main>
317
-
318
- </body>
319
- ```
320
-
321
- ## Feedback
322
- All feedback, comments, bugs, and requests are welcome.
323
- * [Jack's Publishing](https://www.jackspublishing.com)
324
- * [contractor's centre](https://www.contractorscentre.com)
325
- * [Node Package Manager](https://www.npmjs.com/package/pwa-auth)
326
- * [Sponsor Jacek Markiewicz](https://github.com/sponsors/busynest/button)
1
+ # pwa-auth
2
+
3
+ [![npm version](https://img.shields.io/npm/v/pwa-auth)](https://www.npmjs.com/package/pwa-auth)
4
+ [![license](https://img.shields.io/badge/license-MIT-blue)](license)
5
+
6
+ Site owners can start with [a short introduction](intro.md).
7
+
8
+ Jack's Publishing maintains sign-in and account components so a site can stay on its own interface. [Live demo](https://pwa-authentic.firebaseapp.com).
9
+
10
+ Five elements: `user-icon`, `user-drawer`, `user-login`, `user-settings`, and `email-reset`. They sign a person up, sign them in, and let them change name, email, password, and photo, or delete the account. Email and password only. Sign-up sends a verification email. Sign-in still succeeds when that address is unverified. One Firebase session, shared by every tag on the page.
11
+
12
+ Place the tags. Set Firebase with the script or `initialize()`. Listen for `pwa-` events, or call the small API (`getCurrentUser`, `onUserChanged`, `openDrawer`, `closeDrawer`, `toggleDrawer`). Restyle with `--pwa_` variables.
13
+
14
+ Peers: `lit` ^3.3.0 and `firebase` ^12.0.0. The package is ESM (`"type": "module"`).
15
+
16
+ ## Contents
17
+
18
+ - [Quick start](#quick-start)
19
+ - [Install & entries](#install--entries)
20
+ - [Firebase](firebase.md)
21
+ - [Elements](#elements)
22
+ - [Page examples](#page-examples)
23
+ - [Events](#events)
24
+ - [API](#api)
25
+ - [Exports](#exports)
26
+ - [Theme](#theme)
27
+ - [Parts](#parts)
28
+ - [Drawer behaviour](#drawer-behaviour)
29
+ - [Data ownership](#data-ownership)
30
+ - [Contributing](#contributing)
31
+ - [Feedback](#feedback)
32
+
33
+ ## Quick start
34
+
35
+ Install the package and the peers. Serve this page from the project root. Do not open it with `file://`.
36
+
37
+ ```bash
38
+ npm install pwa-auth lit firebase
39
+ ```
40
+
41
+ ```html
42
+ <user-icon></user-icon>
43
+ <user-drawer></user-drawer>
44
+ <script>
45
+ window.process = { env: { FIREBASE_CONFIG: JSON.stringify({
46
+ apiKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
47
+ authDomain: "xxxxxxx.xxxxxxx.xxx",
48
+ databaseURL: "https://xxxxxxx.xxxxxxx.xxx",
49
+ projectId: "xxxxxxx",
50
+ storageBucket: "xxxxxxx.xxxxxxx.xxx",
51
+ messagingSenderId: "xxxxxxxxxxx",
52
+ appId: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
53
+ measurementId: "xxxxxxxxxxx"
54
+ }) } };
55
+ </script>
56
+ <script type="module" src="./node_modules/pwa-auth/source/pwa-auth.js"></script>
57
+ ```
58
+
59
+ The module script loads the production bundle. Lit and Firebase are already in the file. A bundler imports `pwa-auth` instead. See [Install & entries](#install--entries). Setup for that script, including `initialize({ config })`, is in [firebase.md](firebase.md).
60
+
61
+ ## Install & entries
62
+
63
+ ```bash
64
+ npm install pwa-auth lit firebase
65
+ ```
66
+
67
+ `lit` and `firebase` are peers. Redux ships inside the package.
68
+
69
+ Two entries.
70
+
71
+ A bundler (Vite, Rollup, webpack) loads the tsc graph. The peers stay outside the bundle. Install them.
72
+
73
+ ```javascript
74
+ import 'pwa-auth';
75
+ ```
76
+
77
+ `pwa-auth` resolves to `base/export/pwa-auth.js`.
78
+
79
+ A plain module script loads one file. Lit and Firebase are inside it. From the project root:
80
+
81
+ ```html
82
+ <script type="module" src="./node_modules/pwa-auth/source/pwa-auth.js"></script>
83
+ ```
84
+
85
+ The same file, when a bundler asks for it:
86
+
87
+ ```javascript
88
+ import 'pwa-auth/production';
89
+ ```
90
+
91
+ `pwa-auth/production` resolves to `source/pwa-auth.js`.
92
+
93
+ ## Firebase
94
+
95
+ Project setup, `initialize({ config })`, `FIREBASE_CONFIG`, rules, and emulators are in [firebase.md](firebase.md).
96
+
97
+ ## Elements
98
+
99
+ Importing the package defines all five.
100
+
101
+ ### `<user-icon>`
102
+
103
+ The button that opens the drawer.
104
+
105
+ | Attribute | |
106
+ |---|---|
107
+ | `subscribe` | Logged-out label is Subscribe. Without it, the label is Login. |
108
+ | `empty` | Image URL used when the account has no photo and no name or email to initial. |
109
+
110
+ Logged in, the button shows the photo. With no photo, it shows initials from the display name, or from the email. `empty` is the last fallback. The click opens or closes the drawer. Style it with `user-icon::part(button)`, `user-icon::part(photo)`, and `user-icon::part(initials)`.
111
+
112
+ ### `<user-drawer>`
113
+
114
+ Drops open from the top. Timing is in [Drawer behaviour](#drawer-behaviour).
115
+
116
+ | Attribute | |
117
+ |---|---|
118
+ | `subscribe` | Starts on the sign-up form. Without it, starts on sign-in. |
119
+ | `url` | `href` of the Settings control shown after sign-in. Set it only when that page is a real route. Leave it unset when `<user-settings>` is already on this page. |
120
+ | `drawer` | Reflects the open state. Redux overwrites it. Do not treat it as an input. |
121
+
122
+ Logged out, the header reads Subscribe or Login to match the form. The slots are in the signed-in block, so they are not shown until someone is signed in. Logged in, the header shows the display name, or the email when the account has no name, then, in this order:
123
+
124
+ 1. slot `before`
125
+ 2. Settings (`url`, or the button that stays on this page)
126
+ 3. the default slot
127
+ 4. Log out
128
+
129
+ There is no slot named `within`. The second slot is the default slot.
130
+
131
+ Each slot has fallback text so the host can see where a link will sit: `slotted - before` in the before slot, `slotted - default` in the default slot. Pass a link or a button and that marker is replaced.
132
+
133
+ ```html
134
+ <user-drawer>
135
+ <a slot="before" href="/account">Account</a>
136
+ <a href="/archive" aria-current="page">Archive</a>
137
+ </user-drawer>
138
+ ```
139
+
140
+ `::slotted(a)` and `::slotted(button)` share one style: a full-width row, the line colour, and a 44px tap target. `aria-current` on either one uses the nav highlight. A click on a slotted link or button closes the drawer, the same as Settings. Call `preventDefault()` on that click to leave the drawer open.
141
+
142
+ `url` is only the Settings control. It is not the slot. Leave `url` unset when `<user-settings>` is on this page. Set `url` when Settings is a real route. Slotted links are the host's own pages.
143
+
144
+ Slotted links can flash before the element upgrades. Hide them:
145
+
146
+ ```css
147
+ /* Optional - hide slotted links until user-drawer upgrades */
148
+ user-drawer:not(:defined) { display: none; }
149
+ ```
150
+
151
+ Settings does not assume a `/settings` route. With `url` unset, it is a button. The click closes the drawer, scrolls to `<user-settings>` when that element is on the page, and dispatches `pwa-settings` with `{ url: '' }`. The event is cancelable. Call `preventDefault()` to keep the drawer open and skip the scroll. With `url` set, Settings is a link to that href, and the same event carries `{ url }`.
152
+
153
+ ### `<user-login>`
154
+
155
+ The same forms, in the page instead of the drawer.
156
+
157
+ | Attribute | |
158
+ |---|---|
159
+ | `subscribe` | Starts on sign-up. Without it, starts on sign-in. |
160
+
161
+ Sign-in calls `signInWithEmailAndPassword` and sends the password as typed. Sign-up rejects a new password shorter than 8 characters or longer than 128. Spaces and other characters are allowed. The field hint reads "At least 8 characters. A passphrase works well." A failed sign-in or sign-up writes one sentence into an `aria-live` region (`::part(status)`). The button is disabled and reads Signing in… or Creating account… while the request is in flight.
162
+
163
+ Forgot password? sits on the sign-in form. It calls `sendPasswordResetEmail` for the address already in the email field. Success shows the same sentence as `<email-reset>`: "If an account uses that email, a reset link is on its way." A missing account gets that sentence too. The page dispatches `pwa-reset-sent`.
164
+
165
+ Sign-up calls `sendEmailVerification`. `actionCodeSettings` from `initialize` is passed through when it is set. The form shows "Check your inbox for the verification email. You can still sign in." The same notice stays on `<user-login>` and in the drawer until the address is verified.
166
+
167
+ Each password field has a Show control. Logged in, the forms are replaced by slot `content`.
168
+
169
+ ```html
170
+ <user-login>
171
+ <div slot="content">
172
+ <p>Page content</p>
173
+ </div>
174
+ </user-login>
175
+ ```
176
+
177
+ ### `<user-settings>`
178
+
179
+ Four tabs: Icon, Profile, Password, Delete.
180
+
181
+ | Attribute | |
182
+ |---|---|
183
+ | `empty` | Fallback photo, passed through to the uploader as `emptyArtwork`. |
184
+
185
+ Signed out, the element shows one line: sign in to change the photo, name, email, or password. The tabs and fields are not in the tree.
186
+
187
+ Profile saves the display name with `updateProfile`. The icon, the drawer, and this panel read that name back. A saved name is still there after the next sign-in.
188
+
189
+ The photo uploads to `pwa-auth/{uid}/`. On completion the status reads Photo saved. and the same URL is the account photo. Initials stand in until a photo exists.
190
+
191
+ A failed action writes a sentence into that tab's `aria-live` region and dispatches `pwa-auth-error`. The Update, Delete, and upload controls disable and read a busy label while the request is in flight.
192
+
193
+ When the signed-in address is unverified:
194
+
195
+ - That tab shows the address, the words Not verified (`::part(unverified)`), and a Resend verification email button (`::part(verify-submit)`).
196
+ - The same words and the same button are in the drawer, next to the name or email.
197
+ - The status (`::part(verify-status)`) is an `aria-live` region.
198
+ - The button reads Sending… while the request is in flight, then waits 45 seconds. The confirmation is "Check your inbox for the verification email."
199
+ - `auth/too-many-requests` and `auth/network-request-failed` write a short sentence into the status region and dispatch `pwa-auth-error`.
200
+ - A verified address shows a check (`::part(verified)`, aria-label Email verified) beside the email in settings and beside the name or email in the drawer. The colour is `--pwa_verified_color`.
201
+ - Opening the drawer, or focusing the window, calls `user.reload()`. When that reload sees the address become verified, the page fires `pwa-email-verified`.
202
+ - Sign-in is not blocked either way.
203
+ - Changing the email calls `verifyBeforeUpdateEmail`. `actionCodeSettings` from `initialize` is passed through. If the address still on the account is unverified, `sendEmailVerification` runs as well.
204
+
205
+ Email, password, and delete ask for the current password and call `reauthenticate` first.
206
+
207
+ - Email then calls `verifyBeforeUpdateEmail`. On success the page dispatches `pwa-email-changed` on `window` with `{ email }`. The old `userEmailChanged` event still fires and is deprecated.
208
+ - Password requires the verify field to match. A new password is 8 to 128 characters, the same rule as sign-up. On success the page dispatches `pwa-password-changed` on `window` with `{ uid }`.
209
+ - Delete removes this user's files under `pwa-auth/{uid}`, calls `logAccountDelete`, then deletes the auth user. It does not delete `users/{uid}`. See [Data ownership](#data-ownership).
210
+ - A failed action writes a short sentence into the status region and dispatches `pwa-auth-error`.
211
+
212
+ ### `<email-reset>`
213
+
214
+ Sends a password reset for the address in the field. The address is checked before `sendPasswordResetEmail`. An empty or short address fires `pwa-auth-error` with `pwa/missing-email`. A malformed address uses `pwa/invalid-email`.
215
+
216
+ While the request is in flight the button is disabled and reads Sending…. Success shows one sentence either way, including when Firebase returns `auth/user-not-found`: "If an account uses that email, a reset link is on its way." The page dispatches `pwa-reset-sent` on `window` with `{ email }`. The button then waits 45 seconds.
217
+
218
+ `auth/invalid-email`, `auth/too-many-requests`, and `auth/network-request-failed` write a short sentence into the status region and dispatch `pwa-auth-error`. The event still carries the Firebase code.
219
+
220
+ If a sign-in form on the page already has an email, the field starts with that address until someone types in the reset field. Back to sign in opens `<user-drawer>` on the sign-in form. With no drawer, it shows the sign-in form in `<user-login>`.
221
+
222
+ | Attribute | |
223
+ |---|---|
224
+ | `active` | Required. The element renders nothing until `active` is set. |
225
+
226
+ ```html
227
+ <email-reset active></email-reset>
228
+ ```
229
+
230
+ ## Page examples
231
+
232
+ ### Drawer page
233
+
234
+ ```html
235
+ <style>
236
+ /* Optional - hide slotted links until user-drawer upgrades */
237
+ user-drawer:not(:defined) { display: none; }
238
+ </style>
239
+
240
+ <body>
241
+ <header>
242
+ <user-icon subscribe></user-icon>
243
+ </header>
244
+
245
+ <user-drawer subscribe>
246
+ <a slot="before" href="#settings">Settings</a>
247
+ <a href="./elsewhere">Another link</a>
248
+ </user-drawer>
249
+
250
+ <main>
251
+ <user-settings id="settings"></user-settings>
252
+ </main>
253
+ </body>
254
+ ```
255
+
256
+ ### Sign-in page
257
+
258
+ ```html
259
+ <body>
260
+ <header>
261
+ <user-icon subscribe></user-icon>
262
+ </header>
263
+
264
+ <main>
265
+ <user-login subscribe>
266
+ <div slot="content">
267
+ <p>Page content</p>
268
+ </div>
269
+ </user-login>
270
+
271
+ <user-settings></user-settings>
272
+ </main>
273
+ </body>
274
+ ```
275
+
276
+ ## Events
277
+
278
+ Global events fire on `window`. `pwa-drawer-toggle` fires on `<user-drawer>`, bubbles, and is `composed`. Every event is a `CustomEvent` with `bubbles: true` and `composed: true`. Names and detail types live in `typescript/events/names.ts` and `typescript/events/types.ts`.
279
+
280
+ - `pwa-auth-changed` — every `onAuthStateChanged`. Detail: `{ user: { uid, displayName, email, photoURL, emailVerified } | null }`
281
+ - `pwa-login` — email sign-in succeeded. Detail: `{ user: { uid, displayName, email, photoURL, emailVerified } }`
282
+ - `pwa-logout` — `logOut()` finished. Detail: `{ user: null }`
283
+ - `pwa-signup` — `createUserWithEmailAndPassword` succeeded. Detail: `{ user: { uid, displayName, email, photoURL, emailVerified } }`
284
+ - `pwa-account-deleted` — the auth user was deleted. Detail: `{ uid }`. The host deletes its own `users/{uid}` document.
285
+ - `pwa-profile-updated` — display name or photo saved. Detail: `{ uid, displayName, photoURL }`
286
+ - `pwa-email-changed` — `verifyBeforeUpdateEmail` accepted the address. Detail: `{ email }`
287
+ - `pwa-password-changed` — `updatePassword` succeeded. Detail: `{ uid }`. The new password is not included.
288
+ - `pwa-reset-sent` — `sendPasswordResetEmail` finished, or the address has no account. Detail: `{ email }`. The same event either way.
289
+ - `pwa-drawer-toggle` — the drawer open flag changed. Detail: `{ open }`
290
+ - `pwa-settings` — Settings was chosen. Detail: `{ url }`. `url` is empty when the control stays on this page. Cancel the event to handle it yourself.
291
+ - `pwa-auth-error` — an account action failed. Detail: `{ code, message }`
292
+ - `pwa-verification-sent` — `sendEmailVerification` accepted the message. Detail: `{ email }`
293
+ - `pwa-email-verified` — a reload saw `emailVerified` become true. Detail: `{ user }` with `user.emailVerified === true`
294
+
295
+ `userEmailChanged` still fires on `window` with `{ email }`. Deprecated. Listen for `pwa-email-changed`.
296
+
297
+ ```javascript
298
+ import { pwaAuthChanged, pwaDrawerToggleName } from 'pwa-auth';
299
+
300
+ window.addEventListener(pwaAuthChanged, (event) => {
301
+ const user = event.detail.user;
302
+ console.log(user && user.uid);
303
+ });
304
+
305
+ window.addEventListener(pwaDrawerToggleName, (event) => {
306
+ console.log(event.detail.open);
307
+ });
308
+ ```
309
+
310
+ ## API
311
+
312
+ ```javascript
313
+ import {
314
+ initialize,
315
+ getCurrentUser,
316
+ onUserChanged,
317
+ sendVerification,
318
+ isEmailVerified,
319
+ openDrawer,
320
+ closeDrawer,
321
+ toggleDrawer,
322
+ eventName
323
+ } from 'pwa-auth';
324
+
325
+ initialize({ config });
326
+
327
+ const stop = onUserChanged((user) => {
328
+ console.log(user && user.emailVerified);
329
+ });
330
+ stop();
331
+
332
+ getCurrentUser();
333
+ await sendVerification();
334
+ await isEmailVerified();
335
+ openDrawer();
336
+ closeDrawer();
337
+ toggleDrawer();
338
+
339
+ window.addEventListener(eventName.login, (event) => {
340
+ console.log(event.detail.user.email);
341
+ });
342
+ ```
343
+
344
+ | Export | |
345
+ |---|---|
346
+ | `initialize({ app, config, actionCodeSettings })` | See [firebase.md](firebase.md). |
347
+ | `getCurrentUser()` | `{ uid, displayName, email, photoURL, emailVerified }` or `null`. |
348
+ | `onUserChanged(callback)` | Calls back with that same shape. Returns `unsubscribe`. |
349
+ | `sendVerification()` | Sends the verification email for the signed-in user. Resolves `true` when Firebase accepts it. Fires `pwa-verification-sent` with `{ email }`. The constant is `pwaVerificationSent`, and `eventName.verificationSent` is the same string. |
350
+ | `isEmailVerified()` | Reloads the signed-in user and resolves `emailVerified`. Fires `pwa-email-verified` when that flag becomes true. The constant is `pwaEmailVerified`, and `eventName.emailVerified` is the same string. |
351
+ | `openDrawer()` | Opens the drawer. |
352
+ | `closeDrawer()` | Closes the drawer. |
353
+ | `toggleDrawer()` | Flips the drawer. |
354
+ | `eventName` | The `pwa-` strings. `eventName.drawerToggle` is `pwa-drawer-toggle`. |
355
+ | `pwaAuthChanged`, `pwaLogin`, `pwaLogout`, `pwaSignup`, `pwaAccountDeleted`, `pwaProfileUpdated`, `pwaEmailChanged`, `pwaPasswordChanged`, `pwaResetSent`, `pwaDrawerToggleName`, `pwaSettings`, `pwaAuthError` | The same strings, one constant each. `pwaDrawerToggleName` is the event. `pwaDrawerToggle()` is the older close function. `pwaSettings` is `pwa-settings`. |
356
+
357
+ `import { store } from 'pwa-auth'` is not a public export. Use `getCurrentUser`, `onUserChanged`, and the events. Account fields stay inside the package.
358
+
359
+ ## Exports
360
+
361
+ ```javascript
362
+ import 'pwa-auth';
363
+
364
+ import {
365
+ auth, db, storage, application, firebaseConfig, user
366
+ } from 'pwa-auth';
367
+
368
+ import {
369
+ logOut, logAccount, logAccountDelete, deleteDocument, pwaDrawerToggle, reauthenticate
370
+ } from 'pwa-auth';
371
+ ```
372
+
373
+ | Export | |
374
+ |---|---|
375
+ | `auth` | See [firebase.md](firebase.md). |
376
+ | `db` | See [firebase.md](firebase.md). |
377
+ | `storage` | See [firebase.md](firebase.md). |
378
+ | `application` | See [firebase.md](firebase.md). |
379
+ | `firebaseConfig` | See [firebase.md](firebase.md). |
380
+ | `user` | Deprecated. Snapshot of `auth.currentUser` taken when `initialize` runs. It stays `null`. Read `getCurrentUser()` at call time. |
381
+ | `logOut()` | `signOut(auth)`. Then `pwa-logout`. |
382
+ | `logAccount()` | Analytics event `create_account`, after Analytics is ready. No event when Analytics is unsupported. |
383
+ | `logAccountDelete()` | Analytics event `delete_account`. It does not delete the account. |
384
+ | `deleteDocument(collect, item)` | Deletes one Firestore document. |
385
+ | `pwaDrawerToggle()` | Closes the drawer. It does not toggle. Prefer `closeDrawer()`. |
386
+ | `reauthenticate(password)` | Confirms the current password before email, password, and delete. Returns true when it succeeds. |
387
+
388
+ `pwa-auth` and `pwa-auth/production` both resolve types to `base/export/pwa-auth.d.ts`. The production entry is the rollup bundle. `lit` and `firebase` are peer dependencies. Redux ships inside the package. `sideEffects` is true because the entry registers the elements. The published `files` list is `base/`, the production bundle, `source/pwa-styles.css`, `source/empty.jpg`, the readme, `intro.md`, `firebase.md`, and the licenses.
389
+
390
+ ## Theme
391
+
392
+ Optional. Link the sheet or set the variables on `:root`. Names below are the ones the components read.
393
+
394
+ ```html
395
+ <link rel="stylesheet" href="./path_to/pwa-styles.css">
396
+ ```
397
+
398
+ The published sheet is `node_modules/pwa-auth/source/pwa-styles.css`.
399
+
400
+ ```css
401
+ :root {
402
+ /* Required - minimum tap target */
403
+ --pwa_tap: 44px;
404
+
405
+ /* <user-icon> */
406
+ --pwa_icon_background_color: #2a6b45;
407
+ --pwa_icon_hover_color: #214f34;
408
+ --pwa_icon_border: 0;
409
+ --pwa_icon_radius: 10px;
410
+ --pwa_icon_padding: 0 18px;
411
+ --pwa_icon_font: "Avenir Next", "Segoe UI", system-ui, sans-serif;
412
+ --pwa_icon_height: 44px; /* logged out, sync to diameter */
413
+ --pwa_icon_diameter: 44px; /* logged in, sync to height */
414
+
415
+ /* Optional - master beat. See Drawer behaviour for the ratios. */
416
+ --pwa_slide_time: 1.4s;
417
+ /* Optional - shared ease for the drawer and the form swap */
418
+ --pwa_slide_ease: ease-in-out;
419
+
420
+ /* <user-drawer> */
421
+ --pwa_drawer_position: absolute;
422
+ --pwa_drawer_background_color: #fffdf8;
423
+ --pwa_drawer_text_color: #1c2430;
424
+ --pwa_drawer_border: 0;
425
+ --pwa_drawer_border-radius: 0 0 18px 18px;
426
+ --pwa_drawer_z-index: 3;
427
+ --pwa_close_color: #9a3b32;
428
+
429
+ /* <user-settings> and <user-login> */
430
+ --pwa_settings_background_color: #fffdf8;
431
+ --section_background_color: #fffdf8;
432
+ --pwa_header_color: #1c2430;
433
+ --pwa_nav_button_color: #4e5b6a;
434
+ --pwa_nav_highlight_color: #1c2430;
435
+ --pwa_nav_on_background: #f3efe6;
436
+ --pwa_divider_color: #e3daca;
437
+ --pwa_line_color: #e3daca;
438
+ --pwa_label_text_color: #1c2430;
439
+ --pwa_input_background_color: #f3efe6;
440
+ --pwa_action_text_color: #fff;
441
+ --pwa_action_background_color: #2a6b45;
442
+ --pwa_action_border_color: #214f34;
443
+
444
+ /* Email verified check */
445
+ --pwa_verified_color: #2a6b45;
446
+ }
447
+ ```
448
+
449
+ `--pwa_tap` is the minimum size of the drawer close control, the sign-in and sign-up buttons, the settings tabs, and the delete control.
450
+
451
+ ## Parts
452
+
453
+ Hosts style the controls with `::part`. Nested fields are forwarded with `exportparts`, so the host does not enter a shadow root.
454
+
455
+ - `user-icon`: `button`, `photo`, `initials`
456
+ - `user-drawer`: `panel`, `header`, `title`, `close`, `settings`, `notice`, `verified`, `unverified`, `verify-submit`, `verify-status`, `logout`, `login-email`, `login-password`, `login-submit`, `login-switch`, `login-forgot`, `login-status`, `login-reveal`, `signup-email`, `signup-password`, `signup-submit`, `signup-switch`, `signup-status`, `signup-reveal`, `signup-notice`
457
+ - `user-login`: `panel`, `header`, `title`, `notice`, and the same `login-*` and `signup-*` field parts
458
+ - `user-settings`: `tab`, `panel`, `signed-out`, `name`, `name-submit`, `email`, `email-submit`, `verified`, `unverified`, `verify-submit`, `verify-status`, `password`, `verify`, `password-submit`, `progress`, `file`, `preview`, `delete`
459
+ - `email-reset`: `email`, `submit`, `status`, `back`
460
+
461
+ ```css
462
+ user-icon::part(button) { border-radius: 8px; }
463
+ user-drawer::part(panel) { background: #fff; }
464
+ user-drawer::part(login-submit) { letter-spacing: 0.02em; }
465
+ ```
466
+
467
+ ## Drawer behaviour
468
+
469
+ The drawer loads hidden at the top (`max-height: 0`). A press on `user-icon` slides it down.
470
+
471
+ Sign-in and sign-up share one grid area, `pages`. They slide past each other. The closed form is translated `translate3d(0, -100%, 0)`, `visibility: hidden`, and `inert`.
472
+
473
+ `--pwa_slide_time` is the master beat. Default `1.4s`. `--pwa_slide_ease` is the shared curve. Default `ease-in-out`. Durations are multiples of the beat:
474
+
475
+ - drawer max-height, and the close visibility delay: 1x (`1.4s`)
476
+ - `.spec-in`: 1.071x (about `1.5s`)
477
+ - `.spec-out`: 1.571x (about `2.2s`). The forms follow the drawer down
478
+ - form swap, and the closed-form visibility delay: 1.429x (about `2s`)
479
+
480
+ Set `--pwa_slide_time: 0.7s` to halve every one of those. `prefers-reduced-motion: reduce` sets the beat to `0s`.
481
+
482
+ While the drawer is open it covers `user-icon`. Close it with the ✕ button or Escape. The drawer is a dialog. Tab stays inside while it is open, and focus returns to the control that opened it. Off-screen forms are `inert`. The panel is `inert` while it is closed.
483
+
484
+ Slotted links can flash before the element upgrades. Hide them:
485
+
486
+ ```css
487
+ /* Optional - hide slotted links until user-drawer upgrades */
488
+ user-drawer:not(:defined) { display: none; }
489
+ ```
490
+
491
+ ## Data ownership
492
+
493
+ The host app owns its Firestore documents. Contractors Centre creates `users/{uid}` on signup and deletes that document when it hears `pwa-account-deleted`.
494
+
495
+ Sign-up calls `sendEmailVerification` and fires `pwa-verification-sent` with `{ email }`. Sign-in still succeeds when `emailVerified` is false. pwa-auth does not block an unverified account. The host, including Contractors Centre, decides whether a feature needs a verified email. Read `emailVerified` from `getCurrentUser()`, `onUserChanged`, and `pwa-auth-changed`. Call `isEmailVerified()` to reload. When that reload sees the address become verified, the page fires `pwa-email-verified`.
496
+
497
+ pwa-auth does not write `users/{uid}`. Account deletion removes this user's Storage files under `pwa-auth/{uid}`, calls `logAccountDelete`, deletes the Auth user, and fires `pwa-account-deleted` with `{ uid }`.
498
+
499
+ `deleteDocument(collect, item)` is still exported. The host can call it. The package does not call it for `users/{uid}`.
500
+
501
+ ## Contributing
502
+
503
+ ### Project layout
504
+
505
+ Edit `typescript/` only. That folder is the source.
506
+
507
+ `npm run build` runs tsc. The emit lands in `base/`. `base/export/pwa-auth.js` is the default package entry. Do not hand-edit `base/`.
508
+
509
+ Rollup reads that emit. `npm run rollup` writes `source/pwa-auth.js` (the npm production bundle) and `website/javascript/pwa-auth.js` (the site bundle). Do not hand-edit those files.
510
+
511
+ `demonstration/` is the dev demo. It imports `../base/export/pwa-auth.js`. `npm run demo` serves `demonstration/index.html`.
512
+
513
+ `website/` is the hosted site at [pwa-authentic.firebaseapp.com](https://pwa-authentic.firebaseapp.com). It loads `website/javascript/pwa-auth.js`. `npm run website` serves `website/index.html`.
514
+
515
+ Retired code lives in `typescript/deprecated/`. It is not called.
516
+
517
+ ### Build & test
518
+
519
+ ```bash
520
+ npm run build # tsc writes base/, then restores @deprecated notes tsc drops
521
+ npm run rollup # writes source/pwa-auth.js and website/javascript/pwa-auth.js
522
+ npm run demo # serves demonstration/index.html
523
+ npm run website # serves website/index.html
524
+ npm test # vitest
525
+ ```
526
+
527
+ Auth, Firestore, and Storage emulators are in [firebase.md](firebase.md).
528
+
529
+ A pull request runs `.github/workflows/ci.yml`: `npm ci`, `npm run build`, `npm run rollup`, `npm test`.
530
+
531
+ ### Publish
532
+
533
+ `npm publish` runs `prepublishOnly`, which is `npm run build` then `npm run rollup`. The action runs those two commands on their own as well, so the log shows them. No `NPM_TOKEN`.
534
+
535
+ One-time setup on npmjs.com. Package settings, Trusted Publisher, GitHub Actions. Organization or user: `busynest`. Repository: `user`. Workflow filename: `publish.yml`. Leave the environment name empty. Allow direct `npm publish`. A trusted publisher created now only stages unless you allow publish. Merge `publish.yml` to `master` first. npm drops a publisher that has not published within two days.
536
+
537
+ Release. Bump `version` in `package.json`. Tag that version (`v3.5.1` or `3.5.1`). Publish a GitHub release for the tag. The published release starts `.github/workflows/publish.yml`. The tag, without a leading `v`, must match `package.json`. The action runs `npm ci`, `npm run build`, `npm run rollup`, `npm test`, then `npm publish --provenance --access public`. A version already on npm is skipped. `workflow_dispatch` skips the tag check.
538
+
539
+ `3.5.0` is staged from a CLI stage-only token. It is not live. Promote it on npm, or discard it and let this workflow publish `3.5.0`.
540
+
541
+ ## Feedback
542
+
543
+ * [Jack's Publishing](https://www.jackspublishing.com)
544
+ * [contractor's centre](https://www.contractorscentre.com)
545
+ * [npm](https://www.npmjs.com/package/pwa-auth)
546
+ * [Sponsor Jacek Markiewicz](https://github.com/sponsors/busynest)
547
+ * [Issues](https://github.com/busynest/user/issues)