@stokr/components-library 3.0.28 → 3.0.30
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/dist/components/ToDoList/ToDoListTask.js +2 -1
- package/dist/components/icons/LinkIcon.js +2 -2
- package/dist/context/Auth.js +2 -2
- package/dist/context/AuthContext.js +97 -16
- package/dist/firebase-config.js +0 -4
- package/dist/runtime-config.js +1 -1
- package/dist/static/country-list.json +251 -251
- package/dist/static/fonts/Ionicons/ionicons.min.css +2810 -2810
- package/dist/static/fonts/Ionicons/ionicons.min.css.js +1 -1
- package/dist/static/fonts/icomoon/selection.json +910 -910
- package/dist/static/fonts/icomoon/style.css +139 -139
- package/dist/static/images/copy_icon.svg +4 -4
- package/dist/static/images/download_icon.svg +3 -3
- 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/search-icon.svg +3 -3
- package/dist/static/images/transfer-icon.svg +10 -10
- package/dist/static/images/warning-filled.svg +3 -3
- package/dist/utils/get-cookie-domain.js +3 -2
- package/dist/utils/set-redirect-cookie.js +3 -2
- package/dist/utils/user-identity.js +4 -1
- package/package.json +1 -1
|
@@ -21,7 +21,8 @@ import "../RefreshButton/RefreshButton.js";
|
|
|
21
21
|
import "../SectionTitle/SectionTitle.styles.js";
|
|
22
22
|
import "../FAQ/FAQ.js";
|
|
23
23
|
import "js-cookie";
|
|
24
|
-
import "
|
|
24
|
+
import "firebase/app";
|
|
25
|
+
import "firebase/auth";
|
|
25
26
|
import "../../model/axios.js";
|
|
26
27
|
import "../../model/axiosPublic.js";
|
|
27
28
|
import "../../utils/redirect-url.js";
|
|
@@ -17,13 +17,13 @@ const LinkIcon = () => /* @__PURE__ */ jsxs(
|
|
|
17
17
|
/* @__PURE__ */ jsx("g", { children: /* @__PURE__ */ jsx("g", { children: /* @__PURE__ */ jsx(
|
|
18
18
|
"path",
|
|
19
19
|
{
|
|
20
|
-
d: "M312.453,199.601c-6.066-6.102-12.792-11.511-20.053-16.128c-19.232-12.315-41.59-18.859-64.427-18.859\n c-31.697-0.059-62.106,12.535-84.48,34.987L34.949,308.23c-22.336,22.379-34.89,52.7-34.91,84.318\n c-0.042,65.98,53.41,119.501,119.39,119.543c31.648,0.11,62.029-12.424,84.395-34.816l89.6-89.6\n c1.628-1.614,2.537-3.816,2.524-6.108c-0.027-4.713-3.87-8.511-8.583-8.484h-3.413c-18.72,0.066-37.273-3.529-54.613-10.581\n c-3.195-1.315-6.867-0.573-9.301,1.877l-64.427,64.512c-20.006,20.006-52.442,20.006-72.448,0\n c-20.006-20.006-20.006-52.442,0-72.448l108.971-108.885c19.99-19.965,52.373-19.965,72.363,0\n c13.472,12.679,34.486,12.679,47.957,0c5.796-5.801,9.31-13.495,9.899-21.675C322.976,216.108,319.371,206.535,312.453,199.601z"
|
|
20
|
+
d: "M312.453,199.601c-6.066-6.102-12.792-11.511-20.053-16.128c-19.232-12.315-41.59-18.859-64.427-18.859\r\n c-31.697-0.059-62.106,12.535-84.48,34.987L34.949,308.23c-22.336,22.379-34.89,52.7-34.91,84.318\r\n c-0.042,65.98,53.41,119.501,119.39,119.543c31.648,0.11,62.029-12.424,84.395-34.816l89.6-89.6\r\n c1.628-1.614,2.537-3.816,2.524-6.108c-0.027-4.713-3.87-8.511-8.583-8.484h-3.413c-18.72,0.066-37.273-3.529-54.613-10.581\r\n c-3.195-1.315-6.867-0.573-9.301,1.877l-64.427,64.512c-20.006,20.006-52.442,20.006-72.448,0\r\n c-20.006-20.006-20.006-52.442,0-72.448l108.971-108.885c19.99-19.965,52.373-19.965,72.363,0\r\n c13.472,12.679,34.486,12.679,47.957,0c5.796-5.801,9.31-13.495,9.899-21.675C322.976,216.108,319.371,206.535,312.453,199.601z"
|
|
21
21
|
}
|
|
22
22
|
) }) }),
|
|
23
23
|
/* @__PURE__ */ jsx("g", { children: /* @__PURE__ */ jsx("g", { children: /* @__PURE__ */ jsx(
|
|
24
24
|
"path",
|
|
25
25
|
{
|
|
26
|
-
d: "M477.061,34.993c-46.657-46.657-122.303-46.657-168.96,0l-89.515,89.429c-2.458,2.47-3.167,6.185-1.792,9.387\n c1.359,3.211,4.535,5.272,8.021,5.205h3.157c18.698-0.034,37.221,3.589,54.528,10.667c3.195,1.315,6.867,0.573,9.301-1.877\n l64.256-64.171c20.006-20.006,52.442-20.006,72.448,0c20.006,20.006,20.006,52.442,0,72.448l-80.043,79.957l-0.683,0.768\n l-27.989,27.819c-19.99,19.965-52.373,19.965-72.363,0c-13.472-12.679-34.486-12.679-47.957,0\n c-5.833,5.845-9.35,13.606-9.899,21.845c-0.624,9.775,2.981,19.348,9.899,26.283c9.877,9.919,21.433,18.008,34.133,23.893\n c1.792,0.853,3.584,1.536,5.376,2.304c1.792,0.768,3.669,1.365,5.461,2.048c1.792,0.683,3.669,1.28,5.461,1.792l5.035,1.365\n c3.413,0.853,6.827,1.536,10.325,2.133c4.214,0.626,8.458,1.025,12.715,1.195h5.973h0.512l5.12-0.597\n c1.877-0.085,3.84-0.512,6.059-0.512h2.901l5.888-0.853l2.731-0.512l4.949-1.024h0.939c20.961-5.265,40.101-16.118,55.381-31.403\n l108.629-108.629C523.718,157.296,523.718,81.65,477.061,34.993z"
|
|
26
|
+
d: "M477.061,34.993c-46.657-46.657-122.303-46.657-168.96,0l-89.515,89.429c-2.458,2.47-3.167,6.185-1.792,9.387\r\n c1.359,3.211,4.535,5.272,8.021,5.205h3.157c18.698-0.034,37.221,3.589,54.528,10.667c3.195,1.315,6.867,0.573,9.301-1.877\r\n l64.256-64.171c20.006-20.006,52.442-20.006,72.448,0c20.006,20.006,20.006,52.442,0,72.448l-80.043,79.957l-0.683,0.768\r\n l-27.989,27.819c-19.99,19.965-52.373,19.965-72.363,0c-13.472-12.679-34.486-12.679-47.957,0\r\n c-5.833,5.845-9.35,13.606-9.899,21.845c-0.624,9.775,2.981,19.348,9.899,26.283c9.877,9.919,21.433,18.008,34.133,23.893\r\n c1.792,0.853,3.584,1.536,5.376,2.304c1.792,0.768,3.669,1.365,5.461,2.048c1.792,0.683,3.669,1.28,5.461,1.792l5.035,1.365\r\n c3.413,0.853,6.827,1.536,10.325,2.133c4.214,0.626,8.458,1.025,12.715,1.195h5.973h0.512l5.12-0.597\r\n c1.877-0.085,3.84-0.512,6.059-0.512h2.901l5.888-0.853l2.731-0.512l4.949-1.024h0.939c20.961-5.265,40.101-16.118,55.381-31.403\r\n l108.629-108.629C523.718,157.296,523.718,81.65,477.061,34.993z"
|
|
27
27
|
}
|
|
28
28
|
) }) }),
|
|
29
29
|
/* @__PURE__ */ jsx("g", {}),
|
package/dist/context/Auth.js
CHANGED
|
@@ -3,8 +3,8 @@ import axios from "axios";
|
|
|
3
3
|
import axiosInstance from "../model/axios.js";
|
|
4
4
|
import getCookieDomain from "../utils/get-cookie-domain.js";
|
|
5
5
|
import { getLastFirebaseConfig } from "../config.js";
|
|
6
|
-
import {
|
|
7
|
-
import { signInWithEmailAndPassword, createUserWithEmailAndPassword, applyActionCode, verifyPasswordResetCode, confirmPasswordReset, onAuthStateChanged
|
|
6
|
+
import { initFirebase, getFirebaseAuth } from "../firebase-config.js";
|
|
7
|
+
import { updatePassword, updateProfile, signInWithCustomToken, signInWithEmailAndPassword, createUserWithEmailAndPassword, applyActionCode, verifyPasswordResetCode, confirmPasswordReset, onAuthStateChanged } from "firebase/auth";
|
|
8
8
|
import { getConfig } from "../runtime-config.js";
|
|
9
9
|
function normalizeCustomToken(token) {
|
|
10
10
|
if (token == null) return "";
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import axiosInstance from "../model/axios.js";
|
|
4
|
+
import { configure } from "../config.js";
|
|
4
5
|
import React__default, { Component } from "react";
|
|
5
6
|
import fetchData from "../api/fetchData.js";
|
|
6
7
|
import { identify, reset } from "../analytics/index.js";
|
|
7
8
|
import { withRouter } from "../utils/withRouter.js";
|
|
8
|
-
import { configure } from "../config.js";
|
|
9
|
-
import { getPlatformURL, getConfig } from "../runtime-config.js";
|
|
10
|
-
import { isAlreadyOnOnboardingFlow } from "../utils/app-urls.js";
|
|
11
9
|
import { Text } from "../components/Text/Text.styles.js";
|
|
12
|
-
import { Auth } from "./Auth.js";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
10
|
+
import { Auth, DEFAULT_TOKEN_EXPIRY_MS } from "./Auth.js";
|
|
11
|
+
import { hasLoggedInSession } from "../utils/user-identity.js";
|
|
12
|
+
import { getConfig, getPlatformURL } from "../runtime-config.js";
|
|
15
13
|
import { ConfirmModal as ConfirmModalComponent } from "../components/ConfirmModal/ConfirmModal.js";
|
|
14
|
+
import { getFirebaseAuth, isValidFirebaseConfig } from "../firebase-config.js";
|
|
16
15
|
import avatarPlaceholder from "../static/images/avatar-placeholder.png.js";
|
|
17
|
-
import {
|
|
16
|
+
import { isAlreadyOnOnboardingFlow } from "../utils/app-urls.js";
|
|
17
|
+
import { multiFactor, TotpMultiFactorGenerator, signOut, getMultiFactorResolver, PhoneMultiFactorGenerator } from "firebase/auth";
|
|
18
18
|
import { navigateToHref } from "../routing/navigate-app.js";
|
|
19
19
|
const AuthContext = React__default.createContext();
|
|
20
20
|
const FALLBACK_AUTH_CONTEXT_VALUE = { user: null, isFetchingUser: false };
|
|
@@ -135,6 +135,35 @@ class AuthProviderClass extends Component {
|
|
|
135
135
|
const { inactivityTimeMs } = this.props;
|
|
136
136
|
return typeof inactivityTimeMs === "number" && inactivityTimeMs > 0 ? inactivityTimeMs : INACTIVITY_TIME_MS;
|
|
137
137
|
};
|
|
138
|
+
/** Cookie lifetime for `STOKR_ACCESS_TOKEN` — not the same as inactivity timeout. */
|
|
139
|
+
getAccessTokenExpiryMs = () => {
|
|
140
|
+
const n = Number(this.props.accessTokenExpiryMs);
|
|
141
|
+
return Number.isFinite(n) && n > 0 ? n : DEFAULT_TOKEN_EXPIRY_MS;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Diagnostic: after `Auth.setAccessToken`, the cookie must be readable on this origin
|
|
145
|
+
* or refresh/login will not persist (often misconfigured `cookieDomain`).
|
|
146
|
+
*/
|
|
147
|
+
logAccessTokenCookieAfterWrite = (phase) => {
|
|
148
|
+
if (typeof console === "undefined" || !console.log) return;
|
|
149
|
+
const readable = Boolean(Auth.getAccessToken());
|
|
150
|
+
if (readable) {
|
|
151
|
+
console.log(
|
|
152
|
+
`[@stokr/components-library] ${phase}: STOKR_ACCESS_TOKEN cookie readable — next getUser() can authorize API calls.`,
|
|
153
|
+
{
|
|
154
|
+
host: typeof window !== "undefined" ? window.location.hostname : void 0
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
} else {
|
|
158
|
+
console.log(
|
|
159
|
+
`[@stokr/components-library] ${phase}: cookie NOT readable after write — session will not survive reloads. Fix cookieDomain (empty string = host-only for localhost).`,
|
|
160
|
+
{
|
|
161
|
+
cookieDomain: getConfig("cookieDomain") ?? "",
|
|
162
|
+
origin: typeof window !== "undefined" ? window.location.origin : void 0
|
|
163
|
+
}
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
138
167
|
resetInactivityTimer = () => {
|
|
139
168
|
if (this.state.sessionExpiryPendingReason) return;
|
|
140
169
|
const now = Date.now();
|
|
@@ -159,8 +188,8 @@ class AuthProviderClass extends Component {
|
|
|
159
188
|
user = await Auth.login(email, password);
|
|
160
189
|
}
|
|
161
190
|
const token = await user.getIdToken();
|
|
162
|
-
|
|
163
|
-
|
|
191
|
+
Auth.setAccessToken(token, { expiresInMs: this.getAccessTokenExpiryMs() });
|
|
192
|
+
this.logAccessTokenCookieAfterWrite("loginUser");
|
|
164
193
|
this.setState({
|
|
165
194
|
firebaseUser: user
|
|
166
195
|
});
|
|
@@ -233,8 +262,8 @@ class AuthProviderClass extends Component {
|
|
|
233
262
|
const userCredential = await mfaResolver.resolveSignIn(multiFactorAssertion);
|
|
234
263
|
const user = userCredential.user;
|
|
235
264
|
const token = await user.getIdToken();
|
|
236
|
-
|
|
237
|
-
|
|
265
|
+
Auth.setAccessToken(token, { expiresInMs: this.getAccessTokenExpiryMs() });
|
|
266
|
+
this.logAccessTokenCookieAfterWrite("loginUserWithTotp");
|
|
238
267
|
this.setState({ firebaseUser: user, waitingFor2fa: false });
|
|
239
268
|
await this.getUser(token, user);
|
|
240
269
|
} catch (_error) {
|
|
@@ -368,6 +397,11 @@ class AuthProviderClass extends Component {
|
|
|
368
397
|
user: null,
|
|
369
398
|
firebaseUser: null
|
|
370
399
|
});
|
|
400
|
+
if (typeof console !== "undefined" && console.debug) {
|
|
401
|
+
console.debug(
|
|
402
|
+
"[@stokr/components-library] getUser: skipped — no STOKR_ACCESS_TOKEN (normal when logged out). If login just ran, check loginUser cookie log and cookieDomain."
|
|
403
|
+
);
|
|
404
|
+
}
|
|
371
405
|
return;
|
|
372
406
|
}
|
|
373
407
|
this.setState({
|
|
@@ -379,7 +413,26 @@ class AuthProviderClass extends Component {
|
|
|
379
413
|
const existingFirebaseUser = firebaseUserOverride || this.state.firebaseUser || getFirebaseAuth()?.currentUser;
|
|
380
414
|
const [result, tokenRes] = await Promise.all([
|
|
381
415
|
Auth.getUser(),
|
|
382
|
-
!existingFirebaseUser ? fetchData("auth/get-custom-token")
|
|
416
|
+
!existingFirebaseUser ? fetchData("auth/get-custom-token").catch((e) => {
|
|
417
|
+
const status = e?.response?.status;
|
|
418
|
+
if (status === 401 || status === 403) {
|
|
419
|
+
if (typeof console !== "undefined" && console.warn) {
|
|
420
|
+
console.warn(
|
|
421
|
+
"[@stokr/components-library] auth/get-custom-token rejected (" + status + ") — Firebase session unavailable. STOKR session will be preserved if user/get succeeds."
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
if (typeof console !== "undefined" && console.log) {
|
|
425
|
+
console.log(
|
|
426
|
+
"[@stokr/components-library] getUser: auth/get-custom-token failed — trying user/get without Firebase custom token.",
|
|
427
|
+
{
|
|
428
|
+
status
|
|
429
|
+
}
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
return null;
|
|
433
|
+
}
|
|
434
|
+
throw e;
|
|
435
|
+
}) : Promise.resolve(null)
|
|
383
436
|
]);
|
|
384
437
|
let firebaseUser = existingFirebaseUser;
|
|
385
438
|
if (!firebaseUser) {
|
|
@@ -388,12 +441,20 @@ class AuthProviderClass extends Component {
|
|
|
388
441
|
firebaseUser = await Auth.signInWithToken(customToken);
|
|
389
442
|
} catch (firebaseErr) {
|
|
390
443
|
const fbCode = firebaseErr?.code;
|
|
391
|
-
if (fbCode === "auth/internal-error" || fbCode === "auth/network-request-failed") {
|
|
444
|
+
if (fbCode === "auth/internal-error" || fbCode === "auth/network-request-failed" || fbCode === "auth/invalid-custom-token") {
|
|
392
445
|
if (typeof console !== "undefined" && console.warn) {
|
|
393
446
|
console.warn(
|
|
394
447
|
"[@stokr/components-library] Firebase signIn failed (" + fbCode + ") — session preserved. Add this domain to Firebase Console → Authentication → Authorized domains."
|
|
395
448
|
);
|
|
396
449
|
}
|
|
450
|
+
if (typeof console !== "undefined" && console.log) {
|
|
451
|
+
console.log(
|
|
452
|
+
"[@stokr/components-library] getUser: continuing with API user only (no Firebase user on merged object).",
|
|
453
|
+
{
|
|
454
|
+
code: fbCode
|
|
455
|
+
}
|
|
456
|
+
);
|
|
457
|
+
}
|
|
397
458
|
} else {
|
|
398
459
|
throw firebaseErr;
|
|
399
460
|
}
|
|
@@ -402,13 +463,26 @@ class AuthProviderClass extends Component {
|
|
|
402
463
|
const user = this.patchUserObject(result.user, firebaseUser);
|
|
403
464
|
this.checkUserIsValid(user);
|
|
404
465
|
customValidateGetUser?.(user);
|
|
405
|
-
const
|
|
406
|
-
|
|
466
|
+
const userIdForMedia = user._id ?? user.id;
|
|
467
|
+
if (userIdForMedia) {
|
|
468
|
+
const userAvatar = `${getConfig("photoApiUrl")}/media/picture/view/${userIdForMedia}`;
|
|
469
|
+
this.checkUserPhoto(userAvatar);
|
|
470
|
+
}
|
|
407
471
|
this.setUser(user);
|
|
408
472
|
this.setState({
|
|
409
473
|
isFetchingUser: false
|
|
410
474
|
});
|
|
411
|
-
|
|
475
|
+
const identityKey = user._id ?? user.id ?? user.uid;
|
|
476
|
+
if (typeof console !== "undefined" && console.log) {
|
|
477
|
+
console.log(
|
|
478
|
+
"[@stokr/components-library] getUser: user/get succeeded — context User updated; HeaderHo shows Dashboard when hasLoggedInSession is true.",
|
|
479
|
+
{
|
|
480
|
+
identity: identityKey,
|
|
481
|
+
hasLoggedInSession: hasLoggedInSession(user)
|
|
482
|
+
}
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
identify(user._id ?? user.id, {
|
|
412
486
|
role: user.user_type,
|
|
413
487
|
is_internal: user.email?.endsWith("@stokr.io") ?? false
|
|
414
488
|
});
|
|
@@ -420,6 +494,13 @@ class AuthProviderClass extends Component {
|
|
|
420
494
|
});
|
|
421
495
|
const code = error?.code;
|
|
422
496
|
const httpStatus = error?.response?.status;
|
|
497
|
+
if (typeof console !== "undefined" && console.log) {
|
|
498
|
+
console.log("[@stokr/components-library] getUser: request failed or validation error", {
|
|
499
|
+
code,
|
|
500
|
+
httpStatus,
|
|
501
|
+
message: error?.message
|
|
502
|
+
});
|
|
503
|
+
}
|
|
423
504
|
if (code === "auth/internal-error" || code === "auth/network-request-failed") {
|
|
424
505
|
if (typeof console !== "undefined" && console.warn) {
|
|
425
506
|
console.warn(
|
package/dist/firebase-config.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { getApps, getApp, initializeApp } from "firebase/app";
|
|
2
2
|
import { initializeAuth, inMemoryPersistence, getAuth } from "firebase/auth";
|
|
3
3
|
import { getConfig } from "./runtime-config.js";
|
|
4
|
-
const __vite_import_meta_env__ = {};
|
|
5
4
|
let app = null;
|
|
6
5
|
let auth = null;
|
|
7
6
|
function isValidFirebaseConfig(config) {
|
|
@@ -49,9 +48,6 @@ function initFirebase(configOverride) {
|
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
|
-
if (typeof __vite_import_meta_env__ !== "undefined" && isValidFirebaseConfig(getConfig("firebase"))) {
|
|
53
|
-
initFirebase();
|
|
54
|
-
}
|
|
55
51
|
export {
|
|
56
52
|
auth,
|
|
57
53
|
getFirebaseAuth,
|
package/dist/runtime-config.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite_import_meta_env__ = { "BASE_URL": "/", "DEV": false, "MODE": "production", "PROD": true, "SSR": false
|
|
1
|
+
const __vite_import_meta_env__ = { "BASE_URL": "/", "DEV": false, "MODE": "production", "PROD": true, "SSR": false };
|
|
2
2
|
const _overrides = {};
|
|
3
3
|
const ENV_KEY_BY_CONFIG = {
|
|
4
4
|
apiUrl: "VITE_API_URL",
|