pwa-auth 2.0.3 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/CHANGELOG.md +36 -26
  2. package/README.md +101 -87
  3. package/demo/index.html +22 -126
  4. package/demo/pwa-styles.css +77 -0
  5. package/deploy/css/font.d.ts.map +1 -1
  6. package/deploy/css/form/button.d.ts.map +1 -1
  7. package/deploy/css/form/input.d.ts.map +1 -1
  8. package/deploy/css/form/label.d.ts.map +1 -1
  9. package/deploy/css/form/list.d.ts.map +1 -1
  10. package/deploy/css/svg.d.ts.map +1 -1
  11. package/deploy/css/toggle.d.ts.map +1 -1
  12. package/deploy/custom-elements/drawer/css/drawer.d.ts.map +1 -1
  13. package/deploy/custom-elements/drawer/css/exit.d.ts.map +1 -1
  14. package/deploy/custom-elements/drawer/css/link.d.ts.map +1 -1
  15. package/deploy/custom-elements/drawer/css/paragraph.d.ts.map +1 -1
  16. package/deploy/custom-elements/drawer/css/toggle.d.ts.map +1 -1
  17. package/deploy/custom-elements/drawer/drawer.d.ts.map +1 -1
  18. package/deploy/custom-elements/drawer/drawer.js +1 -1
  19. package/deploy/custom-elements/drawer/input/forgot.d.ts.map +1 -1
  20. package/deploy/custom-elements/drawer/input/forgot.js +1 -1
  21. package/deploy/custom-elements/drawer/input/login.d.ts.map +1 -1
  22. package/deploy/custom-elements/drawer/input/login.js +1 -1
  23. package/deploy/custom-elements/drawer/input/sign-up.d.ts.map +1 -1
  24. package/deploy/custom-elements/drawer/input/sign-up.js +1 -1
  25. package/deploy/custom-elements/icon/css/icon.d.ts.map +1 -1
  26. package/deploy/custom-elements/icon/css/icon.js +0 -1
  27. package/deploy/custom-elements/icon/icon.d.ts.map +1 -1
  28. package/deploy/custom-elements/settings/css/navigation.d.ts.map +1 -1
  29. package/deploy/custom-elements/settings/input/delete.d.ts.map +1 -1
  30. package/deploy/custom-elements/settings/input/delete.js +1 -1
  31. package/deploy/custom-elements/settings/input/email.d.ts.map +1 -1
  32. package/deploy/custom-elements/settings/input/email.js +1 -1
  33. package/deploy/custom-elements/settings/input/images.d.ts.map +1 -1
  34. package/deploy/custom-elements/settings/input/images.js +1 -1
  35. package/deploy/custom-elements/settings/input/name.d.ts.map +1 -1
  36. package/deploy/custom-elements/settings/input/name.js +1 -1
  37. package/deploy/custom-elements/settings/input/password.d.ts.map +1 -1
  38. package/deploy/custom-elements/settings/input/password.js +1 -1
  39. package/deploy/custom-elements/settings/input/uploader.d.ts +0 -2
  40. package/deploy/custom-elements/settings/input/uploader.d.ts.map +1 -1
  41. package/deploy/custom-elements/settings/input/uploader.js +11 -22
  42. package/deploy/custom-elements/settings/settings.d.ts.map +1 -1
  43. package/deploy/firebase/firebase-login.d.ts +21 -0
  44. package/deploy/firebase/firebase-login.d.ts.map +1 -0
  45. package/deploy/firebase/firebase-login.js +85 -0
  46. package/deploy/firebase/firebase.d.ts +20 -0
  47. package/deploy/firebase/firebase.d.ts.map +1 -0
  48. package/deploy/firebase/firebase.js +76 -0
  49. package/deploy/firebase/start.d.ts.map +1 -0
  50. package/deploy/{start.js → firebase/start.js} +5 -4
  51. package/deploy/lazy-loader.d.ts.map +1 -1
  52. package/deploy/redux/backend.d.ts.map +1 -1
  53. package/deploy/redux/drawer.d.ts.map +1 -1
  54. package/deploy/redux/frontend.d.ts.map +1 -1
  55. package/deploy/redux/object.d.ts.map +1 -1
  56. package/deploy/store.d.ts.map +1 -1
  57. package/npm/pwa-auth.js +1 -1
  58. package/npm/pwa-styles.css +66 -0
  59. package/package.json +4 -3
  60. package/source/css/font.ts +17 -0
  61. package/source/css/form/button.ts +55 -0
  62. package/source/css/form/input.ts +25 -0
  63. package/source/css/form/label.ts +25 -0
  64. package/source/css/form/list.ts +23 -0
  65. package/source/css/svg.ts +5 -0
  66. package/source/css/toggle.ts +9 -0
  67. package/source/custom-elements/drawer/css/drawer.ts +64 -0
  68. package/source/custom-elements/drawer/css/exit.ts +49 -0
  69. package/source/custom-elements/drawer/css/link.ts +15 -0
  70. package/source/custom-elements/drawer/css/paragraph.ts +11 -0
  71. package/source/custom-elements/drawer/css/toggle.ts +19 -0
  72. package/source/custom-elements/drawer/drawer.ts +120 -0
  73. package/source/custom-elements/drawer/input/forgot.ts +121 -0
  74. package/source/custom-elements/drawer/input/login.ts +135 -0
  75. package/source/custom-elements/drawer/input/sign-up.ts +158 -0
  76. package/source/custom-elements/icon/css/icon.ts +70 -0
  77. package/source/custom-elements/icon/icon.ts +87 -0
  78. package/source/custom-elements/settings/css/navigation.ts +92 -0
  79. package/source/custom-elements/settings/input/delete.ts +83 -0
  80. package/source/custom-elements/settings/input/email.ts +135 -0
  81. package/source/custom-elements/settings/input/images.ts +57 -0
  82. package/source/custom-elements/settings/input/name.ts +99 -0
  83. package/source/custom-elements/settings/input/password.ts +156 -0
  84. package/source/custom-elements/settings/input/uploader.ts +326 -0
  85. package/source/custom-elements/settings/settings.ts +202 -0
  86. package/source/firebase/firebase-login.ts +246 -0
  87. package/source/firebase/firebase.ts +214 -0
  88. package/source/firebase/start.ts +216 -0
  89. package/source/lazy-loader.ts +20 -0
  90. package/source/redux/backend.ts +94 -0
  91. package/source/redux/drawer.ts +37 -0
  92. package/source/redux/frontend.ts +134 -0
  93. package/source/redux/object.ts +31 -0
  94. package/source/store.ts +19 -0
  95. package/website/404.html +33 -0
  96. package/website/THIRD_PARTY_LICENSES.txt +303 -0
  97. package/website/css/pwa-styles.css +36 -0
  98. package/website/css/styles.css +67 -0
  99. package/website/images/empty.jpg +0 -0
  100. package/website/images/favicon.ico +0 -0
  101. package/website/images/manifest/logo-144.png +0 -0
  102. package/website/images/manifest/logo-192.png +0 -0
  103. package/website/images/manifest/logo-48.png +0 -0
  104. package/website/images/manifest/logo-512.png +0 -0
  105. package/website/images/manifest/logo-72.png +0 -0
  106. package/website/images/manifest/logo-96.png +0 -0
  107. package/website/images/manifest/maskable_icon_x128.png +0 -0
  108. package/website/images/manifest/maskable_icon_x192.png +0 -0
  109. package/website/images/manifest/maskable_icon_x384.png +0 -0
  110. package/website/images/manifest/maskable_icon_x48.png +0 -0
  111. package/website/images/manifest/maskable_icon_x512.png +0 -0
  112. package/website/images/manifest/maskable_icon_x72.png +0 -0
  113. package/website/images/manifest/maskable_icon_x96.png +0 -0
  114. package/website/index.html +64 -0
  115. package/website/js/pwa-auth.js +306 -0
  116. package/website/sitemap.xml +11 -0
  117. package/deploy/interface.d.ts +0 -36
  118. package/deploy/interface.d.ts.map +0 -1
  119. package/deploy/interface.js +0 -176
  120. package/deploy/start.d.ts.map +0 -1
  121. /package/deploy/{start.d.ts → firebase/start.d.ts} +0 -0
@@ -0,0 +1,246 @@
1
+ import {
2
+ isSignInWithEmailLink,
3
+ signInAnonymously,
4
+ signInWithCredential,
5
+ signInWithCustomToken,
6
+ signInWithEmailAndPassword,
7
+ signInWithEmailLink,
8
+ signInWithPhoneNumber,
9
+ signInWithPopup,
10
+ signInWithRedirect,
11
+ signOut,
12
+ updateCurrentUser,
13
+ verifyPasswordResetCode,
14
+ sendEmailVerification
15
+ } from "firebase/auth";
16
+
17
+ import { auth, user } from "./start";
18
+
19
+ interface baseVerify {
20
+ verifyPasswordResetCode : any,
21
+ emailVerification: any
22
+ }
23
+
24
+ interface baseLogin {
25
+ signOut : any,
26
+ isSignInWithEmailLink : any,
27
+ signInWithEmailAndPassword : any,
28
+ signInWithPopup : any,
29
+ signInWithRedirect : any,
30
+ signInAnonymously : any,
31
+ signInWithCustomToken : any,
32
+ signInWithEmailLink : any,
33
+ signInWithPhoneNumber : any,
34
+ signInWithCredential : any,
35
+ updateCurrentUser : any
36
+ }
37
+
38
+ export const authVerify : baseVerify = {
39
+ verifyPasswordResetCode: {
40
+ description: "Verifies a password reset code sent to the user.",
41
+ action: (code:any) => verifyPasswordResetCode(auth, code)
42
+ .then(email => ({ email }))
43
+ .catch(error => ({ error: error.code, message: error.message }))
44
+ },
45
+
46
+ // Email Verification
47
+ emailVerification: {
48
+ description: "Sends an email verification to the current user.",
49
+ action: () => { if (user) { sendEmailVerification(user)
50
+ .then(() => ({ success: true }))
51
+ .catch((error:any) => ({ error: error.code, message: error.message }))
52
+ } }
53
+ }
54
+
55
+ }
56
+ export const authLogin : baseLogin = {
57
+
58
+ isSignInWithEmailLink: {
59
+ description: "Checks if a link is a valid sign-in with email link.",
60
+ action: (link:any) => isSignInWithEmailLink(auth, link)
61
+ },
62
+
63
+ signInWithEmailAndPassword: {
64
+ description: "Signs in a user with email and password.",
65
+ action: (email:string, password:string) => signInWithEmailAndPassword(auth, email, password)
66
+ .then(userCredential => ({ user: userCredential.user }))
67
+ .catch(error => ({ error: error.code, message: error.message }))
68
+ },
69
+ signInWithPopup: {
70
+ description: "Signs in a user via a popup with a federated provider (e.g., Google, Facebook).",
71
+ action: (provider:any) => signInWithPopup(auth, provider)
72
+ .then(result => ({ user: result.user }))
73
+ .catch(error => ({ error: error.code, message: error.message }))
74
+ },
75
+ signInWithRedirect: {
76
+ description: "Signs in a user via redirect with a federated provider.",
77
+ action: (provider:any) => signInWithRedirect(auth, provider)
78
+ .catch(error => ({ error: error.code, message: error.message }))
79
+ },
80
+
81
+ signInAnonymously: {
82
+ description: "Signs in a user anonymously without credentials.",
83
+ action: () => signInAnonymously(auth)
84
+ .then(userCredential => ({ user: userCredential.user }))
85
+ .catch(error => ({ error: error.code, message: error.message }))
86
+ },
87
+ signInWithCustomToken: {
88
+ description: "Signs in a user with a custom token from an external auth system.",
89
+ action: (token:any) => signInWithCustomToken(auth, token)
90
+ .then(userCredential => ({ user: userCredential.user }))
91
+ .catch(error => ({ error: error.code, message: error.message }))
92
+ },
93
+ signInWithEmailLink: {
94
+ description: "Signs in a user with an email link.",
95
+ action: (email:string, link:any) => signInWithEmailLink(auth, email, link)
96
+ .then(userCredential => ({ user: userCredential.user }))
97
+ .catch(error => ({ error: error.code, message: error.message }))
98
+ },
99
+ signInWithPhoneNumber: {
100
+ description: "Signs in a user with a phone number and verification code.",
101
+ action: (phoneNumber: any, appVerifier: any) => signInWithPhoneNumber(auth, phoneNumber, appVerifier)
102
+ .then(confirmationResult => ({ confirmationResult }))
103
+ .catch(error => ({ error: error.code, message: error.message }))
104
+ },
105
+ signInWithCredential: {
106
+ description: "Signs in a user with a credential object (e.g., from OAuth).",
107
+ action: (credential:any) => signInWithCredential(auth, credential)
108
+ .then(userCredential => ({ user: userCredential.user }))
109
+ .catch(error => ({ error: error.code, message: error.message }))
110
+ },
111
+
112
+ // User Management
113
+ updateCurrentUser: {
114
+ description: "Updates the current user with a new User object.",
115
+ action: () => updateCurrentUser(auth, user)
116
+ .then(() => ({ success: true }))
117
+ .catch(error => ({ error: error.code, message: error.message }))
118
+ },
119
+
120
+ // Sign-Out
121
+ signOut: {
122
+ description: "Signs out the current user.",
123
+ action: () => signOut(auth)
124
+ .then(() => ({ success: true }))
125
+ .catch(error => ({ error: error.code, message: error.message }))
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
+ // Sign in-out
159
+ isSignInWithEmailLink(auth, emailLink) // Checks if an incoming link is a sign-in with email link suitable for signInWithEmailLink().
160
+ sendSignInLinkToEmail(auth, email, actionCodeSettings) // Sends a sign-in email link to the user with the specified email.
161
+ setPersistence(auth, persistence) // Changes the type of persistence on the Auth instance for the currently saved Auth session and applies this type of persistence for future sign-in requests, including sign-in with redirect requests.
162
+ signInAnonymously(auth) Asynchronously // signs in as an anonymous user.
163
+ signInWithCredential(auth, credential) // Asynchronously signs in with the given credentials.
164
+ signInWithCustomToken(auth, customToken) // Asynchronously signs in using a custom token.
165
+ signInWithEmailAndPassword(auth, email, password) // Asynchronously signs in using an email and password.
166
+ signInWithEmailLink(auth, email, emailLink) // Asynchronously signs in using an email and sign-in email link.
167
+ signInWithPhoneNumber(auth, phoneNumber, appVerifier) // Asynchronously signs in using a phone number.
168
+ signInWithPopup(auth, provider, resolver) // Authenticates a Firebase client using a popup-based OAuth authentication flow.
169
+ signInWithRedirect(auth, provider, resolver) // Authenticates a Firebase client using a full-page redirect flow.
170
+ signOut(auth) // Signs out the current user.
171
+
172
+ // Verify
173
+ updateCurrentUser(auth, user) // Asynchronously sets the provided user as Auth.currentUser on the Auth instance.
174
+ useDeviceLanguage(auth) // Sets the current language to the default device/browser preference.
175
+ validatePassword(auth, password) // Validates the password against the password policy configured for the project or tenant.
176
+ verifyPasswordResetCode(auth, code) // Checks a password reset code sent to the user by email or other out-of-band mechanism.
177
+
178
+ */
179
+
180
+
181
+
182
+
183
+
184
+
185
+
186
+
187
+
188
+
189
+ /*
190
+ // setPersistence,
191
+ // useDeviceLanguage,
192
+
193
+ sendSignInLinkToEmail : any,
194
+ setPersistence : any,
195
+ useDeviceLanguage : any,
196
+ validatePassword : any,
197
+ handleRecoverEmail:any
198
+ */
199
+
200
+ /*
201
+ setPersistence: {
202
+ description: "Sets the persistence mechanism for auth state.",
203
+ example: (persistence:any) => setPersistence(auth, persistence)
204
+ .then(() => ({ success: true }))
205
+ .catch(error => ({ error: error.code, message: error.message }))
206
+ },
207
+ useDeviceLanguage: {
208
+ description: "Sets the auth instance language to the device's language.",
209
+ example: () => useDeviceLanguage(auth)
210
+ },
211
+ */
212
+
213
+
214
+
215
+
216
+
217
+
218
+ /*
219
+ useEmulator: {
220
+ description: "Configures the auth instance to use the Firebase emulator.",
221
+ example: (url) => useEmulator(auth, url)
222
+ }
223
+ };
224
+
225
+ // Handle messages from the main script
226
+ self.onmessage = (event) => {
227
+ const { action, data } = event.data;
228
+
229
+ // Execute the requested authentication function
230
+ if (action === 'executeAuthFunction' && authFunctions[data.functionName]) {
231
+ authFunctions[data.functionName].example(...(data.args || []))
232
+ .then(result => self.postMessage({ status: 'success', result }))
233
+ .catch(error => self.postMessage({ status: 'error', error }));
234
+ } else {
235
+ self.postMessage({ status: 'error', error: 'Invalid function or request' });
236
+ }
237
+ };
238
+
239
+ // Export the auth functions list for reference
240
+ self.postMessage({
241
+ status: 'init',
242
+ authFunctions: Object.keys(authFunctions).map(key => ({
243
+ name: key,
244
+ description: authFunctions[key].description
245
+ }))
246
+ });*/
@@ -0,0 +1,214 @@
1
+ import {
2
+ applyActionCode,
3
+ beforeAuthStateChanged,
4
+ checkActionCode,
5
+ confirmPasswordReset,
6
+ createUserWithEmailAndPassword,
7
+ fetchSignInMethodsForEmail,
8
+ getRedirectResult,
9
+ onAuthStateChanged,
10
+ onIdTokenChanged,
11
+ sendPasswordResetEmail,
12
+ UserCredential
13
+ } from "firebase/auth";
14
+
15
+ import { auth } from "./start";
16
+ import { FirebaseError } from "firebase/app";
17
+
18
+ interface base {
19
+ applyActionCode : any, // applyActionCode(auth, oobCode) // Applies a verification code sent to the user by email or other out-of-band mechanism.
20
+ checkActionCode : any, // checkActionCode(auth, oobCode) // Checks a verification code sent to the user by email or other out-of-band mechanism.
21
+ beforeAuthStateChanged : any,
22
+ confirmPasswordReset : any,
23
+ sendPasswordResetEmail : any,
24
+ connectAuthEmulator : any,
25
+ createUserWithEmailAndPassword : any,
26
+ fetchSignInMethodsForEmail : any,
27
+ getMultiFactorResolver : any,
28
+ getRedirectResult : any,
29
+ initializeRecaptchaConfig : any,
30
+ onAuthStateChanged : any,
31
+ onIdTokenChanged : any,
32
+ revokeAccessToken : any
33
+ }
34
+
35
+ // List of Firebase Authentication functions with descriptions
36
+ export const authFunctions : base = {
37
+
38
+ // 1. Applies a verification code
39
+ applyActionCode: {
40
+ description: "Applies an out-of-band verification code (e.g., email verification).",
41
+ action: (oobCode:any) => applyActionCode(auth, oobCode)
42
+ .then(() => ({ success: true }))
43
+ .catch( (error:FirebaseError) => ({ error: error.code, message: error.message }))
44
+ },
45
+
46
+ // 2. Checks a verification code
47
+ checkActionCode: {
48
+ description: "Checks the metadata of an out-of-band verification code.",
49
+ action: (code:any) => checkActionCode(auth, code)
50
+ .then( (info:any) => ({ info }))
51
+ .catch((error:FirebaseError) => ({ error: error.code, message: error.message }))
52
+ },
53
+
54
+ // 3. Adds a blocking call
55
+ beforeAuthStateChanged: {
56
+ description:'Adds a blocking callback that runs before an auth state change sets a new user.',
57
+ code: (callback:any, onAbort:any) => beforeAuthStateChanged(auth, callback, onAbort)
58
+ },
59
+
60
+ // 4. Confirm Password Reset
61
+ confirmPasswordReset: {
62
+ description: "Completes the password reset process with a code and new password.",
63
+ action: (code:any, newPassword:string) => confirmPasswordReset(auth, code, newPassword)
64
+ .then(() => ({ success: true }))
65
+ .catch( (error:FirebaseError) => ({ error: error.code, message: error.message }))
66
+ },
67
+
68
+ // 5. Send Password Reset Email
69
+ sendPasswordResetEmail: {
70
+ description: "Sends a password reset email to the user.",
71
+ action: (email:string) => sendPasswordResetEmail(auth, email)
72
+ .then(() => ({ success: true }))
73
+ .catch(error => ({ error: error.code, message: error.message }))
74
+ },
75
+
76
+ //
77
+ connectAuthEmulator:{},
78
+
79
+ // 6. New User via Email and Password
80
+ createUserWithEmailAndPassword: {
81
+ description: "Creates a new user account with email and password, and signs them in.",
82
+ action: (email:any, password:any) => createUserWithEmailAndPassword(auth, email, password)
83
+ .then( (userCredential:UserCredential) => ({ user: userCredential.user }))
84
+ .catch( (error:FirebaseError) => ({ error: error.code, message: error.message }))
85
+ },
86
+
87
+ // 7. Utility
88
+ fetchSignInMethodsForEmail: {
89
+ description: "Gets the list of sign-in methods for a given email.",
90
+ action: (email:string) => fetchSignInMethodsForEmail(auth, email)
91
+ .then( (methods:any) => ({ methods }))
92
+ .catch( (error:FirebaseError) => ({ error: error.code, message: error.message }))
93
+ },
94
+
95
+ getMultiFactorResolver:{},
96
+
97
+ // 8. Flow Based Redirect
98
+ getRedirectResult: {
99
+ description: "Retrieves the result of a redirect-based sign-in flow.",
100
+ action: () => getRedirectResult(auth)
101
+ .then( (result:any) => ({ user: result.user }))
102
+ .catch( (error:FirebaseError) => ({ error: error.code, message: error.message }))
103
+ },
104
+
105
+ initializeRecaptchaConfig:{},
106
+
107
+ // 9. Authentication State
108
+ onAuthStateChanged: {
109
+ description: "Listens for changes in the authentication state.",
110
+ action: (callback:any) => onAuthStateChanged(auth, callback)
111
+ },
112
+
113
+ // 10. Listener for ID changes
114
+ onIdTokenChanged: {
115
+ description: "Listens for changes in the ID token.",
116
+ action: (callback:any) => onIdTokenChanged(auth, callback)
117
+ },
118
+
119
+ revokeAccessToken: {}
120
+
121
+ };
122
+
123
+
124
+
125
+
126
+ export const recoverEmail = (/*auth,*/ actionCode:any, /*lang:any*/) => {
127
+
128
+ //handleRecoverEmail(/*auth,*/ actionCode:any, lang:any) {
129
+ // Localize the UI to the selected language as determined by the lang
130
+ // parameter.
131
+ let restoredEmail : any = null;
132
+ // Confirm the action code is valid.
133
+ checkActionCode(auth, actionCode).then((info) => {
134
+ // Get the restored email address.
135
+ restoredEmail = info['data']['email'];
136
+
137
+ // Revert to the old email.
138
+ return applyActionCode(auth, actionCode);
139
+ }).then(() => {
140
+ // Account email reverted to restoredEmail
141
+
142
+ // TODO: Display a confirmation message to the user.
143
+
144
+ // You might also want to give the user the option to reset their password
145
+ // in case the account was compromised:
146
+ sendPasswordResetEmail(auth, restoredEmail).then(() => {
147
+ // Password reset confirmation sent. Ask user to check their email.
148
+ }).catch((error:FirebaseError) => { console.log(error);
149
+ // Error encountered while sending password reset code.
150
+ });
151
+ }).catch((error:FirebaseError) => { console.log(error);
152
+ // Invalid code.
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
+ // Checks
194
+ beforeAuthStateChanged(auth, callback, onAbort) // Adds a blocking callback that runs before an auth state change sets a new user.
195
+
196
+ // Reset
197
+ confirmPasswordReset(auth, oobCode, newPassword) // Completes the password reset process, given a confirmation code and new password.
198
+ sendPasswordResetEmail(auth, email, actionCodeSettings) // Sends a password reset email to the given email address. This method does not throw an error when there's no user account with the given email address and Email Enumeration Protection is enabled.
199
+
200
+ // More
201
+ connectAuthEmulator(auth, url, options) // Changes the Auth instance to communicate with the Firebase Auth Emulator, instead of production Firebase Auth services.
202
+ createUserWithEmailAndPassword(auth, email, password) // Creates a new user account associated with the specified email address and password.
203
+ fetchSignInMethodsForEmail(auth, email) // Gets the list of possible sign in methods for the given email address. This method returns an empty list when Email Enumeration Protection is enabled, irrespective of the number of authentication methods available for the given email.
204
+ getMultiFactorResolver(auth, error) // Provides a MultiFactorResolver suitable for completion of a multi-factor flow.
205
+
206
+ getRedirectResult(auth, resolver) // Returns a UserCredential from the redirect-based sign-in flow.
207
+ initializeRecaptchaConfig(auth) // Loads the reCAPTCHA configuration into the Auth instance.
208
+
209
+ // Change
210
+ onAuthStateChanged(auth, nextOrObserver, error, completed) // Adds an observer for changes to the user's sign-in state.
211
+ onIdTokenChanged(auth, nextOrObserver, error, completed) // Adds an observer for changes to the signed-in user's ID token.
212
+ revokeAccessToken(auth, token) // Revokes the given access token. Currently only supports Apple OAuth access tokens.
213
+
214
+ */
@@ -0,0 +1,216 @@
1
+ // Representational State Transfer - Application Programming Interface
2
+ // Module Imports ---------------- ---------------- ----------------
3
+
4
+ // Redux
5
+ import { store } from '../store';
6
+ import { closeSign, iconAuth, nameAuth, userAuth } from '../redux/frontend';
7
+ import { accID, accEmail, accImage, accName } from '../redux/backend';
8
+
9
+ // Firebase App
10
+ import { FirebaseApp, initializeApp } from 'firebase/app';
11
+
12
+ // Firebase Auth
13
+ import { Auth, User, getAuth, onAuthStateChanged, sendEmailVerification, signOut } from 'firebase/auth';
14
+
15
+ // Firebase Firestore
16
+ import { getFirestore, Firestore, doc, deleteDoc } from "firebase/firestore";
17
+
18
+ // Firebase Storage
19
+ import { getStorage, FirebaseStorage } from "@firebase/storage";
20
+
21
+ //Firebase Analytics
22
+ import { Analytics, getAnalytics, logEvent } from "firebase/analytics";
23
+
24
+ // Firebse Messaginmg
25
+ import { isSupported } from "firebase/messaging";
26
+
27
+
28
+
29
+ // Module Exports ---------------- ---------------- ----------------
30
+
31
+
32
+
33
+ const firebaseConfig: any = JSON.parse(process.env.FIREBASE_CONFIG || "{}");
34
+
35
+ // Memory Reference to Services - Object Type
36
+ export const application : FirebaseApp = initializeApp(firebaseConfig); // Initialize Application
37
+ export const db : Firestore = getFirestore(application); // Initialize Database
38
+ export const storage : FirebaseStorage = getStorage(application); // Reference: Represents a reference to a file or directory in Storage, returned by ref(). // UploadTask: Represents an ongoing upload operation, returned by upload methods. // ListResult: Represents the result of listing files in a directory.
39
+ export const auth : Auth = getAuth(application);
40
+ export const user : User | null = auth.currentUser;
41
+
42
+ // LANGUAGE
43
+ getAuth().useDeviceLanguage();
44
+
45
+ // START ANALYTICS ----------------
46
+
47
+ // const analytics : Analytics = getAnalytics();
48
+ let analytics: Analytics;
49
+
50
+ (async () => {
51
+ if (await isSupported()) {
52
+ console.log('Firebase Analytics Supported');
53
+ // Initialize Firebase Analytics
54
+ analytics = getAnalytics(application);
55
+ // Additional analytics setup code here
56
+ } else {
57
+ console.log("Firebase Analytics is not supported in this environment.");
58
+ }
59
+ })();
60
+
61
+ // END ANALYTICS ----------------
62
+
63
+ // Start Support Checks
64
+
65
+ // Check for Service Worker support
66
+ if ('serviceWorker' in navigator) { console.log('Service Worker is supported'); }
67
+ else { console.log('Service Worker is not supported'); }
68
+
69
+ // Check for Push API support
70
+ if ('PushManager' in window) { console.log('Push API is supported'); }
71
+ else { console.log('Push API is not supported'); }
72
+
73
+ // End Support Checks
74
+
75
+ // Start Distribute Information ---------------- ----------------
76
+
77
+ // Flag to track if an email change is pending verification
78
+ let pendingEmailVerification = false;
79
+
80
+ // Listen for the custom email change event
81
+ window.addEventListener("userEmailChanged", (/*event*/) => {
82
+ // console.log("Custom event received: Email changed to", event.detail.email);
83
+ pendingEmailVerification = true; // Set flag to trigger verification
84
+ });
85
+
86
+
87
+ // Firebase State Change Function
88
+ onAuthStateChanged(auth, (user) => {
89
+
90
+ // Account Login
91
+ if (user) {
92
+
93
+ // Login Indicator
94
+ store.dispatch( userAuth(true) );
95
+
96
+ // Close Drawer State
97
+ store.dispatch( closeSign() );
98
+
99
+ // Backend Data Redux - Firebase User Information - account redux
100
+ store.dispatch( accID ( user.uid ) );
101
+ store.dispatch( accName ( user.displayName || 'John Doe' ) );
102
+ store.dispatch( accEmail ( user.email || 'Nothing' ) );
103
+ store.dispatch( accImage ( user.photoURL || 'images/empty.jpg' ) );
104
+
105
+ // store.dispatch( accPhone ( user.phoneNumber || '(000) 000-0000' ) );
106
+ // store.dispatch( accAnon ( user.isAnonymous ) );
107
+
108
+ // Frontend Data Redux - Firebase User Information - user redux
109
+ store.dispatch( nameAuth ( user.displayName || 'John Doe' ) );
110
+ store.dispatch( iconAuth ( user.photoURL || 'images/empty.jpg' ) );
111
+
112
+ // Email Change Listener - Custom Event
113
+ if (pendingEmailVerification && !user.emailVerified) {
114
+ // Send verification email for the updated email
115
+ sendEmailVerification(user)
116
+ .then(() => {
117
+ console.log("Verification email sent to:"/*, user.email*/);
118
+ pendingEmailVerification = false; // Reset flag after sending
119
+ })
120
+ .catch((error) => {
121
+ console.error("Error sending verification email:", error.message);
122
+ pendingEmailVerification = false; // Reset flag on error
123
+ });
124
+ } else if (user.emailVerified) {
125
+ console.log("User's email is already verified:"/*, user.email*/);
126
+ } else {
127
+ console.log("User signed in, no email verification pending:"/*, user.email*/);
128
+ }
129
+
130
+ // Existing Redux Profile Object
131
+ // const profile = store.getState().account;
132
+
133
+ // Redux - Firebase Database Information
134
+ // Dispatch Profile Object Information
135
+
136
+ }
137
+
138
+ // Account Log out
139
+ else {
140
+ // console.log('logged out');
141
+
142
+ // Login Indicator
143
+ store.dispatch( userAuth ( false ) );
144
+
145
+ // Backend Data Redux - Firebase User Information - account redux
146
+ store.dispatch( accID ( '' ) );
147
+ store.dispatch( accName ( 'John Doe' ) );
148
+ store.dispatch( accEmail ( 'Nothing' ) );
149
+ store.dispatch( accImage ( 'images/empty.jpg' ) );
150
+
151
+ // store.dispatch( accAnon ( false ) );
152
+ // store.dispatch( accPhone ( '(000) 000-0000' ) );
153
+
154
+ // Frontend Data Redux - Firebase User Information - user redux
155
+ store.dispatch( nameAuth ( 'John Doe' ) );
156
+ store.dispatch( iconAuth ( 'images/empty.jpg' ) );
157
+
158
+ // Dispatch Information
159
+
160
+ }
161
+
162
+ });
163
+
164
+ // End Distribute Informatiom ---------------- ----------------
165
+
166
+ // Exact Name Reference - Firebase Action
167
+ export const logOut = async () => { return signOut(auth); };
168
+ export const logAccount = async () => { logEvent(analytics, 'create_account'); };
169
+ export const logAccountDelete = async () => { logEvent(analytics, 'delete_account'); };
170
+ export const deleteDocument = async (collect:string, item:string) => {
171
+
172
+ await deleteDoc(doc(db, collect, item));
173
+
174
+ };
175
+
176
+
177
+
178
+
179
+
180
+ /*
181
+ // Object Initializer Notation
182
+ export interface fire {
183
+ apiKey: string,
184
+ authDomain: string,
185
+ databaseURL: string,
186
+ projectId: string,
187
+ storageBucket: string,
188
+ messagingSenderId: string,
189
+ appId: string,
190
+ measurementId: string
191
+ };
192
+
193
+
194
+ // Initialize Firebase Data
195
+ const admin: fire = {
196
+ appId: connect.appId,
197
+ apiKey: connect.apiKey,
198
+ authDomain: connect.authDomain,
199
+ databaseURL: connect.databaseURL,
200
+ projectId: connect.projectId,
201
+ storageBucket: connect.storageBucket,
202
+ messagingSenderId: connect.messagingSenderId,
203
+ measurementId: connect.measurementId
204
+ };
205
+ */
206
+
207
+
208
+ /*
209
+ window.connect = {};
210
+
211
+ declare global {
212
+ interface Window {
213
+ connect: any;
214
+ }
215
+ }
216
+ */
@@ -0,0 +1,20 @@
1
+
2
+ import { LitElement } from 'lit';
3
+ import { property } from 'lit/decorators.js';
4
+
5
+ export class LazyLoader extends LitElement {
6
+
7
+ /** @attr active */
8
+ @property({type: Boolean}) public active : boolean = false;
9
+
10
+ shouldUpdate() {
11
+ return this.active;
12
+ } // Only render this page, if it is actually visible.
13
+
14
+ }
15
+
16
+ declare global {
17
+ interface HTMLElementTagNameMap {
18
+ 'lazy-loader': LazyLoader;
19
+ }
20
+ }