@stokr/components-library 3.0.76 → 3.1.0-alpha.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/README.md +177 -177
- package/dist/components/Input/InputPassword.js +3 -5
- package/dist/components/Input/OtpInput.js +1 -3
- package/dist/components/MenuNav/MenuNav.styles.js +1 -2
- package/dist/components/Modal/Modal.js +6 -3
- package/dist/components/Modal/Modal.styles.js +2 -3
- package/dist/components/Modal/SuccessModal/SuccessModal.js +6 -3
- package/dist/components/Newsletter/Newsletter.js +1 -3
- package/dist/components/NotificationCounter/NotificationCounter.styles.js +1 -2
- package/dist/components/SmartLink/SmartLink.js +0 -2
- package/dist/components/StepController/StepController.js +3 -5
- package/dist/components/StepController/StepController.styles.js +102 -1
- package/dist/components/StepController/StepControllerProgress.js +1 -1
- package/dist/components/Switch/Switch.js +1 -3
- package/dist/components/ToDoList/ToDoListTask.js +15 -3
- package/dist/components/taxId/register-taxid.js +7 -5
- package/dist/index.js +67 -141
- package/dist/manifest.json +25 -25
- package/dist/robots.txt +3 -3
- package/dist/runtime-config.js +5 -71
- package/dist/static/fonts/icomoon/icomoon.eot +0 -0
- package/dist/static/fonts/icomoon/icomoon.svg +52 -52
- package/dist/static/fonts/icomoon/icomoon.ttf +0 -0
- package/dist/static/fonts/icomoon/icomoon.woff +0 -0
- package/dist/static/fonts/icomoon/selection.json +0 -0
- package/dist/static/fonts/icomoon/style.css +0 -0
- package/dist/static/images/Glassess.svg +5 -5
- package/dist/static/images/add-folder-icon.svg +4 -4
- package/dist/static/images/arrow-down-black.svg +21 -21
- package/dist/static/images/check-icon.svg +3 -3
- package/dist/static/images/checkmark-circle-icon.svg +3 -3
- package/dist/static/images/close-circle-icon.svg +2 -2
- package/dist/static/images/copy_icon.svg +4 -4
- package/dist/static/images/cross-icon.svg +3 -3
- package/dist/static/images/currency/eth.svg +10 -10
- package/dist/static/images/currency/eth_logo.svg +8 -8
- package/dist/static/images/currency/eur.svg +4 -4
- package/dist/static/images/currency/eur.svg.js +1 -1
- package/dist/static/images/currency/usd.svg +4 -4
- package/dist/static/images/currency/usd.svg.js +1 -1
- package/dist/static/images/currency/usdc-logo.svg +5 -5
- package/dist/static/images/doc-icon.svg +3 -3
- package/dist/static/images/download_icon.svg +3 -3
- package/dist/static/images/external-link-icon.svg +3 -3
- package/dist/static/images/filter-icon.svg +6 -6
- package/dist/static/images/globe.svg +15 -15
- package/dist/static/images/mangopay.svg +20 -20
- package/dist/static/images/numbers/number_eight.svg +3 -3
- package/dist/static/images/numbers/number_five.svg +4 -4
- package/dist/static/images/numbers/number_four.svg +3 -3
- package/dist/static/images/numbers/number_nine.svg +4 -4
- package/dist/static/images/numbers/number_one.svg +4 -4
- package/dist/static/images/numbers/number_seven.svg +4 -4
- package/dist/static/images/numbers/number_six.svg +4 -4
- package/dist/static/images/numbers/number_three.svg +3 -3
- package/dist/static/images/numbers/number_two.svg +4 -4
- package/dist/static/images/numbers/number_zero.svg +3 -3
- package/dist/static/images/plus-icon.svg +4 -4
- package/dist/static/images/prof-inv.svg +3 -3
- package/dist/static/images/search-icon.svg +3 -3
- package/dist/static/images/transfer-icon.svg +10 -10
- package/dist/static/images/trash.svg +16 -16
- package/dist/static/images/upload.svg +5 -5
- package/dist/static/images/warning-filled.svg +3 -3
- package/dist/styles/global.js +1 -2
- package/dist/utils/check-todo-status.js +1 -2
- package/package.json +137 -143
- package/dist/api/authenticationApi.js +0 -13
- package/dist/auth/index.js +0 -34
- package/dist/components/2FA/Connect2FA.js +0 -58
- package/dist/components/2FA/EnterCode.js +0 -74
- package/dist/components/2FA/InstallAuthApp.js +0 -68
- package/dist/components/2FA/ResetCode.js +0 -34
- package/dist/components/2FA/Sucess2FA.js +0 -63
- package/dist/components/2FA/disable-2fa-flow.js +0 -104
- package/dist/components/2FA/enable-2fa-flow.js +0 -167
- package/dist/components/2FA/login-with-otp-flow.js +0 -262
- package/dist/components/2FA/main-flow.js +0 -273
- package/dist/components/Footer/Footer.js +0 -69
- package/dist/components/Footer/Footer.styles.js +0 -277
- package/dist/components/Footer/FooterLayout.js +0 -150
- package/dist/components/Footer/FooterMenu.js +0 -107
- package/dist/components/Footer/FooterMenu.styles.js +0 -334
- package/dist/components/ForgotPasswordModal/ForgotPasswordModal.js +0 -121
- package/dist/components/Header/Header.js +0 -441
- package/dist/components/Header/Header.styles.js +0 -568
- package/dist/components/Layout/Layout.js +0 -76
- package/dist/components/LoginModal/LoginModal.js +0 -165
- package/dist/components/MainMenu/DynamicMainMenu.js +0 -38
- package/dist/components/MainMenu/MainMenu.js +0 -220
- package/dist/components/MainMenu/MainMenu.styles.js +0 -362
- package/dist/components/Modal/NewVentureModal/NewVentureModal.js +0 -273
- package/dist/components/RegisterConfirmModal/RegisterConfirmModal.js +0 -74
- package/dist/components/RegisterConfirmModal/RegisterConfirmModal.styles.js +0 -20
- package/dist/components/RegisterModal/RegisterModal.js +0 -278
- package/dist/components/ResetConfirmModal/ResetConfirmModal.js +0 -40
- package/dist/components/ResetConfirmModal/ResetConfirmModal.styles.js +0 -41
- package/dist/components/ResetPasswordModal/ResetPasswordModal.js +0 -145
- package/dist/components/StepsProgress/StepIndicator.js +0 -40
- package/dist/components/StepsProgress/StepIndicator.styles.js +0 -69
- package/dist/components/StepsProgress/StepsProgress.js +0 -67
- package/dist/components/StepsProgress/StepsProgress.styles.js +0 -105
- package/dist/components/TermsModal/TermsModal.js +0 -145
- package/dist/components/TermsModal/_styles.js +0 -313
- package/dist/components/VerifyEmailModal/VerifyEmailModal.js +0 -122
- package/dist/components/headerHo/HeaderHo.js +0 -707
- package/dist/config.js +0 -33
- package/dist/context/Auth.js +0 -423
- package/dist/context/AuthContext.js +0 -1016
- package/dist/firebase-config.js +0 -56
- package/dist/hooks/useNewVentureForm.js +0 -235
- package/dist/static/images/background3.png.js +0 -4
- package/dist/static/images/google_auth.png.js +0 -4
- package/dist/static/images/iso27001-black.svg.js +0 -4
- package/dist/static/images/mangopay.svg.js +0 -4
- package/dist/static/images/social/Facebook_Logo.png.js +0 -4
- package/dist/static/images/social/LI-In-Bug.png.js +0 -4
- package/dist/static/images/social/Telegram-Logo.png.js +0 -4
- package/dist/static/images/social/X-logo-black.png.js +0 -4
- package/dist/static/images/social/youtube_social_circle_red.png.js +0 -4
- package/dist/utils/show-account-locked-modal.js +0 -23
- package/dist/utils/user-identity.js +0 -10
- package/dist/utils/withRouter.js +0 -26
package/dist/config.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { isValidFirebaseConfig, initFirebase } from "./firebase-config.js";
|
|
2
|
-
import axiosInstance from "./model/axios.js";
|
|
3
|
-
import axiosInstance$1 from "./model/axiosPublic.js";
|
|
4
|
-
import { assignRuntimeConfig } from "./runtime-config.js";
|
|
5
|
-
import { getConfig, resetRuntimeConfig } from "./runtime-config.js";
|
|
6
|
-
let _lastFirebaseConfig = null;
|
|
7
|
-
function configure(config = {}) {
|
|
8
|
-
assignRuntimeConfig(config);
|
|
9
|
-
if (config.apiUrl != null) {
|
|
10
|
-
axiosInstance.defaults.baseURL = config.apiUrl;
|
|
11
|
-
}
|
|
12
|
-
if (config.baseUrlPublic != null) {
|
|
13
|
-
axiosInstance$1.defaults.baseURL = config.baseUrlPublic;
|
|
14
|
-
}
|
|
15
|
-
if (Object.prototype.hasOwnProperty.call(config, "firebase")) {
|
|
16
|
-
const fb = config.firebase;
|
|
17
|
-
if (fb != null && isValidFirebaseConfig(fb)) {
|
|
18
|
-
_lastFirebaseConfig = fb;
|
|
19
|
-
initFirebase(fb);
|
|
20
|
-
} else {
|
|
21
|
-
_lastFirebaseConfig = null;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function getLastFirebaseConfig() {
|
|
26
|
-
return _lastFirebaseConfig;
|
|
27
|
-
}
|
|
28
|
-
export {
|
|
29
|
-
configure,
|
|
30
|
-
getConfig,
|
|
31
|
-
getLastFirebaseConfig,
|
|
32
|
-
resetRuntimeConfig
|
|
33
|
-
};
|
package/dist/context/Auth.js
DELETED
|
@@ -1,423 +0,0 @@
|
|
|
1
|
-
import Cookies from "js-cookie";
|
|
2
|
-
import axiosInstance from "../model/axios.js";
|
|
3
|
-
import axiosInstance$1 from "../model/axiosPublic.js";
|
|
4
|
-
import getCookieDomain from "../utils/get-cookie-domain.js";
|
|
5
|
-
import { getLastFirebaseConfig } from "../config.js";
|
|
6
|
-
import { initFirebase, getFirebaseAuth } from "../firebase-config.js";
|
|
7
|
-
import { updatePassword, updateProfile, signInWithCustomToken, signInWithEmailAndPassword, createUserWithEmailAndPassword, applyActionCode, verifyPasswordResetCode, confirmPasswordReset, onAuthStateChanged } from "firebase/auth";
|
|
8
|
-
function normalizeCustomToken(token) {
|
|
9
|
-
if (token == null) return "";
|
|
10
|
-
if (typeof token === "object" && token !== null) {
|
|
11
|
-
const nested = (
|
|
12
|
-
/** @type {{ customToken?: string; custom_token?: string; token?: string }} */
|
|
13
|
-
token
|
|
14
|
-
);
|
|
15
|
-
if (typeof nested.customToken === "string") return normalizeCustomToken(nested.customToken);
|
|
16
|
-
if (typeof nested.custom_token === "string") return normalizeCustomToken(nested.custom_token);
|
|
17
|
-
if (typeof nested.token === "string") return normalizeCustomToken(nested.token);
|
|
18
|
-
return "";
|
|
19
|
-
}
|
|
20
|
-
if (typeof token !== "string") return "";
|
|
21
|
-
let t = token.trim();
|
|
22
|
-
if (!t) return "";
|
|
23
|
-
try {
|
|
24
|
-
t = decodeURIComponent(t.replace(/\+/g, " "));
|
|
25
|
-
} catch {
|
|
26
|
-
}
|
|
27
|
-
return t.trim();
|
|
28
|
-
}
|
|
29
|
-
const DEFAULT_TOKEN_EXPIRY_MS = 60 * 60 * 1e3;
|
|
30
|
-
class Auth {
|
|
31
|
-
/**
|
|
32
|
-
* @param {string} token - Access token to store
|
|
33
|
-
* @param {{ expiresInMs?: number }} [options] - Optional. expiresInMs: cookie lifetime in ms (default 1 hour)
|
|
34
|
-
*/
|
|
35
|
-
static setAccessToken(token, options = {}) {
|
|
36
|
-
this.logout();
|
|
37
|
-
const cookieOptions = getCookieDomain();
|
|
38
|
-
const raw = options?.expiresInMs;
|
|
39
|
-
const expiresInMs = typeof raw === "number" && Number.isFinite(raw) && raw > 0 ? raw : Number(DEFAULT_TOKEN_EXPIRY_MS) || 60 * 60 * 1e3;
|
|
40
|
-
const expiresAtMs = Date.now() + expiresInMs;
|
|
41
|
-
const expiresInDays = expiresInMs / (24 * 60 * 60 * 1e3);
|
|
42
|
-
const finalOptions = { ...cookieOptions, expires: expiresInDays };
|
|
43
|
-
Cookies.set("STOKR_ACCESS_TOKEN", token, finalOptions);
|
|
44
|
-
Cookies.set("STOKR_ACCESS_TOKEN_EXPIRES", String(expiresAtMs), finalOptions);
|
|
45
|
-
}
|
|
46
|
-
static getAccessToken() {
|
|
47
|
-
return Cookies.get("STOKR_ACCESS_TOKEN");
|
|
48
|
-
}
|
|
49
|
-
/** Returns the access token cookie expiry timestamp in ms, or null if not set. */
|
|
50
|
-
static getAccessTokenExpiresAt() {
|
|
51
|
-
const value = Cookies.get("STOKR_ACCESS_TOKEN_EXPIRES");
|
|
52
|
-
if (value == null || value === "") return null;
|
|
53
|
-
const ts = parseInt(value, 10);
|
|
54
|
-
return Number.isFinite(ts) ? ts : null;
|
|
55
|
-
}
|
|
56
|
-
static logout() {
|
|
57
|
-
const cookieDomain = getCookieDomain();
|
|
58
|
-
Cookies.remove("STOKR_ACCESS_TOKEN", cookieDomain);
|
|
59
|
-
Cookies.remove("STOKR_ACCESS_TOKEN_EXPIRES", cookieDomain);
|
|
60
|
-
if (cookieDomain.domain) {
|
|
61
|
-
Cookies.remove("STOKR_ACCESS_TOKEN");
|
|
62
|
-
Cookies.remove("STOKR_ACCESS_TOKEN_EXPIRES");
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
static async login(email, password) {
|
|
66
|
-
const auth = getFirebaseAuth();
|
|
67
|
-
if (!auth) {
|
|
68
|
-
throw new Error(
|
|
69
|
-
"Firebase is not configured. Pass config.firebase via configure() / AuthProvider, or set VITE_FIREBASE_* for dev."
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
try {
|
|
73
|
-
const userCredential = await signInWithEmailAndPassword(auth, email, password);
|
|
74
|
-
return userCredential?.user;
|
|
75
|
-
} catch (sdkError) {
|
|
76
|
-
if (sdkError?.code !== "auth/network-request-failed") {
|
|
77
|
-
throw sdkError;
|
|
78
|
-
}
|
|
79
|
-
console.warn("[Auth.login] SDK signIn failed with network-request-failed, trying REST API fallback…");
|
|
80
|
-
const apiKey = auth.config?.apiKey;
|
|
81
|
-
if (!apiKey) throw sdkError;
|
|
82
|
-
const res = await fetch(`https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=${apiKey}`, {
|
|
83
|
-
method: "POST",
|
|
84
|
-
headers: { "Content-Type": "application/json" },
|
|
85
|
-
body: JSON.stringify({ email, password, returnSecureToken: true })
|
|
86
|
-
});
|
|
87
|
-
const data = await res.json();
|
|
88
|
-
if (!res.ok) {
|
|
89
|
-
const fbCode = data?.error?.message;
|
|
90
|
-
const err = new Error(
|
|
91
|
-
fbCode === "INVALID_LOGIN_CREDENTIALS" ? "The credentials are not correct. Try again?" : data?.error?.message || "Authentication failed"
|
|
92
|
-
);
|
|
93
|
-
err.code = fbCode === "INVALID_LOGIN_CREDENTIALS" ? "auth/invalid-credential" : "auth/internal-error";
|
|
94
|
-
throw err;
|
|
95
|
-
}
|
|
96
|
-
const { signInWithCustomToken: signInCustom } = await import("firebase/auth");
|
|
97
|
-
try {
|
|
98
|
-
const cred = await signInCustom(auth, data.idToken);
|
|
99
|
-
return cred?.user;
|
|
100
|
-
} catch {
|
|
101
|
-
return {
|
|
102
|
-
uid: data.localId,
|
|
103
|
-
email: data.email,
|
|
104
|
-
emailVerified: data.emailVerified ?? false,
|
|
105
|
-
displayName: data.displayName || "",
|
|
106
|
-
getIdToken: () => Promise.resolve(data.idToken),
|
|
107
|
-
toJSON: () => ({ uid: data.localId, email: data.email })
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
static createUser(email, password) {
|
|
113
|
-
return new Promise((resolve, reject) => {
|
|
114
|
-
const auth = getFirebaseAuth();
|
|
115
|
-
if (!auth) {
|
|
116
|
-
reject(new Error("Firebase is not configured."));
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
createUserWithEmailAndPassword(auth, email, password).then((userCredential) => {
|
|
120
|
-
const user = userCredential?.user;
|
|
121
|
-
resolve(user);
|
|
122
|
-
}).catch((error) => {
|
|
123
|
-
reject(error);
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
static twoFactor(data) {
|
|
128
|
-
return new Promise((resolve, reject) => {
|
|
129
|
-
axiosInstance.post(`auth/confirm2fa`, data).then((response) => {
|
|
130
|
-
resolve(response.data);
|
|
131
|
-
}).catch((err) => {
|
|
132
|
-
reject(err);
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
static reportFailedLoginAttempt(email) {
|
|
137
|
-
return new Promise((resolve, reject) => {
|
|
138
|
-
axiosInstance$1.post(`auth/failed-login-attempt`, { email }).then((response) => {
|
|
139
|
-
resolve(response.data);
|
|
140
|
-
}).catch((err) => {
|
|
141
|
-
reject(err);
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
static resendActivationEmail(email) {
|
|
146
|
-
return new Promise((resolve, reject) => {
|
|
147
|
-
axiosInstance.post(`auth/resend-activation-email`, {
|
|
148
|
-
email
|
|
149
|
-
}).then((response) => {
|
|
150
|
-
resolve(response.data);
|
|
151
|
-
}).catch((err) => {
|
|
152
|
-
reject(err);
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
static handleVerifyEmail(actionCode) {
|
|
157
|
-
return new Promise((resolve, reject) => {
|
|
158
|
-
const auth = getFirebaseAuth();
|
|
159
|
-
if (!auth) {
|
|
160
|
-
reject(new Error("Firebase is not configured."));
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
applyActionCode(auth, actionCode).then((resp) => {
|
|
164
|
-
resolve(resp);
|
|
165
|
-
}).catch((error) => {
|
|
166
|
-
reject(error);
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
static handleResetPassword(actionCode, newPassword) {
|
|
171
|
-
return new Promise((resolve, reject) => {
|
|
172
|
-
const auth = getFirebaseAuth();
|
|
173
|
-
if (!auth) {
|
|
174
|
-
reject(new Error("Firebase is not configured."));
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
verifyPasswordResetCode(auth, actionCode).then((email) => {
|
|
178
|
-
const accountEmail = email;
|
|
179
|
-
confirmPasswordReset(auth, actionCode, newPassword).then(() => {
|
|
180
|
-
resolve(accountEmail);
|
|
181
|
-
}).catch((error) => {
|
|
182
|
-
reject(error);
|
|
183
|
-
});
|
|
184
|
-
}).catch((error) => {
|
|
185
|
-
reject(error);
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
static getUser() {
|
|
190
|
-
return new Promise((resolve, reject) => {
|
|
191
|
-
axiosInstance.post(`user/get`).then((response) => {
|
|
192
|
-
resolve(response.data);
|
|
193
|
-
}).catch((err) => {
|
|
194
|
-
reject(err);
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
static getFirebaseUser() {
|
|
199
|
-
return new Promise((resolve, reject) => {
|
|
200
|
-
const auth = getFirebaseAuth();
|
|
201
|
-
if (!auth) {
|
|
202
|
-
reject(new Error("Firebase is not configured."));
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
const unsubscribe = onAuthStateChanged(auth, (user) => {
|
|
206
|
-
unsubscribe();
|
|
207
|
-
if (user) {
|
|
208
|
-
resolve(user);
|
|
209
|
-
} else {
|
|
210
|
-
reject("User is signed out");
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
static refreshIdToken() {
|
|
216
|
-
return new Promise((resolve, reject) => {
|
|
217
|
-
const auth = getFirebaseAuth();
|
|
218
|
-
if (!auth) {
|
|
219
|
-
reject(new Error("Firebase is not configured."));
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
var user = auth.currentUser;
|
|
223
|
-
if (!user) reject("User not available");
|
|
224
|
-
user.getIdToken(true).then((idToken) => {
|
|
225
|
-
resolve(idToken);
|
|
226
|
-
}).catch((error) => {
|
|
227
|
-
reject(error);
|
|
228
|
-
});
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
static signInWithToken(token) {
|
|
232
|
-
return new Promise((resolve, reject) => {
|
|
233
|
-
const normalized = normalizeCustomToken(token);
|
|
234
|
-
if (!normalized) {
|
|
235
|
-
reject(
|
|
236
|
-
Object.assign(new Error("Invalid or empty Firebase custom token."), {
|
|
237
|
-
code: "auth/invalid-custom-token"
|
|
238
|
-
})
|
|
239
|
-
);
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
let auth = getFirebaseAuth();
|
|
243
|
-
if (!auth) {
|
|
244
|
-
const fb = getLastFirebaseConfig();
|
|
245
|
-
if (fb) {
|
|
246
|
-
initFirebase(fb);
|
|
247
|
-
auth = getFirebaseAuth();
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
if (!auth) {
|
|
251
|
-
reject(new Error("Firebase is not configured. Pass config.firebase via configure() / AuthProvider."));
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
signInWithCustomToken(auth, normalized).then((userCredential) => {
|
|
255
|
-
const user = userCredential?.user;
|
|
256
|
-
if (!user) {
|
|
257
|
-
reject(new Error("signInWithCustomToken returned no user."));
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
resolve(user);
|
|
261
|
-
}).catch((error) => {
|
|
262
|
-
reject(error);
|
|
263
|
-
});
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
static updateUserPassword(user, newPassword) {
|
|
267
|
-
return new Promise((resolve, reject) => {
|
|
268
|
-
updatePassword(user, newPassword).then(() => {
|
|
269
|
-
resolve();
|
|
270
|
-
}).catch((error) => {
|
|
271
|
-
reject(error);
|
|
272
|
-
});
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
static requestUpdateEmail(data) {
|
|
276
|
-
return new Promise((resolve, reject) => {
|
|
277
|
-
axiosInstance.post(`user/requestUpdateEmail`, data).then((response) => {
|
|
278
|
-
resolve(response.data);
|
|
279
|
-
}).catch((err) => {
|
|
280
|
-
reject(err);
|
|
281
|
-
});
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
static checkPrivateInvestor(data) {
|
|
285
|
-
return new Promise((resolve, reject) => {
|
|
286
|
-
axiosInstance.post(`private-investor/check`, data).then((response) => {
|
|
287
|
-
resolve(response.data);
|
|
288
|
-
}).catch((err) => {
|
|
289
|
-
reject(err);
|
|
290
|
-
});
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
static checkIfUserSubscribed(data) {
|
|
294
|
-
return new Promise((resolve, reject) => {
|
|
295
|
-
axiosInstance.post(`emails/checksubscription`, data).then((response) => {
|
|
296
|
-
resolve(response.data);
|
|
297
|
-
}).catch((err) => {
|
|
298
|
-
reject(err);
|
|
299
|
-
});
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
static fetchTrackingUserLastTime(data) {
|
|
303
|
-
return new Promise((resolve, reject) => {
|
|
304
|
-
axiosInstance.post(`tracking-user/getLast`, data).then((response) => {
|
|
305
|
-
resolve(response.data);
|
|
306
|
-
}).catch((err) => {
|
|
307
|
-
reject(err);
|
|
308
|
-
});
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
static updateUser(data) {
|
|
312
|
-
return new Promise((resolve, reject) => {
|
|
313
|
-
axiosInstance.post(`user/update`, data).then((response) => {
|
|
314
|
-
resolve(response.data);
|
|
315
|
-
}).catch((err) => {
|
|
316
|
-
reject(err);
|
|
317
|
-
});
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
static updateFirebaseUser(user, data) {
|
|
321
|
-
return new Promise((resolve, reject) => {
|
|
322
|
-
updateProfile(user, data).then(() => {
|
|
323
|
-
resolve();
|
|
324
|
-
}).catch((error) => {
|
|
325
|
-
reject(error);
|
|
326
|
-
});
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
static sendWelcomeEmail() {
|
|
330
|
-
return new Promise((resolve, reject) => {
|
|
331
|
-
axiosInstance.post(`user/welcomeEmail`).then(() => {
|
|
332
|
-
resolve();
|
|
333
|
-
}).catch((err) => {
|
|
334
|
-
reject(err);
|
|
335
|
-
});
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
static createWallet(data) {
|
|
339
|
-
return new Promise((resolve, reject) => {
|
|
340
|
-
axiosInstance.post(`wallets/create`, data).then((response) => {
|
|
341
|
-
resolve(response.data);
|
|
342
|
-
}).catch((err) => {
|
|
343
|
-
reject(err);
|
|
344
|
-
});
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
static uploaProofOfAddress(data, ip) {
|
|
348
|
-
const kycBaseUrl = "https://kycdocs.stokr.io";
|
|
349
|
-
return new Promise((resolve, reject) => {
|
|
350
|
-
axiosInstance.post(`${kycBaseUrl}/kyc/upload?ip=${encodeURIComponent(ip)}`, data, {
|
|
351
|
-
headers: {
|
|
352
|
-
"Content-Type": "multipart/form-data"
|
|
353
|
-
}
|
|
354
|
-
}).then((response) => {
|
|
355
|
-
resolve(response.data);
|
|
356
|
-
}).catch((err) => {
|
|
357
|
-
reject(err);
|
|
358
|
-
});
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
static validateGreenWalletId(id) {
|
|
362
|
-
return new Promise((resolve, reject) => {
|
|
363
|
-
axiosInstance.post(`wallets/validate-gaid`, {
|
|
364
|
-
gaid: id
|
|
365
|
-
}).then((response) => {
|
|
366
|
-
resolve(response.data);
|
|
367
|
-
}).catch((err) => {
|
|
368
|
-
reject(err);
|
|
369
|
-
});
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
/**
|
|
373
|
-
* Get the authenticated user's avatar from service-media.
|
|
374
|
-
* Returns the image Blob, or null when the user has no picture (404).
|
|
375
|
-
*/
|
|
376
|
-
static getAvatar() {
|
|
377
|
-
return new Promise((resolve, reject) => {
|
|
378
|
-
axiosInstance.post(`media/user/avatar/get`, void 0, { responseType: "blob" }).then((response) => {
|
|
379
|
-
resolve(response.data);
|
|
380
|
-
}).catch((err) => {
|
|
381
|
-
if (err?.response?.status === 404) {
|
|
382
|
-
resolve(null);
|
|
383
|
-
return;
|
|
384
|
-
}
|
|
385
|
-
reject(err);
|
|
386
|
-
});
|
|
387
|
-
});
|
|
388
|
-
}
|
|
389
|
-
/**
|
|
390
|
-
* Upload the authenticated user's avatar to service-media.
|
|
391
|
-
* Responds 201 with the processed (resized) image, so we read it back as a Blob.
|
|
392
|
-
* @param data FormData with a `file` field (jpeg/png, ≤10mb)
|
|
393
|
-
*/
|
|
394
|
-
static uploadPhoto(data) {
|
|
395
|
-
return new Promise((resolve, reject) => {
|
|
396
|
-
axiosInstance.post(`media/user/avatar/upload`, data, {
|
|
397
|
-
responseType: "blob",
|
|
398
|
-
headers: { "Content-Type": "multipart/form-data" }
|
|
399
|
-
}).then((response) => {
|
|
400
|
-
resolve(response.data);
|
|
401
|
-
}).catch((err) => {
|
|
402
|
-
reject(err);
|
|
403
|
-
});
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* Delete the authenticated user's avatar from service-media.
|
|
408
|
-
*/
|
|
409
|
-
static deletePhoto() {
|
|
410
|
-
return new Promise((resolve, reject) => {
|
|
411
|
-
axiosInstance.post(`media/user/avatar/delete`).then((response) => {
|
|
412
|
-
resolve(response.data);
|
|
413
|
-
}).catch((err) => {
|
|
414
|
-
reject(err);
|
|
415
|
-
});
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
export {
|
|
420
|
-
Auth,
|
|
421
|
-
DEFAULT_TOKEN_EXPIRY_MS,
|
|
422
|
-
Auth as default
|
|
423
|
-
};
|