@mxpicture/gcp-functions-frontend 0.1.17 → 0.1.18
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const authErrorText: (code: string | undefined) => string | undefined;
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { AuthErrorCodes as c } from "firebase/auth";
|
|
2
|
+
const errorMessages = [
|
|
3
|
+
{
|
|
4
|
+
code: c.ADMIN_ONLY_OPERATION,
|
|
5
|
+
text: "Admin Restricted Operation",
|
|
6
|
+
},
|
|
7
|
+
{ code: c.ARGUMENT_ERROR, text: "Argument Error" },
|
|
8
|
+
{ code: c.APP_NOT_AUTHORIZED, text: "App Not Authorized" },
|
|
9
|
+
{ code: c.APP_NOT_INSTALLED, text: "App Not Installed" },
|
|
10
|
+
{ code: c.CAPTCHA_CHECK_FAILED, text: "Captcha Check Failed" },
|
|
11
|
+
{ code: c.CODE_EXPIRED, text: "Code Expired" },
|
|
12
|
+
{ code: c.CORDOVA_NOT_READY, text: "Cordova Not Ready" },
|
|
13
|
+
{ code: c.CORS_UNSUPPORTED, text: "Cors Unsupported" },
|
|
14
|
+
{
|
|
15
|
+
code: c.CREDENTIAL_ALREADY_IN_USE,
|
|
16
|
+
text: "Credential Already In Use",
|
|
17
|
+
},
|
|
18
|
+
{ code: c.CREDENTIAL_MISMATCH, text: "Custom Token Mismatch" },
|
|
19
|
+
{
|
|
20
|
+
code: c.CREDENTIAL_TOO_OLD_LOGIN_AGAIN,
|
|
21
|
+
text: "Requires Recent Login",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
code: c.DEPENDENT_SDK_INIT_BEFORE_AUTH,
|
|
25
|
+
text: "Dependent Sdk Initialized Before Auth",
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
code: c.DYNAMIC_LINK_NOT_ACTIVATED,
|
|
29
|
+
text: "Dynamic Link Not Activated",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
code: c.EMAIL_CHANGE_NEEDS_VERIFICATION,
|
|
33
|
+
text: "Email Change Needs Verification",
|
|
34
|
+
},
|
|
35
|
+
{ code: c.EMAIL_EXISTS, text: "Email Already In Use" },
|
|
36
|
+
{
|
|
37
|
+
code: c.EMULATOR_CONFIG_FAILED,
|
|
38
|
+
text: "Emulator Config Failed",
|
|
39
|
+
},
|
|
40
|
+
{ code: c.EXPIRED_OOB_CODE, text: "Expired Action Code" },
|
|
41
|
+
{
|
|
42
|
+
code: c.EXPIRED_POPUP_REQUEST,
|
|
43
|
+
text: "Cancelled Popup Request",
|
|
44
|
+
},
|
|
45
|
+
{ code: c.INTERNAL_ERROR, text: "Internal Error" },
|
|
46
|
+
{ code: c.INVALID_API_KEY, text: "Invalid Api Key" },
|
|
47
|
+
{
|
|
48
|
+
code: c.INVALID_APP_CREDENTIAL,
|
|
49
|
+
text: "Invalid App Credential",
|
|
50
|
+
},
|
|
51
|
+
{ code: c.INVALID_APP_ID, text: "Invalid App Id" },
|
|
52
|
+
{ code: c.INVALID_AUTH, text: "Invalid User Token" },
|
|
53
|
+
{ code: c.INVALID_AUTH_EVENT, text: "Invalid Auth Event" },
|
|
54
|
+
{ code: c.INVALID_CERT_HASH, text: "Invalid Cert Hash" },
|
|
55
|
+
{ code: c.INVALID_CODE, text: "Invalid Verification Code" },
|
|
56
|
+
{ code: c.INVALID_CONTINUE_URI, text: "Invalid Continue Uri" },
|
|
57
|
+
{
|
|
58
|
+
code: c.INVALID_CORDOVA_CONFIGURATION,
|
|
59
|
+
text: "Invalid Cordova Configuration",
|
|
60
|
+
},
|
|
61
|
+
{ code: c.INVALID_CUSTOM_TOKEN, text: "Invalid Custom Token" },
|
|
62
|
+
{
|
|
63
|
+
code: c.INVALID_DYNAMIC_LINK_DOMAIN,
|
|
64
|
+
text: "Invalid Dynamic Link Domain",
|
|
65
|
+
},
|
|
66
|
+
{ code: c.INVALID_EMAIL, text: "Invalid Email" },
|
|
67
|
+
{
|
|
68
|
+
code: c.INVALID_EMULATOR_SCHEME,
|
|
69
|
+
text: "Invalid Emulator Scheme",
|
|
70
|
+
},
|
|
71
|
+
{ code: c.INVALID_IDP_RESPONSE, text: "Invalid Credential" },
|
|
72
|
+
{
|
|
73
|
+
code: c.INVALID_LOGIN_CREDENTIALS,
|
|
74
|
+
text: "Invalid Credential",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
code: c.INVALID_MESSAGE_PAYLOAD,
|
|
78
|
+
text: "Invalid Message Payload",
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
code: c.INVALID_MFA_SESSION,
|
|
82
|
+
text: "Invalid Multi Factor Session",
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
code: c.INVALID_OAUTH_CLIENT_ID,
|
|
86
|
+
text: "Invalid Oauth Client Id",
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
code: c.INVALID_OAUTH_PROVIDER,
|
|
90
|
+
text: "Invalid Oauth Provider",
|
|
91
|
+
},
|
|
92
|
+
{ code: c.INVALID_OOB_CODE, text: "Invalid Action Code" },
|
|
93
|
+
{ code: c.INVALID_ORIGIN, text: "Unauthorized Domain" },
|
|
94
|
+
{ code: c.INVALID_PASSWORD, text: "Wrong Password" },
|
|
95
|
+
{
|
|
96
|
+
code: c.INVALID_PERSISTENCE,
|
|
97
|
+
text: "Invalid Persistence Type",
|
|
98
|
+
},
|
|
99
|
+
{ code: c.INVALID_PHONE_NUMBER, text: "Invalid Phone Number" },
|
|
100
|
+
{ code: c.INVALID_PROVIDER_ID, text: "Invalid Provider Id" },
|
|
101
|
+
{
|
|
102
|
+
code: c.INVALID_RECIPIENT_EMAIL,
|
|
103
|
+
text: "Invalid Recipient Email",
|
|
104
|
+
},
|
|
105
|
+
{ code: c.INVALID_SENDER, text: "Invalid Sender" },
|
|
106
|
+
{
|
|
107
|
+
code: c.INVALID_SESSION_INFO,
|
|
108
|
+
text: "Invalid Verification Id",
|
|
109
|
+
},
|
|
110
|
+
{ code: c.INVALID_TENANT_ID, text: "Invalid Tenant Id" },
|
|
111
|
+
{
|
|
112
|
+
code: c.MFA_INFO_NOT_FOUND,
|
|
113
|
+
text: "Multi Factor Info Not Found",
|
|
114
|
+
},
|
|
115
|
+
{ code: c.MFA_REQUIRED, text: "Multi Factor Auth Required" },
|
|
116
|
+
{
|
|
117
|
+
code: c.MISSING_ANDROID_PACKAGE_NAME,
|
|
118
|
+
text: "Missing Android Pkg Name",
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
code: c.MISSING_APP_CREDENTIAL,
|
|
122
|
+
text: "Missing App Credential",
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
code: c.MISSING_AUTH_DOMAIN,
|
|
126
|
+
text: "Auth Domain Config Required",
|
|
127
|
+
},
|
|
128
|
+
{ code: c.MISSING_CODE, text: "Missing Verification Code" },
|
|
129
|
+
{ code: c.MISSING_CONTINUE_URI, text: "Missing Continue Uri" },
|
|
130
|
+
{ code: c.MISSING_IFRAME_START, text: "Missing Iframe Start" },
|
|
131
|
+
{ code: c.MISSING_IOS_BUNDLE_ID, text: "Missing Ios Bundle Id" },
|
|
132
|
+
{
|
|
133
|
+
code: c.MISSING_OR_INVALID_NONCE,
|
|
134
|
+
text: "Missing Or Invalid Nonce",
|
|
135
|
+
},
|
|
136
|
+
{ code: c.MISSING_MFA_INFO, text: "Missing Multi Factor Info" },
|
|
137
|
+
{
|
|
138
|
+
code: c.MISSING_MFA_SESSION,
|
|
139
|
+
text: "Missing Multi Factor Session",
|
|
140
|
+
},
|
|
141
|
+
{ code: c.MISSING_PHONE_NUMBER, text: "Missing Phone Number" },
|
|
142
|
+
{ code: c.MISSING_PASSWORD, text: "Missing Password" },
|
|
143
|
+
{
|
|
144
|
+
code: c.MISSING_SESSION_INFO,
|
|
145
|
+
text: "Missing Verification Id",
|
|
146
|
+
},
|
|
147
|
+
{ code: c.MODULE_DESTROYED, text: "App Deleted" },
|
|
148
|
+
{
|
|
149
|
+
code: c.NEED_CONFIRMATION,
|
|
150
|
+
text: "Account Exists With Different Credential",
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
code: c.NETWORK_REQUEST_FAILED,
|
|
154
|
+
text: "Network Request Failed",
|
|
155
|
+
},
|
|
156
|
+
{ code: c.NULL_USER, text: "Null User" },
|
|
157
|
+
{ code: c.NO_AUTH_EVENT, text: "No Auth Event" },
|
|
158
|
+
{ code: c.NO_SUCH_PROVIDER, text: "No Such Provider" },
|
|
159
|
+
{ code: c.OPERATION_NOT_ALLOWED, text: "Operation Not Allowed" },
|
|
160
|
+
{
|
|
161
|
+
code: c.OPERATION_NOT_SUPPORTED,
|
|
162
|
+
text: "Operation Not Supported In This Environment",
|
|
163
|
+
},
|
|
164
|
+
{ code: c.POPUP_BLOCKED, text: "Popup Blocked" },
|
|
165
|
+
{ code: c.POPUP_CLOSED_BY_USER, text: "Popup Closed By User" },
|
|
166
|
+
{
|
|
167
|
+
code: c.PROVIDER_ALREADY_LINKED,
|
|
168
|
+
text: "Provider Already Linked",
|
|
169
|
+
},
|
|
170
|
+
{ code: c.QUOTA_EXCEEDED, text: "Quota Exceeded" },
|
|
171
|
+
{
|
|
172
|
+
code: c.REDIRECT_CANCELLED_BY_USER,
|
|
173
|
+
text: "Redirect Cancelled By User",
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
code: c.REDIRECT_OPERATION_PENDING,
|
|
177
|
+
text: "Redirect Operation Pending",
|
|
178
|
+
},
|
|
179
|
+
{ code: c.REJECTED_CREDENTIAL, text: "Rejected Credential" },
|
|
180
|
+
{
|
|
181
|
+
code: c.SECOND_FACTOR_ALREADY_ENROLLED,
|
|
182
|
+
text: "Second Factor Already In Use",
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
code: c.SECOND_FACTOR_LIMIT_EXCEEDED,
|
|
186
|
+
text: "Maximum Second Factor Count Exceeded",
|
|
187
|
+
},
|
|
188
|
+
{ code: c.TENANT_ID_MISMATCH, text: "Tenant Id Mismatch" },
|
|
189
|
+
{ code: c.TIMEOUT, text: "Timeout" },
|
|
190
|
+
{ code: c.TOKEN_EXPIRED, text: "User Token Expired" },
|
|
191
|
+
{
|
|
192
|
+
code: c.TOO_MANY_ATTEMPTS_TRY_LATER,
|
|
193
|
+
text: "Too Many Requests",
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
code: c.UNAUTHORIZED_DOMAIN,
|
|
197
|
+
text: "Unauthorized Continue Uri",
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
code: c.UNSUPPORTED_FIRST_FACTOR,
|
|
201
|
+
text: "Unsupported First Factor",
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
code: c.UNSUPPORTED_PERSISTENCE,
|
|
205
|
+
text: "Unsupported Persistence Type",
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
code: c.UNSUPPORTED_TENANT_OPERATION,
|
|
209
|
+
text: "Unsupported Tenant Operation",
|
|
210
|
+
},
|
|
211
|
+
{ code: c.UNVERIFIED_EMAIL, text: "Unverified Email" },
|
|
212
|
+
{ code: c.USER_CANCELLED, text: "User Cancelled" },
|
|
213
|
+
{ code: c.USER_DELETED, text: "User Not Found" },
|
|
214
|
+
{ code: c.USER_DISABLED, text: "User Disabled" },
|
|
215
|
+
{ code: c.USER_MISMATCH, text: "User Mismatch" },
|
|
216
|
+
{ code: c.USER_SIGNED_OUT, text: "User Signed Out" },
|
|
217
|
+
{ code: c.WEAK_PASSWORD, text: "Weak Password" },
|
|
218
|
+
{
|
|
219
|
+
code: c.WEB_STORAGE_UNSUPPORTED,
|
|
220
|
+
text: "Web Storage Unsupported",
|
|
221
|
+
},
|
|
222
|
+
{ code: c.ALREADY_INITIALIZED, text: "Already Initialized" },
|
|
223
|
+
{ code: c.RECAPTCHA_NOT_ENABLED, text: "Recaptcha Not Enabled" },
|
|
224
|
+
{
|
|
225
|
+
code: c.MISSING_RECAPTCHA_TOKEN,
|
|
226
|
+
text: "Missing Recaptcha Token",
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
code: c.INVALID_RECAPTCHA_TOKEN,
|
|
230
|
+
text: "Invalid Recaptcha Token",
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
code: c.INVALID_RECAPTCHA_ACTION,
|
|
234
|
+
text: "Invalid Recaptcha Action",
|
|
235
|
+
},
|
|
236
|
+
{ code: c.MISSING_CLIENT_TYPE, text: "Missing Client Type" },
|
|
237
|
+
{
|
|
238
|
+
code: c.MISSING_RECAPTCHA_VERSION,
|
|
239
|
+
text: "Missing Recaptcha Version",
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
code: c.INVALID_RECAPTCHA_VERSION,
|
|
243
|
+
text: "Invalid Recaptcha Version",
|
|
244
|
+
},
|
|
245
|
+
{ code: c.INVALID_REQ_TYPE, text: "Invalid Req Type" },
|
|
246
|
+
{
|
|
247
|
+
code: c.INVALID_HOSTING_LINK_DOMAIN,
|
|
248
|
+
text: "Invalid Hosting Link Domain",
|
|
249
|
+
},
|
|
250
|
+
];
|
|
251
|
+
export const authErrorText = (code) => errorMessages.find((e) => e.code === code)?.text ?? code;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { authErrorText } from "./auth.helper.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { authErrorText } from "./auth.helper.js";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { configFirebase } from "../../config/firebase.config.js";
|
|
2
2
|
import { loadFirebaseAuth } from "../../loader/firebase.loader.js";
|
|
3
|
+
import { authErrorText } from "../../helper/auth.helper.js";
|
|
3
4
|
class AuthService {
|
|
4
5
|
async login(credentials) {
|
|
5
6
|
try {
|
|
@@ -67,14 +68,7 @@ class AuthService {
|
|
|
67
68
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
68
69
|
handleAuthError(error) {
|
|
69
70
|
// Map Firebase error codes to user-friendly messages
|
|
70
|
-
const
|
|
71
|
-
"auth/user-not-found": "User not found",
|
|
72
|
-
"auth/wrong-password": "Incorrect password",
|
|
73
|
-
"auth/email-already-in-use": "Email already in use",
|
|
74
|
-
"auth/weak-password": "Password is too weak",
|
|
75
|
-
"auth/invalid-email": "Invalid email format",
|
|
76
|
-
};
|
|
77
|
-
const message = errorMessages[error.code] || error.message || "An error occurred";
|
|
71
|
+
const message = authErrorText(error?.code) || error.message || "An error occurred";
|
|
78
72
|
return new Error(message);
|
|
79
73
|
}
|
|
80
74
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mxpicture/gcp-functions-frontend",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"description": "Utils for google cloud functions, publishing both CommonJS and ESM builds",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "MXPicture",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"./services/firebase": "./dist/services/firebase/index.js",
|
|
15
15
|
"./types": "./dist/types/index.js",
|
|
16
16
|
"./api": "./dist/api/index.js",
|
|
17
|
+
"./helper": "./dist/helper/index.js",
|
|
17
18
|
"./package.json": "./package.json"
|
|
18
19
|
},
|
|
19
20
|
"files": [
|