pwa-auth 3.4.8 → 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.
- package/LICENSES.txt +36 -15
- package/README.md +547 -311
- package/base/api/drawer.d.ts +4 -0
- package/base/api/drawer.d.ts.map +1 -0
- package/base/api/drawer.js +12 -0
- package/base/api/drawer.js.map +1 -0
- package/base/api/user.d.ts +4 -0
- package/base/api/user.d.ts.map +1 -0
- package/base/api/user.js +25 -0
- package/base/api/user.js.map +1 -0
- package/base/api/verify.d.ts +4 -0
- package/base/api/verify.d.ts.map +1 -0
- package/base/api/verify.js +113 -0
- package/base/api/verify.js.map +1 -0
- package/base/deprecated/email-changed.d.ts +5 -0
- package/base/deprecated/email-changed.d.ts.map +1 -0
- package/base/deprecated/email-changed.js +9 -0
- package/base/deprecated/email-changed.js.map +1 -0
- package/base/events/emit.d.ts +12 -0
- package/base/events/emit.d.ts.map +1 -0
- package/base/events/emit.js +30 -0
- package/base/events/emit.js.map +1 -0
- package/base/events/names.d.ts +31 -0
- package/base/events/names.d.ts.map +1 -0
- package/base/events/names.js +31 -0
- package/base/events/names.js.map +1 -0
- package/base/events/types.d.ts +71 -0
- package/base/events/types.d.ts.map +1 -0
- package/base/events/types.js +2 -0
- package/base/events/types.js.map +1 -0
- package/base/export/pwa-auth.d.ts +17 -7
- package/base/export/pwa-auth.d.ts.map +1 -0
- package/base/export/pwa-auth.js +13 -7
- package/base/export/pwa-auth.js.map +1 -1
- package/base/firebase/attribute.d.ts +2 -0
- package/base/firebase/attribute.d.ts.map +1 -0
- package/base/firebase/attribute.js +17 -0
- package/base/firebase/attribute.js.map +1 -0
- package/base/firebase/authentication.d.ts +21 -10
- package/base/firebase/authentication.d.ts.map +1 -0
- package/base/firebase/authentication.js +65 -8
- package/base/firebase/authentication.js.map +1 -1
- package/base/firebase/interface.d.ts +7 -1
- package/base/firebase/interface.d.ts.map +1 -0
- package/base/firebase/interface.js +99 -68
- package/base/firebase/interface.js.map +1 -1
- package/base/firebase/message.d.ts +2 -0
- package/base/firebase/message.d.ts.map +1 -0
- package/base/firebase/message.js +34 -0
- package/base/firebase/message.js.map +1 -0
- package/base/firebase/password.d.ts +11 -0
- package/base/firebase/password.d.ts.map +1 -0
- package/base/firebase/password.js +16 -0
- package/base/firebase/password.js.map +1 -0
- package/base/lazyLoader.d.ts +1 -0
- package/base/lazyLoader.d.ts.map +1 -0
- package/base/redux/backend.d.ts +1 -0
- package/base/redux/backend.d.ts.map +1 -0
- package/base/redux/backend.js +1 -1
- package/base/redux/backend.js.map +1 -1
- package/base/redux/frontend.d.ts +16 -1
- package/base/redux/frontend.d.ts.map +1 -0
- package/base/redux/frontend.js +6 -3
- package/base/redux/frontend.js.map +1 -1
- package/base/store.d.ts +1 -6
- package/base/store.d.ts.map +1 -0
- package/base/store.js +2 -4
- package/base/store.js.map +1 -1
- package/base/webcomponents/css/animation.d.ts +1 -0
- package/base/webcomponents/css/animation.d.ts.map +1 -0
- package/base/webcomponents/css/animation.js +79 -67
- package/base/webcomponents/css/animation.js.map +1 -1
- package/base/webcomponents/css/svg.d.ts +1 -2
- package/base/webcomponents/css/svg.d.ts.map +1 -0
- package/base/webcomponents/css/svg.js +2 -4
- package/base/webcomponents/css/svg.js.map +1 -1
- package/base/webcomponents/css/tap.d.ts +3 -0
- package/base/webcomponents/css/tap.d.ts.map +1 -0
- package/base/webcomponents/css/tap.js +9 -0
- package/base/webcomponents/css/tap.js.map +1 -0
- package/base/webcomponents/css/toggle.d.ts +1 -0
- package/base/webcomponents/css/toggle.d.ts.map +1 -0
- package/base/webcomponents/css/toggle.js +5 -5
- package/base/webcomponents/drawer/css/drawer.d.ts +1 -0
- package/base/webcomponents/drawer/css/drawer.d.ts.map +1 -0
- package/base/webcomponents/drawer/css/drawer.js +101 -74
- package/base/webcomponents/drawer/css/drawer.js.map +1 -1
- package/base/webcomponents/drawer/css/exit.d.ts +1 -0
- package/base/webcomponents/drawer/css/exit.d.ts.map +1 -0
- package/base/webcomponents/drawer/css/exit.js +58 -52
- package/base/webcomponents/drawer/css/exit.js.map +1 -1
- package/base/webcomponents/drawer/css/link.d.ts +1 -0
- package/base/webcomponents/drawer/css/link.d.ts.map +1 -0
- package/base/webcomponents/drawer/css/link.js +9 -10
- package/base/webcomponents/drawer/css/link.js.map +1 -1
- package/base/webcomponents/drawer/css/paragraph.d.ts +1 -0
- package/base/webcomponents/drawer/css/paragraph.d.ts.map +1 -0
- package/base/webcomponents/drawer/css/paragraph.js +37 -20
- package/base/webcomponents/drawer/css/paragraph.js.map +1 -1
- package/base/webcomponents/drawer/drawer.d.ts +21 -7
- package/base/webcomponents/drawer/drawer.d.ts.map +1 -0
- package/base/webcomponents/drawer/drawer.js +292 -90
- package/base/webcomponents/drawer/drawer.js.map +1 -1
- package/base/webcomponents/drawer/keys.d.ts +4 -0
- package/base/webcomponents/drawer/keys.d.ts.map +1 -0
- package/base/webcomponents/drawer/keys.js +57 -0
- package/base/webcomponents/drawer/keys.js.map +1 -0
- package/base/webcomponents/form/css/button.d.ts +1 -0
- package/base/webcomponents/form/css/button.d.ts.map +1 -0
- package/base/webcomponents/form/css/button.js +69 -51
- package/base/webcomponents/form/css/button.js.map +1 -1
- package/base/webcomponents/form/css/input.d.ts +1 -0
- package/base/webcomponents/form/css/input.d.ts.map +1 -0
- package/base/webcomponents/form/css/input.js +22 -21
- package/base/webcomponents/form/css/input.js.map +1 -1
- package/base/webcomponents/form/css/label.d.ts +1 -0
- package/base/webcomponents/form/css/label.d.ts.map +1 -0
- package/base/webcomponents/form/css/label.js +22 -21
- package/base/webcomponents/form/css/label.js.map +1 -1
- package/base/webcomponents/form/css/list.d.ts +1 -0
- package/base/webcomponents/form/css/list.d.ts.map +1 -0
- package/base/webcomponents/form/css/list.js +19 -19
- package/base/webcomponents/form/css/notice.d.ts +3 -0
- package/base/webcomponents/form/css/notice.d.ts.map +1 -0
- package/base/webcomponents/form/css/notice.js +20 -0
- package/base/webcomponents/form/css/notice.js.map +1 -0
- package/base/webcomponents/form/css/status.d.ts +4 -0
- package/base/webcomponents/form/css/status.d.ts.map +1 -0
- package/base/webcomponents/form/css/status.js +44 -0
- package/base/webcomponents/form/css/status.js.map +1 -0
- package/base/webcomponents/form/css/toggle.d.ts +1 -0
- package/base/webcomponents/form/css/toggle.d.ts.map +1 -0
- package/base/webcomponents/form/css/toggle.js +43 -17
- package/base/webcomponents/form/css/toggle.js.map +1 -1
- package/base/webcomponents/form/draft.d.ts +5 -0
- package/base/webcomponents/form/draft.d.ts.map +1 -0
- package/base/webcomponents/form/draft.js +22 -0
- package/base/webcomponents/form/draft.js.map +1 -0
- package/base/webcomponents/form/forgot.d.ts +26 -3
- package/base/webcomponents/form/forgot.d.ts.map +1 -0
- package/base/webcomponents/form/forgot.js +297 -30
- package/base/webcomponents/form/forgot.js.map +1 -1
- package/base/webcomponents/form/letters.d.ts +3 -0
- package/base/webcomponents/form/letters.d.ts.map +1 -0
- package/base/webcomponents/form/letters.js +21 -0
- package/base/webcomponents/form/letters.js.map +1 -0
- package/base/webcomponents/form/login.d.ts +10 -0
- package/base/webcomponents/form/login.d.ts.map +1 -0
- package/base/webcomponents/form/login.js +221 -89
- package/base/webcomponents/form/login.js.map +1 -1
- package/base/webcomponents/form/notice.d.ts +4 -0
- package/base/webcomponents/form/notice.d.ts.map +1 -0
- package/base/webcomponents/form/notice.js +14 -0
- package/base/webcomponents/form/notice.js.map +1 -0
- package/base/webcomponents/form/reveal.d.ts +3 -0
- package/base/webcomponents/form/reveal.d.ts.map +1 -0
- package/base/webcomponents/form/reveal.js +14 -0
- package/base/webcomponents/form/reveal.js.map +1 -0
- package/base/webcomponents/form/signup.d.ts +8 -0
- package/base/webcomponents/form/signup.d.ts.map +1 -0
- package/base/webcomponents/form/signup.js +201 -100
- package/base/webcomponents/form/signup.js.map +1 -1
- package/base/webcomponents/form/verified.d.ts +3 -0
- package/base/webcomponents/form/verified.d.ts.map +1 -0
- package/base/webcomponents/form/verified.js +45 -0
- package/base/webcomponents/form/verified.js.map +1 -0
- package/base/webcomponents/icon/css/icon.d.ts +1 -0
- package/base/webcomponents/icon/css/icon.d.ts.map +1 -0
- package/base/webcomponents/icon/css/icon.js +63 -49
- package/base/webcomponents/icon/css/icon.js.map +1 -1
- package/base/webcomponents/icon/icon.d.ts +6 -4
- package/base/webcomponents/icon/icon.d.ts.map +1 -0
- package/base/webcomponents/icon/icon.js +48 -27
- package/base/webcomponents/icon/icon.js.map +1 -1
- package/base/webcomponents/login/css/auth.d.ts +1 -0
- package/base/webcomponents/login/css/auth.d.ts.map +1 -0
- package/base/webcomponents/login/css/auth.js +37 -36
- package/base/webcomponents/login/css/auth.js.map +1 -1
- package/base/webcomponents/login/css/link.d.ts +1 -0
- package/base/webcomponents/login/css/link.d.ts.map +1 -0
- package/base/webcomponents/login/css/link.js +9 -10
- package/base/webcomponents/login/css/link.js.map +1 -1
- package/base/webcomponents/login/css/paragraph.d.ts +1 -0
- package/base/webcomponents/login/css/paragraph.d.ts.map +1 -0
- package/base/webcomponents/login/css/paragraph.js +8 -8
- package/base/webcomponents/login/page.d.ts +10 -6
- package/base/webcomponents/login/page.d.ts.map +1 -0
- package/base/webcomponents/login/page.js +96 -55
- package/base/webcomponents/login/page.js.map +1 -1
- package/base/webcomponents/settings/css/navigation.d.ts +1 -0
- package/base/webcomponents/settings/css/navigation.d.ts.map +1 -0
- package/base/webcomponents/settings/css/navigation.js +78 -68
- package/base/webcomponents/settings/css/navigation.js.map +1 -1
- package/base/webcomponents/settings/input/delete.d.ts +7 -6
- package/base/webcomponents/settings/input/delete.d.ts.map +1 -0
- package/base/webcomponents/settings/input/delete.js +135 -47
- package/base/webcomponents/settings/input/delete.js.map +1 -1
- package/base/webcomponents/settings/input/email.d.ts +7 -5
- package/base/webcomponents/settings/input/email.d.ts.map +1 -0
- package/base/webcomponents/settings/input/email.js +155 -50
- package/base/webcomponents/settings/input/email.js.map +1 -1
- package/base/webcomponents/settings/input/name.d.ts +8 -5
- package/base/webcomponents/settings/input/name.d.ts.map +1 -0
- package/base/webcomponents/settings/input/name.js +116 -53
- package/base/webcomponents/settings/input/name.js.map +1 -1
- package/base/webcomponents/settings/input/password.d.ts +8 -5
- package/base/webcomponents/settings/input/password.d.ts.map +1 -0
- package/base/webcomponents/settings/input/password.js +200 -103
- package/base/webcomponents/settings/input/password.js.map +1 -1
- package/base/webcomponents/settings/input/uploader.d.ts +8 -6
- package/base/webcomponents/settings/input/uploader.d.ts.map +1 -0
- package/base/webcomponents/settings/input/uploader.js +209 -170
- package/base/webcomponents/settings/input/uploader.js.map +1 -1
- package/base/webcomponents/settings/input/verify.d.ts +64 -0
- package/base/webcomponents/settings/input/verify.d.ts.map +1 -0
- package/base/webcomponents/settings/input/verify.js +272 -0
- package/base/webcomponents/settings/input/verify.js.map +1 -0
- package/base/webcomponents/settings/settings.d.ts +15 -10
- package/base/webcomponents/settings/settings.d.ts.map +1 -0
- package/base/webcomponents/settings/settings.js +226 -146
- package/base/webcomponents/settings/settings.js.map +1 -1
- package/firebase.md +107 -0
- package/intro.md +19 -0
- package/license +21 -21
- package/package.json +116 -85
- package/source/pwa-auth.js +1097 -404
- package/source/pwa-styles.css +50 -68
- package/base/redux/drawer.d.ts +0 -17
- package/base/redux/drawer.js +0 -22
- package/base/redux/drawer.js.map +0 -1
- package/demonstration/index.html +0 -99
- package/demonstration/pwa-styles.css +0 -77
- package/demonstration/styles.css +0 -77
- package/source/THIRD_PARTY_LICENSES.txt +0 -303
package/README.md
CHANGED
|
@@ -1,311 +1,547 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
- `<user-settings>`
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
<
|
|
265
|
-
<user-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
1
|
+
# pwa-auth
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/pwa-auth)
|
|
4
|
+
[](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)
|